Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ private void doGcLedgers() {
/**
* Garbage collect those entry loggers which are not associated with any active ledgers.
*/
private void doGcEntryLogs() throws EntryLogMetadataMapException {
protected void doGcEntryLogs() throws EntryLogMetadataMapException {
Copy link
Contributor

Choose a reason for hiding this comment

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

protectd could be removed. Default access modifiers is enough.

// Get a cumulative count, don't update until complete
AtomicLong activeEntryLogSizeAcc = new AtomicLong(0L);
AtomicLong totalEntryLogSizeAcc = new AtomicLong(0L);
Expand Down Expand Up @@ -847,20 +847,7 @@ protected void extractMetaFromEntryLogs() throws EntryLogMetadataMapException {
try {
// Read through the entry log file and extract the entry log meta
EntryLogMetadata entryLogMeta = entryLogger.getEntryLogMetadata(entryLogId, throttler);
removeIfLedgerNotExists(entryLogMeta);
if (entryLogMeta.isEmpty()) {
// This means the entry log is not associated with any active
// ledgers anymore.
// We can remove this entry log file now.
LOG.info("Deleting entryLogId {} as it has no active ledgers!", entryLogId);
if (removeEntryLog(entryLogId)) {
gcStats.getReclaimedSpaceViaDeletes().addCount(entryLogMeta.getTotalSize());
} else {
gcStats.getReclaimFailedToDelete().inc();
}
} else {
entryLogMetaMap.put(entryLogId, entryLogMeta);
}
entryLogMetaMap.put(entryLogId, entryLogMeta);
} catch (IOException | RuntimeException e) {
LOG.warn("Premature exception when processing {} recovery will take care of the problem",
entryLogId, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ private void testExtractMetaFromEntryLogs(EntryLogger entryLogger, File ledgerDi
// all ledgers exist, nothing should disappear
final EntryLogMetadataMap entryLogMetaMap = gcThread.getEntryLogMetaMap();
gcThread.extractMetaFromEntryLogs();
gcThread.doGcEntryLogs();

assertThat(entryLogger.getFlushedLogIds(), containsInAnyOrder(logId1, logId2));
assertTrue(entryLogMetaMap.containsKey(logId1));
Expand All @@ -210,6 +211,7 @@ private void testExtractMetaFromEntryLogs(EntryLogger entryLogger, File ledgerDi
entryLogMetaMap.clear();
storage.deleteLedger(2L);
gcThread.extractMetaFromEntryLogs();
gcThread.doGcEntryLogs();

assertThat(entryLogger.getFlushedLogIds(), containsInAnyOrder(logId1));
assertTrue(entryLogMetaMap.containsKey(logId1));
Expand All @@ -220,6 +222,7 @@ private void testExtractMetaFromEntryLogs(EntryLogger entryLogger, File ledgerDi
storage.deleteLedger(1L);
storage.deleteLedger(3L);
gcThread.extractMetaFromEntryLogs();
gcThread.doGcEntryLogs();

assertThat(entryLogger.getFlushedLogIds(), empty());
assertTrue(entryLogMetaMap.isEmpty());
Expand All @@ -233,6 +236,7 @@ private void testExtractMetaFromEntryLogs(EntryLogger entryLogger, File ledgerDi

entryLogMetaMap.clear();
gcThread.extractMetaFromEntryLogs();
gcThread.doGcEntryLogs();

assertThat(entryLogger.getFlushedLogIds(), empty());
assertTrue(entryLogMetaMap.isEmpty());
Expand Down