Repository navigation
[Fix][Connector-V2] Fix RocketMQ silent rewind on transient consumer group metadata lookup failures - #12340
[Fix][Connector-V2] Fix RocketMQ silent rewind on transient consumer group metadata lookup failures #12340sun-9545sunoj wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
One or more issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes RocketMQ group-offset lookup so transient metadata failures do not silently rewind consumption.
Changes:
- Handles
TOPIC_NOT_EXISTper topic. - Checks topic existence before deciding offsets are absent.
- Propagates failures for existing topics.
File summaries
| File | Description |
|---|---|
| seatunnel-connectors-v2/connector-rocketmq/src/main/java/org/apache/seatunnel/connectors/seatunnel/rocketmq/common/RocketMqAdminUtil.java | Updated as part of this pull request. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
DanielLeens
left a comment
There was a problem hiding this comment.
Welcome to Apache SeaTunnel, @sun-9545sunoj, and thank you for this first contribution! You clearly did real diagnostic work here — tracing a silent-rewind data-duplication bug all the way down to a specific RocketMQ response code is exactly the kind of root-cause investigation we want to see. I dug through the surrounding call chain (including decompiling the actual rocketmq-tools:4.9.4 client to confirm the low-level behavior) and left detailed notes below. There are two things I'd like addressed before merge, and they're both very tractable.
What Problem Does This PR Solve?
RocketMqAdminUtil.currentOffsets() is used by RocketMqSourceSplitEnumerator.listConsumerGroupOffsets() when start.mode = CONSUME_FROM_GROUP_OFFSETS. Before this change, any MQClientException with ResponseCode.TOPIC_NOT_EXIST thrown while looking up the consumer group's committed offsets was caught and translated into Collections.emptyMap(). Back in RocketMqSourceSplitEnumerator.setPartitionStartOffset(), an empty groupOffsets map is treated as "consumer group truly has no committed offset yet" and triggers a fallback to CONSUME_FROM_FIRST_OFFSET — i.e. the connector starts re-reading the topic from the very beginning.
If the TOPIC_NOT_EXIST was actually caused by a transient/temporary inability to resolve route info (rather than a genuinely-new consumer group), this silently duplicates the entire topic's data into downstream sinks — a serious correctness bug for exactly-once/at-least-once pipelines relying on CONSUME_FROM_GROUP_OFFSETS to avoid reprocessing. The PR removes the blanket catch so any MQClientException (including TOPIC_NOT_EXIST) now propagates as RocketMqConnectorException(GET_CONSUMER_GROUP_OFFSETS_ERROR) instead of being swallowed.
1. Code Change Review
1.1 Core Logic Analysis
Before:
} catch (MQClientException | MQBrokerException | RemotingException | InterruptedException e) {
if (e instanceof MQClientException) {
if (((MQClientException) e).getResponseCode() == ResponseCode.TOPIC_NOT_EXIST) {
return Collections.emptyMap();
} else {
throw new RocketMqConnectorException(RocketMqConnectorErrorCode.GET_CONSUMER_GROUP_OFFSETS_ERROR, e);
}
} else {
throw new RocketMqConnectorException(RocketMqConnectorErrorCode.GET_CONSUMER_GROUP_OFFSETS_ERROR, e);
}
}After (RocketMqAdminUtil.java:296-299):
} catch (MQClientException | MQBrokerException | RemotingException | InterruptedException e) {
throw new RocketMqConnectorException(RocketMqConnectorErrorCode.GET_CONSUMER_GROUP_OFFSETS_ERROR, e);
}Does the normal path reach it? Yes. currentOffsets() is only invoked from RocketMqSourceSplitEnumerator.listConsumerGroupOffsets(), which is only called from setPartitionStartOffset() inside the CONSUME_FROM_GROUP_OFFSETS branch. That branch runs once, synchronously, during the enumerator's run() (SourceSplitEnumeratorTask.stateProcess(), STARTING -> RUNNING), i.e. on every job start/restart for any table configured with start.mode = CONSUME_FROM_GROUP_OFFSETS. This is squarely on the main startup path for that mode, not an obscure corner.
Does it correctly distinguish "transient" from "legitimate no-offset-yet"? This is the part I want to push back on. I decompiled DefaultMQAdminExtImpl.examineConsumeStats(String group, String topic) from rocketmq-tools-4.9.4.jar to see exactly what triggers TOPIC_NOT_EXIST:
public ConsumeStats examineConsumeStats(String consumerGroup, String topic) {
String retryTopic = MixAll.getRetryTopic(consumerGroup); // "%RETRY%" + group
TopicRouteData topicRouteData = examineTopicRouteInfo(retryTopic); // <-- looks up the RETRY topic, not `topic`!
...
for (BrokerData bd : topicRouteData.getBrokerDatas()) {
... this.mqClientInstance.getMQClientAPIImpl().getConsumeStats(addr, consumerGroup, topic, timeout);
result.getOffsetTable().putAll(...);
}
if (result.getOffsetTable().isEmpty()) {
throw new MQClientException(206, "Not found the consumer group consume stats, ...");
}
return result;
}The very first thing this method does is resolve route info for the consumer group's %RETRY%<group> topic — not the business topic passed in — and that lookup is where MQClientException(TOPIC_NOT_EXIST) originates (via examineTopicRouteInfo). Whether %RETRY%<group> exists in the name server depends on broker-side subscription-group auto-creation behavior, which is not purely a "temporary route-propagation blip":
- It can be genuinely transient (name-server route-info replication lag right after a broker restart) — this is the case the PR description targets, and the fix correctly turns this into a fail-fast/retryable error instead of silent data duplication. Good.
- It can also be a deterministic, long-lived condition: clusters that run with
autoCreateSubscriptionGroup=false(a common hardening setting for production RocketMQ clusters) never auto-create%RETRY%<group>unless an operator explicitly provisions the subscription group. For such a group,examineConsumeStatswill throwTOPIC_NOT_EXISTon every attempt, not just transiently.
Both cases produce the identical exception/response code, and the current fix cannot tell them apart. The net effect: this PR trades "silently re-reads the whole topic" for "silently caught nothing here, but now crash-loops forever" for the second class of deployments — the job will fail at every STARTING state transition, the engine's restart strategy will exhaust its retry budget, and the job dies without ever starting, until an operator manually provisions the subscription group/retry topic on the broker. That's a real behavioral regression risk for that class of deployment, and since it's config/cluster-hardening-dependent rather than code-path-dependent, it's exactly the kind of thing that won't show up in this PR's own testing but will show up in someone's production cluster.
I want to be clear this doesn't invalidate the fix's core direction — failing loudly is the right default for a data-correctness bug like this, and is strictly safer than silent duplication. But "fail fast and let the engine retry" only helps if the underlying condition can actually resolve on retry; for the autoCreateSubscriptionGroup=false case it never will. I'd suggest one of:
- A few bounded retries with backoff around the
examineConsumeStatscall specifically forTOPIC_NOT_EXISTbefore giving up and throwing (smooths over genuine name-server propagation delay without permanently blocking legitimately-provisioned-but-never-retried groups), or - At minimum, a clear, specific log/error message at the throw site distinguishing "consumer group offset lookup failed because
%RETRY%<group>route could not be resolved" from a generic wrapped exception, so operators aren't left guessing — right nowGET_CONSUMER_GROUP_OFFSETS_ERROR's message is the generic "Failed to get the offsets of the current consumer group" (RocketMqConnectorErrorCode.java:36-37), and the real cause is only visible if someone reads the wrapped cause's message.
I don't think a full retry-loop is a hard blocker for this specific fix (see Issue #2 below for what I do consider blocking), but I'd like the author/committers to at least explicitly weigh in on whether this edge case is acceptable as a fast-follow.
Checkpoint/restore interaction: I traced this carefully because it's the highest-risk area for this kind of change. currentOffsets()/listConsumerGroupOffsets() is not on the checkpoint-restore path. RocketMqSourceSplitEnumerator.setPartitionStartOffset() explicitly skips any MessageQueue present in restoredSplits (RocketMqSourceSplitEnumerator.java:328-336), and restoredSplits is populated by addSplitsBack() when isRestored && !initialized (splits delivered by the engine from the checkpoint before run() is first called). So a checkpoint-restored split's persisted offset is honored regardless of whether this new exception path is hit — restore correctness is unaffected by this change. Good.
1.2 Compatibility Impact
The PR description says "No. This restores the intended behavior..." — I'd push back on that framing. This is a genuine user-facing behavior change for start.mode = CONSUME_FROM_GROUP_OFFSETS: jobs that previously started successfully (even if silently mis-consuming data) in environments hitting this TOPIC_NOT_EXIST path will now fail to start at all until the underlying condition is resolved. That's the correct trade-off for data correctness, but it should be described accurately in the PR/release notes as an intentional behavior change ("connector now fails fast instead of silently rewinding"), not "no user-facing change," so operators upgrading know what to expect if they hit it.
No config options, public API, or serialization formats changed — good.
1.3 Performance / Side-Effect Analysis
currentOffsets()is only invoked once during enumerator startup (STARTING -> RUNNING), not on the periodic 60s dynamic-discovery loop (discoverySplits()only callsfetchPendingPartitionSplit()/offsetTopics(), which is a separate code path). So this is not a per-tick hot path — no steady-state performance concern.- No new retry logic was added, so there's no new retry-storm risk from this PR as written. (See 1.1 — if a bounded-retry mitigation is added later, it should use backoff to avoid hammering the name server.)
- If the underlying condition is non-transient, the engine's restart-strategy will retry job startup repeatedly per its configured policy — this is existing engine behavior, not something this PR introduces, but it's worth the author/committers knowing this PR is what would newly trigger that restart loop for the
autoCreateSubscriptionGroup=falsescenario above.
1.4 Error Handling and Logging
- Location:
RocketMqAdminUtil.java:296-299(newcatchblock). Problem: All four exception types (MQClientException,MQBrokerException,RemotingException,InterruptedException) are now wrapped with the same genericGET_CONSUMER_GROUP_OFFSETS_ERRORmessage ("Failed to get the offsets of the current consumer group"), and the specificTOPIC_NOT_EXIST/%RETRY%<group>-route-lookup context that the PR is specifically about is not surfaced at the SeaTunnel error-message level (only inside the wrapped cause). Risk: Slower triage in production — an operator seeingROCKETMQ-09in logs has no quick way to tell "genuinely transient" from "subscription group not provisioned" without digging into the stack trace. Improvement: Add a short log line (or extend the error message) identifying that this is a consumer-group-offset lookup failure specifically, so it's greppable and distinguishable from otherGET_CONSUMER_GROUP_OFFSETS_ERRORcauses. Severity: Minor. Raised by another reviewer: No. - Location: PR description, "Does this PR introduce any user-facing change?" section. Problem: Answered "No," but per 1.2 above this does change observable startup behavior for
CONSUME_FROM_GROUP_OFFSETSjobs hitting this path. Risk: Understates the change for anyone scanning the changelog; not a code risk. Improvement: Update the PR description to acknowledge the behavior change. Severity: Minor. Raised by another reviewer: No.
2. Code Quality Assessment
2.1 Standards / Comments
The change itself is minimal and easy to read; removing the nested instanceof branch in favor of a flat throw is a nice simplification and matches the multi-catch style already used for the other three exception types in this method. No new methods/classes were added, so no new Javadoc is required. Fine as-is.
2.2 Test Coverage
This is my other blocking item. The PR adds no test at all — the diff touches exactly one file (RocketMqAdminUtil.java, +2/-12), with no changes anywhere under src/test/java.
There's an existing, directly relevant test class, RocketMqSourceSplitEnumeratorTest, which already statically mocks RocketMqAdminUtil (via Mockito.mockStatic) and has a test for this exact code path: testRun_fallsBackToFirstOffsetWhenGroupOffsetsAreMissing (RocketMqSourceSplitEnumeratorTest.java:105-140). That test still passes with this change because it mocks RocketMqAdminUtil.currentOffsets(...) to directly return Collections.emptyMap(), bypassing the real try/catch entirely — so it doesn't actually exercise (or protect) the new behavior at all.
What's missing, and what I'd like to see before merge:
- A unit test that exercises the real (not the enumerator-level mocked)
RocketMqAdminUtil.currentOffsets()and confirms that when the underlying admin call throwsMQClientExceptionwithResponseCode.TOPIC_NOT_EXIST, the method now throwsRocketMqConnectorExceptionrather than returning an empty map. This is a small, self-contained test (mock/stubDefaultMQAdminExt/the admin tool) and directly proves the fix does what the PR claims. - Ideally, a companion enumerator-level test (extending
RocketMqSourceSplitEnumeratorTest, per this repo's test-class convention) asserting that whenlistConsumerGroupOffsetspropagates an exception,run()propagates it too instead of silently falling back toCONSUME_FROM_FIRST_OFFSET— this is the actual regression this PR is meant to prevent, so it deserves a test that would fail against the pre-fix code.
Per this repo's AGENTS.md/CLAUDE.md test-class convention, please extend RocketMqSourceSplitEnumeratorTest (and/or add a focused RocketMqAdminUtilTest if one doesn't exist) rather than creating an unrelated new test file.
2.3 Documentation
docs/en/connectors/source/RocketMQ.md currently documents CONSUME_FROM_GROUP_OFFSETS as "start from committed offsets of the consumer group" with no mention of failure-handling behavior, so this PR doesn't introduce a factual inaccuracy in the docs. Given 1.2 above, I'd suggest (non-blocking) a one-line addition noting that offset-lookup failures now fail the job rather than silently falling back, but I won't block on this — the connector changelog page is auto-generated from merged commits, so no manual changelog edit is needed here.
3. Architectural Soundness
The fix stays entirely within RocketMqAdminUtil/RocketMqSourceSplitEnumerator, doesn't touch any shared/engine-level code, doesn't add dependencies, and doesn't change any Option/config contract — very well-scoped for a first PR. The "fail loud instead of silently degrading correctness" direction is the right architectural choice for this connector. The one soundness gap is the one covered in 1.1: the chosen signal (ResponseCode.TOPIC_NOT_EXIST from the %RETRY%<group> route lookup) is necessary but not sufficient to prove "transient," so the fix is correct for the reported bug but incomplete as a general transient-vs-permanent classifier. That's a reasonable scope decision for a first, minimal PR as long as it's explicitly acknowledged rather than asserted as fully solved.
4. Issue Summary
| # | Location | Issue | Severity | Blocking? | Raised by another reviewer |
|---|---|---|---|---|---|
| 1 | RocketMqAdminUtil.java (whole PR) |
No test coverage at all for the changed behavior; existing test bypasses the real code path via mocking | Major | Yes | No |
| 2 | RocketMqAdminUtil.currentOffsets via examineConsumeStats's %RETRY%<group> route lookup |
TOPIC_NOT_EXIST is treated uniformly as "fail fast," but can also be a deterministic/long-lived condition (e.g. autoCreateSubscriptionGroup=false clusters), turning some legitimate deployments into a startup crash-loop instead of a duplication bug |
Major | Should be addressed or explicitly acknowledged/discussed before merge | No (Copilot's earlier automated review flagged a related but now-superseded concern against an older commit — see note below) |
| 3 | RocketMqAdminUtil.java:296-299 / error code message |
Generic wrapped error message doesn't distinguish this specific lookup failure for faster operator triage | Minor | No | No |
| 4 | PR description | "No user-facing change" understates the intentional startup-behavior change for CONSUME_FROM_GROUP_OFFSETS |
Minor | No | No |
Note on prior automated review: GitHub Copilot left a review against commit 6277d0d3, which reviewed an earlier iteration of this PR that included a topicExist(...) helper method. That code no longer exists in the current head commit (43064107) — the PR was simplified since then, and Copilot's specific inline comment about topicExist at old lines 190-198 no longer applies. Its underlying concern (inability to distinguish transient from non-transient TOPIC_NOT_EXIST) is conceptually the same class of issue as Issue #2 above, which I independently verified against the current code by decompiling the RocketMQ client.
5. Merge Recommendation
Thanks again for tracking this down, sun-9545sunoj — the root-cause diagnosis (tracing the silent rewind back to the specific TOPIC_NOT_EXIST swallow) is genuinely solid work, and "fail loud instead of silently duplicating data" is the right call for this bug. This isn't ready to merge yet, but the gap is small and very fixable:
Blocking items:
- Add test coverage that actually exercises the changed exception-handling logic in
RocketMqAdminUtil.currentOffsets()(not just the already-mocked enumerator test), proving the fix does what it claims and would fail against the old code. - Please respond to the transient-vs-permanent distinction issue (#2 in the table above) — either add a bounded retry/backoff around the
TOPIC_NOT_EXISTcase to smooth over genuine transient name-server delay, or explicitly confirm in the PR discussion that the "fail fast, no distinction" trade-off is acceptable to committers for clusters where the retry topic is never auto-created. Either outcome is fine, it just needs to be a conscious decision rather than an implicit one.
Everything else (scope, minimal diff, no dependency/API/compat surface changes, correct checkpoint/restore handling) looks good. Once the test coverage is in and #2 is addressed or explicitly discussed, I'd be happy to take another look — this should be a quick turnaround. Nice work, and welcome to the project!
Overall assessment: Changes requested (not yet mergeable).
|
Good job. Thanks a lot for your valuable contribution to Apache SeaTunnel! To pass the automated CI checks for this PR, could you please enable CI workflows in your forked repository first? You can refer to the check run link below as a reference for the required CI configuration: https://github.com/apache/seatunnel/runs/104752283889 If you run into any trouble enabling CI or encounter related errors during the process, feel free to leave a comment here. Contributors are always ready to offer help~ |
|
Thanks so much for the thorough review and for decompiling the client to trace the %RETRY%GroupName behavior! You are completely right about the autoCreateSubscriptionGroup=false edge case. I've updated the PR to address all your blocking and minor points:
Let me know if this looks good to you! |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround, sun-9545sunoj. I re-reviewed the latest head (0efc9e4) against my last round of comments. Both blocking items from my previous review are addressed: you added real test coverage that exercises the actual retry/exception path (not just a mocked bypass), and you added a bounded retry-with-backoff around the TOPIC_NOT_EXIST case, which was one of the two options I offered for the transient-vs-permanent distinction. Nice work closing the loop quickly.
I did find a few new, non-blocking things worth your attention in this new commit, and one important cross-PR note: PR #12349 ("Surface RocketMQ group-offset lookup failures instead of rewinding") targets the exact same root cause in the exact same method and takes a materially different approach. Maintainers should compare the two before merging either — see section 3.1 below.
What Problem Does This PR Solve?
RocketMqAdminUtil.currentOffsets() (used by RocketMqSourceSplitEnumerator.listConsumerGroupOffsets() when start.mode = CONSUME_FROM_GROUP_OFFSETS) previously caught any MQClientException with ResponseCode.TOPIC_NOT_EXIST from examineConsumeStats() and translated it into Collections.emptyMap(). The enumerator interprets an empty offsets map as "this consumer group has never committed anything" and falls back to CONSUME_FROM_FIRST_OFFSET, silently re-reading the whole topic. Since examineConsumeStats resolves route info for the group's %RETRY%<group> topic (not the business topic), a transient name-server route hiccup was indistinguishable from a genuinely new group, causing silent full-topic re-delivery. This commit replaces the blind "fail fast" from the previous iteration with a bounded retry (up to 3 attempts, 1s/2s/3s backoff) around the TOPIC_NOT_EXIST case, so brief route-propagation delays self-heal instead of immediately failing the job.
1. Code Change Review
1.1 Core Logic Analysis
This commit's diff (RocketMqAdminUtil.java:276-338):
for (String topic : topics) {
ConsumeStats consumeStats = null;
int maxRetries = 3;
int retryCount = 0;
while (true) {
try {
consumeStats = adminClient.examineConsumeStats(config.getGroupId(), topic);
break;
} catch (MQClientException e) {
if (e.getResponseCode() == ResponseCode.TOPIC_NOT_EXIST) {
if (retryCount < maxRetries) {
retryCount++;
Thread.sleep(1000L * retryCount);
continue;
} else {
throw new RocketMqConnectorException(... "route info ... could not be resolved" ...);
}
}
throw e;
}
}
if (consumeStats != null) {
consumerOffsets.putAll(consumeStats.getOffsetTable());
}
}Correctness: The logic is sound. retryCount is scoped per-topic (reset each loop iteration), non-TOPIC_NOT_EXIST MQClientExceptions are rethrown immediately without retry and land in the outer catch at line 331, and other exception types (MQBrokerException, RemotingException, InterruptedException) are unaffected by this change. The if (consumeStats != null) guard at line 320 is unreachable dead code in practice: by that point the loop has either break-ed with a non-null result or thrown, so consumeStats can never be null there — harmless but worth simplifying for readability.
Runtime path: As established in my last review, currentOffsets() -> listConsumerGroupOffsets() is called synchronously from RocketMqSourceSplitEnumerator.setPartitionStartOffset(), itself called from SourceSplitEnumeratorTask.stateProcess()'s STARTING -> RUNNING transition (SourceSplitEnumeratorTask.java:334, enumerator.run()). This confirms the blocking Thread.sleep calls execute on whatever thread is running that task's call(). I traced TaskExecutionService.java:173-174: tasks are submitted to Executors.newCachedThreadPool(new BlockingTaskThreadFactory()) — an elastic, per-task-oriented pool (not a small fixed cooperative pool), so a single task blocking for up to 6s (worst case: 1+2+3s across 3 retries) during job startup does not starve other jobs' coordination threads the way it would in a fixed-size shared executor. This lowers my initial concern from a P0 scheduling-starvation risk to a more moderate one (see 1.3).
Restore/checkpoint interaction: Unchanged from my last review — setPartitionStartOffset() explicitly skips any MessageQueue already present in restoredSplits, so checkpoint-restored splits are unaffected by this code path regardless of the retry outcome. Still correct.
Does the retry actually solve the transient-vs-permanent ambiguity from my last review? Only partially, by converting the ambiguity into "wait 6s longer before failing" rather than truly distinguishing the two cases. For a genuinely unprovisioned subscription group (autoCreateSubscriptionGroup=false), the job still fails at every STARTING transition — it just now takes ~6s longer per attempt to get there. That satisfies the letter of what I asked for last time (I offered "bounded retry with backoff" as one of two acceptable options), so I'm not re-opening this as a blocker. But it's worth flagging that sibling PR #12349 solves this more precisely without any blocking sleep at all — see 3.1.
1.2 Compatibility Impact
Same assessment as my last review: no config/API/serialization changes, but this is still a genuine behavior change for start.mode = CONSUME_FROM_GROUP_OFFSETS — jobs that previously started (silently mis-consuming) now block for up to ~6s longer on the failure path before failing outright. The PR description's "Does this PR introduce any user-facing change? No." still understates this; I flagged this as a minor, non-blocking item last round and it remains unaddressed. No action required, just noting it's still open.
1.3 Performance / Side-Effect Analysis
- Confirmed not a steady-state hot path:
currentOffsets()only runs once per job start/restart forCONSUME_FROM_GROUP_OFFSETStopics, not on the periodicdiscoverySplits()loop. - The retry loop uses
Thread.sleepdirectly in the loop body rather than the project's existingorg.apache.seatunnel.common.utils.RetryUtils.retryWithException(Execution, RetryMaterial)utility, which is already used by ~15 other modules (elasticsearch, easysearch, starrocks, typesense, engine checkpoint code, etc.) for exactly this bounded-retry-with-backoff pattern. Reusing it here would reduce duplicated retry/backoff logic and keep the codebase consistent. This is a code-quality suggestion, not a defect. - Under a mass-restart scenario (e.g. cluster-wide failover restarting many
CONSUME_FROM_GROUP_OFFSETSjobs simultaneously while name-server routes are still propagating), each affected enumerator task thread blocks up to 6s. Given the cached-thread-pool model this grows threads rather than deadlocking, but it does mean a burst of OS thread creation proportional to the number of concurrently-starting jobs hitting this path — bounded and self-resolving, not a leak, just worth the committers' awareness at very large job-concurrency scale.
1.4 Error Handling and Logging
Issue 3 (see table below): the improved error message at RocketMqAdminUtil.java:308-312 is a good fix for my prior minor point — it now explicitly names the topic and explains the two possible causes. No further action needed there.
2. Code Quality Assessment
2.1 Coding Standards
No new public methods or classes were added, so no new Javadoc obligations. Minor nit: the new test file (RocketMqSourceSplitEnumeratorTest.java) uses fully-qualified inline class names (org.apache.seatunnel.connectors.seatunnel.rocketmq.exception.RocketMqConnectorException) three times instead of adding imports — not a functional problem, just inconsistent with the rest of the codebase's style. Worth a quick cleanup pass but not blocking.
2.2 Test Coverage and Test Stability
Both tests genuinely exercise the changed behavior (unlike the previous round's enumerator test, which bypassed the real code via static mocking):
RocketMqAdminUtilTest.testCurrentOffsetsThrowsWhenRouteInfoNotFounddrives the realcurrentOffsets()retry loop via a mockedDefaultMQAdminExtand asserts 4 totalexamineConsumeStatsinvocations (1 + 3 retries) and the final exception message. Good, this is exactly the test I asked for.RocketMqSourceSplitEnumeratorTest.testRun_propagatesExceptionWhenGroupOffsetsLookupFailsasserts thatenumerator.run()propagates the exception instead of falling back toCONSUME_FROM_FIRST_OFFSET. This directly protects the regression this PR fixes.
Mandatory flaky-test-analysis rating: Risk present. RocketMqAdminUtilTest.testCurrentOffsetsThrowsWhenRouteInfoNotFound deterministically triggers the full retry budget (the mock always throws TOPIC_NOT_EXIST), which means this single test always burns the real 1000L*1 + 1000L*2 + 1000L*3 = 6 seconds of wall-clock time via Thread.sleep inside production code, with no way to inject a shorter backoff for tests. It won't produce false failures (deterministic outcome), so this isn't "High risk," but it's a real instance of the "hard wait instead of injectable/configurable delay" anti-pattern this review protocol calls out, and it will measurably slow down this module's test suite every run. Suggest making the backoff base delay a package-private constant or injectable parameter so tests can override it to near-zero.
2.3 Documentation Updates
No documentation changes needed for this iteration; same as my last review, docs/en/connectors/source/RocketMQ.md doesn't currently claim any failure-handling behavior that this PR contradicts.
3. Architectural Soundness
3.1 Precise fix / workaround / long-term, and comparison with PR #12349
This PR's retry-with-backoff is a reasonable, minimal, pragmatic fix for the reported bug, and it does stop the silent-rewind data-duplication issue. However, I want to flag clearly for committers: PR #12349 ("Surface RocketMQ group-offset lookup failures instead of rewinding") modifies the exact same method in the exact same file to fix the exact same root cause, and takes a different, arguably more precise approach — instead of blindly retrying examineConsumeStats on TOPIC_NOT_EXIST and waiting out a fixed timeout, it adds a topicRouteAvailable(adminClient, topic) helper that re-resolves the requested business topic's own route (not the retry-topic route) to decide whether the TOPIC_NOT_EXIST on the retry topic reflects a genuine "group never registered" state (business topic route still resolves -> return empty map, correct fallback) versus a real outage (business topic route also unavailable -> propagate the failure). That approach makes an immediate, non-blocking determination with no Thread.sleep at all, and it is a closer match to what GitHub Copilot's automated review originally suggested on this PR's earlier commit (distinguish via the main topic's route, not a boolean re-check of the same failing signal).
The two PRs are not complementary drop-in additions to each other — they touch overlapping code and both claim to fully fix the same issue (#12332), so only one should be merged as-is, or the two approaches should be reconciled into a single PR. I'd recommend committers read #12349's diff alongside this one before deciding; from a pure design standpoint #12349's route-recheck avoids the blocking-sleep and slow-test concerns raised in 1.3/2.2 above, at the cost of relying on the assumption that a name-server route outage affects the business topic and its group's retry topic together (a reasonable but not airtight assumption, since topics can be sharded to different brokers). This PR's retry-based approach is simpler to reason about but pays for it in wall-clock latency and doesn't reuse the project's existing RetryUtils.
3.2 Maintainability
Change stays fully within RocketMqAdminUtil, no shared/engine-level code touched, no new dependencies. Reasonably maintainable, modulo the RetryUtils duplication noted in 1.3.
3.3 Extensibility
No new public surface added; low extensibility concern either way.
3.4 Historical-version compatibility
No config/API/protocol/serialization changes. The observable behavior change (slower failure instead of instant fallback for permanently-unresolvable groups) is a runtime-behavior change only, not a version-compatibility break.
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | Hand-rolled Thread.sleep-based retry duplicates the project's existing RetryUtils.retryWithException/RetryMaterial utility already used across ~15 other modules |
RocketMqAdminUtil.java:289-318 |
Minor |
| 2 | New unit test deterministically burns ~6 real seconds of wall-clock time due to hard-coded retry backoff with no injectable/configurable delay for tests | RocketMqAdminUtilTest.java (whole test) |
Minor |
| 3 | PR description still answers "No" to "Does this PR introduce any user-facing change?" despite the startup-failure-timing behavior change (carried over from my last review, still unaddressed) | PR description | Minor |
| 4 | Overlaps with PR #12349, which fixes the same root cause via a non-blocking route-recheck instead of blocking retry; only one should be merged, or the approaches should be reconciled | N/A (cross-PR) | Medium (process, not code defect) |
| 5 | Dead/unreachable null-check on consumeStats after the retry loop |
RocketMqAdminUtil.java:320 |
Trivial |
| 6 | CI Build check is action_required ("Unable to detect the workflow run") — GitHub Actions still appears disabled on the fork; this was already flagged in my prior comment |
https://github.com/apache/seatunnel/runs/105080624653 | Blocking for merge (infra, not code) |
5. Merge Recommendation
Conclusion: Ready to merge after fixes
1. Blockers — must be fixed:
- CI is not currently producing a real signal for this PR (
Buildcheck isaction_required, workflow run not detected on the fork — see Issue 6). This must resolve to actual green CI results before merge, independent of code quality. - Committers must decide the PR #12349 overlap (Issue 4) before merging either PR, since both modify the same method to fix the same root cause via different mechanisms.
2. Recommended fixes — non-blocking:
- Reuse
RetryUtils.retryWithExceptioninstead of the hand-rolled loop (Issue 1). - Make the retry backoff configurable/injectable so
RocketMqAdminUtilTestdoesn't need real 6-second sleeps (Issue 2). - Update the PR description's user-facing-change answer (Issue 3).
- Clean up the dead null-check (Issue 5) and the inline-FQN test style nit noted in 2.1.
Both blocking items from my previous review are genuinely resolved in this commit — the fix now fails loud with real test coverage backing it, and the retry/backoff addresses the transient-vs-permanent concern I raised, even if not as elegantly as #12349's approach. Setting aside the CI and duplicate-PR situation, the code itself is in good shape. Thanks again for the responsive follow-up, and welcome to the project.
Overall assessment: code-level changes look solid; merge is gated on CI actually running and on committers resolving the overlap with #12349.
…group metadata lookup failures
… to consumer group offset lookup
|
Thanks for the detailed review and for pointing out PR #12349! I've taken a close look at how PR #12349 solves the issue. Their approach of using topicRouteAvailable to distinguish between a genuinely unprovisioned consumer group and a missing route is a great, precise solution. However, if used alone, it will still instantly throw an exception and fail the job if the name server is experiencing a transient route propagation delay (i.e., if both routes are temporarily missing).
Let me know if this hybrid approach looks good for merging! |
DanielLeens
left a comment
There was a problem hiding this comment.
Thank you for the follow-up, @sun-9545sunoj, and for rebasing onto the latest dev after #12349 landed. Your 2026-09-21 comment describes a hybrid design: keep the topicRouteAvailable decision from #12349 (healthy business-topic route means a genuinely new group, so return an empty map without retrying), and add a bounded RetryUtils retry only when both routes are missing. That is a sensible idea, and it answers the overlap concern I raised last round (#12349 is now on dev as b70652be8af, so this PR is now purely "bounded retry on top of the merged fix"). I re-read the whole effective diff against dev at head 57dda37 (3 files). Unfortunately the current head cannot compile, and a few other things need attention before it can go further. I know that is a lot to receive in a row, so I have listed a concrete fix for each item below, and I think all of it is small.
What Problem Does This PR Solve?
- User pain point: With
start.mode = CONSUME_FROM_GROUP_OFFSETS, a name-server route hiccup while resolving the group's%RETRY%<group>topic makesexamineConsumeStatsfail withTOPIC_NOT_EXIST. Older code treated that as "nothing committed" and the enumerator silently re-read the whole topic (#12332). - Fix approach (current head):
currentOffsetswrapsexamineConsumeStatsinRetryUtils.retryWithException; it retries only when the requested topic's own route is also unavailable. After the retries it re-probes: route healthy -> empty map (cold start), route missing ->RocketMqConnectorException. - One-sentence summary: Add a bounded retry on top of #12349's route probe so a short name-server blip does not fail the job immediately.
- Before/after: before (
dev), route outage -> immediateRocketMqConnectorExceptionand the job fails; after (intended), route outage -> retry up to 3 attempts, then fail.
1. Code Change Review
1.1 Core Logic Analysis
Effective diff vs dev: RocketMqAdminUtil.java (retry wrapper, new RETRY_BACKOFF_MILLIS field, rewritten catch block), RocketMqAdminUtilTest.java (backoff override, extra verify(times(..)) assertions, and deletion of the license header and Javadocs), RocketMqSourceSplitEnumeratorTest.java (one new test).
Key change in RocketMqAdminUtil.currentOffsets(DefaultMQAdminExt, ...) (RocketMqAdminUtil.java:330-402):
// dev
catch (MQClientException e) {
if (TOPIC_NOT_EXIST && topicRouteAvailable(...)) { return Collections.emptyMap(); }
throw new RocketMqConnectorException(GET_CONSUMER_GROUP_OFFSETS_ERROR, e);
} catch (MQBrokerException | RemotingException e) { throw new RocketMqConnectorException(...); }
catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RocketMqConnectorException(...); }
// this PR
ConsumeStats s = RetryUtils.retryWithException(() -> adminClient.examineConsumeStats(groupId, topic),
new RetryUtils.RetryMaterial(3, true, e -> TOPIC_NOT_EXIST && !topicRouteAvailable(..), RETRY_BACKOFF_MILLIS, true));
...
catch (Exception e) {
Throwable cause = (RuntimeException with message containing "failed after retry") ? e.getCause() : e;
if (TOPIC_NOT_EXIST) { probe again -> emptyMap() or RocketMqConnectorException }
if (cause instanceof MQClientException) throw (MQClientException) cause; // raw rethrow
... MQBrokerException / RemotingException raw rethrow ... throw new RuntimeException(cause);
}Key findings:
- The idea is right and the healthy-route cold-start branch and the "other response codes are not retried" branch are structurally correct.
- The rewritten catch block does not compile (Issue 1) and replaces the connector's error contract with raw checked exceptions and
RuntimeException(Issue 4). - The backoff that
RetryUtilsproduces withsleepTimeIncrease = trueis 2s + 4s + 8s, not the 1s/2s/3s described in the PR comment (Issue 6). - The final decision re-probes the route after the retries, so a confirmed outage can still turn into "nothing committed" (Issue 5).
Runtime path (does the normal user path reach this code? yes, for every job with CONSUME_FROM_GROUP_OFFSETS):
SourceSplitEnumeratorTask.stateProcess STARTING -> RUNNING (SourceSplitEnumeratorTask.java:334, enumerator.run())
-> RocketMqSourceSplitEnumerator.setPartitionStartOffset (case CONSUME_FROM_GROUP_OFFSETS, RocketMqSourceSplitEnumerator.java:379-380)
-> listConsumerGroupOffsets (RocketMqSourceSplitEnumerator.java:455-458)
-> RocketMqAdminUtil.currentOffsets(config, ...) (RocketMqAdminUtil.java:295)
-> currentOffsets(adminClient, ...) <- changed code (RocketMqAdminUtil.java:330)
empty map -> CONSUME_FROM_FIRST_OFFSET fallback (silent replay); exception -> task fails
The retry sleeps on the task thread (TaskExecutionService.java:174 uses a cached pool, as I traced last round), only once per (re)start, and checkpoint-restored splits are skipped before this lookup, so restore semantics are unchanged. No duplicate or lost records are introduced by the retry itself; the only data-correctness exposure is the empty-map path in Issue 5.
1.2 Compatibility Impact
Fully compatible for config options, defaults, state and serialization (nothing in those layers changes). Two behavior notes: the failure path becomes slower (Issue 6), and the exception types leaving currentOffsets change (Issue 4), which must be reverted to keep the existing contract.
1.3 Performance / Side-Effect Analysis
- Not a hot path: one lookup per job start/restart.
- Worst-case blocking is 14s (2+4+8) on the enumerator task thread, including an 8s sleep after the last failed attempt that is never followed by another try. On a mass restart during a name-server incident, every affected enumerator blocks that long (Issue 6).
- Each retry decision performs an extra
examineTopicRouteInfoRPC, and the final decision performs one more. That is small, but during an outage each call can also wait for a client timeout.
1.4 Error Handling and Logging
Issue 1: The head does not compile (missing import and unreported checked exceptions)
- Location:
RocketMqAdminUtil.java:374(Collections.emptyMap()),:385,:388,:391 - Problem: The diff removes
import java.util.Collections;(the import block at:53-60no longer has it) butCollections.emptyMap()is still used at:374. In addition,currentOffsets(DefaultMQAdminExt, ...)at:330has nothrowsclause, yet the new catch block doesthrow (MQClientException) cause;,throw (MQBrokerException) cause;,throw (RemotingException) cause;. In the pinned dependencyrocketmq-client:4.9.4(connector-rocketmq/pom.xml:32),MQClientException,MQBrokerExceptionandRemotingExceptionall extendjava.lang.Exception, so these are checked exceptions. - Potential risk: The connector module and every job that ships it fail to build. This is a static-reading conclusion; I did not run the build (it is also why I expect the fork CI to fail once it runs).
- Best improvement: Restore the
java.util.Collectionsimport and stop rethrowing raw checked exceptions (see Issue 4 for the shape). - Severity: High
- Raised by another reviewer: No
Issue 2: The ASF license header was deleted from the existing test file
- Location:
RocketMqAdminUtilTest.java:1(the file now starts withpackage; ondevit starts with the ASF header) - Problem: The ASF license header and the class/method Javadocs from #12349 were removed in this diff (probably a side effect of resolving the merge conflict). The repository has a
license-headerjob (.github/workflows/backend.yml:39-47) that other jobs depend on (needs: [ license-header, ... ]at:92,:143). - Potential risk: License-header check fails, which blocks all the downstream backend jobs, and the file is no longer compliant with Apache policy.
- Best improvement: Restore the header exactly as on
dev. While there, please also restore the Javadocs that explained the contract of each test (see Issue 9); only the added lines (RETRY_BACKOFF_MILLIS = 0Land theverify(...)calls) are actual changes. - Severity: High
- Raised by another reviewer: No
Issue 3: The updated tests do not match the implementation
- Location:
RocketMqAdminUtilTest.java:80(times(4)),:84-105 - Problem: (a)
routeOutageSurfacesAsFailureWithRetriesasserts 4 calls toexamineConsumeStats.RetryUtils.retryWithExceptionrunsdo { i++; execute ... } while (i < retryTimes)(RetryUtils.java:45-73), soretryTimes = 3means 3 executions, not 1 + 3. By my reading of the code the assertion should betimes(3); with the current value the test would fail once the module compiles. (b)otherResponseCodeSurfacesEvenWhenRouteHealthyexpectsRocketMqConnectorException, but for a non-TOPIC_NOT_EXISTMQClientExceptionthe new code rethrows the rawMQClientException(:385), so that assertion would fail too (this is the Issue 4 regression, which the test correctly catches). - Potential risk: The module's unit tests are red even after Issue 1 is fixed.
- Best improvement: Change the expectation to the true number of executions after deciding the retry budget you actually want (see Issue 6), and fix Issue 4 so (b) passes unchanged.
- Severity: High
- Raised by another reviewer: No
Issue 4: The error contract of currentOffsets changed: raw exceptions and RuntimeException instead of RocketMqConnectorException
- Location:
RocketMqAdminUtil.java:357-398 - Problem: On
devevery failure leaves this method asRocketMqConnectorException(GET_CONSUMER_GROUP_OFFSETS_ERROR, cause), includingInterruptedException(with the interrupt flag restored). The new block rethrows rawMQClientException/MQBrokerException/RemotingException, and turnsInterruptedExceptioninto a plainRuntimeException. It also detects theRetryUtilswrapper by matching the substring"failed after retry"in the message (:359-362), which is brittle: any otherRuntimeExceptionwhose message contains that text, or a future rewording inRetryUtils, silently changes behavior. - Potential risk: Callers and tests that rely on
RocketMqConnectorException(includingRocketMqAdminUtilTest.java:84-105and the enumerator tests) break, and operators lose theGET_CONSUMER_GROUP_OFFSETS_ERRORcode in logs. - Best improvement: One uniform exit: unwrap the retry wrapper via
e.getCause()wheneis aRuntimeExceptionwhose cause is anException, handle theTOPIC_NOT_EXISTdecision, and then always thrownew RocketMqConnectorException(RocketMqConnectorErrorCode.GET_CONSUMER_GROUP_OFFSETS_ERROR, cause). Ifcauseis anInterruptedException, callThread.currentThread().interrupt()first. Note thatRetryUtils.retryWithExceptiondeclaresthrows Exception, so this singlecatch (Exception e)is fine. - Severity: High (it changes an existing contract and is what makes Issue 1 hard to fix by just adding
throws) - Raised by another reviewer: No
Issue 5: After the retries are exhausted the code probes the route again, so a confirmed outage can still become "nothing committed"
- Location:
RocketMqAdminUtil.java:346-351(retry predicate) and:367-374(final decision) - Problem: Every retry was justified because the probe said the business topic route was missing, but the final
if (topicRouteAvailable(...))at:367is a fresh, independent probe made after up to 14s of sleeping. If the business route has come back by then while the%RETRY%route is still unresolved, the method returnsCollections.emptyMap(), and the enumerator replays the whole topic (RocketMqSourceSplitEnumerator.java:381-383). That is exactly the silent rewind #12332 is about. The window exists ondevtoo, but the retry loop makes it wider and adds a second decision point that can disagree with the first. Whether the routes actually recover in that order on a real cluster is an inference on my side; the double-decision structure itself is verifiable in the code. - Potential risk: Rare silent full-topic re-delivery after an outage.
- Best improvement: Decide once. For example, record, in a sticky flag (an
AtomicBooleanset to true the first time the predicate sees the route missing), that an outage was observed, and use that flag in the final branch instead of probing again, so "we retried because the route was missing" can never end in "empty map". - Severity: Medium
- Raised by another reviewer: No
Issue 6: Backoff is 2s + 4s + 8s (14s), not 1s/2s/3s, and it sleeps after the last attempt
- Location:
RocketMqAdminUtil.java:354-355(RETRY_BACKOFF_MILLIS, true),RetryUtils.java:60and:159 - Problem: With
sleepTimeIncrease = truethe wait issleepTimeMillis << attempt(RetryUtils.java:159), i.e. 2s, 4s, 8s, andRetryUtilsalso sleeps after the third failed attempt before giving up (:60-67runs before thewhilecheck). The PR comment says 1s, 2s and 3s. The job therefore blocks for 14s on the enumerator thread before it can fail, and 8s of that is pure waiting. - Potential risk: Slower failure than described; heavier during mass restarts.
- Best improvement: Use the 4-argument
RetryMaterial(3, true, condition, RETRY_BACKOFF_MILLIS)(fixed interval), or keep the increase but pick a smaller base so the total stays in the few-second range you intended. - Severity: Medium
- Raised by another reviewer: No
Issue 7: Non-final mutable static used for test injection, never reset
- Location:
RocketMqAdminUtil.java:67,RocketMqAdminUtilTest.java:28,:54,:85 - Problem:
static long RETRY_BACKOFF_MILLISis written by three tests and never restored, so it leaks to any other test in the same JVM, and the two "successful lookup" tests silently depend on whether it was already set. It is harmless in production today, but it is a mutable global in a utility class. - Potential risk: Order-dependent tests; surprising global state.
- Best improvement: Add a package-private overload
currentOffsets(adminClient, groupId, topics, queues, long backoffMillis)(the existing 4-arg method delegates with the default), and let tests pass0L. No static state needed. - Severity: Low
- Raised by another reviewer: No
Issue 8: The new enumerator test duplicates an existing, stronger test
- Location:
RocketMqSourceSplitEnumeratorTest.java:150versus:363 - Problem:
testRun_propagatesExceptionWhenGroupOffsetsLookupFailsis the same scenario asdev'stestRun_doesNotFallBackToFirstOffsetWhenGroupOffsetLookupFails(:363), which additionally verifies thatflatOffsetTopicsis never called. Both mockRocketMqAdminUtil.currentOffsetsstatically, so neither exercises this PR's retry code. - Potential risk: None functionally; extra maintenance.
- Best improvement: Drop the new test (the retry behavior belongs in
RocketMqAdminUtilTest). - Severity: Low
- Raised by another reviewer: No
Issue 9: Removed Javadocs, and currentOffsets Javadoc does not mention the retry
- Location:
RocketMqAdminUtilTest.java(class and per-test Javadocs),RocketMqAdminUtil.java:306-329 - Problem: The test Javadocs from #12349 explained why each case exists; they were deleted. The production Javadoc still describes only the single probe, not the retry budget or the "both routes missing" condition.
- Best improvement: Restore the test Javadocs and add two sentences to the production Javadoc (retry only when both routes are missing; single decision as in Issue 5).
- Severity: Low
- Raised by another reviewer: No
Issue 10: PR description is stale
- Location: PR description
- Problem: It still says the exception is simply allowed to propagate (the first iteration), answers "No" to the user-facing-change question, and does not describe the hybrid design from your 2026-09-21 comment. This was already noted last round (my old Issue 3).
- Best improvement: Update the description to the hybrid approach and mention the failure-path delay.
- Severity: Low
- Raised by another reviewer: No
Status of the points from my previous review (0efc9e4):
| # | Previous point | Status at 57dda37 |
Evidence |
|---|---|---|---|
| 1 | Hand-rolled Thread.sleep loop should use RetryUtils |
FIXED (with new issues 4, 5, 6) | RocketMqAdminUtil.java:339-355 |
| 2 | Unit test burned 6 real seconds | PARTIALLY | Backoff is injectable (:67, tests :28,:54,:85), but through a mutable static (Issue 7), and the production budget is now 14s (Issue 6) |
| 3 | PR description says "no user-facing change" | NOT FIXED | PR description, Issue 10 |
| 4 | Overlap with #12349 | FIXED | b70652be8af is on dev; this PR is rebased on it and only adds the retry |
| 5 | Dead null-check on consumeStats |
FIXED | Removed; consumeStats.getOffsetTable() at :356 |
| 6 | CI Build check action_required |
NOT FIXED / unchanged | See CI note in section 5 |
| - | Fully-qualified names in the test | FIXED | New enumerator test uses imports (RocketMqSourceSplitEnumeratorTest.java:23-24) |
2. Code Quality Assessment
2.1 Coding Standards
Issues 1, 2, 4 and 9 above. The long String.format literal at :378 is fine for spotless, but you mentioned running spotless; the missing license header suggests the merge resolution touched the file afterwards, so please run ./mvnw spotless:apply -pl seatunnel-connectors-v2/connector-rocketmq -nsu once more after the fixes.
2.2 Test Coverage and Test Stability
The intended coverage is good: healthy route -> 1 call and empty map, route outage -> retries then failure, other response code -> no retry. Those three are exactly the right cases. They need the corrections in Issues 2, 3, 4. Missing case worth adding: route probe says "missing" on the first attempt and "available" on the last (Issue 5), asserting the method throws rather than returning empty.
Stability rating: Risk present (RocketMqAdminUtilTest.java:28,54,85 mutate RocketMqAdminUtil.RETRY_BACKOFF_MILLIS without restoring it; separately, the outage test's times(4) at :80 is a deterministic mismatch, tracked as Issue 3). No sleeps, ports or containers are used, because the backoff is 0 in the retry tests.
2.3 Documentation Updates
No connector doc change is needed (docs/en and docs/zh RocketMQ pages describe options, not failure timing). The PR description needs updating (Issue 10).
3. Architectural Soundness
3.1 Elegance of the Solution
Reasonable long-term direction, currently not clean: two independent decision points (retry predicate and final catch) and two exception-mapping styles make the method hard to reason about. A single "probe result" plus a single exit that wraps everything in RocketMqConnectorException would make it a precise, small addition on top of #12349.
3.2 Maintainability
Reusing RetryUtils is good. Detecting its wrapper by message substring and the static test hook are the two maintainability costs (Issues 4, 7).
3.3 Extensibility
No public surface added. If maintainers later want the retry budget configurable, a package-private parameter (Issue 7) is the easy first step.
3.4 Historical-Version Compatibility
No option, default, state or serialization change, so old jobs and checkpoint restore are unaffected. The one behavioral difference to document is the longer failure path when both routes are missing.
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | Head does not compile: missing Collections import, checked exceptions rethrown without throws |
RocketMqAdminUtil.java:374,385,388,391 |
High |
| 2 | ASF license header deleted from existing test file | RocketMqAdminUtilTest.java:1 |
High |
| 3 | Tests contradict implementation (times(4) vs 3 executions; RocketMqConnectorException expectation vs raw rethrow) |
RocketMqAdminUtilTest.java:80,84-105 |
High |
| 4 | Error contract changed: raw exceptions / RuntimeException, brittle "failed after retry" matching |
RocketMqAdminUtil.java:357-398 |
High |
| 5 | Re-probe after retries can turn a confirmed outage into an empty map (silent rewind) | RocketMqAdminUtil.java:346-351,367-374 |
Medium |
| 6 | Real backoff is 2s+4s+8s (14s) including a useless final sleep; PR says 1s/2s/3s | RocketMqAdminUtil.java:354-355 |
Medium |
| 7 | Mutable static test hook never reset | RocketMqAdminUtil.java:67 |
Low |
| 8 | New enumerator test duplicates existing stronger test | RocketMqSourceSplitEnumeratorTest.java:150 |
Low |
| 9 | Test Javadocs removed; production Javadoc silent on retry | RocketMqAdminUtilTest.java, RocketMqAdminUtil.java:306-329 |
Low |
| 10 | PR description stale | PR description | Low |
5. Merge Recommendation
Conclusion: Not recommended for merge
CI status (head 57dda37): the apache-side Build check is action_required (https://github.com/apache/seatunnel/runs/106259425553, "Workflow run detection failed"). As a first-time contributor's workflow run, it needs a committer to approve the workflow run before the real jobs execute. I also could not find any workflow run for this head in your fork, so if approval alone does not start the jobs, please double-check that GitHub Actions is enabled in your fork (Actions tab, enable workflows) and push a commit to trigger it. Either way, I expect the compile error (Issue 1) and the license-header job (Issue 2) to show up as soon as CI runs, so please fix those first.
- Blockers - must be fixed
- Issue 1: restore the
Collectionsimport and remove the raw checked-exception rethrows. - Issue 2: restore the license header (and Javadocs) in
RocketMqAdminUtilTest.java. - Issue 3: correct the test expectations (3 executions with
retryTimes = 3;RocketMqConnectorExceptionfor other response codes). - Issue 4: keep the existing error contract: one exit that wraps everything as
RocketMqConnectorException(GET_CONSUMER_GROUP_OFFSETS_ERROR, cause), restoring the interrupt flag onInterruptedException.
- Issue 1: restore the
- Recommended fixes - non-blocking but I would do them in the same push
- Issue 5 (single probe decision) and Issue 6 (fixed 1s interval, or a smaller base) because they decide whether the retry is actually safe and cheap.
- Issues 7-10 as cleanup.
Overall assessment: the direction (retry only when both routes are missing) is a reasonable refinement of #12349, but the implementation is not yet in a mergeable shape. A compact shape that would cover Issues 4, 5 and 6 together:
for (String topic : topics) {
AtomicBoolean routeMissing = new AtomicBoolean(false);
try {
ConsumeStats stats = RetryUtils.retryWithException(
() -> adminClient.examineConsumeStats(groupId, topic),
new RetryUtils.RetryMaterial(3, true, e -> {
boolean retry = isTopicNotExist(e) && !topicRouteAvailable(adminClient, topic);
if (retry) { routeMissing.set(true); } // sticky: once missing, never fall back to empty
return retry;
}, backoffMillis));
consumerOffsets.putAll(stats.getOffsetTable());
} catch (Exception e) {
Throwable cause = unwrapRetryFailure(e); // e.getCause() for the RetryUtils wrapper
if (isTopicNotExist(cause) && !routeMissing.get()) { /* healthy route: cold start */ return Collections.emptyMap(); }
if (cause instanceof InterruptedException) { Thread.currentThread().interrupt(); }
throw new RocketMqConnectorException(RocketMqConnectorErrorCode.GET_CONSUMER_GROUP_OFFSETS_ERROR, cause);
}
}Option A (recommended): fix the items above on this PR. Option B: since #12349 already fixes the reported silent rewind on dev, the maintainers could decide that the extra retry is not worth its added complexity and close this PR; that is a call for the committers, and I would understand either outcome. There is no maintainer approval on the current head. My round-1 change request was resolved in the previous iteration and my last round was a non-blocking comment; this round requests changes because the new head no longer compiles and breaks the tests and license check.
Thanks again for sticking with this one and for the quick iterations. The fixes are small, and I am happy to look again once the compile and test issues are sorted.
|
Thanks for your time reviewing this! Considering the overlap and conflicts with the fix merged in #12349, I've decided to close this PR. I look forward to contributing to other issues. |
Title: [Fix][Connector-V2] Fix RocketMQ silent rewind on transient consumer group metadata lookup failures
Purpose of this pull request
This PR fixes a critical bug where RocketMqAdminUtil.currentOffsets treats a transient metadata lookup failure as proof that a consumer group has committed nothing, causing the connector to silently
rewind and re-deliver the entire topic when start.mode = CONSUME_FROM_GROUP_OFFSETS.
The Issue:
When adminClient.examineConsumeStats attempts to look up consumer group offsets and the name server temporarily has no route for the group (e.g., the %RETRY%GroupName topic), it throws an
MQClientException with ResponseCode.TOPIC_NOT_EXIST. The connector was unconditionally catching this and returning an empty map. Because the core topic itself genuinely exists, the subsequent listOffsets
call succeeds, setting the start offset to 0 and silently rewinding the consumer.
The Fix:
Inside RocketMqAdminUtil.currentOffsets, we no longer catch and swallow MQClientException when the response code is TOPIC_NOT_EXIST. Instead, we allow the exception to propagate as a
RocketMqConnectorException(GET_CONSUMER_GROUP_OFFSETS_ERROR). This ensures that transient lookup failures fail fast and allow the engine to retry, rather than silently reporting that no offsets exist.
(Note: If a topic genuinely does not exist, the job correctly fails rather than silently consuming 0 records).
(Resolves #12332)
Does this PR introduce any user-facing change?
No. This restores the intended behavior of CONSUME_FROM_GROUP_OFFSETS by preventing silent data re-delivery during transient name server route unavailability.
How was this patch tested?
The defect was established by logic and by CI logs demonstrating that transient route unavailability drops name server responses for minutes at a time. The fix removes the faulty empty-map fallback,
ensuring that any missing route information triggers a fast failure and retry instead of a silent rewind.
Check list
[✓] If any new Jar binary package adding in your PR, please add License Notice according New License Guide https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md (N/A - no new
dependencies)
[✓] If necessary, please update the documentation to describe the new feature. (N/A - bug fix)
[✓] If necessary, please update incompatible-changes.md to describe the incompatibility caused by this PR. (N/A - behavior restored, no config changes)
[✓] If you are contributing the connector code, please check that the following files are updated:
1. Update plugin-mapping.properties and add new connector information in it (N/A - existing connector)
2. Update the pom file of seatunnel-dist (N/A)
3. Add ci label in label-scope-conf (N/A)
4. Add e2e testcase in seatunnel-e2e (N/A - transient name server lookup failures are difficult to simulate in standard E2E containers)
5. Update connector plugin_config (N/A)***