]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix CLUSTER progress reporting of number of blocks scanned.
authorFujii Masao <fujii@postgresql.org>
Fri, 27 Nov 2020 11:16:44 +0000 (20:16 +0900)
committerFujii Masao <fujii@postgresql.org>
Fri, 27 Nov 2020 11:18:02 +0000 (20:18 +0900)
commitfce17e486f3579fd2617c12f332608a5e78fefac
treec9fdc4a9c2f77ea83b3bcf0b4fc33a0351889f37
parentea7a167daa3e7c9c7b03fb09432aafcea1cf4d88
Fix CLUSTER progress reporting of number of blocks scanned.

Previously pg_stat_progress_cluster view reported the current block
number in heap scan as the number of heap blocks scanned (i.e.,
heap_blks_scanned). This reported number could be incorrect when
synchronize_seqscans is enabled, because it allowed the heap scan to
start at block in middle. This could result in wraparounds in the
heap_blks_scanned column when the heap scan wrapped around.
This commit fixes the bug by calculating the number of blocks from
the block that the heap scan starts at to the current block in scan,
and reporting that number in the heap_blks_scanned column.

Also, in pg_stat_progress_cluster view, previously heap_blks_scanned
could not reach heap_blks_total at the end of heap scan phase
if the last pages scanned were empty. This commit fixes the bug by
manually updating heap_blks_scanned to the same value as
heap_blks_total when the heap scan phase finishes.

Back-patch to v12 where pg_stat_progress_cluster view was introduced.

Reported-by: Matthias van de Meent
Author: Matthias van de Meent
Reviewed-by: Fujii Masao
Discussion: https://postgr.es/m/CAEze2WjCBWSGkVfYag001Rc4+-nNLDpWM7QbyD6yPvuhKs-gYQ@mail.gmail.com
src/backend/access/heap/heapam_handler.c