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 | |
| 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')
| -rw-r--r-- | zenserver/admin/admin.cpp | 4 | ||||
| -rw-r--r-- | zenserver/cache/structuredcache.cpp | 28 | ||||
| -rw-r--r-- | zenserver/config.cpp | 2 | ||||
| -rw-r--r-- | zenserver/config.h | 2 |
4 files changed, 23 insertions, 13 deletions
diff --git a/zenserver/admin/admin.cpp b/zenserver/admin/admin.cpp index 8a3ab460c..15314b12a 100644 --- a/zenserver/admin/admin.cpp +++ b/zenserver/admin/admin.cpp @@ -43,9 +43,9 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler) : m_GcScheduler(Sched const HttpServerRequest::QueryParams Params = HttpReq.GetQueryParams(); GcScheduler::TriggerParams GcParams; - if (auto Param = Params.GetValue("smallobjects"); Param == "true"sv) + if (auto Param = Params.GetValue("smallobjects"); Param.empty() == false) { - GcParams.CollectSmallObjects = true; + GcParams.CollectSmallObjects = Param == "true"sv; } if (auto Param = Params.GetValue("maxcacheduration"); Param.empty() == false) 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, diff --git a/zenserver/config.cpp b/zenserver/config.cpp index e57a97c8b..5e5676494 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -314,7 +314,7 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) "", "gc-small-objects", "Whether garbage collection is enabled or not.", - cxxopts::value<bool>(ServerOptions.GcConfig.CollectSmallObjects)->default_value("false"), + cxxopts::value<bool>(ServerOptions.GcConfig.CollectSmallObjects)->default_value("true"), ""); options.add_option("gc", diff --git a/zenserver/config.h b/zenserver/config.h index bc8768961..8a507df39 100644 --- a/zenserver/config.h +++ b/zenserver/config.h @@ -76,7 +76,7 @@ struct ZenGcConfig ZenCasEvictionPolicy Cas; ZenCacheEvictionPolicy Cache; int32_t IntervalSeconds = 0; - bool CollectSmallObjects = false; + bool CollectSmallObjects = true; bool Enabled = true; }; |