Skip to content

fix(pubsub): make publish hedging robust to clock jumps, queue errors, and shutdown - #14860

Open
tonyyyycui wants to merge 7 commits into
googleapis:mainfrom
tonyyyycui:publish-hedging-bug-fixes
Open

tonyyyycui wants to merge 7 commits into
googleapis:mainfrom
tonyyyycui:publish-hedging-bug-fixes

Conversation

@tonyyyycui

Copy link
Copy Markdown
Contributor

Follow-up to #13735 with minor fixes for publish hedging.

@tonyyyycui
tonyyyycui requested review from a team as code owners October 29, 2026 20:18

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 Publisher class to use separate clocks for hedging (hedgeClock using NanoClock) and wall time (wallClock). It also improves robustness by wrapping the hedging queue processing in a try-catch-finally block, ensuring proper scheduling even on failures, and securing the queue shutdown with a lock. Additionally, tests are updated and expanded to cover winning hedged attempts and hedging during shutdown. The review feedback suggests two key improvements: adding an instanceof check before casting responseObserver in FakePublisherServiceImpl to prevent potential ClassCastExceptions, and adding an isAlive() check to the test thread waiting loop to allow the test to fail-fast if the thread terminates prematurely.

@tonyyyycui tonyyyycui changed the title fix(pubsub): make publish hedging robust to clock umps, queue errors, and shutdown fix(pubsub): make publish hedging robust to clock jumps, queue errors, and shutdown Oct 29, 2026

This branch has not been deployed

No deployments
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.

1 participant