Conversation
| addFileNum(1); | ||
| File lastFile = currentWALFileWriter.getLogFile(); | ||
| if (!hasPendingRoll()) { | ||
| // Record the boundary only after sealing and forcing the old WAL have both succeeded. |
There was a problem hiding this comment.
Preserves the sealed WAL and current rotation stage across retries, so a later sync task can continue after disk space is restored without closing or counting the old file twice.
| final long startTime = System.nanoTime(); | ||
|
|
||
| if (syncFailure != null) { | ||
| failListeners(syncFailure); |
There was a problem hiding this comment.
Propagates a failed sync batch to all listeners and keeps the buffer recoverable. SET SYSTEM TO RUNNING alone cannot repair an incomplete WAL record, so retry state is cleared only after the pending roll completes.
| logChannel.write(headerBuffer); | ||
| } | ||
| while (buffer.hasRemaining()) { | ||
| logChannel.write(buffer); |
There was a problem hiding this comment.
Consumes the full buffer and lets ClosedChannelException reach the caller. A partial or failed write must trigger WAL recovery instead of being acknowledged as a successful flush.
| logChannel.write(buffer); | ||
| // A successful seal is the recovery boundary for switching to the next WAL file. | ||
| while (buffer.hasRemaining()) { | ||
| logChannel.write(buffer); |
There was a problem hiding this comment.
Persists the complete metadata trailer before treating the file as sealed; this trailer is the recovery boundary for switching to the next WAL file.
| */ | ||
| @Test | ||
| public void testResumeBeforeWritingAfterRepeatedOpenFailures() throws Exception { | ||
| writeAndAwait(entry(1, 1, "before"), Status.SUCCESS); |
There was a problem hiding this comment.
Covers repeated successor creation failures and verifies recovery resumes at the saved roll stage without duplicate sealing, counter inflation, or data loss.
| /** Unexpected channel closure must propagate to the buffer instead of acknowledging a write. */ | ||
| @Test | ||
| public void testClosedChannelWriteAndForceFail() throws IOException { | ||
| WALWriter writer = new WALWriter(walFile); |
There was a problem hiding this comment.
Confirms closed-channel write and force operations fail visibly and leave the WAL unchanged.
|
LGTM |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #18653 +/- ##
============================================
+ Coverage 42.82% 42.84% +0.01%
Complexity 442 442
============================================
Files 5451 5451
Lines 395425 395477 +52
Branches 51805 51818 +13
============================================
+ Hits 169349 169431 +82
+ Misses 226076 226046 -30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Problem
A DataNode can remain read-only after disk recovery because WAL rotation may fail after the current channel is closed, leaving the buffer in a state that cannot progress to the next WAL file.
Changes
Validation