Remove expired negative cache rows in the eviction loop (closes #244) #262

Merged
clawbot merged 6 commits from issue-244-clean-expired-negative-cache into next 2026-10-15 15:02:28 +02:00
6 Commits
Author SHA1 Message Date
sneak ac5db758ff Move the TODO.md entry for the negative cache cleanup to the top
check / check (push) Waiting to run
The rebase onto next left it below the entries next gained since.

Model: opus-5-5
2026-10-15 12:17:03 +00:00
sneak 288bbfbe4a Test that CleanExpired removes more than one batch of expired rows
TestCleanExpiredRemovesMoreThanOneBatch stores one expired negative
cache row more than a batch holds and calls CleanExpired alone, so a
CleanExpired that stops after its first batch fails it.

Model: opus-5-5
2026-10-15 12:16:27 +00:00
sneak 581c5e0872 Delete expired negative cache rows in batches
CleanExpired deletes at most 1000 expired rows per statement and starts
no further statement once its context ends, so a request on the one
database connection waits behind one batch at most.

Model: opus-5-5
2026-10-15 12:16:27 +00:00
sneak 4834e2444c Test that expired negative cache rows are deleted in batches
One statement deletes one batch and no more, CleanExpired removes the
rest, and it deletes nothing once its context has ended.

Model: opus-5-5
2026-10-15 12:16:27 +00:00
sneak 47246d1d1c Remove expired negative cache rows in the eviction loop (closes #244)
A negative cache row was deleted only when its source URL was requested
again after it expired, and CleanExpired was never called, so a client
asking for a new missing path each time grew the database without
limit. The eviction goroutine now calls CleanExpired at startup and on
every periodic tick, so a row stays at most NegativeTTL plus one
interval. The goroutine also starts with the disk cache disabled, where
reconciliation and eviction already do nothing, since the negative
cache is used either way.

Model: opus-5-5
2026-10-15 12:16:27 +00:00
sneak 22c0a50fdc Test that the eviction loop removes expired negative cache rows
A failed fetch stored in the negative cache must be removed by the
eviction loop once it has expired, although its URL is never requested
again, with the disk cache enabled and disabled; a row that has not
expired stays. Fails until the fix for
#244 lands.

Model: opus-5-5
2026-10-15 12:16:27 +00:00