diff options
| author | Dan Engelbrecht <[email protected]> | 2023-05-12 21:35:32 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-12 21:35:32 +0200 |
| commit | f7927ad8e34bc6224765bb159644304f253cc577 (patch) | |
| tree | c2875dcf689a5db7436aa2545d07a05fca445c95 | |
| parent | v0.2.11-pre0 (diff) | |
| download | zen-f7927ad8e34bc6224765bb159644304f253cc577.tar.xz zen-f7927ad8e34bc6224765bb159644304f253cc577.zip | |
wipe cache buckets block store that may contain invalid state (#300)
* wipe cache buckets block store that may contain invalid state
* Update CHANGELOG.md
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | src/zenserver/cache/structuredcachestore.cpp | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 47ce391df..afdf09bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ ## - Feature: Gracefully exit if Ctrl-C is pressed -- Feature: Structured cache now writes an activity log to `logs/c$` which may be used to understand client interactions better. Enabled by default for the time being +- Feature: Structured cache now writes an activity log to `logs/z$` which may be used to understand client interactions better. Enabled by default for the time being - 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 +- Bugfix: GC could mix up locations of cache bucket items causing it to return the wrong item for a specific key. All cache buckets from previous versions will be wiped to remove inconsistent state - 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 2fd8e8be8..7368d45da 100644 --- a/src/zenserver/cache/structuredcachestore.cpp +++ b/src/zenserver/cache/structuredcachestore.cpp @@ -49,6 +49,12 @@ namespace { #pragma pack(push) #pragma pack(1) + // We use this to indicate if a on disk bucket needs wiping + // In version 0.2.5 -> 0.2.11 there was a GC corruption bug that would scrable the references + // to block items. + // See: https://github.com/EpicGames/zen/pull/299 + static const uint32_t CurrentDiskBucketVersion = 1; + struct CacheBucketIndexHeader { static constexpr uint32_t ExpectedMagic = 0x75696478; // 'uidx'; @@ -720,6 +726,12 @@ ZenCacheDiskLayer::CacheBucket::OpenOrCreate(std::filesystem::path BucketDir, bo { return false; } + uint32_t Version = Manifest["Version"sv].AsUInt32(0); + if (Version != CurrentDiskBucketVersion) + { + ZEN_INFO("Wiping bucket '{}', found version {}, required version {}", BucketDir, Version, CurrentDiskBucketVersion); + IsNew = true; + } } else if (AllowCreate) { @@ -727,6 +739,7 @@ ZenCacheDiskLayer::CacheBucket::OpenOrCreate(std::filesystem::path BucketDir, bo CbObjectWriter Writer; Writer << "BucketId"sv << m_BucketId; + Writer << "Version"sv << CurrentDiskBucketVersion; Manifest = Writer.Save(); SaveCompactBinaryObject(ManifestPath, Manifest); IsNew = true; @@ -1250,6 +1263,7 @@ ZenCacheDiskLayer::CacheBucket::SaveManifest() CbObjectWriter Writer; Writer << "BucketId"sv << m_BucketId; + Writer << "Version"sv << CurrentDiskBucketVersion; if (!m_Index.empty()) { |