mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +03:00
Make new replication slot test code less racy
The new test code added in ead9e51e8236 is racy -- it hinges on shared-memory state, which changes before the WARNING message is logged. Put it the other way around. Backpatch to 13. Author: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/202107161809.zclasccpfcg3@alvherre.pgsql
This commit is contained in:
parent
4466b38ec6
commit
d8f3b021c6
@ -177,18 +177,21 @@ ok( !find_in_log(
|
|||||||
my $logstart = get_log_size($node_primary);
|
my $logstart = get_log_size($node_primary);
|
||||||
advance_wal($node_primary, 7);
|
advance_wal($node_primary, 7);
|
||||||
|
|
||||||
# This slot should be broken, wait for that to happen
|
# wait until the WARNING is issued
|
||||||
$node_primary->poll_query_until(
|
my $invalidated = 0;
|
||||||
'postgres',
|
for (my $i = 0; $i < 10000; $i++)
|
||||||
qq[SELECT wal_status = 'lost' FROM pg_replication_slots
|
{
|
||||||
WHERE slot_name = 'rep1']);
|
if (find_in_log(
|
||||||
|
|
||||||
# WARNING should be issued
|
|
||||||
ok( find_in_log(
|
|
||||||
$node_primary,
|
$node_primary,
|
||||||
"invalidating slot \"rep1\" because its restart_lsn [0-9A-F/]+ exceeds max_slot_wal_keep_size",
|
"invalidating slot \"rep1\" because its restart_lsn [0-9A-F/]+ exceeds max_slot_wal_keep_size",
|
||||||
$logstart),
|
$logstart))
|
||||||
'check that the warning is logged');
|
{
|
||||||
|
$invalidated = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
usleep(100_000);
|
||||||
|
}
|
||||||
|
ok($invalidated, 'check that slot invalidation has been logged');
|
||||||
|
|
||||||
$result = $node_primary->safe_psql(
|
$result = $node_primary->safe_psql(
|
||||||
'postgres',
|
'postgres',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user