diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 6c37d33a0e1..6ecd7631489 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -1074,9 +1074,14 @@ finalize_block_range(ChangeContext *chgcxt, BlockNumber cur, * following range (for which we'll use more recent snapshot). Thus it'd * be non-trivial to apply the UPDATE later. By replaying it now, we get * rid of the old tuple in the current range. + * + * The scan has passed all blocks before 'cur', not only those before + * 'end': it does not stop at blocks that have no tuples. So 'cur' is the + * upper bound here. The next snapshot is not used for those blocks, so + * changes skipped now would be lost. */ end_of_wal = GetFlushRecPtr(NULL); - repack_process_concurrent_changes(chgcxt, end_of_wal, start, end, true, + repack_process_concurrent_changes(chgcxt, end_of_wal, start, cur, true, false); /*