From cb1d6bfc8f5015f5980bd61540a07bca8b8746d3 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 18 Jan 2021 14:40:48 +1100 Subject: [PATCH] Fix boundary conditions trimming sqlite3 storage cache --- storage/sqlite/sqlite-storage.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/sqlite/sqlite-storage.go b/storage/sqlite/sqlite-storage.go index 22b4b8fd..b046d0d3 100644 --- a/storage/sqlite/sqlite-storage.go +++ b/storage/sqlite/sqlite-storage.go @@ -92,16 +92,16 @@ with recursive excess ( length(cast(data as blob)) from blob order by last_used, rowid limit 1 ) - where usage_with >= (select value from setting where name='capacity') + where usage_with > (select value from setting where name='capacity') union all select - usage_with-data_length, + usage_with-data_length as new_usage_with, blob.last_used, blob.rowid, length(cast(data as blob)) from excess join blob on blob.rowid=(select rowid from blob where (last_used, rowid) > (excess.last_used, blob_rowid)) - where usage_with >= (select value from setting where name='capacity') + where new_usage_with > (select value from setting where name='capacity') ) select * from excess; -- 2.48.1