diff options
| author | Dan Engelbrecht <[email protected]> | 2023-11-27 11:16:01 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-27 17:16:01 +0100 |
| commit | 8f93ed186d11ec01e14af38751bc2b08e13bd2b7 (patch) | |
| tree | f839466825dd36c0ba57800b7900e6b5acb0a6ec | |
| parent | gcv2 tests for project store and bugfixes (#571) (diff) | |
| download | zen-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
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/zenstore/compactcas.cpp | 6 | ||||
| -rw-r--r-- | src/zenstore/filecas.cpp | 7 |
3 files changed, 10 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d819bf28c..7bb2f34ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Feature: Added `zen gc-stop` command to cancel a running garbage collect operation - Bugfix: Fix sentry host name where last character of name was being truncated - Bugfix: GCv2 - make sure to discover all projects and oplogs before checking for expired data +- Bugfix: Fix sync of log position and state log when writing cas index snapshot - Improvement: The frontend html content is no longer appended at the end of the executable which prevented signing, instead it is compiled in from the `/src/zenserver/frontend/html.zip` archive - Improvement: MacOS now does ad-hoc code signing by default when issuing `xmake bundle`, signing with proper cert is done on CI builds - Improvement: Updated branding to be consistent with current working name ("Unreal Zen Storage Server" etc) 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) { |