DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
Once we separate the log file for compaction, we can achieve a transactional compaction operation. By "transactional", we mean that if anything fail at any phases during compaction, we should be able to roll back the current compaction properly, failed compaction would still be able to retry in the next scan, but rolling back the failed compaction would help us clean up the duplicated data.
Add recovery for compaction
...
If for any reason we succeed in flushing the compaction log but then fail to update the index or flush the ledger cache, we would get into the situation that the index is partially updated. In this case, we can't simply roll back by deleting the old entry log or compaction log, because the partially updated index file might already pointing some ledgers to the new compaction log. So we need a way to recover the partially updated index file for the compaction log file.
Design
Independent Entry Allocation Logic
| Code Block |
|---|
EntryLogWriteChannel createNewCompactionLog() throws IOException {
synchronized (createCompactionLogLock) {
List<File> writableDirs;
try {
writableDirs = new ArrayList<>(ledgerDirsManager.getWritableLedgerDirs());
} catch (LedgerDirsManager.NoWritableLedgerDirException nlde) {
// if all ledgers dirs are full, try to pick a ledger dir that has enough space for compaction log.
writableDirs = ledgerDirsManager.getAllLedgerDirs();
for (File dir : writableDirs) {
if (dir.getUsableSpace() <= logSizeLimit) {
writableDirs.remove(dir);
}
}
}
EntryLogWriteChannel bc = allocateNewLogFile(COMPACTING_SUFFIX, writableDirs);
LOG.info("Created new compaction logger {}.", bc.getLogId());
return bc;
}
} |