Skip to content

Fix: Hardening AMQP failure handling and daisy worker logging - #29

Merged
Hyask merged 2 commits into
ubuntu:mainfrom
rishprsi:robust-logging
Nov 25, 2026
Merged

Hyask merged 2 commits into
ubuntu:mainfrom
rishprsi:robust-logging

Conversation

@rishprsi

Copy link
Copy Markdown
Contributor

Summary

Improve AMQP connection and queue-operation failure handling, and capture Python stack traces when Gunicorn aborts a Daisy worker.

Motivation

Daisy workers have reported WORKER TIMEOUT messages around the same time RabbitMQ reports unexpectely closed TCP connections, without an application traceback.

A worker terminated while blocked may never reach the AMQP exception handler.

Changes

  • Distinguished recoverable transport failures from authentication and protocol errors.
  • Added a 10-second AMQP connection-establishment timeout.
  • Discarded and cleaned failed or disconnected cached connections.
  • Protected connection acuisition, channel creation, and queue declarations with queue helpers.
  • Logged enqueue and polling features with context and tracebacks.
  • Returned errors for recoverable failures and raised errors for unrecoverable failures.
  • Stopped the cleanup efforts from masking the original failure.
  • Added a Gunicorn worker_abort hook that logs the PID and thread stacks to stderr.
  • Added regressions tests for connection lifecycle

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical transport-failure path ignores the failed publication result and removes the retracing marker after acknowledging the input, leaving no queued retry or recovery path.

1 open issue
What changed in this PR

This PR hardens Error Tracker’s shared AMQP helpers and adds diagnostics for Daisy worker timeouts, improving failure handling and visibility into blocked workers.

Changes:

  • Classifies recoverable transport failures, adds a 10-second connection timeout, and cleans up failed cached connections.
  • Protects queue operations and cleanup, with regression tests for connection lifecycle and failure behavior.
  • Logs Python thread stacks when Gunicorn aborts a worker and documents how to inspect them.

Draft commit message: fix: harden AMQP failure handling and Daisy timeout diagnostics

File Description
src/​tests/​test_amqp_utils.py Adds tests for connection reuse, failure classification, queue operations, and cleanup.
src/​errortracker/​amqp_utils.py Hardens connection management, queue error handling, and logging.
src/​daisy/​gunicorn_config.py Adds an abort hook that logs worker PID and thread stacks.
README.md Documents timeout diagnostics and journal inspection.

Review effort: Balanced

Comment thread src/errortracker/amqp_utils.py Resolved

@Hyask Hyask left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good in overall.
Small nitpick: you wrote a good commit message in the PR description, but not in the commit itself. Can we get the opposite?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the AMQP failure-handling and Daisy diagnostics changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@Hyask Hyask left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Hyask
Hyask merged commit de25027 into ubuntu:main Nov 25, 2026
6 of 8 checks passed
@rishprsi
rishprsi deleted the robust-logging branch November 25, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants