Re: [HACKERS] CLUSTER command progress monitor
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>,
Tatsuro Yamada <tatsuro.yamada.tf@nttcom.co.jp>, Alvaro Herrera <alvherre@2ndquadrant.com>,
Rafia Sabih <rafia.pghackers@gmail.com>, Dmitry Dolgov <9erthalion6@gmail.com>, Peter Geoghegan <pg@bowt.ie>, PostgreSQL-development <pgsql-hackers@postgresql.org>,
Jeff Janes <jeff.janes@gmail.com>, Thomas Munro <thomas.munro@enterprisedb.com>,
Michael Paquier <michael.paquier@gmail.com>
Date: 2019-09-04T13:18:39Z
Lists: pgsql-hackers
On Tue, Sep 3, 2019 at 1:02 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > After more thought, even if we don't start a new command progress when > there is another one already started the progress update functions > could be called and these functions don't specify the command type. > Therefore, the progress information might be changed with wrong value > by different command. Probably we can change the caller of progress > updating function so that it doesn't call all of them if the command > could not start a new progress report, but it might be a big change. > > As an alternative idea, we can make pgstat_progress_end_command() have > one argument that is command the caller wants to end. That is, we > don't end the command progress when the specified command type doesn't > match to the command type of current running command progress. We > unconditionally clear the progress information at CommitTransaction() > and AbortTransaction() but we can do that by passing > PROGRESS_COMMAND_INVALID to pgstat_progress_end_command(). I think this is all going in the wrong direction. It's the responsibility of the people who are calling the pgstat_progress_* functions to only do so when it's appropriate. Having the pgstat_progress_* functions try to untangle whether or not they ought to ignore calls made to them is backwards. It seems to me that the problem here can be summarized in this way: there's a bunch of code reuse in the relevant paths here, and somebody wasn't careful enough when adding progress reporting for one of the new commands, and so now things are broken, because e.g. CLUSTER progress reporting gets ended by a pgstat_progress_end_command() call that was intended for some other utility command but is reached in the CLUSTER case anyway. The solution to that problem in my book is to figure out which commit broke it, and then the person who made that commit either needs to fix it or revert it. It's quite possible here that we need a bigger redesign to make adding progress reporting for new command easier and less prone to bugs, but I don't think it's at all clear what such a redesign should look like or even that we definitely need one, and September is not the right time to be redesigning features for the pending release. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Commits
-
Fix progress reporting of CLUSTER / VACUUM FULL
- 6212276e4343 13.0 landed
- da47e43dc32e 12.0 landed
-
Fix thinko when ending progress report for a backend
- f4b91a50e9e6 9.6.16 landed
- 4950f09e7ae2 10.11 landed
- af28744288b1 11.6 landed
- 4c3e750ab4b5 12.0 landed
- ae060a52b288 13.0 landed
-
Report progress of REINDEX operations
- 03f9e5cba0ee 12.0 cited
-
Add progress reporting for CLUSTER and VACUUM FULL.
- 6f97457e0ddd 12.0 landed
-
Un-hide most cascaded-drop details in regression test results.
- 940311e4bb32 12.0 cited
-
Fix memory leak in printtup.c.
- f2004f19ed9c 12.0 cited
-
Remove unused macro
- fb5806533f9f 12.0 cited