Conversation
Metric time series data expires via the pcp:values:series: stream TTL
(stream.expire, default 86400s), but the ~10 ancillary keys per series
(pcp:desc:series:, pcp:series:metric.name:, pcp:series:label.*.value:,
etc.) accumulated indefinitely, causing unbounded key server growth.
Add pmSeriesGC() to libpcp_web and a --gc / --dryrun mode to pmseries
that scans pcp:desc:series:* for all known series, checks whether each
stream is still alive, and for stale series removes:
- pcp:desc:series:H, pcp:metric.name:series:H
- pcp:instances:series:H, pcp:labelvalue:series:H, pcp:labelflags:series:H
- membership in pcp:series:metric.name:*, pcp:series:inst.name:*,
pcp:series:label.<name>.value:*, pcp:series:context.name:*
- orphaned pcp:inst:series:* hashes when their inst-name set empties
All key server operations are fully async using the existing
baton/callback infrastructure. Three new pmproxy MMV metrics track GC
activity: series.gc.calls, series.gc.scanned, series.gc.cleaned.
Output uses the standard info callback so results appear on stdout for
the CLI and in the pmproxy log when invoked from a timer.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pcp:desc:series:,pcp:series:metric.name:,pcp:series:label.*.value:, etc.) accumulated indefinitely after stream TTL expiry, causing unbounded key server growthpmSeriesGC()to libpcp_web andpmseries --gc/--dryrunto scan for expired series and remove all associated keys asynchronouslyseries.gc.calls,series.gc.scanned,series.gc.cleanedDetails
When
pcp:values:series:Hexpires (viastream.expire, default 86400s) the raw data is reclaimed but ~10 ancillary keys per series remain.--gcscanspcp:desc:series:*, checks each stream's liveness, and for dead series removes:pcp:desc:series:H,pcp:metric.name:series:H,pcp:instances:series:H,pcp:labelvalue:series:H,pcp:labelflags:series:Hpcp:series:metric.name:*,pcp:series:inst.name:*,pcp:series:label.<name>.value:*,pcp:series:context.name:*pcp:inst:series:*hashes when their inst-name set becomes emptyOutput goes through the standard info callback (stdout for CLI, pmproxy log for timer use). A
--dryrunflag logs what would be removed without writing anything.Tested against a local Valkey instance: 9547 series scanned, 8402 identified for cleanup.
Known limitation: SCAN is sent to the first node only (
keySlotsRequestFirstNode); full cluster support is future work.Test plan
pmseries --gc --dryrun— verify series listed without any key server writespmseries --gc— verify ancillary keys removedseries.gc.*MMV metrics visible via pmproxy after a GC run--gcis mutually exclusive with--load,--query,--values,--window--dryrunwithout--gcis rejected with a clear error🤖 Generated with Claude Code