Repository navigation
fix(storage): open metadata DB without engine-level TTL - #218
Conversation
RocksDB's TTL compaction filter drops every key not rewritten within the window — including per-segment delete-index records, the FIFO eviction index, and bucketed access keys. With the DB TTL set to the cache entry TTL (24h in prod), a segment's delete-index record is silently erased ~24h after its last merge, so the recompactor loses its only fragmentation signal and dead segment bytes become permanently unreclaimable. Observed on ORD: 68% of 814 GiB of segments dead with zero recompactions over 30h; PVCs hit 82%. Entry expiry is owned by the application cleaner (which scans metadata and stages reclamation); the engine TTL was redundant for that. Opening with OpenDbWithTTL(..., 0) disables the filter while preserving the on-disk value format, so existing DBs stay readable. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01L5DLvDTo9dhD38YQXhHpU9 Signed-off-by: Ovais Tariq <[email protected]>
Greptile SummaryThis PR disables RocksDB engine-level TTL for the metadata database so application-owned cleanup can expire entries without deleting long-lived lifecycle indexes.
Confidence Score: 4/5The PR appears safe to merge, with non-blocking follow-up recommended for migration coverage and the now-inert TTL configuration surface. The application Cleaner continues to own entry expiration and all production metadata initialization uses zero engine TTL; the remaining concerns are test coverage for upgrading existing databases and misleading dead configuration. Files Needing Attention: storage/metadata_engine_ttl_test.go, storage/storage.go Important Files Changed
Reviews (1): Last reviewed commit: "fix(storage): open metadata DB without e..." | Re-trigger Greptile |
| // multiplex merge operator installed. The entry TTL the cache would use is | ||
| // deliberately tiny so the wait below exceeds it. | ||
| const entryTTLSeconds = 1 | ||
| db, err := metadata.NewMetaDB(dir, 0, merge.NewMultiplexOperator(), nil) |
There was a problem hiding this comment.
Cover the production TTL transition
This test creates a fresh database with engine TTL disabled, so it does not exercise the promised production transition where a database written with a nonzero engine TTL is reopened with TTL zero. Add coverage for that reopen sequence so an on-disk compatibility regression cannot pass this test while making existing metadata unreadable.
Knowledge Base Used: Storage Engine
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| // cleaner, which scans metadata and stages reclamation; the engine TTL was redundant for that. | ||
| // OpenDbWithTTL(…, 0) keeps the on-disk value format (timestamp suffixes) so existing DBs | ||
| // remain readable; 0 means "never expire". | ||
| meta, err := metadata.NewMetaDB(config.DiskPath, 0, mergeOp, rocksConfig) |
There was a problem hiding this comment.
Remove the inert TTL configuration
This literal makes StorageConfig.TTL ineffective while production and test callers continue to populate it. Remove or deprecate the field and update its callers, or document its new semantics, so configuration and tests do not imply that changing it still affects the metadata engine.
Knowledge Base Used: Storage Engine
…#223) Removing the metadata DB's engine-level TTL (#218) left StorageConfig.TTL with no consumer: a Put with no key-level TTL never received an expiry, so configured default expiry silently stopped working (flagged by Cursor Bugbot on the release PR). Apply the default app-side in Put, where expiry is enforced by the cleaner — which stages file and segment reclamation — instead of the engine filter that dropped bookkeeping keys and orphaned backing bytes. Signed-off-by: Ovais Tariq <[email protected]>
|
🎉 This PR is included in version 1.10.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Problem
The metadata DB is opened with
grocksdb.OpenDbWithTTL(opts, dbPath, ttl)wherettlis the cache-wide entry TTL (TAG passes 24 h). RocksDB's TTL DB applies a compaction filter to every key in the DB, silently dropping any key not rewritten within the window — including internal bookkeeping that must outlive entry TTLs:!delete:segment/…) — the recompactor's only fragmentation signalA segment's delete index receives its last merge roughly when the segment's last entry expires (~T+24 h for 24 h-TTL data), so RocksDB erases the record around T+48 h and the segment looks clean forever. Its dead bytes become permanently unreclaimable.
Production impact (ORD, 3 nodes, TAG v1.17.5 / ocache v1.10.1): live accounting ~258 GB/pod (under the 400 GB eviction cap) while
segments/held 814 GiB in 3,267 files — ~68% dead bytes, growing ~200 GB/pod/day.ocache_recompaction_segments_totalstayed 0 over 30 h (54 runs). PVCs reached 82% and low-disk alerts fired.Reproduced locally: two
MakeDeleteIndexOperandmerges into a TTL-opened MetaDB read back correctly within TTL (entries=2, bytes=250), then after TTL + oneCompactRangethe key is silently absent.Fix
Open the metadata DB with engine TTL 0 ("never expire"). Entry expiry is owned by the application cleaner, which scans metadata and stages reclamation correctly (it deleted ~232 GB / ~240k keys per pod in those same 30 h) — the engine TTL was redundant for its intended purpose and destructive to bookkeeping.
OpenDbWithTTL(…, 0)keeps the on-disk value format (timestamp suffixes), so existing production DBs remain readable — no migration needed.Testing
TestDeleteIndexSurvivesEntryTTL: delete-index records outlive an entry-TTL-sized wait plus a full compaction (fails against the old behavior with engine TTL = entry TTL)./storage/...suite passes (11 packages)Related: perfloop could not trace this one (
anchor_failed— startup-config + engine-internal actors aren't workload-reachable), hence the direct fix. Sibling leak (Putoverwrite skippingstageFileDeletion) is being worked by perfloop ascase_ch2hff4wv9.Note: this fix prevents future orphaning; bytes already orphaned have no surviving records and need a one-time cache wipe to reclaim.
🤖 Generated with Claude Code
https://claude.ai/code/session_01L5DLvDTo9dhD38YQXhHpU9
Note
Cursor Bugbot is generating a summary for commit aa35544. Configure here.