Skip to content

Fix subscription prefetch wakeups for late replicated WAL entries - #19194

Merged
jt2594838 merged 3 commits into
masterfrom
fix/subscription-remote-wal-wakeup
Nov 13, 2026
Merged

jt2594838 merged 3 commits into
masterfrom
fix/subscription-remote-wal-wakeup

Conversation

@Caideyipi

@Caideyipi Caideyipi commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Replicated WAL entries can arrive after a subscription prefetch worker becomes idle without advancing the local WAL search index or entering the realtime queue. Previously, repeated polls could remain empty until another event woke the worker.

Expose a replicated-batch version through WALNode, published by WALBuffer only after a successful flush/force. An empty poll wakes an idle worker only when that version differs from the version captured before its last prefetch round. Capturing it before scanning preserves replication that arrives after the final iterator check. This replaces the periodic 100 ms retry while preserving initialization, seek, close, and executor-binding guards.

For example, on an idle follower whose local WAL search index remains 0, a replicated entry from writer 8 with sequence 10 and timestamp 10 now becomes available for delivery and acknowledgement after an empty poll triggers replay. With no new replicated batch, empty polls leave the idle worker unscheduled.

Validation

At commit cabaa63fc95f7c0d897ffb938c0cb2374b00d479:

  • All required IoTDB modules and test sources compiled from clean source in the 28-module reactor; 482/482 Maven goals executed without build-cache restores.
  • WALBufferRollRecoveryTest: 11 tests passed; ConsensusPrefetchingQueueSeekTest: 9 tests passed in Surefire.
  • ConsensusPrefetchingQueueReplicationTest: both tests passed using JUnitCore with the same reactor classes and JVM options and immutable copies of the TsFile dependencies. Their first Surefire attempt hit class-loading errors while the dependency JARs were being replaced during the run.
  • Spotless, Checkstyle, and git diff --check passed.

Subscription was temporarily enabled in the verification source and restored before committing. The submitted diff does not change the subscription switch. The full test suite and distributed integration tests have not been run.

Wake an existing idle prefetch task after an empty poll so replicated WAL entries can be discovered without another local write. Preserve initialization, seek, lifecycle and executor-binding guards. Add a regression covering delivery and acknowledgement without advancing the local WAL cursor.
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.85714% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.04%. Comparing base (36c35f6) to head (cabaa63).
⚠️ Report is 38 commits behind head on master.

Files with missing lines Patch % Lines
...on/broker/consensus/ConsensusPrefetchingQueue.java 0.00% 8 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19194      +/-   ##
============================================
+ Coverage     48.80%   49.04%   +0.24%     
- Complexity      674      689      +15     
============================================
  Files          5574     5590      +16     
  Lines        412836   413988    +1152     
  Branches      54448    54636     +188     
============================================
+ Hits         201480   203056    +1576     
+ Misses       211356   210932     -424     

☔ 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.

@jt2594838 jt2594838 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to sense the repication of WAL via WALNode, like recording the lastReplicatedNano in it.

@Caideyipi
Caideyipi marked this pull request as draft November 13, 2026 02:36
@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Review follow-up for cabaa63fc95f7c0d897ffb938c0cb2374b00d479:

@jt2594838, addressed your WALNode suggestion. WALNode.getReplicatedWalVersion() now exposes a version published only after a batch containing replicated entries successfully flushes. Empty polls compare it with the version captured before the last prefetch round, so they do not repeatedly scan an unchanged WAL. Capturing the version before scanning also prevents replication arriving during the final scan from being lost when the worker becomes dormant. A counter provides this change signal without timestamp ordering or clock-resolution concerns.

Regarding the Codecov report: the root Surefire configuration excludes **/subscription/** from default test runs. I explicitly exercised the subscription regressions and added normal WAL-buffer unit coverage for publication only after force, and for write/force failures. The new subscription tests use real WAL files and Mockito without PowerMock.

Validation: clean compilation of the required IoTDB dependency closure in the 28-module reactor, Spotless, Checkstyle, and git diff --check passed. Surefire passed 11 WAL-buffer tests and 9 existing seek tests. The two new subscription tests passed in a focused JUnitCore rerun using the same reactor classes/JVM options and immutable TsFile dependency copies; their initial Surefire attempt encountered class-loading errors while the dependency JARs were replaced during the run. All five newly added tests have been run locally and passed. A temporary subscription-source enablement override was restored before committing. Full-suite and distributed integration testing were not run.

Reviewed SHA: 3a343faaff65424068f357819ecfe97c8a41ca9d. Final local and confirmed remote SHA: cabaa63fc95f7c0d897ffb938c0cb2374b00d479. The PR remains draft for a fresh independent re-review of this behavioral update. Discussions have been left unresolved.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@Caideyipi
Caideyipi marked this pull request as ready for review November 13, 2026 03:22
@jt2594838
jt2594838 merged commit 8a2f85a into master Nov 13, 2026
41 of 42 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.

2 participants