Skip to content

[ISSUE #11481] fix(broker): do not abort the queue-mapping clean pass on a missing remote queue - #11482

Merged
RongtongJin merged 1 commit into
apache:developfrom
Felix-Gong:fix/queue-mapping-clean-null-remote-items
Oct 23, 2026
Merged

RongtongJin merged 1 commit into
apache:developfrom
Felix-Gong:fix/queue-mapping-clean-null-remote-items

Conversation

@Felix-Gong

Copy link
Copy Markdown
Contributor

Fixes #11481

cleanItemListMoreThanSecondGen() reads the new leader's mapping with hostedQueues.get(qId) and calls isEmpty() without a null check. When the remote mapping has no entry for that queue id — the transient state this service is there to reconcile — the read returns null and the pass dies with a NullPointerException, which the per-topic catch (Throwable) swallows. The result is silent and sticky: the rest of that topic's queues are skipped for this cycle, the mapping stays half-cleaned, and the error repeats every five minutes.

The change is one guard — a missing remote queue is treated like every other "not confirmed yet" case around it:

if (items == null || items.isEmpty()) {
    continue;
}

Red/green: remoteLeaderMissingTheQueueIdDoesNotAbortTheRestOfTheTopic builds a topic with two moved queues; the new leader's mapping confirms queue 1 but has no entry for queue 0. On the old code the NPE aborts the pass and queue 1 is never removed (test fails); with the guard queue 1 is removed and queue 0 is left alone (test passes). The existing five tests in the class stay green.

Broker module: 815 tests, the 7 failures (RocksDB transfer, store filter, schedule, pop-lite, BrokerOuterAPI) are pre-existing — stashing this change reproduces the exact same set, and all live in unrelated areas.

No coordination needed: no open PR touches this file; the only related closed item is #8728 (test coverage enhancement, already resolved).

…n pass on a missing remote queue

cleanItemListMoreThanSecondGen() validates, for every queue whose leader
moved, that the new leader agrees. It reads the new leader's hosted
queues with get(qId) and calls isEmpty() on the result unconditionally:
when the remote broker's mapping does not contain that queue id at all —
the transient state this service exists to reconcile — the read returns
null and the pass dies with a NullPointerException.

The exception is swallowed by the per-topic catch, so the visible damage
is silent: every remaining queue of that topic is skipped for this cycle,
the mapping is left half-cleaned, and the failure repeats every five
minutes.

Treat a missing remote queue as "not confirmed yet" and continue, which
is how the surrounding reads already handle absent data.

Red/green: remoteLeaderMissingTheQueueIdDoesNotAbortTheRestOfTheTopic
fails on the old code (the second queue is never removed because the NPE
aborts the pass) and passes with the null guard. Broker module: 815
tests, the 7 failures are pre-existing (RocksDB/filter/schedule/pop-lite/
BrokerOuterAPI) and reproduce identically with this change stashed.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 49.75%. Comparing base (57c2dc0) to head (947ad6d).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
...mq/broker/topic/TopicQueueMappingCleanService.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11482      +/-   ##
=============================================
- Coverage      49.79%   49.75%   -0.05%     
+ Complexity     14387    14366      -21     
=============================================
  Files           1390     1390              
  Lines         103264   103264              
  Branches       13504    13504              
=============================================
- Hits           51419    51377      -42     
- Misses         45657    45675      +18     
- Partials        6188     6212      +24     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RongtongJin
RongtongJin merged commit 8ab8191 into apache:develop Oct 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Queue-mapping clean pass aborts the whole topic when the remote leader has no entry for a queue

3 participants