Skip to content

fix(sqs): confirm FIFO drain with queue attributes before exit_on_empty - #123

Merged
Divyanshu Tiwari (divyanshu-tiwari) merged 4 commits into
mainfrom
fix/sqs-fifo-confirm-empty
Sep 11, 2026
Merged

Divyanshu Tiwari (divyanshu-tiwari) merged 4 commits into
mainfrom
fix/sqs-fifo-confirm-empty

Conversation

@divyanshu-tiwari

Copy link
Copy Markdown
Contributor

Summary

  • FIFO exit_on_empty treated an empty ReceiveMessage as a drained queue whenever this process had no outstanding receipts. That is wrong when a sibling consumer, or a dead container still inside the visibility timeout, still holds group heads. Prod hits: pdp_walmart_priority_queue.fifo (walmart_us_dag) and catalog_listings.fifo (catalog_listings_hourly).
  • #116 already skipped drain while this process holds receipts. That in-memory check does not survive an ECS restart, and it does not cover messages in flight elsewhere.
  • On FIFO, exit_on_empty now also calls GetQueueAttributes and only exits when visible, not-visible, and delayed counts are all present and 0. Attribute errors, incomplete maps, and this process's outstanding receipts also refuse to exit. Standard queues are unchanged.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • I have added tests to cover my changes.

Test plan

  • go test ./internal/pkg/pipeline/task/sqs/ ./internal/pkg/pipeline/task/
  • After deploy, confirm a FIFO reader with exit_on_empty keeps polling when ApproximateNumberOfMessages / NotVisible is non-zero (catalog listings restart, walmart multi-task)
  • Confirm it still exits with Queue is empty, exiting once attributes are all 0
  • Confirm standard (non-FIFO) queues still exit on the first empty receive without GetQueueAttributes

Empty ReceiveMessage is not a drained FIFO queue when a sibling consumer
or a dead container still holds group heads. Ask GetQueueAttributes
before treating the queue as empty.
Keep the FIFO drain fix without adding a test file to the PR.
…docs

The interface existed only for tests that are not in this PR. Restore *qs.Client
and keep the drain rule in one place.
Outstanding only tracks this process; the rest of the why is in the attribute check.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM!

@divyanshu-tiwari
Divyanshu Tiwari (divyanshu-tiwari) merged commit 3fc815e into main Sep 11, 2026
7 checks passed
@divyanshu-tiwari
Divyanshu Tiwari (divyanshu-tiwari) deleted the fix/sqs-fifo-confirm-empty branch September 11, 2026 09:49
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.

2 participants