Skip to content

Commit 2eb1fc8

Browse files
committed
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
1 parent 53aafdb commit 2eb1fc8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/bin/pg_checksums/pg_checksums.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,19 @@ scan_file(const char *fn, BlockNumber segmentno)
229229
}
230230
blocks++;
231231

232+
/*
233+
* Since the file size is counted as total_size for progress status
234+
* information, the sizes of all pages including new ones in the file
235+
* should be counted as current_size. Otherwise the progress reporting
236+
* calculated using those counters may not reach 100%.
237+
*/
238+
current_size += r;
239+
232240
/* New pages have no checksum yet */
233241
if (PageIsNew(header))
234242
continue;
235243

236244
csum = pg_checksum_page(buf.data, blockno + segmentno * RELSEG_SIZE);
237-
current_size += r;
238245
if (mode == PG_MODE_CHECK)
239246
{
240247
if (csum != header->pd_checksum)

0 commit comments

Comments
 (0)