aboutsummaryrefslogtreecommitdiff
path: root/zenstore/compactcas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-04-01 08:34:18 +0200
committerDan Engelbrecht <[email protected]>2022-04-01 08:34:18 +0200
commit671c82ec68fef9ea5668f69866a31fd158977442 (patch)
tree94079942f49e92c366f57ce8a238c91fad949602 /zenstore/compactcas.cpp
parentleave legacy files so we can switch back to older version without crashing (diff)
downloadzen-671c82ec68fef9ea5668f69866a31fd158977442.tar.xz
zen-671c82ec68fef9ea5668f69866a31fd158977442.zip
call Initialize before replay on caslog
Diffstat (limited to 'zenstore/compactcas.cpp')
-rw-r--r--zenstore/compactcas.cpp54
1 files changed, 30 insertions, 24 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp
index 0c4a84dd1..1dd1a3906 100644
--- a/zenstore/compactcas.cpp
+++ b/zenstore/compactcas.cpp
@@ -280,7 +280,10 @@ namespace {
TCasLogFile<CasDiskIndexEntry> CasLog;
CasLog.Open(SlogPath, CasLogFile::EMode::kRead);
- CasLog.Replay([&](const CasDiskIndexEntry& Record) { Entries.push_back(Record); });
+ if (CasLog.Initialize())
+ {
+ CasLog.Replay([&](const CasDiskIndexEntry& Record) { Entries.push_back(Record); });
+ }
}
return Entries;
}
@@ -354,29 +357,32 @@ namespace {
LegacyDiskIndex.size(),
NiceTimeSpanMs(Timer.GetElapsedTimeMs()));
});
- LegacyCasLog.Replay([&](const LegacyCasDiskIndexEntry& Record) {
- std::string InvalidEntryReason;
- if (Record.Flags & LegacyCasDiskIndexEntry::kTombstone)
- {
- LegacyDiskIndex.erase(Record.Key);
- return;
- }
- if (!ValidateLegacyEntry(Record, InvalidEntryReason))
- {
- ZEN_WARN("skipping invalid entry in '{}', '{}'", LegacyLogPath, InvalidEntryReason);
- return;
- }
- uint64_t EntryEnd = Record.Location.GetOffset() + Record.Location.GetSize();
- if (EntryEnd > FileSize)
- {
- return;
- }
- if (ExistingChunks.contains(Record.Key))
- {
- return;
- }
- LegacyDiskIndex[Record.Key] = Record;
- });
+ if (LegacyCasLog.Initialize())
+ {
+ LegacyCasLog.Replay([&](const LegacyCasDiskIndexEntry& Record) {
+ std::string InvalidEntryReason;
+ if (Record.Flags & LegacyCasDiskIndexEntry::kTombstone)
+ {
+ LegacyDiskIndex.erase(Record.Key);
+ return;
+ }
+ if (!ValidateLegacyEntry(Record, InvalidEntryReason))
+ {
+ ZEN_WARN("skipping invalid entry in '{}', '{}'", LegacyLogPath, InvalidEntryReason);
+ return;
+ }
+ uint64_t EntryEnd = Record.Location.GetOffset() + Record.Location.GetSize();
+ if (EntryEnd > FileSize)
+ {
+ return;
+ }
+ if (ExistingChunks.contains(Record.Key))
+ {
+ return;
+ }
+ LegacyDiskIndex[Record.Key] = Record;
+ });
+ }
}
if (LegacyDiskIndex.empty())