Skip to content

Commit 4ec0ca8

Browse files
committed
app/: retention leaves a blob that a render reused in the last day names as a page image, checked again under the row's lock
1 parent e5a8481 commit 4ec0ca8

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎app/src/domain/retention.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,14 @@ async fn delete_marked(store: Option<&BlobStore>, sha256: &str) -> laravel::Resu
370370
if locked.is_none() {
371371
return Ok(Deleted::KeptForNow);
372372
}
373-
// Named since it was marked (a snapshot or diff committed after a registration that found it uploaded): it stays.
373+
// Named since it was marked (a snapshot or diff committed after a registration that found it uploaded, or a page
374+
// image of a render reused since): it stays.
374375
let named: Option<i64> = db::query!(
375376
"SELECT 1::BIGINT WHERE EXISTS (SELECT 1 FROM snapshots WHERE source_blob = {sha256}) \
376377
OR EXISTS (SELECT 1 FROM renders WHERE source_blob = {sha256}) \
377-
OR EXISTS (SELECT 1 FROM diffs WHERE overlay_blob = {sha256})"
378+
OR EXISTS (SELECT 1 FROM diffs WHERE overlay_blob = {sha256}) \
379+
OR EXISTS (SELECT 1 FROM renders r, jsonb_array_elements(r.pages) pg \
380+
WHERE r.used_at >= now() - interval '24 hours' AND pg->>'image' = {sha256})"
378381
)
379382
.scalar()
380383
.await?;

0 commit comments

Comments
 (0)