Repository navigation
Conversation
feywind
added this pull request to stack #9467
September 29, 2026 02:09
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements publish hedging support in the Pub/Sub publisher, integrating a hedging scheduler, token bucket, and cancellation coordinator into the message queues, while ensuring ordered queues do not use hedging. It also adds support for abort signals in API requests to handle cancellations immediately. The review feedback suggests replacing shallow copies of gaxOpts with deep copies using extend to prevent accidental mutation of nested configuration options by underlying libraries.
This was referenced Sep 29, 2026
feywind
force-pushed
the
pubsub/hedging-queue-integration-and-tests
branch
from
September 29, 2026 03:05
d12ddf1 to
f675ae1
Compare
feywind
force-pushed
the
pubsub/hedging-queue-integration-and-tests
branch
from
October 13, 2026 18:36
f675ae1 to
3c11c08
Compare
feywind
force-pushed
the
pubsub/hedging-queue-integration-and-tests
branch
from
October 13, 2026 19:33
3c11c08 to
e954f8d
Compare
feywind
force-pushed
the
pubsub/hedging-queue-integration-and-tests
branch
2 times, most recently
from
October 13, 2026 22:09
e95b3c8 to
b6382d8
Compare
feywind
commented
Oct 13, 2026
feywind
force-pushed
the
pubsub/hedging-queue-integration-and-tests
branch
2 times, most recently
from
October 15, 2026 19:01
e89fc18 to
02582a7
Compare
This was referenced Oct 15, 2026
feywind
marked this pull request as ready for review
October 15, 2026 21:33
feywind
force-pushed
the
pubsub/hedging-queue-integration-and-tests
branch
from
October 19, 2026 21:58
02582a7 to
1231c0c
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 5 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 MessageQueue(this PR)test(pubsub): add unit tests for publish hedging queue integrationtest(pubsub): add publish hedging system testsSummary of Changes in This PR
This layer wires
CancellationSharer,HedgingScheduler,AbortSignalcancellation, and OpenTelemetry/logging intoPublisher,MessageQueue._publish, andPubSub.prototype.request:PubSub.prototype.request(handwritten/pubsub/src/pubsub.ts):config.gaxOpts?.signal?.abortedbefore and afterthis.getClient_, immediately invoking the callback with aCANCELLEDServiceErrorif aborted before the GAPIC method is called.PublisherLifecycle (handwritten/pubsub/src/publisher/index.ts):HedgingSchedulerinsetOptionswhenhedgingis configured (logging'Hedging rate limited due to lack of tokens.'at debug level when rate-limited) and clears any pending timer onflush().MessageQueue._publish&OrderedQueue(handwritten/pubsub/src/publisher/message-queues.ts):OrderedQueuenever hedges (allowsHedging()returnsfalse).Queue:0with its ownAbortControllerand full GAX retry settings.hedgingScheduler.scheduleFirstHedge: each hedged attempt logs'Publishing hedged attempt %i', recordsPubsubEvents.publishStartHedged, and dispatches a non-retrying (retry: null) publish RPC withtimeout: attemptTimeout.millisecondsand its ownAbortController.PubsubEvents.publishEndHedgedwhen a hedged attempt wins (orPubsubEvents.publishEndotherwise) and resolves message callbacks with the winning attempt'smessageIds.