diff options
| author | Dan Engelbrecht <[email protected]> | 2024-09-20 12:57:56 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-09-20 12:57:56 +0200 |
| commit | c66d244eb7847ec907936a95195ef1f888fc87cd (patch) | |
| tree | 6008cb25be0f51e34867589971160e2b5b6ff232 /src/zenstore/cache/cachedisklayer.cpp | |
| parent | End was clamped to the wrong side if Count was defaulted (diff) | |
| download | zen-c66d244eb7847ec907936a95195ef1f888fc87cd.tar.xz zen-c66d244eb7847ec907936a95195ef1f888fc87cd.zip | |
unblock PreCache (#164)
Don't lock disk cache buckets from writing when scanning records for attachment references
Diffstat (limited to 'src/zenstore/cache/cachedisklayer.cpp')
| -rw-r--r-- | src/zenstore/cache/cachedisklayer.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp index 110acba9e..63f6d708a 100644 --- a/src/zenstore/cache/cachedisklayer.cpp +++ b/src/zenstore/cache/cachedisklayer.cpp @@ -3587,7 +3587,7 @@ ZenCacheDiskLayer::CacheBucket::ReadAttachmentsFromMetaData(uint32_t BlockI } bool -ZenCacheDiskLayer::CacheBucket::GetReferencesLocked(GcCtx& Ctx, std::vector<IoHash>& OutReferences) +ZenCacheDiskLayer::CacheBucket::GetReferences(GcCtx& Ctx, bool StateIsAlreadyLocked, std::vector<IoHash>& OutReferences) { ZEN_TRACE_CPU("Z$::Bucket::GetReferencesLocked"); @@ -3611,7 +3611,11 @@ ZenCacheDiskLayer::CacheBucket::GetReferencesLocked(GcCtx& Ctx, std::vector<IoHa { std::unordered_map<uint32_t, std::size_t> BlockIndexToChunkIndexes; - + std::unique_ptr<RwLock::SharedLockScope> StateLock; + if (!StateIsAlreadyLocked) + { + StateLock = std::make_unique<RwLock::SharedLockScope>(m_IndexLock); + } for (const auto& Entry : m_Index) { if (Ctx.IsCancelledFlag.load()) @@ -3784,9 +3788,7 @@ public: m_CacheBucket.m_IndexLock.WithExclusiveLock([&]() { m_CacheBucket.m_TrackedReferences = std::make_unique<HashSet>(); }); - RwLock::SharedLockScope IndexLock(m_CacheBucket.m_IndexLock); - bool Continue = m_CacheBucket.GetReferencesLocked(Ctx, m_References); - IndexLock.ReleaseNow(); + bool Continue = m_CacheBucket.GetReferences(Ctx, /*StateIsAlreadyLocked*/ false, m_References); if (!Continue) { m_CacheBucket.m_IndexLock.WithExclusiveLock([&]() { m_CacheBucket.m_TrackedReferences.reset(); }); |