Symptom and impact
The configured maxsize does not cap the SQLite cache while a SqliteStore instance is in use. Each accepted write can grow the database beyond the configured limit, so a long-running process can keep expanding the cache file and consume more disk than the caller allowed.
Steps to reproduce
- Create a
Fbe::Middleware::SqliteStore with a maxsize that is larger than its initial database file and a maxvsize large enough for individual entries.
- Write enough distinct cache entries for the database file to exceed
store.path's configured maxsize.
- Keep using the same store instance and inspect the file size after further writes.
Actual result
The writes continue without enforcing @maxsize; eviction is only performed by init! when the database is opened. The cache can remain over the configured limit for the rest of the process lifetime.
Expected result
The store should enforce the size limit as entries are written, or otherwise provide a clearly defined bound that prevents a live cache from growing beyond maxsize.
Technical evidence
lib/fbe/middleware/sqlite_store.rb checks File.size(@path) > @maxsize and removes old entries only inside init!. write enforces @maxvsize for one serialized value, but after inserting it does not check or trim the total database size. Reopening the store runs the cleanup, which means the cap is delayed until that happens.
This follows from the current code paths; no runtime test was run for this report.
Symptom and impact
The configured
maxsizedoes not cap the SQLite cache while aSqliteStoreinstance is in use. Each accepted write can grow the database beyond the configured limit, so a long-running process can keep expanding the cache file and consume more disk than the caller allowed.Steps to reproduce
Fbe::Middleware::SqliteStorewith amaxsizethat is larger than its initial database file and amaxvsizelarge enough for individual entries.store.path's configuredmaxsize.Actual result
The writes continue without enforcing
@maxsize; eviction is only performed byinit!when the database is opened. The cache can remain over the configured limit for the rest of the process lifetime.Expected result
The store should enforce the size limit as entries are written, or otherwise provide a clearly defined bound that prevents a live cache from growing beyond
maxsize.Technical evidence
lib/fbe/middleware/sqlite_store.rbchecksFile.size(@path) > @maxsizeand removes old entries only insideinit!.writeenforces@maxvsizefor one serialized value, but after inserting it does not check or trim the total database size. Reopening the store runs the cleanup, which means the cap is delayed until that happens.This follows from the current code paths; no runtime test was run for this report.