Skip to content

Fix Pub/Sub nack - #5192

Open
ievdokdm wants to merge 2 commits into
flutter:mainfrom
ievdokdm:196333-processing-presubmit-retry
Open

ievdokdm wants to merge 2 commits into
flutter:mainfrom
ievdokdm:196333-processing-presubmit-retry

Conversation

@ievdokdm

Copy link
Copy Markdown
Contributor

Fixes Pub/Sub push retry drops in SubscriptionHandler when forwarding to ordered-presubmit (or any handler) fails with 5XX:

  • Distinguish in-progress (p) vs processed (l) cache locks and return 503 (NACK) instead of 200 (ACK) on concurrent redeliveries while a message is still in flight.
  • Update or purge the cache lock before flushing/closing the HTTP response so immediate Pub/Sub retries do not hit a stale lock.
  • Close httpClient in PubSub.publish.

fix: flutter/flutter#196333

@ievdokdm
ievdokdm requested a review from jtmcdole November 19, 2026 01:18
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Nov 19, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors request and subscription handling to improve reliability and concurrency control. Key changes include introducing distinct in-progress and processed cache locks to handle concurrent Pub/Sub redeliveries with 503 NACKs, ensuring HTTP clients are closed in PubSub, and refactoring RequestHandler to separate dispatching from responding. Feedback on these changes suggests removing a redundant HttpStatusException catch block, reusing the inherited respond helper method to avoid manual response writing, and wrapping cache operations (purge and update) in try-catch blocks to prevent suppressing original exceptions or blocking successful responses due to transient cache failures.

@ievdokdm

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the request and subscription handling logic to improve reliability and concurrency management. Specifically, it introduces distinct 'processing' and 'processed' lock states in SubscriptionHandler to return a 503 NACK when a message is already being processed concurrently, and updates or purges locks before responding to prevent race conditions on retries. Additionally, it refactors RequestHandler to separate dispatching from responding, ensures httpClient is closed in PubSub, and adds comprehensive tests for these scenarios. I have no further feedback to provide as the changes are well-implemented and covered by tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retry submitting in ordered-presubmit topic

1 participant