Repository navigation
fix(pubsub): make publish hedging robust to clock jumps, queue errors, and shutdown - #14860
tonyyyycui wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
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.
Follow-up to #13735 with minor fixes for publish hedging.