diff options
| author | Stefan Boberg <[email protected]> | 2023-10-09 11:42:18 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-09 11:42:18 +0200 |
| commit | 38d82c4c6be428b4eef4665766ef4f677915a82b (patch) | |
| tree | fc3c1fcc61e37418365489a3474111c8364f5a27 /src | |
| parent | Fixes to shared server config (diff) | |
| download | zen-38d82c4c6be428b4eef4665766ef4f677915a82b.tar.xz zen-38d82c4c6be428b4eef4665766ef4f677915a82b.zip | |
reject bad bucket reads (#456)
* extended bad bucket rejection logic to include GET operations as well as PUTs
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenserver/cache/httpstructuredcache.cpp | 2 | ||||
| -rw-r--r-- | src/zenserver/cache/structuredcachestore.cpp | 17 | ||||
| -rw-r--r-- | src/zenserver/cache/structuredcachestore.h | 2 |
3 files changed, 16 insertions, 5 deletions
diff --git a/src/zenserver/cache/httpstructuredcache.cpp b/src/zenserver/cache/httpstructuredcache.cpp index d499ccd9f..f37fe1cc9 100644 --- a/src/zenserver/cache/httpstructuredcache.cpp +++ b/src/zenserver/cache/httpstructuredcache.cpp @@ -3300,7 +3300,7 @@ HttpStructuredCacheService::HandleStatsRequest(HttpServerRequest& Request) { Cbo.BeginObject("store"); Cbo << "hits" << CacheStoreStats.HitCount << "misses" << CacheStoreStats.MissCount << "writes" << CacheStoreStats.WriteCount - << "rejected_writes" << CacheStoreStats.RejectedWriteCount; + << "rejected_writes" << CacheStoreStats.RejectedWriteCount << "rejected_reads" << CacheStoreStats.RejectedReadCount; const uint64_t StoreTotal = CacheStoreStats.HitCount + CacheStoreStats.MissCount; Cbo << "hit_ratio" << (StoreTotal > 0 ? (double(CacheStoreStats.HitCount) / double(StoreTotal)) : 0.0); EmitSnapshot("read", CacheStoreStats.GetOps, Cbo); diff --git a/src/zenserver/cache/structuredcachestore.cpp b/src/zenserver/cache/structuredcachestore.cpp index f7960f498..fe0b84f33 100644 --- a/src/zenserver/cache/structuredcachestore.cpp +++ b/src/zenserver/cache/structuredcachestore.cpp @@ -416,6 +416,14 @@ ZenCacheStore::Get(const CacheRequestContext& Context, const IoHash& HashKey, ZenCacheValue& OutValue) { + // Ad hoc rejection of known bad usage patterns for DDC bucket names + + if (IsKnownBadBucketName(Bucket)) + { + m_RejectedReadCount++; + return false; + } + ZEN_TRACE_CPU("Z$::Get"); metrics::RequestStats::Scope OpScope(m_GetOps, 0); @@ -470,10 +478,6 @@ ZenCacheStore::Put(const CacheRequestContext& Context, const IoHash& HashKey, const ZenCacheValue& Value) { - ZEN_TRACE_CPU("Z$::Put"); - - metrics::RequestStats::Scope $(m_PutOps, Value.Value.GetSize()); - // Ad hoc rejection of known bad usage patterns for DDC bucket names if (IsKnownBadBucketName(Bucket)) @@ -482,6 +486,10 @@ ZenCacheStore::Put(const CacheRequestContext& Context, return; } + ZEN_TRACE_CPU("Z$::Put"); + + metrics::RequestStats::Scope $(m_PutOps, Value.Value.GetSize()); + if (m_WriteLogEnabled) { ZEN_TRACE_CPU("Z$::Get::WriteLog"); @@ -690,6 +698,7 @@ ZenCacheStore::Stats() .MissCount = m_MissCount, .WriteCount = m_WriteCount, .RejectedWriteCount = m_RejectedWriteCount, + .RejectedReadCount = m_RejectedReadCount, .PutOps = m_PutOps.Snapshot(), .GetOps = m_GetOps.Snapshot()}; IterateNamespaces([&](std::string_view NamespaceName, ZenCacheNamespace& Store) { diff --git a/src/zenserver/cache/structuredcachestore.h b/src/zenserver/cache/structuredcachestore.h index 1602b43ad..eca2f1880 100644 --- a/src/zenserver/cache/structuredcachestore.h +++ b/src/zenserver/cache/structuredcachestore.h @@ -173,6 +173,7 @@ public: uint64_t MissCount; uint64_t WriteCount; uint64_t RejectedWriteCount; + uint64_t RejectedReadCount; metrics::RequestStatsSnapshot PutOps; metrics::RequestStatsSnapshot GetOps; std::vector<NamedNamespaceStats> NamespaceStats; @@ -235,6 +236,7 @@ private: std::atomic<uint64_t> m_MissCount{}; std::atomic<uint64_t> m_WriteCount{}; std::atomic<uint64_t> m_RejectedWriteCount{}; + std::atomic<uint64_t> m_RejectedReadCount{}; metrics::RequestStats m_PutOps; metrics::RequestStats m_GetOps; |