Stop cache eviction in progress at shutdown (closes #102) #173

Merged
clawbot merged 4 commits from issue-102-cancellable-eviction into next 2026-10-04 09:24:42 +02:00
4 Commits
Author SHA1 Message Date
clawbot fbe45af544 Test that a reconciliation pass logs nothing once cancelled
check / check (push) Waiting to run
A reconciliation pass run with an already cancelled context logs no
warning, so a periodic tick the eviction loop takes after a stop adds
no warning to the one from the pass the stop interrupted.

Model: opus-5-5
2026-10-04 06:49:02 +00:00
clawbot b9d32985f6 Start no eviction pass after a stop, and end a pass quietly
Both pass runners do nothing once the loop's context is cancelled, so
a stop no longer starts an eviction pass after a cancelled
reconciliation or on a pending write-pressure wakeup or tick. In
evictBatch, a candidate that fails after cancellation ends the batch
with the context's error instead of logging its own warning; this
replaces the check before each candidate, since every candidate
started after cancellation fails at its first database call. A stop
now logs at most one warning.

Model: opus-5-5
2026-10-04 06:45:53 +00:00
clawbot 92e48a7a91 Test the warnings a stop logs and stopping between eviction candidates
The stop-during-reconciliation test now also expects exactly one
warning; it fails while the loop still starts an eviction pass after a
cancelled reconciliation. A new test cancels the context while the
oldest of three source blobs is evicted and expects EvictToLimit to
return context.Canceled, leave the other two on disk and log no
warning for them.

Model: opus-5-5
2026-10-04 06:45:53 +00:00
clawbot d930e352b0 Stop cache eviction in progress at shutdown (closes #102)
StartEviction runs the eviction goroutine with its own context, which
StopEviction cancels in place of the old stop channel, so a pass in
progress stops at its next database call, file, row or eviction
candidate instead of running to completion. StopEviction takes a
context: when it ends before the goroutine exits, StopEviction stops
waiting and returns an error wrapping it. The handlers' stop hook
passes fx's stop context, so an eviction still running at fx's stop
deadline fails the stop and the exit code is 1. The contextcheck
suppression on the start hook stays, with a one-line reason: the loop
outlives OnStart.

Model: opus-5-5
2026-10-04 06:45:53 +00:00