Skip to content

Commit 8f61e44

Browse files
committed
Tweak logic for when to display:
"Waiting for %d transactions to finish. First PID: %s" message. Display it on every loop through the SQL_XID_ALIVE check (i.e. every second), instead of only when the number of transactions we're waiting on changes -- previously, it was too easy for that important message to get lost in other messages. And don't display the message at all when running under pg_regress, i.e. as part of `make installcheck`. We had been getting occasional errors from pg_regress when autovacuum was running and that message got logged.
1 parent 0cb40b6 commit 8f61e44

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

bin/pg_repack.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,6 @@ repack_one_table(repack_table *table, const char *orderby)
987987
PGresult *res = NULL;
988988
const char *params[2];
989989
int num;
990-
int num_waiting = 0;
991990
char *vxid = NULL;
992991
char buffer[12];
993992
StringInfoData sql;
@@ -997,6 +996,11 @@ repack_one_table(repack_table *table, const char *orderby)
997996
char indexbuffer[12];
998997
int j;
999998

999+
/* appname will be "pg_repack" in normal use on 9.0+, or
1000+
* "pg_regress" when run under `make installcheck`
1001+
*/
1002+
const char *appname = getenv("PGAPPNAME");
1003+
10001004
/* Keep track of whether we have gotten through setup to install
10011005
* the z_repack_trigger, log table, etc. ourselves. We don't want to
10021006
* go through repack_cleanup() if we didn't actually set up the
@@ -1312,15 +1316,14 @@ repack_one_table(repack_table *table, const char *orderby)
13121316
if (num > 0)
13131317
{
13141318
/* Wait for old transactions.
1315-
* Only display the message below when the number of
1316-
* transactions we are waiting on changes (presumably,
1317-
* num_waiting should only go down), so as not to
1318-
* be too noisy.
1319+
* Only display this message if we are NOT
1320+
* running under pg_regress, so as not to cause
1321+
* noise which would trip up pg_regress.
13191322
*/
1320-
if (num != num_waiting)
1323+
1324+
if (!appname || strcmp(appname, "pg_regress") != 0)
13211325
{
13221326
elog(NOTICE, "Waiting for %d transactions to finish. First PID: %s", num, PQgetvalue(res, 0, 0));
1323-
num_waiting = num;
13241327
}
13251328

13261329
CLEARPGRES(res);

0 commit comments

Comments
 (0)