Skip to content

SqliteStore can grow past maxsize until it is reopened #1350

Description

@gemshrine

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

  1. Create a Fbe::Middleware::SqliteStore with a maxsize that is larger than its initial database file and a maxvsize large enough for individual entries.
  2. Write enough distinct cache entries for the database file to exceed store.path's configured maxsize.
  3. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions