Keep a variant's accounting row when its file cannot be read (closes #340)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The reconciliation pass dropped a variant's accounting row on any error reading its file's size, and logged every such file as missing. A file still on disk then had no row, so eviction no longer counted it against cache_max_bytes. Now only a missing file (ErrNotFound, which FileStore.Size returns for it) loses its row, with the same info line. Any other error keeps the row and logs a warning naming the variant key and the error, and the pass goes on to the next key. README.md says so under Storage. Model: opus-5-5
This commit was merged in pull request #342.
This commit is contained in:
@@ -613,7 +613,9 @@ func (c *Cache) adoptVariantFile(
|
||||
}
|
||||
|
||||
// reconcileVariantRows drops accounting rows whose variant files are
|
||||
// missing, so the database never references deleted content.
|
||||
// missing, so the database never references deleted content. A file whose
|
||||
// size cannot be read for another reason may still be on disk, so its row
|
||||
// stays, with a warning naming its key and the error.
|
||||
func (c *Cache) reconcileVariantRows(ctx context.Context) error {
|
||||
var after imagerequest.VariantKey
|
||||
|
||||
@@ -641,6 +643,13 @@ func (c *Cache) reconcileVariantRows(ctx context.Context) error {
|
||||
continue
|
||||
}
|
||||
|
||||
if !errors.Is(err, ErrNotFound) {
|
||||
c.log.Warn("kept accounting row for unreadable variant file",
|
||||
"cache_key", key, "error", err)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
_, err = c.db.ExecContext(ctx,
|
||||
`DELETE FROM variant_content WHERE cache_key = ?`, string(key))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user