diff options
| author | Dan Engelbrecht <[email protected]> | 2022-04-04 12:05:25 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-04-04 12:05:25 +0200 |
| commit | 605b4f330eed43b14135f37ffb58c14fa1cd79c2 (patch) | |
| tree | e8c99f26abb0634ecf53afe76cebd6f0c05742ca /zenstore/caslog.cpp | |
| parent | logging cleanup (diff) | |
| download | zen-605b4f330eed43b14135f37ffb58c14fa1cd79c2.tar.xz zen-605b4f330eed43b14135f37ffb58c14fa1cd79c2.zip | |
always keep full log but read from index snapshot location if available
Diffstat (limited to 'zenstore/caslog.cpp')
| -rw-r--r-- | zenstore/caslog.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/zenstore/caslog.cpp b/zenstore/caslog.cpp index e080d6771..03a56f010 100644 --- a/zenstore/caslog.cpp +++ b/zenstore/caslog.cpp @@ -123,7 +123,7 @@ CasLogFile::GetLogSize() uint64_t CasLogFile::GetLogCount() { - uint64_t LogFileSize = m_File.FileSize(); + uint64_t LogFileSize = m_AppendOffset.load(std::memory_order_acquire); if (LogFileSize < sizeof(FileHeader)) { return 0; @@ -134,19 +134,22 @@ CasLogFile::GetLogCount() } void -CasLogFile::Replay(std::function<void(const void*)>&& Handler) +CasLogFile::Replay(std::function<void(const void*)>&& Handler, uint64_t SkipEntryCount) { uint64_t LogFileSize = m_File.FileSize(); // Ensure we end up on a clean boundary - const uint64_t LogBaseOffset = sizeof(FileHeader); - const size_t LogEntryCount = (LogFileSize - LogBaseOffset) / m_RecordSize; + uint64_t LogBaseOffset = sizeof(FileHeader); + size_t LogEntryCount = (LogFileSize - LogBaseOffset) / m_RecordSize; - if (LogEntryCount == 0) + if (LogEntryCount <= SkipEntryCount) { return; } + LogBaseOffset += SkipEntryCount * m_RecordSize; + LogEntryCount -= SkipEntryCount; + // This should really be streaming the data rather than just // reading it into memory, though we don't tend to get very // large logs so it may not matter |