Custom pruning is not actually needed because an old job cannot exist in the table due to our use of [replace: true] when retrying jobs or walking it through the different phases
This commit is contained in:
parent
6e4b5edc25
commit
a5e11ad110
2 changed files with 2 additions and 29 deletions
|
|
@ -599,12 +599,11 @@ config :pleroma, Oban,
|
|||
search_indexing: [limit: 10, paused: true],
|
||||
slow: 5
|
||||
],
|
||||
plugins: [{Oban.Plugins.Pruner, max_age: 900, exclude: [Pleroma.Workers.ReachabilityWorker]}],
|
||||
plugins: [{Oban.Plugins.Pruner, max_age: 900}],
|
||||
crontab: [
|
||||
{"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker},
|
||||
{"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker},
|
||||
{"*/10 * * * *", Pleroma.Workers.Cron.AppCleanupWorker},
|
||||
{"0 2 * * *", Pleroma.Workers.Cron.ReachabilityPruner}
|
||||
{"*/10 * * * *", Pleroma.Workers.Cron.AppCleanupWorker}
|
||||
]
|
||||
|
||||
config :pleroma, Pleroma.Formatter,
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
defmodule Pleroma.Workers.Cron.ReachabilityPruner do
|
||||
use Oban.Worker, queue: :background, max_attempts: 1
|
||||
|
||||
import Ecto.Query
|
||||
require Logger
|
||||
|
||||
@reachability_worker "Elixir.Pleroma.Workers.ReachabilityWorker"
|
||||
@prune_days 2
|
||||
|
||||
@impl true
|
||||
def perform(_job) do
|
||||
cutoff = DateTime.utc_now() |> DateTime.add(-@prune_days * 24 * 60 * 60, :second)
|
||||
|
||||
{count, _} =
|
||||
from(j in Oban.Job,
|
||||
where: j.worker == @reachability_worker and j.inserted_at < ^cutoff
|
||||
)
|
||||
|> Pleroma.Repo.delete_all()
|
||||
|
||||
if count > 0 do
|
||||
Logger.debug(fn -> "Pruned #{count} old ReachabilityWorker jobs." end)
|
||||
end
|
||||
|
||||
:ok
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue