Skip to content

fix(store): add 14-day retention for the sessions/ directory (#949) - #970

Open
hakanbaysal wants to merge 2 commits into
mksglu:nextfrom
hakanbaysal:fix/sessions-retention-949
Open

fix(store): add 14-day retention for the sessions/ directory (#949)#970
hakanbaysal wants to merge 2 commits into
mksglu:nextfrom
hakanbaysal:fix/sessions-retention-949

Conversation

@hakanbaysal

Copy link
Copy Markdown

What / Why / How

Fixes #949.

content/ has pruned stale per-project DBs at 14 days since day one, but
sessions/ had no retention path at all: per-session stats-*.json files
(one per server process, never reread once the session ends) and idle
per-project session DBs accumulate without bound. The issue reports a
two-month heavy install at 5,294 files / ~331MB in sessions/ while
content/ stayed bounded at ~52MB.

Fix: add cleanupStaleSessionFiles(sessionsDir, maxAgeDays) next to
cleanupStaleContentDBs and run it in the same one-time startup cleanup cycle,
with the same 14-day window.

Two deliberate design points:

Note: pruning old stats-*.json slightly reduces the Pi lifetime byte
aggregation (patchPiLifetimeFromStatsFiles sums all stats files) — the same
class of trade-off the existing 14-day content/ pruning already makes.

Affected platforms

  • All platforms

Test plan

Checklist

  • Tests added/updated (TDD: red → green)
  • npm test passes (store + server suites; full build requires Node >=22.5)
  • npm run typecheck passes
  • Docs updated if needed — n/a
  • No Windows path regressions (join() throughout, no hardcoded separators)
  • Targets next branch

hakanbaysal and others added 2 commits July 17, 2026 23:31
)

content/ has pruned stale per-project DBs at 14 days since day one, but
sessions/ had no retention path at all: per-session stats-*.json files
(one per server process, never reread once the session ends) and idle
per-project session DBs accumulate without bound. A two-month heavy
install reached 5,294 files / ~331MB in sessions/ while content/ stayed
bounded at ~52MB (mksglu#949).

Add cleanupStaleSessionFiles(sessionsDir, maxAgeDays) and run it in the
same one-time startup cleanup cycle as the content/ pruning, with the
same 14-day window. Retention is purely mtime-based: every hook write
refreshes the DB mtime, so a file untouched for 14 days cannot belong to
a live session. Deliberately no WAL-staleness liveness guess — that
heuristic can delete files under a live handle (mksglu#880) — and unknown file
types in the directory are never touched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant