From 8f93ed186d11ec01e14af38751bc2b08e13bd2b7 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Mon, 27 Nov 2023 11:16:01 -0500 Subject: fix missing locks/sync of log position when writing index snapshots (#572) * fix missing locks/sync of log position when writing index snapshots * changelog --- src/zenstore/compactcas.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/zenstore/compactcas.cpp') diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp index 95198fd59..c4f9ff2c6 100644 --- a/src/zenstore/compactcas.cpp +++ b/src/zenstore/compactcas.cpp @@ -884,9 +884,11 @@ CasContainerStrategy::MakeIndexSnapshot() // Write the current state of the location map to a new index state std::vector Entries; + uint64_t IndexLogPosition = 0; { RwLock::SharedLockScope ___(m_LocationMapLock); + IndexLogPosition = m_CasLog.GetLogCount(); Entries.resize(m_LocationMap.size()); uint64_t EntryIndex = 0; @@ -901,7 +903,7 @@ CasContainerStrategy::MakeIndexSnapshot() BasicFile ObjectIndexFile; ObjectIndexFile.Open(IndexPath, BasicFile::Mode::kTruncate); CasDiskIndexHeader Header = {.EntryCount = Entries.size(), - .LogPosition = LogCount, + .LogPosition = IndexLogPosition, .PayloadAlignment = gsl::narrow(m_PayloadAlignment)}; Header.Checksum = CasDiskIndexHeader::ComputeChecksum(Header); @@ -911,7 +913,7 @@ CasContainerStrategy::MakeIndexSnapshot() ObjectIndexFile.Flush(); ObjectIndexFile.Close(); EntryCount = Entries.size(); - m_LogFlushPosition = LogCount; + m_LogFlushPosition = IndexLogPosition; } catch (std::exception& Err) { -- cgit v1.2.3