Repository navigation
[ISSUE #151] fix(remoting): make split assignment and partition discovery survive direct-connect route races - #152
Merged
Conversation
… discovery survive direct-connect route races Two silent defects surface when the client talks to NameServers directly (open-source deployment, no proxy): 1. Starting offsets are ignored for a random subset of queues. RebalancePullImpl.computePullFromWhereWithException is hard-coded to 0, so assign() lets the client-internal rebalance thread dispatch a first pull from offset 0 while handleSplitsChanges is still seeking to the configured starting offset. No Flink-side lock scope can win that race. Enforce the starting offset deterministically at the fetch() outlet instead: records below max(startingOffset, 0) are dropped there, and seek() remains as a traffic optimization. 2. A NameServer outage restarts the job and rewinds offsets. The periodic partition discovery flattened per-topic route fetch failures into an empty queue set; diffed against the allocated set that revokes every split, and the queues returning after recovery are re-initialized from scratch (observed: +150 replayed records). A failed fetch says nothing about the actual route: exclude failed topics from the round, skip the round when every topic failed, and keep the current assignment when an empty result arrives while queues are allocated. Genuine deletions surface again on later rounds. Also document that EXACTLY_ONCE is not supported on proxy-fronted endpoints (transaction state lives in per-proxy-process memory and is silently dropped), while direct deployments do support it. Cluster verification of the outage scenario after the fix: job RUNNING throughout the 60s NameServer stop, zero split decreases, zero replay (sink grew exactly by the second wave), producer recovered within 150s of the NameServer coming back.
lizhimins
force-pushed
the
direct-connect-stability
branch
from
October 29, 2026 05:56
b34b979 to
3d8b17c
Compare
This was referenced Nov 2, 2026
lizhimins
added a commit
that referenced
this pull request
Nov 6, 2026
…me re-added queues from checkpoint offsets (#162) Two gaps remained in periodic partition discovery after #152: 1. A partial route-fetch failure across multiple topics still revoked the failed topic's queues: requestServiceDiscovery only skipped the round when every topic failed, and the plain set difference against the allocated set reported the failed topic's queues as decreased. The discovery callable now returns the failed topics together with the discovered queues, and the coordinator excludes their queues from the decrease evaluation. A failed fetch is no evidence of absence. 2. A revoked queue that reappeared restarted from the configured starting selector: initializeSourceSplits discarded the checkedOffsets entry on decrease, so the re-added queue was re-resolved (with EARLIEST, replaying the whole queue). The last checkpointed offset is now retained for revoked queues and preferred when the queue reappears, the same rule the migration path already applies to surviving queues. The selector still applies to genuinely new queues, and after coordinator failover where the retained offsets are lost. RocketMQSourceEnumeratorDiscoveryToleranceTest now covers the per-topic exclusion on partial failures at both the handler and the diff level; the new RocketMQSourceEnumeratorRevokedOffsetResumeTest covers checkpoint resume, new-queue selector fallback, mixed rounds, and the NO_STOPPING_OFFSET guard.
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.
What is the purpose of the change
Fixes the two silent defects reported in #151, both observed during an acceptance run against an open-source RocketMQ 5.5.1 cluster with clients connecting to NameServers directly (no proxy):
Starting-offset race (D24) —
RebalancePullImpl.computePullFromWhereWithExceptionin rocketmq-client 5.5.1 is hard-coded toreturn 0, soassign()lets the client-internal rebalance thread dispatch a first pull from offset 0 whilehandleSplitsChangesis still seeking to the configured starting offset. Withlatest/timestamp/ explicit-offset modes, a random subset of queues (~half per run, subset varies) replays history. No Flink-side lock scope can win this race — the pull happens on client-internal threads, and presetting the offset store does not help becausecomputePullFromWherenever reads it (both alternatives were tried and verified ineffective).Fix: enforce the starting offset deterministically at the
fetch()outlet — records withqueueOffset < max(startingOffset, 0)are dropped using the split's recorded starting offset.seek()remains as a traffic-reduction optimization.Route-fetch failure misread as an empty route (D26) — during a NameServer outage every
fetchMessageQueuescall fails and the periodic discovery flattens the failures into an empty queue set; diffed against the allocated set, that revokes every split, and the queues returning after recovery go throughinitializeSourceSplitsagain (observed: job restart + 150 replayed records). The client already treats the NameServer as a weak dependency (topicRouteTablekeeps the last route on refresh failure), so the connector needs no route cache of its own — only the failure semantics fixed here.Fix: failed topics are excluded from the round (they cannot contribute decreases); a round where every topic failed is skipped; an empty result while queues are allocated keeps the current assignment. Genuine deletions surface again on later rounds.
Also documents that
EXACTLY_ONCEis not supported on proxy-fronted endpoints (transaction state lives in per-proxy-process memory and commits can be silently dropped), while direct deployments support it.Brief change log
RocketMQSplitReader.fetch(): drop records below the split's starting offset at the outlet.RocketMQSourceEnumerator: per-topic failure isolation inrequestServiceDiscovery, null round on total failure, empty-set guard inhandleSourceQueueChange.RocketMQSourceEnumeratorDiscoveryToleranceTest(5 cases, including documenting the empty-set diff hazard); existing split-reader tests cover the offset filter.docs/remoting-connector.md: EXACTLY_ONCE support matrix per endpoint type.Verifications
RESTARTING, sink 200 → 350 (+150 replayed);RUNNINGin 6/6 samples during the outage, guard log every discovery round, zero decreases, sink grew exactly by the second wave (202 = 101 + 101, 0 replayed), producer recovered within 150s of the NameServer returning.latest/timestamp/specific=10all show 0 out-of-range records and sink physical offsets exactly 101 per tier.Closes #151