Merge pull request 'federation/out: tweak publish retry backoff' (#884) from Oneric/akkoma:publish_backoff into develop
Some checks failed
ci/woodpecker/push/lint Pipeline is pending
ci/woodpecker/push/test/1 unknown status
ci/woodpecker/push/test/2 unknown status
ci/woodpecker/push/build-arm64 unknown status
ci/woodpecker/push/build-amd64 unknown status
ci/woodpecker/push/docs unknown status

Reviewed-on: #884
This commit is contained in:
Oneric 2025-05-09 20:12:56 +00:00
commit 8cdfbf872d
2 changed files with 14 additions and 1 deletions

View file

@ -9,7 +9,11 @@ defmodule Pleroma.Workers.PublisherWorker do
use Pleroma.Workers.WorkerHelper, queue: "federator_outgoing"
def backoff(%Job{attempt: attempt}) when is_integer(attempt) do
Pleroma.Workers.WorkerHelper.sidekiq_backoff(attempt, 5)
if attempt > 3 do
Pleroma.Workers.WorkerHelper.exponential_backoff(attempt, 9.5)
else
Pleroma.Workers.WorkerHelper.sidekiq_backoff(attempt, 6)
end
end
@impl Oban.Worker

View file

@ -22,6 +22,15 @@ def sidekiq_backoff(attempt, pow \\ 4, base_backoff \\ 15) do
trunc(backoff)
end
def exponential_backoff(attempt, base, base_backoff \\ 15) do
backoff =
:math.pow(base, attempt) +
base_backoff +
:rand.uniform(2 * base_backoff) * attempt
trunc(backoff)
end
defmacro __using__(opts) do
caller_module = __CALLER__.module
queue = Keyword.fetch!(opts, :queue)