diff options
| author | Dan Engelbrecht <[email protected]> | 2023-05-12 15:37:46 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-12 15:37:46 +0200 |
| commit | a3738d2613d61fc0dccfaac6533674d76d1b9c9f (patch) | |
| tree | 044f856073cfb49422484808c6c8d43742385dbd | |
| parent | implemented structured cache logging (#296) (diff) | |
| download | zen-a3738d2613d61fc0dccfaac6533674d76d1b9c9f.tar.xz zen-a3738d2613d61fc0dccfaac6533674d76d1b9c9f.zip | |
fix gc bucket index compaction (#299)
* fix compaction of m_Payloads and m_AccessTimes in ZenCacheDiskLayer::CacheBucket
* changelog
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/zenserver/cache/structuredcachestore.cpp | 9 |
2 files changed, 6 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index fd79b0da1..f798ae690 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Bugfix: Return error code on exit as set by application - Bugfix: Fix crash at startup if dead process handles are detected in ZenServerState - Bugfix: Fixed assert/error when running block store GC and a block to GC does not exist +- Bugfix: GC could mix up locations of cache bucket items causing it to return the wrong item for a specific key - Improvement: Log details about file and read operation when it fails inside IoBuffer::Materialize() ## 0.2.10 diff --git a/src/zenserver/cache/structuredcachestore.cpp b/src/zenserver/cache/structuredcachestore.cpp index a95ae4ca2..2fd8e8be8 100644 --- a/src/zenserver/cache/structuredcachestore.cpp +++ b/src/zenserver/cache/structuredcachestore.cpp @@ -1691,10 +1691,11 @@ ZenCacheDiskLayer::CacheBucket::CollectGarbage(GcContext& GcCtx) Index.reserve(EntryCount); for (auto It : m_Index) { - size_t EntryIndex = Payloads.size(); - Payloads.push_back(m_Payloads[EntryIndex]); - AccessTimes.push_back(m_AccessTimes[EntryIndex]); - Index.insert({It.first, EntryIndex}); + size_t OldEntryIndex = It.second; + size_t NewEntryIndex = Payloads.size(); + Payloads.push_back(m_Payloads[OldEntryIndex]); + AccessTimes.push_back(m_AccessTimes[OldEntryIndex]); + Index.insert({It.first, NewEntryIndex}); } m_Index.swap(Index); m_Payloads.swap(Payloads); |