| From: | Manu <manuelreyesbravo(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Cc: | Michael Paquier <michael(at)paquier(dot)xyz> |
| Subject: | Count the last block of the validation scan in CIC progress |
| Date: | 2026-10-26 17:21:00 |
| Message-ID: | 179303526069.2212386.7608335332316408826@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
While CREATE INDEX CONCURRENTLY waits in "waiting for old snapshots",
pg_stat_progress_create_index shows blocks_done one short of
blocks_total for the whole wait: 442 of 443 on a 443-block table, with
a REPEATABLE READ transaction opened before the command and left open.
REINDEX CONCURRENTLY shows the same 442 of 443 in "waiting for old
snapshots" and in both "waiting for readers" phases.
heapam_index_validate_scan() reports each block when the scan starts
on it and nothing when the scan ends, so the last block is never
counted, and the phases that follow do not touch the block counters.
The attached patch reports rs_nblocks once the scan ends, the same as
the build scan's final report in heapam_index_build_range_scan(). The
validation scan does not use syncscan, so that is the total it
reported at its start. With it, the four waits show 443 of 443.
repro-f3.sh.txt reproduces it (bash repro-f3.sh.txt <bindir>); its
output on master and with the patch is attached. With the patch,
make check, the isolation suite, the injection_points tests,
test_misc's 010 and reindexdb's 090 pass (cassert build, no warnings).
I think this is for master only, like 3be29d9346d. It came up while
sweeping progress reporting for the framework in CF 7331. Mihail's
CIC series (v40-0004) moves this scan to tuples_done, so the fix is
for the code as it is today.
Regards,
Manu
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Count-the-last-block-of-the-validation-scan-of-a-con.patch | text/x-patch | 1.9 KB |
| repro-f3.sh.txt | text/plain | 3.6 KB |
| repro-output-master.txt | text/plain | 1.9 KB |
| repro-output-fix.txt | text/plain | 1.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Manu | 2026-10-26 17:33:40 | Re: UNDO with FILEOPS, and the FLUX table AM |
| Previous Message | Tom Lane | 2026-10-26 17:05:52 | Re: Let's drop support for named POSIX semaphores |