diff options
| author | Per Larsson <[email protected]> | 2021-12-14 09:41:04 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-12-14 09:41:04 +0100 |
| commit | 5f8136b25040046c466c95cbec3874594ff91d0c (patch) | |
| tree | b6cdbf23a5074c18ed7565e8c81709a9df350c0c /zenserver/cache/structuredcache.cpp | |
| parent | Remove Cid to CAS chunk mapping after GC. (diff) | |
| download | zen-5f8136b25040046c466c95cbec3874594ff91d0c.tar.xz zen-5f8136b25040046c466c95cbec3874594ff91d0c.zip | |
Fixed bug in z$ service returning partial cache records and enable small object GC by default.
Diffstat (limited to 'zenserver/cache/structuredcache.cpp')
| -rw-r--r-- | zenserver/cache/structuredcache.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index e74030e07..22c8c4afb 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -847,29 +847,37 @@ HttpStructuredCacheService::HandleRpcGetCacheRecords(zen::HttpServerRequest& Req if (m_CacheStore.Get(Key.Bucket, Key.Hash, CacheValue)) { CbObjectView CacheRecord(CacheValue.Value.Data()); - - if (!SkipAttachments) - { - CacheRecord.IterateAttachments([this, &MissingCount, &RpcResponse](CbFieldView AttachmentHash) { + CacheRecord.IterateAttachments([this, SkipAttachments, &MissingCount, &RpcResponse](CbFieldView AttachmentHash) { + if (SkipAttachments && MissingCount == 0) + { + if (!m_CidStore.ContainsChunk(AttachmentHash.AsHash())) + { + MissingCount++; + } + } + else + { if (IoBuffer Chunk = m_CidStore.FindChunkByCid(AttachmentHash.AsHash())) { + ZEN_ASSERT(Chunk.GetSize() > 0); RpcResponse.AddAttachment(CbAttachment(CompressedBuffer::FromCompressed(SharedBuffer(Chunk)))); } else { MissingCount++; } - }); - } + } + }); } if (CacheValue.Value && (MissingCount == 0 || PartialOnError)) { - ZEN_DEBUG("HIT - '{}/{}' {} '{}' (LOCAL)", + ZEN_DEBUG("HIT - '{}/{}' {} '{}' (LOCAL) {}", Key.Bucket, Key.Hash, NiceBytes(CacheValue.Value.Size()), - ToString(CacheValue.Value.GetContentType())); + ToString(CacheValue.Value.GetContentType()), + MissingCount ? "(PARTIAl)" : ""sv); CacheValues[KeyIndex] = std::move(CacheValue.Value); m_CacheStats.HitCount++; @@ -880,7 +888,7 @@ HttpStructuredCacheService::HandleRpcGetCacheRecords(zen::HttpServerRequest& Req } else { - ZEN_DEBUG("MISS - '{}/{}' {}", Key.Bucket, Key.Hash, MissingCount ? "(partial)"sv : ""sv); + ZEN_DEBUG("MISS - '{}/{}' {}", Key.Bucket, Key.Hash, MissingCount ? "(PARTIAl)"sv : ""sv); m_CacheStats.MissCount++; } @@ -1091,6 +1099,8 @@ HttpStructuredCacheService::HandleRpcGetCachePayloads(zen::HttpServerRequest& Re { if (IoBuffer Chunk = m_CidStore.FindChunkByCid(ChunkRequest.ChunkId)) { + ZEN_ASSERT(Chunk.GetSize() > 0); + ZEN_DEBUG("HIT - '{}/{}/{}' {} '{}' ({})", ChunkRequest.Key.Bucket, ChunkRequest.Key.Hash, |