Configurable logging for the API and worker (SCR-5)
CI / notify (push) Successful in 6s
CI / lint (push) Successful in 18s
CI / test (push) Successful in 5m26s
CI / validate-monitoring (push) Successful in 15s
CI / federation-interop (push) Successful in 1m17s
CI / images (push) Successful in 33s
CI / assets (push) Successful in 9s
CI / python-package (push) Successful in 18s
CI / trigger-deploy (push) Successful in 3s
CI / notify (push) Successful in 6s
CI / lint (push) Successful in 18s
CI / test (push) Successful in 5m26s
CI / validate-monitoring (push) Successful in 15s
CI / federation-interop (push) Successful in 1m17s
CI / images (push) Successful in 33s
CI / assets (push) Successful in 9s
CI / python-package (push) Successful in 18s
CI / trigger-deploy (push) Successful in 3s
Shared LOG_LEVEL/LOG_FORMAT (text or json) set up in create_app, per-task activity and duration logs in the worker, and more context on delivery, inbox and import failures. Alembic's fileConfig no longer disables loggers. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
65cd610468
commit
ad383b602e
16 files changed
+212
-7
No files matched your search
@@ -68,6 +68,13 @@ def _retry_or_abandon(delivery: FederationDelivery, error: str, status: int | No
|
||||
delivery.last_status, delivery.last_error = status, error[:1000]
|
||||
if _now() - delivery.created_at >= GIVE_UP_AFTER:
|
||||
delivery.status = "abandoned"
|
||||
log.warning(
|
||||
"delivery %s to %s abandoned after %s attempts: %s",
|
||||
delivery.id,
|
||||
delivery.inbox,
|
||||
delivery.attempts,
|
||||
error[:200],
|
||||
)
|
||||
return "abandoned"
|
||||
delay = (
|
||||
RETRY_DELAYS[delivery.attempts - 1]
|
||||
@@ -75,6 +82,14 @@ def _retry_or_abandon(delivery: FederationDelivery, error: str, status: int | No
|
||||
else LATER_DELAY
|
||||
)
|
||||
delivery.next_attempt_at = _now() + delay
|
||||
log.warning(
|
||||
"delivery %s to %s failed (attempt %s), retrying in %s: %s",
|
||||
delivery.id,
|
||||
delivery.inbox,
|
||||
delivery.attempts,
|
||||
delay,
|
||||
error[:200],
|
||||
)
|
||||
return "retry"
|
||||
|
||||
|
||||
@@ -135,7 +150,7 @@ def _deliver_in_context(app, delivery_id: int) -> str:
|
||||
try:
|
||||
return deliver(delivery_id)
|
||||
except Exception:
|
||||
log.exception("delivery %s failed unexpectedly", delivery_id)
|
||||
log.exception("delivery %s failed unexpectedly (will be retried)", delivery_id)
|
||||
db.session.rollback()
|
||||
return "retry" # the lease expires and it becomes due again
|
||||
finally:
|
||||
|
||||
@@ -224,7 +224,13 @@ def process(item: FederationInboxItem) -> None:
|
||||
db.session.rollback()
|
||||
transient = isinstance(err, FetchError) and err.reason == "network"
|
||||
if not transient:
|
||||
log.exception("inbox item %s failed", item.id)
|
||||
log.exception(
|
||||
"inbox item %s (%s) failed on attempt %s of %s",
|
||||
item.id,
|
||||
item.activity_type,
|
||||
item.attempts,
|
||||
MAX_ATTEMPTS,
|
||||
)
|
||||
if item.attempts < MAX_ATTEMPTS:
|
||||
_finish(item, "queued", f"retrying: {err}"[:255], done=False)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user