hangc0276 commented on code in PR #4803:
URL: https://github.com/apache/bookkeeper/pull/4803#discussion_r4761348748
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/DefaultEntryLogTest.java:
##########
@@ -983,6 +994,138 @@ public void testReadEntryWithoutLedgerID() throws
Exception {
}
}
+ @Test
+ public void testRecoverCompactedLogUsesHexFinalLogFileName() throws
Exception {
Review Comment:
These tests cover id 500 only, and call `makeAvailable()` and `scan()`
directly rather than the real recovery path. I added a variant through
`TransactionalEntryLogCompactor.cleanUpAndRecover()` for ids 10, 15, 16, 255
and 500, plus a control with id 5 (where decimal equals hex). It fails on the
old naming (marker stays, hex log not created) and passes with the PR. It's in
the review summary if you'd like to add it.
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/DefaultEntryLogTest.java:
##########
@@ -983,6 +994,138 @@ public void testReadEntryWithoutLedgerID() throws
Exception {
}
}
+ @Test
+ public void testRecoverCompactedLogUsesHexFinalLogFileName() throws
Exception {
+ ByteBuf entry = generateEntry(COMPACTION_LEDGER_ID,
COMPACTION_ENTRY_ID);
+ try {
+ prepareCompactedLog(entry);
+
+ CompactionEntryLog recoveredLog = recoverSingleCompactionLog();
+
+ // Recovery creates the final entry log in makeAvailable(). It
must create
+ // the normal hex entry log name, not the decimal name from the
parsed id.
+ recoveredLog.makeAvailable();
+ assertTrue(hexFinalLogFile().exists(), "Recovery should create the
hex-named final log");
+ assertFalse(decimalFinalLogFile().exists(), "Recovery should not
create a decimal-named final log");
+ assertCompactionLogContainsEntry(recoveredLog);
+ } finally {
+ ReferenceCountUtil.release(entry);
+ }
+ }
+
+ @Test
+ public void
testRecoverCompactedLogWithStaleDecimalLogFileFromOldRecovery() throws
Exception {
Review Comment:
One correction to the wording in the description and in this test's
assertion message ("unrelated stale decimal logs"). The stale `500.log` left by
an old recovery is a hard link of the compacted file, so it holds a real second
copy of the compacted entries, and the entry logger treats it as entry log id
`0x500`: after recovery `entryLogger.logExists(0x500)` is `true` for me. It
isn't harmful: the log-id allocator skips ids whose file exists
(`EntryLoggerAllocator`, the `testLogFile.exists()` loop), and once the ledgers
in it are deleted GC removes it like any other log. Until then it costs disk
space equal to the compacted log. Calling it an older duplicate (and maybe
mentioning it in the release notes) would be more accurate, and removing a
stale decimal hard link of the same `.compacted` file during recovery would
clean it up.
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/DefaultEntryLogger.java:
##########
@@ -1470,7 +1470,8 @@ public Collection<CompactionEntryLog>
incompleteCompactionLogs() {
}
continue;
}
- File finalLogFile = new
File(compactedFile.getParentFile(), compactionLogId + ".log");
+ File finalLogFile = new File(compactedFile.getParentFile(),
+ logId2HexString(compactionLogId) + ".log");
Review Comment:
The fix is correct, and I checked it through the real recovery path, not
only through `makeAvailable()`/`scan()`. With
`TransactionalEntryLogCompactor.cleanUpAndRecover()`, for destination ids 10,
15, 16, 255 and 500 (where the hex spelling differs from decimal), recovery now
updates the index with locations in the destination log, removes the
`.compacted` marker, creates the hex-named final log and asks for the source
log to be removed. With the old decimal naming, recovery for id 10 leaves the
marker in place, so it is stuck on every restart. ids 0–9 print the same in
decimal and hex (my control, id 5, passes either way). I also checked the
sibling `DirectEntryLogger.incompleteCompactionLogs()`: it parses hex ids and
builds the final file with its own hex `logFile(...)`, so it doesn't have this
bug.
--
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]