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)?;