Pubsub: let a queue subscribe to the same topic more than once - #168
Merged
Merged
Conversation
Current Aviator status
This PR was merged using Aviator (commit 60e8db2).
See the real-time status of this PR on the
Aviator webapp.
Use the Aviator Chrome Extension
to see the status of your PR within GitHub.
|
rjhuijsman
force-pushed
the
rjh.pubsub-idempotent-subscribe
branch
from
September 11, 2026 20:43
a380f1c to
a1bc2a1
Compare
rjhuijsman
marked this pull request as ready for review
September 11, 2026 20:46
rjhuijsman
requested review from
benh and
katfang
and removed request for
katfang
September 11, 2026 20:46
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
benh
approved these changes
Sep 13, 2026
`Topic.Subscribe` appended to `state.queue_ids` unconditionally, so subscribing the same queue to the same topic twice left a duplicate entry. `Topic.Broker` fans out over those ids, so a duplicate made it call `Enqueue` on one queue twice using a single `context`, which Reboot refuses: ValueError: To call 'rbt.std.collections.queue.v1.QueueMethods.Enqueue' of 'receiving-queue' more than once using the same context an idempotency alias or key must be specified The broker then retried with backoff forever and the topic never drained. That only happened when a second `Subscribe` landed before the broker had drained the topic, so it surfaced as a timeout under load: `//tests/reboot/std/pubsub/v1:test_pubsub_tests_ts` hit its 300s deadline in https://github.com/reboot-dev/reboot/actions/runs/34603229734/job/103275784303 `Subscribe` now skips a queue id the topic already carries, and `Broker` deduplicates the ids before fanning out, so a topic whose state accumulated duplicates before this fix drains instead of retrying forever. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TQxdTEi8qsBfxCcuLxrNmQ
Co-authored-by: Benjamin Hindman <benjamin.hindman@gmail.com>
aviator-app
Bot
force-pushed
the
rjh.pubsub-idempotent-subscribe
branch
from
September 14, 2026 09:24
99c28c3 to
80bc24d
Compare
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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.
Before this PR, PubSub's
Topic.Subscribeappended tostate.queue_idswithout checking whether that queue was already subscribed, so subscribing the same queue to a topic twice left a duplicate entry.Topic.Brokerfans out overstate.queue_ids, so the duplicate made it callEnqueueon that one queue twice using a singlecontext, which Reboot refuses:The broker then retried with backoff forever, so the topic never drained. Depending on the situation it may be a race — a second
Subscribemust land before the topic is drained — so this was seen as a flake in//tests/reboot/std/pubsub/v1:test_pubsub_tests_tsin this CI job on an unrelated PR.This commit makes it so that a second
Subscribedoes nothing.TESTED: new unit test.