commit: f77911f05b99bc9c9ac33cbf1c87d9f3a07a4ca5
parent 058f8acb586b832864b9c3912970f4072aaea255
Author: feld <feld@feld.me>
Date: Mon, 22 Jul 2024 17:45:44 +0000
Merge branch 'oban/more-improvements' into 'develop'
Oban: more improvements
See merge request pleroma/pleroma!4187
Diffstat:
12 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/changelog.d/oban-cancel-badreq.change b/changelog.d/oban-cancel-badreq.change
@@ -0,0 +1 @@
+Publisher jobs will not retry if the error received is a 400
diff --git a/changelog.d/oban-cancel-poll-result.change b/changelog.d/oban-cancel-poll-result.change
@@ -0,0 +1 @@
+PollWorker jobs will not retry if the activity no longer exists.
diff --git a/changelog.d/oban-cancel-receiverworker.change b/changelog.d/oban-cancel-receiverworker.change
@@ -0,0 +1 @@
+Improved detecting unrecoverable errors for incoming federation jobs
diff --git a/changelog.d/oban-timeouts.skip b/changelog.d/oban-timeouts.skip
diff --git a/lib/pleroma/web/activity_pub/publisher.ex b/lib/pleroma/web/activity_pub/publisher.ex
@@ -123,6 +123,7 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
Logger.error("Publisher failed to inbox #{inbox} with status #{code}")
case response do
+ %{status: 400} -> {:cancel, :bad_request}
%{status: 403} -> {:cancel, :forbidden}
%{status: 404} -> {:cancel, :not_found}
%{status: 410} -> {:cancel, :not_found}
diff --git a/lib/pleroma/web/activity_pub/side_effects.ex b/lib/pleroma/web/activity_pub/side_effects.ex
@@ -453,7 +453,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
) do
orig_object_ap_id = updated_object["id"]
orig_object = Object.get_by_ap_id(orig_object_ap_id)
- orig_object_data = orig_object.data
+ orig_object_data = Map.get(orig_object, :data)
updated_object =
if meta[:local] do
diff --git a/lib/pleroma/workers/background_worker.ex b/lib/pleroma/workers/background_worker.ex
@@ -40,5 +40,5 @@ defmodule Pleroma.Workers.BackgroundWorker do
end
@impl Oban.Worker
- def timeout(_job), do: :timer.seconds(5)
+ def timeout(_job), do: :timer.seconds(15)
end
diff --git a/lib/pleroma/workers/poll_worker.ex b/lib/pleroma/workers/poll_worker.ex
@@ -17,6 +17,9 @@ defmodule Pleroma.Workers.PollWorker do
with %Activity{} = activity <- find_poll_activity(activity_id),
{:ok, notifications} <- Notification.create_poll_notifications(activity) do
Notification.stream(notifications)
+ else
+ {:error, :poll_activity_not_found} = e -> {:cancel, e}
+ e -> {:error, e}
end
end
diff --git a/lib/pleroma/workers/receiver_worker.ex b/lib/pleroma/workers/receiver_worker.ex
@@ -47,11 +47,13 @@ defmodule Pleroma.Workers.ReceiverWorker do
case errors do
{:error, :origin_containment_failed} -> {:cancel, :origin_containment_failed}
{:error, :already_present} -> {:cancel, :already_present}
- {:error, {:validate_object, reason}} -> {:cancel, reason}
- {:error, {:error, {:validate, reason}}} -> {:cancel, reason}
- {:error, {:reject, reason}} -> {:cancel, reason}
+ {:error, {:validate_object, _} = reason} -> {:cancel, reason}
+ {:error, {:error, {:validate, {:error, _changeset} = reason}}} -> {:cancel, reason}
+ {:error, {:reject, _} = reason} -> {:cancel, reason}
{:signature, false} -> {:cancel, :invalid_signature}
- {:error, {:error, reason = "Object has been deleted"}} -> {:cancel, reason}
+ {:error, "Object has been deleted"} = reason -> {:cancel, reason}
+ {:error, {:side_effects, {:error, :no_object_actor}} = reason} -> {:cancel, reason}
+ {:error, :not_found} = reason -> {:cancel, reason}
{:error, _} = e -> e
e -> {:error, e}
end
diff --git a/lib/pleroma/workers/remote_fetcher_worker.ex b/lib/pleroma/workers/remote_fetcher_worker.ex
@@ -31,5 +31,5 @@ defmodule Pleroma.Workers.RemoteFetcherWorker do
end
@impl Oban.Worker
- def timeout(_job), do: :timer.seconds(10)
+ def timeout(_job), do: :timer.seconds(15)
end
diff --git a/lib/pleroma/workers/user_refresh_worker.ex b/lib/pleroma/workers/user_refresh_worker.ex
@@ -13,5 +13,5 @@ defmodule Pleroma.Workers.UserRefreshWorker do
end
@impl Oban.Worker
- def timeout(_job), do: :timer.seconds(5)
+ def timeout(_job), do: :timer.seconds(15)
end
diff --git a/test/pleroma/workers/receiver_worker_test.exs b/test/pleroma/workers/receiver_worker_test.exs
@@ -16,7 +16,7 @@ defmodule Pleroma.Workers.ReceiverWorkerTest do
with_mock Pleroma.Web.ActivityPub.Transmogrifier,
handle_incoming: fn _ -> {:reject, "MRF"} end do
- assert {:cancel, "MRF"} =
+ assert {:cancel, {:reject, "MRF"}} =
ReceiverWorker.perform(%Oban.Job{
args: %{"op" => "incoming_ap_doc", "params" => params}
})