Skip to content

Commit

Permalink
Merge branch 'gun/snooze' into 'develop'
Browse files Browse the repository at this point in the history
Gun: Publisher job behavior improvement

See merge request pleroma/pleroma!4202
  • Loading branch information
feld committed Aug 2, 2024
2 parents 8f1866e + 1f986ec commit b389b85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/oban_gun_snooze.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Publisher behavior improvement when snoozing Oban jobs due to Gun connection pool contention.
8 changes: 7 additions & 1 deletion lib/pleroma/web/activity_pub/publisher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
_ -> {:error, e}
end

{:error, {:already_started, _}} ->
Logger.debug("Publisher snoozing worker job due worker :already_started race condition")
connection_pool_snooze()

{:error, :pool_full} ->
Logger.debug("Publisher snoozing worker job due to full connection pool")
{:snooze, 30}
connection_pool_snooze()

e ->
unless params[:unreachable_since], do: Instances.set_unreachable(inbox)
Expand All @@ -155,6 +159,8 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
end
end

defp connection_pool_snooze, do: {:snooze, 3}

defp signature_host(%URI{port: port, scheme: scheme, host: host}) do
if port == URI.default_port(scheme) do
host
Expand Down

0 comments on commit b389b85

Please sign in to comment.