Skip to content

[Bugfix] Bound consensus subscription WAL scans per prefetch round - #18849

Merged
jt2594838 merged 2 commits into
apache:masterfrom
Caideyipi:fix/subscription-wal-scan-fairness
Oct 14, 2026
Merged

jt2594838 merged 2 commits into
apache:masterfrom
Caideyipi:fix/subscription-wal-scan-fairness

Conversation

@Caideyipi

Copy link
Copy Markdown
Collaborator

When consensus subscription replay scans a wide WAL prefix or a fragmented request, a single ProgressWALIterator.hasNext() can read many physical entries before returning a logical request. The queue's logical-request limit does not bound this work, so one region can occupy a shared prefetch worker for minutes while other regions stop delivering data.

Share a physical-entry scan budget and a cooperative 50 ms time slice across WAL catch-up, pending-gap recovery, readability probes, and end-of-round scheduling. A yielded scan preserves its reader position, pending fragments, and buffered retry request, publishes completed tablets, and requeues the task so other regions can run. Repeated realtime jumps continue a yielded gap scan instead of reopening it at the old cursor. A yield is distinct from WAL exhaustion and does not trigger a WAL roll or an incomplete-scan error. The public unbounded iterator API retains its existing behavior.

Regression coverage checks skipped prefixes and replicated request fragments across several rounds, deadline expiry and buffered retries, and repeated pending gaps with exactly one delivery per request. Existing memory backpressure, seek, WAL corruption/retry, and queue tests also pass.

Validation:

  • mvn -nsu -Ddevelocity.off=true -pl iotdb-core/datanode spotless:apply
  • mvn -nsu -Ddevelocity.off=true -pl iotdb-core/datanode -am test-compile -DskipTests
  • mvn -nsu -Ddevelocity.off=true -pl iotdb-core/datanode -am test -Dtest=ProgressWALIteratorTest,ConsensusPrefetchingQueueTest,ConsensusPrefetchingQueueWalBackpressureTest,ConsensusPrefetchingQueueSeekTest -Dsurefire.failIfNoSpecifiedTests=false — 76 tests, 0 failures/errors, 1 optional benchmark skipped.
  • mvn -nsu -Ddevelocity.off=true -pl iotdb-core/datanode -am test-compile -P with-zh-locale -DskipTests
  • git diff --check

The time slice is checked between WAL operations and cannot interrupt an individual file read. The original hour-long, wide-table workload has not been rerun, so its throughput and stall-duration improvement still need workload validation.

@jt2594838
jt2594838 merged commit 0c0116a into apache:master Oct 14, 2026
38 of 39 checks passed
@jt2594838
jt2594838 deleted the fix/subscription-wal-scan-fairness branch October 14, 2026 08:11
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