From: Matt Joiner Date: Mon, 18 Jan 2021 03:40:48 +0000 (+1100) Subject: Fix boundary conditions trimming sqlite3 storage cache X-Git-Tag: v1.21.0~4 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=cb1d6bfc8f5015f5980bd61540a07bca8b8746d3;p=btrtrc.git Fix boundary conditions trimming sqlite3 storage cache --- 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;