Skip to content

Commit 57ac725

Browse files
ldanilekConvex, Inc.
authored andcommitted
Revert "use documents_multiget in retention" (#34365)
revert most of https://github.com/get-convex/convex/pull/34317 (leaving the test improvements) because it's causing issues where the retention check is throwing false-positive errors GitOrigin-RevId: 8d8be2fe9da2d406fbc2f6f68825a03ade4a2e7c
1 parent 8c33283 commit 57ac725

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

crates/database/src/retention.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -561,36 +561,25 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
561561
// Each prev rev has 1 or 2 index entries to delete per index -- one entry at
562562
// the prev rev's ts, and a tombstone at the current rev's ts if
563563
// the document was deleted or its index key changed.
564+
// TODO: use prev_ts when available
564565
let prev_revs = reader_
565-
.documents_multiget(
566-
chunk
567-
.iter()
568-
.filter_map(|entry| entry.prev_ts.map(|prev_ts| (entry.id, prev_ts)))
569-
.collect(),
570-
)
566+
.previous_revisions(chunk.iter().map(|entry| (entry.id, entry.ts)).collect())
571567
.await?;
572568
for DocumentLogEntry {
573569
ts,
574570
id,
575571
value: maybe_doc,
576-
prev_ts: prev_rev_ts,
577572
..
578573
} in chunk
579574
{
580575
// If there is no prev rev, there's nothing to delete.
581576
// If this happens for a tombstone, it means the document was created and
582577
// deleted in the same transaction, with no index rows.
583-
let Some(prev_rev_ts) = prev_rev_ts else {
584-
log_retention_scanned_document(maybe_doc.is_none(), false);
585-
continue;
586-
};
587-
// If there is a prev_ts on the log entry but the previous revision
588-
// does not exist, it was probably deleted before and we don't need to
589-
// worry about it.
590578
let Some(DocumentLogEntry {
579+
ts: prev_rev_ts,
591580
value: maybe_prev_rev,
592581
..
593-
}) = prev_revs.get(&(id, prev_rev_ts))
582+
}) = prev_revs.get(&(id, ts))
594583
else {
595584
log_retention_scanned_document(maybe_doc.is_none(), false);
596585
continue;
@@ -626,7 +615,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
626615
key_prefix: key.prefix.clone(),
627616
key_suffix: key.suffix.clone(),
628617
key_sha256: key_sha256.to_vec(),
629-
ts: prev_rev_ts,
618+
ts: *prev_rev_ts,
630619
deleted: false,
631620
},
632621
));

0 commit comments

Comments
 (0)