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-11-26 20:16:46
Message-ID: 136416.1795724206@chrudos
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

> v04 fixes two of the four cases from my last mail. The two COPY
> trigger cases are still there, and two related cases are now worse
> than on master. All of this is on master 9ebc9a458c3 with v04-0001
> and v04-0002, using the attached script. The session reads its own
> progress row, so it gives the same output on every run.
>
> > Should work in v04 [1].
>
> It does. After the failed two-scan query the session reports progress
> again, and the Assert in xact_callback() no longer fires. The cursor
> case is fixed too, and so are the rows Adam and Alberto saw left
> behind by CREATE INDEX CONCURRENTLY and REINDEX CONCURRENTLY.
>
> > This should also work in v04.
>
> Not for the two COPY trigger cases:
>
> 1. If a COPY fails inside a two-scan query run by its trigger, its
> row stays after the error and through later commands. While the
> next CREATE INDEX runs, pg_stat_progress_create_index has no row
> for it, and the session still shows the failed COPY. On master the
> row goes away with the error.
>
> 2. A two-scan query that succeeds inside a COPY trigger still removes
> the outer COPY's row for the rest of that COPY. Master does the
> same, so this one is not a regression.
>
> The two related cases: if the two-scan query fails inside a
> subtransaction and the error is caught, either in a PL/pgSQL
> EXCEPTION block or with SAVEPOINT and ROLLBACK TO, the session stops
> reporting progress altogether. A later COPY or CREATE INDEX in that
> session has no row at all. On master both show up normally, and a
> new session is fine with v04 too.

I thought you described all the problem directly in the email, but now it
seems that the attachment was important too. So I tried to parse it, but
didn't have much success. Somehow I could reproduce one problem (the xact
callbacks are called too late, so in v05 I use PG_TRY-PG_CATCH block instead),
but the output of the script does not look very human readable.

If you still see any problem in v05, can you please give me a little bit
information how I can reproduce it? Thanks.

> The parallel BRIN build still looks the way Adam described, which I
> take it you already plan to drop.

Done.

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

Attachment Content-Type Size
v05-0001-Allow-progress-tracking-of-sub-commands.patch application/mbox 48.4 KB
v05-0002-Do-not-report-progress-of-two-or-more-COPY-commands-.patch application/mbox 5.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-11-26 20:58:21 Re: Fix assert failure in composite type dependency check for index expr
Previous Message Tom Lane 2026-11-26 19:58:11 Re: [PATCH] pg_input_is_valid() reuses the first type name inside a PL/pgSQL loop