REINDEX CONCURRENTLY reports lockers_done > lockers_total

From: Manu <manuelreyesbravo(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Michael Paquier <michael(at)paquier(dot)xyz>
Subject: REINDEX CONCURRENTLY reports lockers_done > lockers_total
Date: 2026-11-17 05:24:48
Message-ID: 179489308882.313551.16760472116841542703@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While REINDEX CONCURRENTLY is "waiting for readers before marking
dead", pg_stat_progress_create_index can show lockers_done greater
than lockers_total (2 and 1 with the attached script), though the
docs say these columns contain the progress information for the
current phase.

WaitForOlderSnapshots() leaves lockers_total, lockers_done and
current_locker_pid set when it returns, while WaitForLockersMultiple()
resets all three. Both only set lockers_total when they start, so the
wait that comes next inherits the other two.

The attached patch resets them in WaitForOlderSnapshots() the same
way. The same code is in 14 to 19.

Found with the progress trace from [1].

[1] https://www.postgresql.org/message-id/179381939119.1041924.8156751512243472203@gmail.com

--
Manu

Attachment Content-Type Size
v1-0001-Reset-lockers-progress-columns-at-end-of-WaitForO.patch text/x-patch 1.8 KB
repro-waitfor.sh.txt text/plain 3.7 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2026-11-17 05:25:53 RE: Document prepared transaction lock waits with two_phase subscriptions
Previous Message Manu 2026-11-17 05:10:24 Re: Assertion failure with temporary relations in single-user mode