Replace deprecated log_connections values in docs and tests

9219093cab2607f modularized log_connections output to allow more
granular control over which aspects of connection establishment are
logged. It converted the boolean log_connections GUC into a list of strings
and deprecated previously supported boolean-like values on, off, true,
false, 1, 0, yes, and no. Those values still work, but they are
supported mainly for backwards compatability. As such, documented
examples of log_connections should not use these deprecated values.

Update references in the docs to deprecated log_connections values. Many
of the tests use log_connections. This commit also updates the tests to
use the new values of log_connections. In some of the tests, the updated
log_connections value covers a narrower set of aspects (e.g. the
'authentication' aspect in the tests in src/test/authentication and the
'receipt' aspect in src/test/postmaster). In other cases, the new value
for log_connections is a superset of the previous included aspects (e.g.
'all' in src/test/kerberos/t/001_auth.pl).

Reported-by: Peter Eisentraut <peter@eisentraut.org>
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Discussion: https://postgr.es/m/e1586594-3b69-4aea-87ce-73a7488cdc97%40eisentraut.org
This commit is contained in:
Melanie Plageman 2025-05-22 17:14:54 -04:00
parent d376ab570e
commit cb1456423d
20 changed files with 24 additions and 21 deletions

View File

@ -140,7 +140,7 @@
An example of what this file might look like is: An example of what this file might look like is:
<programlisting> <programlisting>
# This is a comment # This is a comment
log_connections = yes log_connections = all
log_destination = 'syslog' log_destination = 'syslog'
search_path = '"$user", public' search_path = '"$user", public'
shared_buffers = 128MB shared_buffers = 128MB
@ -337,7 +337,7 @@ UPDATE pg_settings SET setting = reset_val WHERE name = 'configuration_parameter
<option>-c name=value</option> command-line parameter, or its equivalent <option>-c name=value</option> command-line parameter, or its equivalent
<option>--name=value</option> variation. For example, <option>--name=value</option> variation. For example,
<programlisting> <programlisting>
postgres -c log_connections=yes --log-destination='syslog' postgres -c log_connections=all --log-destination='syslog'
</programlisting> </programlisting>
Settings provided in this way override those set via Settings provided in this way override those set via
<filename>postgresql.conf</filename> or <command>ALTER SYSTEM</command>, <filename>postgresql.conf</filename> or <command>ALTER SYSTEM</command>,

View File

@ -3693,7 +3693,7 @@ set_debug_options(int debug_flag, GucContext context, GucSource source)
if (debug_flag >= 1 && context == PGC_POSTMASTER) if (debug_flag >= 1 && context == PGC_POSTMASTER)
{ {
SetConfigOption("log_connections", "true", context, source); SetConfigOption("log_connections", "all", context, source);
SetConfigOption("log_disconnections", "true", context, source); SetConfigOption("log_disconnections", "true", context, source);
} }
if (debug_flag >= 2) if (debug_flag >= 2)

View File

@ -107,7 +107,7 @@ $node->append_conf(
listen_addresses = '$hostaddr' listen_addresses = '$hostaddr'
# Capturing the EVENTS that occur during tests requires these settings # Capturing the EVENTS that occur during tests requires these settings
log_connections = on log_connections = 'receipt,authentication,authorization'
log_disconnections = on log_disconnections = on
trace_connection_negotiation = on trace_connection_negotiation = on
lc_messages = 'C' lc_messages = 'C'

View File

@ -71,7 +71,7 @@ sub test_role
my $node = PostgreSQL::Test::Cluster->new('node'); my $node = PostgreSQL::Test::Cluster->new('node');
$node->init; $node->init;
$node->append_conf('postgresql.conf', "log_connections = on\n"); $node->append_conf('postgresql.conf', "log_connections = authentication\n");
# Needed to allow connect_fails to inspect postmaster log: # Needed to allow connect_fails to inspect postmaster log:
$node->append_conf('postgresql.conf', "log_min_messages = debug2"); $node->append_conf('postgresql.conf', "log_min_messages = debug2");
$node->start; $node->start;

View File

@ -18,7 +18,7 @@ if (!$windows_os || $use_unix_sockets)
# Initialize primary node # Initialize primary node
my $node = PostgreSQL::Test::Cluster->new('primary'); my $node = PostgreSQL::Test::Cluster->new('primary');
$node->init; $node->init;
$node->append_conf('postgresql.conf', "log_connections = on\n"); $node->append_conf('postgresql.conf', "log_connections = authentication\n");
$node->start; $node->start;
my $huge_pages_status = my $huge_pages_status =

View File

@ -20,7 +20,7 @@ my $node = PostgreSQL::Test::Cluster->new('primary');
$node->init; $node->init;
$node->append_conf( $node->append_conf(
'postgresql.conf', q[ 'postgresql.conf', q[
log_connections = on log_connections = 'receipt,authentication'
]); ]);
$node->start; $node->start;

View File

@ -65,7 +65,7 @@ $node->append_conf(
'postgresql.conf', qq{ 'postgresql.conf', qq{
listen_addresses = '$hostaddr' listen_addresses = '$hostaddr'
krb_server_keyfile = '$krb->{keytab}' krb_server_keyfile = '$krb->{keytab}'
log_connections = on log_connections = all
log_min_messages = debug2 log_min_messages = debug2
lc_messages = 'C' lc_messages = 'C'
}); });

