aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-11-27 11:16:01 -0500
committerGitHub <[email protected]>2023-11-27 17:16:01 +0100
commit8f93ed186d11ec01e14af38751bc2b08e13bd2b7 (patch)
treef839466825dd36c0ba57800b7900e6b5acb0a6ec /src
parentgcv2 tests for project store and bugfixes (#571) (diff)
downloadzen-8f93ed186d11ec01e14af38751bc2b08e13bd2b7.tar.xz
zen-8f93ed186d11ec01e14af38751bc2b08e13bd2b7.zip
fix missing locks/sync of log position when writing index snapshots (#572)
* fix missing locks/sync of log position when writing index snapshots * changelog
Diffstat (limited to 'src')
-rw-r--r--src/zenstore/compactcas.cpp6
-rw-r--r--src/zenstore/filecas.cpp7
2 files changed, 9 insertions, 4 deletions
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<CasDiskIndexEntry> 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<uint32_t>(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)
{
diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp
index 6ba282163..bf12a0c1a 100644
--- a/src/zenstore/filecas.cpp
+++ b/src/zenstore/filecas.cpp
@@ -1097,8 +1097,11 @@ FileCasStrategy::MakeIndexSnapshot()
// Write the current state of the location map to a new index state
std::vector<FileCasIndexEntry> Entries;
+ uint64_t IndexLogPosition = 0;
{
+ RwLock::SharedLockScope __(m_Lock);
+ IndexLogPosition = m_CasLog.GetLogCount();
Entries.resize(m_Index.size());
uint64_t EntryIndex = 0;
@@ -1112,7 +1115,7 @@ FileCasStrategy::MakeIndexSnapshot()
BasicFile ObjectIndexFile;
ObjectIndexFile.Open(IndexPath, BasicFile::Mode::kTruncate);
- filecas::impl::FileCasIndexHeader Header = {.EntryCount = Entries.size(), .LogPosition = LogCount};
+ filecas::impl::FileCasIndexHeader Header = {.EntryCount = Entries.size(), .LogPosition = IndexLogPosition};
Header.Checksum = filecas::impl::FileCasIndexHeader::ComputeChecksum(Header);
@@ -1121,7 +1124,7 @@ FileCasStrategy::MakeIndexSnapshot()
ObjectIndexFile.Flush();
ObjectIndexFile.Close();
EntryCount = Entries.size();
- m_LogFlushPosition = LogCount;
+ m_LogFlushPosition = IndexLogPosition;
}
catch (std::exception& Err)
{