aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2021-04-03 00:07:00 +0900
committerFujii Masao <fujii@postgresql.org>2021-04-03 00:08:05 +0900
commit24bcce3bd6b458d0d2b064c2ab2ed2837c1211a3 (patch)
tree46a3b59c1cba3d313390379213771761ea10f88b
parent677357047b9c920e351b73d9670a813fcdc6801b (diff)
downloadpostgresql-24bcce3bd6b458d0d2b064c2ab2ed2837c1211a3.tar.gz
postgresql-24bcce3bd6b458d0d2b064c2ab2ed2837c1211a3.zip
pg_checksums: Fix progress reporting.
pg_checksums uses two counters, total size and current size, to calculate the progress. Previously the progress that pg_checksums reported could not reach 100% at the end. The cause of this issue was that the sizes of only pages excluding new ones in each file were counted as the current size while the size of each file is counted as the total size. That is, the total size of all new pages could be reported as the difference between the total size and current size. This commit fixes this issue by making pg_checksums count the sizes of all pages including new ones in each file as the current size. Back-patch to v12 where progress reporting was added to pg_checksums. Reported-by: Shinya Kato Author: Shinya Kato Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/TYAPR01MB289656B1ACA0A5E7CAD07BE3C47A9@TYAPR01MB2896.jpnprd01.prod.outlook.com
-rw-r--r--src/bin/pg_checksums/pg_checksums.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c
index c3e5704cdde..2a749266adb 100644
--- a/src/bin/pg_checksums/pg_checksums.c
+++ b/src/bin/pg_checksums/pg_checksums.c
@@ -228,12 +228,19 @@ scan_file(const char *fn, BlockNumber segmentno)
}
blocks++;
+ /*
+ * Since the file size is counted as total_size for progress status
+ * information, the sizes of all pages including new ones in the file
+ * should be counted as current_size. Otherwise the progress reporting
+ * calculated using those counters may not reach 100%.
+ */
+ current_size += r;
+
/* New pages have no checksum yet */
if (PageIsNew(header))
continue;
csum = pg_checksum_page(buf.data, blockno + segmentno * RELSEG_SIZE);
- current_size += r;
if (mode == PG_MODE_CHECK)
{
if (csum != header->pd_checksum)