Prerequisites
Install Method
Docker
Operating System
macOS (Apple Silicon), Docker Desktop
Steps to Reproduce
- Use web search / content fetching so the search and content caches fill.
- Restart the container.
- Keep using search normally, then inspect the cache directory.
Expected Behaviour
Entries past their max age are removed.
Actual Behaviour
cleanup_cache in services/search/cache.py evicts based on a process-local in-memory index. That index is empty after every restart, so every file written before the last restart becomes invisible to the cleaner and is never removed — permanently orphaned.
Found here: 158 orphaned content files (5.5 MB), days old, whose configured max age is 2 hours. The cleaner reported nothing to do, because as far as its index was concerned there was nothing there.
Compounding it: cleanup only runs on writes (throttled to at most 1/h for search, 1/2h for content), so a quiet instance never cleans at all.
Additional Information
Fix running here: the directory is the ground truth (glob("*.cache")); the index supplies the timestamp when it knows one, otherwise the file's mtime is used. Age and max-count semantics unchanged, signature unchanged (callers and tests unaffected), each deletion individually exception-wrapped so cleanup can never fail a search.
First run after the fix: evictions=158, content 158 → 0.
General shape worth applying to both caches: cache eviction must be judged against the filesystem, not against a data structure that dies with the process.
Are you willing to submit a fix?
Yes — the fix described above is running in production here and I can open a PR.
Prerequisites
devbranch.Install Method
Docker
Operating System
macOS (Apple Silicon), Docker Desktop
Steps to Reproduce
Expected Behaviour
Entries past their max age are removed.
Actual Behaviour
cleanup_cacheinservices/search/cache.pyevicts based on a process-local in-memory index. That index is empty after every restart, so every file written before the last restart becomes invisible to the cleaner and is never removed — permanently orphaned.Found here: 158 orphaned content files (5.5 MB), days old, whose configured max age is 2 hours. The cleaner reported nothing to do, because as far as its index was concerned there was nothing there.
Compounding it: cleanup only runs on writes (throttled to at most 1/h for search, 1/2h for content), so a quiet instance never cleans at all.
Additional Information
Fix running here: the directory is the ground truth (
glob("*.cache")); the index supplies the timestamp when it knows one, otherwise the file's mtime is used. Age and max-count semantics unchanged, signature unchanged (callers and tests unaffected), each deletion individually exception-wrapped so cleanup can never fail a search.First run after the fix:
evictions=158, content 158 → 0.General shape worth applying to both caches: cache eviction must be judged against the filesystem, not against a data structure that dies with the process.
Are you willing to submit a fix?
Yes — the fix described above is running in production here and I can open a PR.