From 583d44928c82bea66df12474c22698bd4d6998bf Mon Sep 17 00:00:00 2001 From: Maksim Dimitrov Date: Tue, 10 Feb 2026 00:32:22 +0200 Subject: [PATCH] Fix/missing version on prune rebuild (#6340) * store: Fix for_prune range for nonfinal entities Signed-off-by: Maksim Dimitrov * graph: Fix earliest_block off-by-one calculation for pruning after copy_nonfinal_entities bounds fix Signed-off-by: Maksim Dimitrov --------- Signed-off-by: Maksim Dimitrov --- graph/src/components/store/mod.rs | 4 +++- store/postgres/src/relational/prune.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/graph/src/components/store/mod.rs b/graph/src/components/store/mod.rs index 585df5945f1..943bbb69652 100644 --- a/graph/src/components/store/mod.rs +++ b/graph/src/components/store/mod.rs @@ -1067,7 +1067,9 @@ impl PruneRequest { )); } - let earliest_block = latest_block - history_blocks; + // We need to add + 1 to `earliset_block` because the lower bound is inclusive + // and otherwise we would end up with `history_blocks + 1` blocks of history instead of `history_blocks` + let earliest_block = latest_block - history_blocks + 1; let final_block = latest_block - reorg_threshold; Ok(Self { diff --git a/store/postgres/src/relational/prune.rs b/store/postgres/src/relational/prune.rs index 1c33eca4aeb..c2e618c04fb 100644 --- a/store/postgres/src/relational/prune.rs +++ b/store/postgres/src/relational/prune.rs @@ -163,7 +163,7 @@ impl TablePair { let column_list = self.column_list(); // Determine the last vid that we need to copy - let range = VidRange::for_prune(conn, &self.src, final_block + 1, BLOCK_NUMBER_MAX)?; + let range = VidRange::for_prune(conn, &self.src, final_block, BLOCK_NUMBER_MAX)?; let mut batcher = VidBatcher::load(conn, &self.src.nsp, &self.src, range)?; tracker.start_copy_nonfinal(conn, &self.src, range)?;