From 6c987c76708a4f334f9c2ad9b249c0f462fd9511 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Thu, 28 Jan 2021 16:50:21 +0300 Subject: [PATCH 1/3] fix and delete purge activities duplicates --- lib/pleroma/workers/purge_expired_activity.ex | 2 +- ...e_duplicates_from_activity_expiration_queue.exs | 29 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 priv/repo/migrations/20210128092834_remove_duplicates_from_activity_expiration_queue.exs diff --git a/lib/pleroma/workers/purge_expired_activity.ex b/lib/pleroma/workers/purge_expired_activity.ex index 01256831b..027171c1e 100644 --- a/lib/pleroma/workers/purge_expired_activity.ex +++ b/lib/pleroma/workers/purge_expired_activity.ex @@ -7,7 +7,7 @@ defmodule Pleroma.Workers.PurgeExpiredActivity do Worker which purges expired activity. """ - use Oban.Worker, queue: :activity_expiration, max_attempts: 1 + use Oban.Worker, queue: :activity_expiration, max_attempts: 1, unique: [period: :infinity] import Ecto.Query diff --git a/priv/repo/migrations/20210128092834_remove_duplicates_from_activity_expiration_queue.exs b/priv/repo/migrations/20210128092834_remove_duplicates_from_activity_expiration_queue.exs new file mode 100644 index 000000000..309009205 --- /dev/null +++ b/priv/repo/migrations/20210128092834_remove_duplicates_from_activity_expiration_queue.exs @@ -0,0 +1,29 @@ +defmodule Pleroma.Repo.Migrations.RemoveDuplicatesFromActivityExpirationQueue do + use Ecto.Migration + + import Ecto.Query, only: [from: 2] + + def up do + duplicate_ids = + from(j in Oban.Job, + where: j.queue == "activity_expiration", + where: j.worker == "Pleroma.Workers.PurgeExpiredActivity", + where: j.state == "scheduled", + select: + {fragment("(?)->>'activity_id'", j.args), fragment("array_agg(?)", j.id), count(j.id)}, + group_by: fragment("(?)->>'activity_id'", j.args), + having: count(j.id) > 1 + ) + |> Pleroma.Repo.all() + |> Enum.map(fn {_, ids, _} -> + max_id = Enum.max(ids) + List.delete(ids, max_id) + end) + |> List.flatten() + + from(j in Oban.Job, where: j.id in ^duplicate_ids) + |> Pleroma.Repo.delete_all() + end + + def down, do: :noop +end From dd1be13f752e62214c5345ca76f49ea2c82f3809 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Thu, 28 Jan 2021 17:01:31 +0300 Subject: [PATCH 2/3] changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4f3867a2..24873f591 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Creating incorrect IPv4 address-style HTTP links when encountering certain numbers. - Reblog API Endpoint: Do not set visibility parameter to public by default and let CommonAPI to infer it from status, so a user can reblog their private status without explicitly setting reblog visibility to private. - Tag URLs in statuses are now absolute +- Creation of duplicate purge expired activities jobs
API Changes From 22486fb4af49214fb2b0eff09f00006fbfdd9745 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 2 Feb 2021 11:15:47 -0600 Subject: [PATCH 3/3] Improve changelog description --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24873f591..5225217bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,7 +58,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Creating incorrect IPv4 address-style HTTP links when encountering certain numbers. - Reblog API Endpoint: Do not set visibility parameter to public by default and let CommonAPI to infer it from status, so a user can reblog their private status without explicitly setting reblog visibility to private. - Tag URLs in statuses are now absolute -- Creation of duplicate purge expired activities jobs +- Removed duplicate jobs to purge expired activities
API Changes