Re: Report index currently being vacuumed in pg_stat_progress_vacuum - Mailing list pgsql-hackers

From Sami Imseih
Subject Re: Report index currently being vacuumed in pg_stat_progress_vacuum
Date
Msg-id CAA5RZ0sw8ZuAYt+bJ_VvJvcHVKe+=1tstC7oqAqUye9_3Ta6gg@mail.gmail.com
Whole thread
In response to Re: Report index currently being vacuumed in pg_stat_progress_vacuum  (Sami Imseih <samimseih@gmail.com>)
List pgsql-hackers
Hi,

See the attached v2.

It aggregates on the leader (if parallel) at the SQL level with two new
columns: index_vacuum_pids and index_vacuum_oids. These are pid and oid
arrays respectively and are order-aligned. The leader is listed first when
it is itself processing an index; otherwise one of the workers is,
obviously, first.
For a serial vacuum, each array is a single value. The array fields will be
NULL if no index is currently being processed.

Using array typed columns is new for the pg_stat_progress_* views, none of
them expose arrays today, or any other pg_stat_* views. It's a bit unusual here,
but I think it's the natural fit.

Now, with this, parallel workers now register their own progress entry
so they show up as additional rows in pg_stat_get_progress_info('VACUUM').
The progress_vacuum view filters them out, but any code that reads the function
directly will now see an extra (mostly zeros) row per worker.
pg_stat_get_progress_info()
is not meant to be used directly, hence it's not documented for direct
use, so I think this is OK.

I also noticed in v1 that we weren't resetting the index after the vacuum
completed, and the index was being set in the wrong place. I fixed that. I
also removed the unnecessary typecast for InvalidOid.

Lastly, with this approach we no longer need the external function to
retrieve the leader pid.

What do you think?

--
Sami

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: walsummarizer can get stuck when switching timelines
Next
From: Peter Geoghegan
Date:
Subject: Re: Bug: GiST index-only scans can use tuple descriptor with incorrect alignment when deforming