Re: Allow progress tracking of sub-commands

From: Antonin Houska <ah(at)cybertec(dot)at>
To: Manu <manuelreyesbravo(at)gmail(dot)com>
Cc: Alberto Piai <alberto(dot)piai(at)gmail(dot)com>, Rahila Syed <rahilasyed90(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, alvherre(at)kurilemu(dot)de, pgsql-hackers(at)lists(dot)postgresql(dot)org, bharath(dot)rupireddyforpostgres(at)gmail(dot)com, mihailnikalayeu(at)gmail(dot)com, adam8157(at)gmail(dot)com
Subject: Re: Allow progress tracking of sub-commands
Date: 2026-12-01 17:09:07
Message-ID: 169295.1796144947@chrudos
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Manu <manuelreyesbravo(at)gmail(dot)com> wrote:

> v07 fixes case 2: the script from my last mail now gives 1, 1 and 1 rows,
> and the earlier cases still pass. But in 0002, nodes is counted when the
> plan is made and nodes_ended when the scans end, and the two counts can
> drift apart. When they do, progress reporting stays off for the rest of the
> session,

I thought about this, but haven't figured out particular case where it can
really happen.

> CREATE INDEX included. Tested on master 9ebc9a458c3.

How does CREATE INDEX relate to FDW?

> The cases below use ft and ft2, file_fdw tables over seq 1000, and

...

I've decided to disable progress reporting by COPY FROM whenever it's launched
from file_fdw, regardless the number of nodes. The commit message of 0002
explains why.

> One point from my mail to Alberto on 25-11 is still open in v07, and
> it is not only about readers. With another session holding an
> uncommitted INSERT, REINDEX INDEX CONCURRENTLY shows command NULL and
> index_relid 0 while it waits for writers, where master shows REINDEX
> CONCURRENTLY and the index. The waits in phases 2, 3 and 5 start a
> new command and set only the phase. Any table with writes waits
> there.

Indeed, the parameter PROGRESS_CREATEIDX_COMMAND wasn't always set. Fixed in
v08.

> Alberto's suggestion, updating the phase of the current command, would avoid
> it.

In [1] Alberto deals with ReindexRelationConcurrently(). Why is it wrong to
call pgstat_progress_start_command() for each index? This is actually what
master does. What I had to do is making the _start_command() / _end_command()
calls balanced.

[1]
https://www.postgresql.org/message-id/DN49WENZXU2W.NZRYHQWDF8ED%40gmail.com

--
Antonin Houska
Web: https://www.cybertec-postgresql.com

Attachment Content-Type Size
v08-0001-Allow-progress-tracking-of-sub-commands.patch application/mbox 50.6 KB
v08-0002-Disable-progress-reporting-in-file_fdw.patch application/mbox 10.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Nidzwetzki 2026-12-01 17:27:28 Re: pg_rewind reports "no rewind required" due to stale minRecoveryPoint
Previous Message Ethan Tran 2026-12-01 16:42:40 Re: [WiP] GiST intrapage indexing