aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/filecas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-06-09 09:03:39 +0200
committerGitHub Enterprise <[email protected]>2025-06-09 09:03:39 +0200
commit6f2d68d2c11011d541259d0037908dd76eadeb8a (patch)
tree4fa165343dd42544dded51fad0e13ebae44dd442 /src/zenstore/filecas.cpp
parent5.6.10-pre0 (diff)
downloadzen-6f2d68d2c11011d541259d0037908dd76eadeb8a.tar.xz
zen-6f2d68d2c11011d541259d0037908dd76eadeb8a.zip
missing chunks bugfix (#424)
* make sure to close log file when resetting log * drop entries that refers to missing blocks * Don't scrub keys that has been rewritten * currectly count added bytes / m_TotalSize * fix negative sleep time in BlockStoreFile::Open() * be defensive when fetching log position * append to log files *after* we updated all state successfully * explicitly close stuff in destructors with exception catching * clean up empty size block store files
Diffstat (limited to 'src/zenstore/filecas.cpp')
-rw-r--r--src/zenstore/filecas.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp
index 539b5e95b..11a266f1c 100644
--- a/src/zenstore/filecas.cpp
+++ b/src/zenstore/filecas.cpp
@@ -969,14 +969,11 @@ FileCasStrategy::MakeIndexSnapshot(bool ResetLog)
{
// Write the current state of the location map to a new index state
std::vector<FileCasIndexEntry> Entries;
- uint64_t IndexLogPosition = 0;
+ // Be defensive regarding log position as it is written to without acquiring m_LocationMapLock
+ const uint64_t IndexLogPosition = ResetLog ? 0 : m_CasLog.GetLogCount();
{
RwLock::SharedLockScope __(m_Lock);
- if (!ResetLog)
- {
- IndexLogPosition = m_CasLog.GetLogCount();
- }
Entries.resize(m_Index.size());
uint64_t EntryIndex = 0;
@@ -1019,12 +1016,14 @@ FileCasStrategy::MakeIndexSnapshot(bool ResetLog)
if (IsFile(LogPath))
{
+ m_CasLog.Close();
if (!RemoveFile(LogPath, Ec) || Ec)
{
// This is non-critical, it only means that we will replay the events of the log over the snapshot - inefficent but in
// the end it will be the same result
ZEN_WARN("Snapshot failed to clean log file '{}', reason: '{}'", LogPath, IndexPath, Ec.message());
}
+ m_CasLog.Open(LogPath, CasLogFile::Mode::kWrite);
}
}
m_LogFlushPosition = IndexLogPosition;