From 46367e739f0e77a9106dc8c825be241f16a5fdc5 Mon Sep 17 00:00:00 2001 From: Maksim Dimitrov Date: Mon, 9 Feb 2026 22:46:40 +0200 Subject: [PATCH 1/2] store: Fix for_prune range for nonfinal entities Signed-off-by: Maksim Dimitrov --- store/postgres/src/relational/prune.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/store/postgres/src/relational/prune.rs b/store/postgres/src/relational/prune.rs index 4154eb5110a..d7747fef5e9 100644 --- a/store/postgres/src/relational/prune.rs +++ b/store/postgres/src/relational/prune.rs @@ -170,7 +170,7 @@ impl TablePair { let column_list = Arc::new(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).await?; + let range = VidRange::for_prune(conn, &self.src, final_block, BLOCK_NUMBER_MAX).await?; let mut batcher = VidBatcher::load(conn, &self.src.nsp, &self.src, range).await?; tracker.start_copy_nonfinal(conn, &self.src, range).await?; From fa6d6770315233174084735c1accb666e1c53acd Mon Sep 17 00:00:00 2001 From: Maksim Dimitrov Date: Mon, 9 Feb 2026 23:04:28 +0200 Subject: [PATCH 2/2] graph: Fix earliest_block off-by-one calculation for pruning after copy_nonfinal_entities bounds fix Signed-off-by: Maksim Dimitrov --- graph/src/components/store/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/graph/src/components/store/mod.rs b/graph/src/components/store/mod.rs index b2b6783349b..9951f966c40 100644 --- a/graph/src/components/store/mod.rs +++ b/graph/src/components/store/mod.rs @@ -1043,7 +1043,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 {