mirror of
https://github.com/postgres/postgres.git
synced 2026-04-04 00:36:17 -04:00
Test pg_stat_statements across crash restart
Add 'pg_stat_statements' to the crash restart test, to test that shared memory and LWLock initialization works across crash restart in a library listed in shared_preload_libraries. We had no test coverage for that. Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com
This commit is contained in:
parent
4441d6b2e4
commit
148fe2b05d
1 changed files with 29 additions and 4 deletions
|
|
@ -21,14 +21,32 @@ my $psql_timeout = IPC::Run::timer($PostgreSQL::Test::Utils::timeout_default);
|
|||
|
||||
my $node = PostgreSQL::Test::Cluster->new('primary');
|
||||
$node->init(allows_streaming => 1);
|
||||
|
||||
# Enable pg_stat_statements to test restart of shared_preload_libraries.
|
||||
$node->append_conf(
|
||||
'postgresql.conf',
|
||||
qq{shared_preload_libraries = 'pg_stat_statements'
|
||||
pg_stat_statements.max = 50000
|
||||
compute_query_id = 'regress'
|
||||
});
|
||||
|
||||
$node->start();
|
||||
|
||||
# by default PostgreSQL::Test::Cluster doesn't restart after a crash
|
||||
$node->safe_psql(
|
||||
'postgres',
|
||||
q[ALTER SYSTEM SET restart_after_crash = 1;
|
||||
ALTER SYSTEM SET log_connections = receipt;
|
||||
SELECT pg_reload_conf();]);
|
||||
'postgres', q[
|
||||
ALTER SYSTEM SET restart_after_crash = 1;
|
||||
ALTER SYSTEM SET log_connections = receipt;
|
||||
SELECT pg_reload_conf();
|
||||
]);
|
||||
|
||||
# Remember the time that pg_stat_statements was reset. We'll use it later to
|
||||
# verify that it gets re-initialized after crash.
|
||||
my $stats_reset = $node->safe_psql(
|
||||
'postgres', q[
|
||||
CREATE EXTENSION pg_stat_statements;
|
||||
SELECT stats_reset FROM pg_stat_statements_info;
|
||||
]);
|
||||
|
||||
# Run psql, keeping session alive, so we have an alive backend to kill.
|
||||
my ($killme_stdin, $killme_stdout, $killme_stderr) = ('', '', '');
|
||||
|
|
@ -141,6 +159,13 @@ $killme->run();
|
|||
($monitor_stdin, $monitor_stdout, $monitor_stderr) = ('', '', '');
|
||||
$monitor->run();
|
||||
|
||||
# Verify that pg_stat_statements, loaded via shared_preload_libraries,
|
||||
# was re-initialized at the crash.
|
||||
my $stats_reset_after = $node->safe_psql('postgres',
|
||||
q[SELECT stats_reset FROM pg_stat_statements_info]);
|
||||
cmp_ok($stats_reset, 'ne', $stats_reset_after,
|
||||
"pg_stat_statements was reset by restart");
|
||||
|
||||
|
||||
# Acquire pid of new backend
|
||||
$killme_stdin .= q[
|
||||
|
|
|
|||
Loading…
Reference in a new issue