View File

@ -47,7 +47,7 @@ note "setting up PostgreSQL instance";
my $node = PostgreSQL::Test::Cluster->new('node'); my $node = PostgreSQL::Test::Cluster->new('node');
$node->init; $node->init;
$node->append_conf('postgresql.conf', "log_connections = on\n"); $node->append_conf('postgresql.conf', "log_connections = all\n");
# Needed to allow connect_fails to inspect postmaster log: # Needed to allow connect_fails to inspect postmaster log:
$node->append_conf('postgresql.conf', "log_min_messages = debug2"); $node->append_conf('postgresql.conf', "log_min_messages = debug2");
$node->start; $node->start;

View File

@ -43,7 +43,7 @@ note "setting up PostgreSQL instance";
my $node = PostgreSQL::Test::Cluster->new('node'); my $node = PostgreSQL::Test::Cluster->new('node');
$node->init; $node->init;
$node->append_conf('postgresql.conf', "log_connections = on\n"); $node->append_conf('postgresql.conf', "log_connections = all\n");
$node->start; $node->start;
$node->safe_psql('postgres', 'CREATE USER test0;'); $node->safe_psql('postgres', 'CREATE USER test0;');

View File

@ -42,7 +42,8 @@ note "setting up PostgreSQL instance";
my $node = PostgreSQL::Test::Cluster->new('node'); my $node = PostgreSQL::Test::Cluster->new('node');
$node->init; $node->init;
$node->append_conf('postgresql.conf', "log_connections = on\n"); $node->append_conf('postgresql.conf',
"log_connections = 'receipt,authentication,authorization'\n");
$node->append_conf('postgresql.conf', $node->append_conf('postgresql.conf',
"shared_preload_libraries = 'ldap_password_func'"); "shared_preload_libraries = 'ldap_password_func'");
$node->start; $node->start;

View File

@ -45,7 +45,7 @@ if ($ENV{with_python} ne 'yes')
my $node = PostgreSQL::Test::Cluster->new('primary'); my $node = PostgreSQL::Test::Cluster->new('primary');
$node->init; $node->init;
$node->append_conf('postgresql.conf', "log_connections = on\n"); $node->append_conf('postgresql.conf', "log_connections = all\n");
$node->append_conf('postgresql.conf', $node->append_conf('postgresql.conf',
"oauth_validator_libraries = 'validator'\n"); "oauth_validator_libraries = 'validator'\n");
# Needed to allow connect_fails to inspect postmaster log: # Needed to allow connect_fails to inspect postmaster log:

View File

@ -26,7 +26,7 @@ if (!$ENV{PG_TEST_EXTRA} || $ENV{PG_TEST_EXTRA} !~ /\boauth\b/)
my $node = PostgreSQL::Test::Cluster->new('primary'); my $node = PostgreSQL::Test::Cluster->new('primary');
$node->init; $node->init;
$node->append_conf('postgresql.conf', "log_connections = on\n"); $node->append_conf('postgresql.conf', "log_connections = all\n");
$node->append_conf('postgresql.conf', $node->append_conf('postgresql.conf',
"oauth_validator_libraries = 'validator'\n"); "oauth_validator_libraries = 'validator'\n");
$node->start; $node->start;

View File

