Skip to content

[To dev/1.3] Fix SyncStatus batch memory reservation retry - #18557

Merged
jt2594838 merged 3 commits into
dev/1.3from
fix-syncstatus-retry-dev-1.3
Sep 1, 2026
Merged

[To dev/1.3] Fix SyncStatus batch memory reservation retry#18557
jt2594838 merged 3 commits into
dev/1.3from
fix-syncstatus-retry-dev-1.3

Conversation

@jt2594838

Copy link
Copy Markdown
Contributor

Summary\n- Retry SyncStatus batch memory reservation when memory is temporarily unavailable.\n- Add a regression test covering a failed first reservation and a later successful retry.\n- Adapt the test to the memory manager API available on dev/1.3.\n\n## Test\n- mvn -pl iotdb-core/consensus -am -Dtest=SyncStatusTest -Dsurefire.failIfNoSpecifiedTests=false test\n- mvn -pl iotdb-core/consensus -am -DskipTests compile

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.83%. Comparing base (1663766) to head (d1162d7).

Additional details and impacted files
@@              Coverage Diff              @@
##             dev/1.3   #18557      +/-   ##
=============================================
- Coverage      44.84%   44.83%   -0.02%     
  Complexity       198      198              
=============================================
  Files           3663     3663              
  Lines         250109   250110       +1     
  Branches       30859    30858       -1     
=============================================
- Hits          112168   112128      -40     
- Misses        137941   137982      +41     

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

@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

}
// Memory may be freed by another SyncStatus, which cannot notify this monitor.
wait(Math.max(1, config.getReplication().getBasicRetryWaitTimeMs()));
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This retry loop fixes a liveness gap after batch memory reservation fails: memory can be released by another SyncStatus instance without notifying this monitor, so an unbounded wait could leave the dispatcher stuck. The timed wait rechecks reservation using the existing basicRetryWaitTimeMs while the separate pending-batch wait still enforces maxPendingBatchesNum. The change preserves the synchronized lifecycle and passed the SyncStatusTest and two-replica concurrent-write integration test.

long previousMaxQueueMemory = memoryManager.getMaxMemorySizeForQueueInByte();
ExecutorService executor = Executors.newSingleThreadExecutor();
CountDownLatch taskStarted = new CountDownLatch(1);
memoryManager.init(0, 0);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This regression test forces the first reservation to fail with zero memory, verifies the writer remains pending, then raises the limit and requires completion within a timeout. It deterministically covers the retry path and restores the singleton memory-manager limits, executor, and SyncStatus state in finally so it remains isolated from neighboring tests. The targeted consensus Maven test suite passed with zero failures.

.setBasicRetryWaitTimeMs(10)
// Only one large batch fits, forcing competing dispatchers to retry
// reservation.
.setAllocateMemoryForConsensus(REQUEST_PAYLOAD_SIZE * 2L)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This integration scenario starts two real IoTConsensus replicas and launches eight concurrent 8 MiB writes (four per replica) while the consensus memory cap admits only one two-entry batch. That deliberate contention exercises dispatcher reservation retries; the test then waits for both minSyncIndex values and all 16 state-machine deliveries, proving large concurrent requests do not deadlock synchronization. Dynamic port selection and duplicate writable buffers keep the test isolated and Thrift-compatible; the test passed in the consensus Maven module.

@jt2594838
jt2594838 merged commit 42eae6a into dev/1.3 Sep 1, 2026
18 of 19 checks passed
@jt2594838
jt2594838 deleted the fix-syncstatus-retry-dev-1.3 branch September 1, 2026 03:23
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.

1 participant