diff options
| author | Dan Engelbrecht <[email protected]> | 2022-06-07 22:27:13 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-06-07 22:27:13 +0200 |
| commit | 3f3e91a6a1721a1a532ed296dd6e830fcfda8118 (patch) | |
| tree | 887596c8f2c00199df6f722d15576a047c2b9f15 | |
| parent | Merge pull request #120 from EpicGames/de/fix-failed-to-finalize-file (diff) | |
| download | zen-3f3e91a6a1721a1a532ed296dd6e830fcfda8118.tar.xz zen-3f3e91a6a1721a1a532ed296dd6e830fcfda8118.zip | |
We need to make each Cache Key contribution per bucket unique even across namespaces
| -rw-r--r-- | zenserver/cache/structuredcachestore.cpp | 4 | ||||
| -rw-r--r-- | zenstore/gc.cpp | 18 | ||||
| -rw-r--r-- | zenstore/include/zenstore/gc.h | 4 |
3 files changed, 10 insertions, 16 deletions
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp index bc60a1d26..330534528 100644 --- a/zenserver/cache/structuredcachestore.cpp +++ b/zenserver/cache/structuredcachestore.cpp @@ -1461,7 +1461,7 @@ ZenCacheDiskLayer::CacheBucket::GatherReferences(GcContext& GcCtx) } GcCtx.ContributeCids(Cids); - GcCtx.ContributeCacheKeys(m_BucketName, std::move(ExpiredKeys)); + GcCtx.ContributeCacheKeys(fmt::format("{}", reinterpret_cast<void*>(this)), std::move(ExpiredKeys)); } void @@ -1506,7 +1506,7 @@ ZenCacheDiskLayer::CacheBucket::CollectGarbage(GcContext& GcCtx) m_SlogFile.Flush(); - std::span<const IoHash> ExpiredCacheKeys = GcCtx.ExpiredCacheKeys(m_BucketName); + std::span<const IoHash> ExpiredCacheKeys = GcCtx.ExpiredCacheKeys(fmt::format("{}", reinterpret_cast<void*>(this))); std::vector<IoHash> DeleteCacheKeys; DeleteCacheKeys.reserve(ExpiredCacheKeys.size()); GcCtx.FilterCas(ExpiredCacheKeys, [&](const IoHash& ChunkHash, bool Keep) { diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp index 8e2d441f8..dfa3d54ab 100644 --- a/zenstore/gc.cpp +++ b/zenstore/gc.cpp @@ -170,15 +170,9 @@ SaveCompactBinaryObject(const fs::path& Path, const CbObject& Object) struct GcContext::GcState { - struct CacheBucket - { - std::vector<IoHash> ValidKeys; - std::vector<IoHash> ExpiredKeys; - }; - - using CacheBuckets = std::unordered_map<std::string, CacheBucket>; + using CacheKeyContexts = std::unordered_map<std::string, std::vector<IoHash>>; - CacheBuckets m_CacheBuckets; + CacheKeyContexts m_ExpiredCacheKeys; CasChunkSet m_CasChunks; CasChunkSet m_DeletedCasChunks; CasChunkSet m_CidChunks; @@ -212,9 +206,9 @@ GcContext::ContributeCas(std::span<const IoHash> Cas) } void -GcContext::ContributeCacheKeys(const std::string& Bucket, std::vector<IoHash>&& ExpiredKeys) +GcContext::ContributeCacheKeys(const std::string& CacheKeyContext, std::vector<IoHash>&& ExpiredKeys) { - m_State->m_CacheBuckets[Bucket].ExpiredKeys = std::move(ExpiredKeys); + m_State->m_ExpiredCacheKeys[CacheKeyContext] = std::move(ExpiredKeys); } void @@ -254,9 +248,9 @@ GcContext::DeletedCas() } std::span<const IoHash> -GcContext::ExpiredCacheKeys(const std::string& Bucket) const +GcContext::ExpiredCacheKeys(const std::string& CacheKeyContext) const { - return m_State->m_CacheBuckets[Bucket].ExpiredKeys; + return m_State->m_ExpiredCacheKeys[CacheKeyContext]; } bool diff --git a/zenstore/include/zenstore/gc.h b/zenstore/include/zenstore/gc.h index 6268588ec..a3ad19e10 100644 --- a/zenstore/include/zenstore/gc.h +++ b/zenstore/include/zenstore/gc.h @@ -53,7 +53,7 @@ public: void ContributeCids(std::span<const IoHash> Cid); void ContributeCas(std::span<const IoHash> Hash); - void ContributeCacheKeys(const std::string& Bucket, std::vector<IoHash>&& ExpiredKeys); + void ContributeCacheKeys(const std::string& CacheKeyContext, std::vector<IoHash>&& ExpiredKeys); void IterateCids(std::function<void(const IoHash&)> Callback); @@ -64,7 +64,7 @@ public: void DeletedCas(std::span<const IoHash> Cas); CasChunkSet& DeletedCas(); - std::span<const IoHash> ExpiredCacheKeys(const std::string& Bucket) const; + std::span<const IoHash> ExpiredCacheKeys(const std::string& CacheKeyContext) const; bool IsDeletionMode() const; void SetDeletionMode(bool NewState); |