@ -20,7 +20,8 @@ $node->init(
$node->append_conf('postgresql.conf', "max_connections = 6"); $node->append_conf('postgresql.conf', "max_connections = 6");
$node->append_conf('postgresql.conf', "reserved_connections = 2"); $node->append_conf('postgresql.conf', "reserved_connections = 2");
$node->append_conf('postgresql.conf', "superuser_reserved_connections = 1"); $node->append_conf('postgresql.conf', "superuser_reserved_connections = 1");
$node->append_conf('postgresql.conf', "log_connections = on"); $node->append_conf('postgresql.conf',
"log_connections = 'receipt,authentication,authorization'");
$node->append_conf('postgresql.conf', "log_min_messages=debug2"); $node->append_conf('postgresql.conf', "log_min_messages=debug2");
$node->start; $node->start;

View File

@ -33,7 +33,8 @@ $node->append_conf('postgresql.conf', "max_connections = 5");
$node->append_conf('postgresql.conf', "max_wal_senders = 0"); $node->append_conf('postgresql.conf', "max_wal_senders = 0");
$node->append_conf('postgresql.conf', "autovacuum_max_workers = 1"); $node->append_conf('postgresql.conf', "autovacuum_max_workers = 1");
$node->append_conf('postgresql.conf', "max_worker_processes = 1"); $node->append_conf('postgresql.conf', "max_worker_processes = 1");
$node->append_conf('postgresql.conf', "log_connections = on"); $node->append_conf('postgresql.conf',
"log_connections = 'receipt,authentication,authorization'");
$node->append_conf('postgresql.conf', "log_min_messages = debug2"); $node->append_conf('postgresql.conf', "log_min_messages = debug2");
$node->append_conf('postgresql.conf', $node->append_conf('postgresql.conf',
"authentication_timeout = '$authentication_timeout s'"); "authentication_timeout = '$authentication_timeout s'");

View File

@ -27,7 +27,7 @@ $node->start();
$node->safe_psql( $node->safe_psql(
'postgres', 'postgres',
q[ALTER SYSTEM SET restart_after_crash = 1; q[ALTER SYSTEM SET restart_after_crash = 1;
ALTER SYSTEM SET log_connections = 1; ALTER SYSTEM SET log_connections = receipt;
SELECT pg_reload_conf();]); SELECT pg_reload_conf();]);
# Run psql, keeping session alive, so we have an alive backend to kill. # Run psql, keeping session alive, so we have an alive backend to kill.

View File

@ -26,7 +26,7 @@ $node->start();
$node->safe_psql( $node->safe_psql(
'postgres', 'postgres',
q[ALTER SYSTEM SET remove_temp_files_after_crash = on; q[ALTER SYSTEM SET remove_temp_files_after_crash = on;
ALTER SYSTEM SET log_connections = 1; ALTER SYSTEM SET log_connections = receipt;
ALTER SYSTEM SET work_mem = '64kB'; ALTER SYSTEM SET work_mem = '64kB';
ALTER SYSTEM SET restart_after_crash = on; ALTER SYSTEM SET restart_after_crash = on;
SELECT pg_reload_conf();]); SELECT pg_reload_conf();]);

View File

@ -14,7 +14,7 @@ $node_primary->init(allows_streaming => 1);
$node_primary->append_conf( $node_primary->append_conf(
'postgresql.conf', q[ 'postgresql.conf', q[
allow_in_place_tablespaces = true allow_in_place_tablespaces = true
log_connections=on log_connections=receipt
# to avoid "repairing" corruption # to avoid "repairing" corruption
full_page_writes=off full_page_writes=off
log_min_messages=debug2 log_min_messages=debug2

View File

@ -15,7 +15,7 @@ $node->append_conf(
autovacuum = off autovacuum = off
max_prepared_transactions=5 max_prepared_transactions=5
log_min_duration_statement=0 log_min_duration_statement=0
log_connections=on log_connections=receipt
log_disconnections=on log_disconnections=on
)); ));

View File

@ -200,7 +200,7 @@ sub configure_test_server_for_ssl
$node->append_conf( $node->append_conf(
'postgresql.conf', <<EOF 'postgresql.conf', <<EOF
fsync=off fsync=off
log_connections=on log_connections=all
log_hostname=on log_hostname=on
listen_addresses='$serverhost' listen_addresses='$serverhost'
log_statement=all log_statement=all

View File

@ -8,7 +8,7 @@ max_prepared_transactions = 10
# Settings that make logs more useful # Settings that make logs more useful
log_autovacuum_min_duration = 0 log_autovacuum_min_duration = 0
log_checkpoints = true log_checkpoints = true
log_connections = true log_connections = all
log_disconnections = true log_disconnections = true
log_line_prefix = '%m [%p][%b] %q[%a][%v:%x] ' log_line_prefix = '%m [%p][%b] %q[%a][%v:%x] '
log_lock_waits = true log_lock_waits = true