Repository navigation
Conversation
feywind
added this pull request to stack #9467
October 15, 2026 19:01
This was referenced Oct 15, 2026
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive suite of system tests for publish hedging in handwritten/pubsub/system-test/hedging.test.ts, covering default and custom hedging configurations, dynamic option updates, rate limiting, OpenTelemetry tracing, and message ordering interactions. The review feedback highlights potential race conditions in several tests where mock request interceptors set up both a setTimeout and an AbortSignal listener. If the timeout fires before an abort occurs, a subsequent abort could trigger the callback a second time. The reviewer suggests removing the abort event listeners once the timers fire to prevent duplicate callback invocations.
feywind
force-pushed
the
pubsub/hedging-system-tests
branch
from
October 15, 2026 19:14
6967b0f to
c7afb42
Compare
feywind
marked this pull request as ready for review
October 15, 2026 21:33
This was referenced Oct 15, 2026
feywind
force-pushed
the
pubsub/hedging-system-tests
branch
from
October 19, 2026 21:58
c7afb42 to
0ad47ac
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR is Layer 7 of 7 in Stack #9467, which implements Publish Hedging for
@google-cloud/pubsubto mitigate high-percentile (p99/p99.9) publish tail latencies by sending backup (hedged) publish RPCs when an in-flight batch takes longer than a configurablehedgeDelaythreshold.Stack Structure
feat(gax): support AbortSignal cancellation in CallOptions and createApiCallfeat(pubsub): add HedgingOptions validation and HedgingTokenBucketfeat(pubsub): add CancellationSharer and HedgingSchedulerfeat(pubsub): add OpenTelemetry events and logging for hedged publishfeat(pubsub): integrate publish hedging into MessageQueuetest(pubsub): add unit tests for publish hedging queue integrationtest(pubsub): add publish hedging system tests(this PR)Summary of Changes in This PR
This layer adds live end-to-end system tests against the Pub/Sub service in
handwritten/pubsub/system-test/hedging.test.ts:hedging: {}enabled (hedgeDelay: 1000ms,maxTokens: 50,refillRatio: 0.1).HedgingOptions, asserting token bucket replenishment andmaxTokenscapping.setPublishOptions.PublisherClientthat holdsattempt 0while allowing the backup (attempt 1) RPC through to the live Pub/Sub service:attempt 1resolves the publish with a valid livemessageId, cancelsattempt 0viaAbortSignal, delivers the message to the live subscription, and recordsPubsubEvents.publishStartHedgedandPubsubEvents.publishEndHedgedon the OpenTelemetrypublish_rpcspan.attempt 0resolves the publish when it finishes just afterhedgeDelay, cancelsattempt 1, and recordsPubsubEvents.publishStartHedged+PubsubEvents.publishEndon thepublish_rpcspan.0: Asserts no backup RPC is dispatched whentokenBucket.tokens < 1and logs'Hedging rate limited due to lack of tokens.'on thepubsub:publish-hedgedsublogger.enableMessageOrdering: true.NOT_FOUNDon a non-existent topic) propagates cleanly and cancels any scheduled/in-flight hedged attempts.