jt2594838 opened a new pull request, #17662: URL: https://github.com/apache/iotdb/pull/17662
## Summary - Fix a bug in `AbstractWALBuffer` where the first `currentWALFileWriter` created in the constructor was not counted in `fileNum` statistics, causing `fileNum` (and `WALManager.totalFileNum`) to always be 1 less than the actual number of WAL files on disk. - Add `WALBufferFileNumTest` with 4 test cases verifying the file count correctness after construction, single roll, multiple rolls, and `WALManager` global consistency. ## Root Cause In `AbstractWALBuffer`'s constructor, `addFileNum(walFiles.length)` only counted pre-existing WAL files on disk, but the newly created `currentWALFileWriter` was never counted. When `rollLogWriter()` later closed this file and called `addFileNum(1)`, that increment was for the new file being opened — so the initial file's count was permanently missing. ## Fix Added `addFileNum(1)` immediately after creating `currentWALFileWriter` in the constructor. ## Test plan - [x] `testInitialFileNumAfterConstruction` — verifies `fileNum == 1` on fresh directory - [x] `testFileNumAfterRoll` — verifies `fileNum == 2` after one roll - [x] `testFileNumAfterMultipleRolls` — verifies `fileNum == N+1` after N rolls - [x] `testTotalFileNumInWALManager` — verifies `WALManager.getTotalFileNum()` stays in sync - [x] All 4 tests pass: `mvn test -pl iotdb-core/datanode -Dtest=WALBufferFileNumTest` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
