Cache.Stats reads never-populated output_content/request_cache tables, so TotalItems and TotalSizeBytes are always 0 #56
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Discovered while implementing #51 (out of scope there, filing per repo policy).
Cache.Statsininternal/imgcache/cache.gocomputesTotalItemsfromrequest_cacheandTotalSizeBytesfromoutput_content:No code path ever inserts into
output_contentorrequest_cache(they were created by migration 001 for a design that stored variants content-addressed with a request mapping, but the implementation went with key-addressedVariantStorageinstead). Both stats are therefore always 0.Since #51 (PR #55), real accounting exists:
variant_contenttracks processed variants andsource_contenttracks source blobs, andCache.UsageBytesreturns the true total. Suggested fix:TotalItems/TotalSizeBytesatvariant_content+source_content(or reuseUsageBytes).output_content/request_cachetables in a future migration or leave them for the originally intended design.Also worth a look in the same pass: the
metaCachefield onCache(in-memory variant meta cache) is initialized but never read or written.Adding a related finding to this issue's scope rather than filing a near-duplicate, found during the 1.0.0 survey and verified against
mainat61f42e6.The stats problem is wider than
Cache.Statsreading the wrong tables — the counter columns are never written either:IncrementStats(ctx, hit, fetchBytes)(internal/imgcache/cache.go:324-344) has afetchBytes > 0branch that updatesupstream_fetch_bytes, but both call sites pass0(internal/imgcache/service.go:134and:148). Soupstream_fetch_countandupstream_fetch_bytesnever move.transform_counthas no writer anywhere in the codebase.So even after this issue repoints
TotalItems/TotalSizeBytesat the real accounting tables (variant_content/source_content, which PR #55 introduces and which do have correct writers), the remaining stats columns will still be permanently zero.Suggest folding into this issue's definition of done, since it is the same "stats surface reports zeros" defect:
IncrementStatsreceives the real fetched byte count from both call sites inservice.gorather than0.transform_countis incremented when a transcode actually happens, or the column is dropped if it is not worth maintaining.Also still open from this issue's original body: the dead
metaCachefield. That has grown enough scope (it is the mechanism behindREADME.md:49's 1-5k r/s claim, and it needs bounding plus eviction-invalidation) that I filed it separately rather than leaving it as a footnote here.Milestoned
1.0.0. Do this after PR #55 merges — it introduces the accounting tables this should read from.