1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Don't propagate PGAPPNAME through pg_ctl in tests

When libpq is loaded in the server (for instance, by
libpqwalreceiver), it may use libpq environment variables set in the
postmaster environment for connection parameter defaults.  This has
some confusing effects in our test suites.  For example, the TAP test
infrastructure sets PGAPPNAME to allow identifying clients in the
server log.  But this environment variable is also inherited by
temporary servers started with pg_ctl and is then in turn used by
libpqwalreceiver as the application_name for connecting to remote
servers where it then shows up in pg_stat_replication and is relevant
for things like synchronous_standby_names.  Replication already has a
suitable default for application_name, and overriding that
accidentally then requires the individual test cases to re-override
that, which is all very confusing and unnecessary.

To fix, unset PGAPPNAME temporarily before running pg_ctl start or
restart in the tests.

More comprehensive approaches like unsetting all environment variables
in pg_ctl were considered but might be too complicated to achieve
portably.

The now unnecessary re-overriding of application_name by test cases is
also removed.

Reviewed-by: Noah Misch <noah@leadboat.com>
Discussion: https://www.postgresql.org/message-id/flat/33383613-690e-6f1b-d5ba-4957ff40f6ce@2ndquadrant.com
This commit is contained in:
Peter Eisentraut
2019-03-15 21:24:05 +01:00
parent c21d6033f7
commit 8e93a516e6
13 changed files with 82 additions and 71 deletions

View File

@ -160,7 +160,7 @@ sub create_standby
$node_standby->append_conf(
"postgresql.conf", qq(
primary_conninfo='$connstr_master application_name=rewind_standby'
primary_conninfo='$connstr_master'
));
$node_standby->set_standby_mode();
@ -180,7 +180,7 @@ sub promote_standby
# up standby
# Wait for the standby to receive and write all WAL.
$node_master->wait_for_catchup('rewind_standby', 'write');
$node_master->wait_for_catchup($node_standby, 'write');
# Now promote standby and insert some new data on master, this will put
# the master out-of-sync with the standby.