Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita6e04b1

Browse files
author
Amit Kapila
committed
Test that invalidated logical slots doesn't retain WAL.
Author: Bertrand DrouvotReviewed-by: Shi yu, Amit Kapila, Vignesh CDiscussion:https://postgr.es/m/2fefa454-5a70-2174-ddbf-4a0e41537139@gmail.com
1 parent1ab763f commita6e04b1

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

‎src/test/recovery/t/035_standby_logical_decoding.pl

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,43 @@ sub check_for_invalidation
500500
check_slots_conflicting_status(1);
501501

502502
##################################################
503-
# Verify that invalidated logical slots do not lead to retaining WAL
503+
# Verify that invalidated logical slots do not lead to retaining WAL.
504504
##################################################
505-
# XXXXX TODO
505+
506+
# Wait for the cascading standby to catchup before removing the WAL file(s)
507+
$node_standby->wait_for_replay_catchup($node_cascading_standby,$node_primary);
508+
509+
# Get the restart_lsn from an invalidated slot
510+
my$restart_lsn =$node_standby->safe_psql('postgres',
511+
"SELECT restart_lsn from pg_replication_slots WHERE slot_name = 'vacuum_full_activeslot' and conflicting is true;"
512+
);
513+
514+
chomp($restart_lsn);
515+
516+
# As pg_walfile_name() can not be executed on the standby,
517+
# get the WAL file name associated to this lsn from the primary
518+
my$walfile_name =$node_primary->safe_psql('postgres',
519+
"SELECT pg_walfile_name('$restart_lsn')");
520+
521+
chomp($walfile_name);
522+
523+
# Generate some activity and switch WAL file on the primary
524+
$node_primary->safe_psql(
525+
'postgres',"create table retain_test(a int);
526+
select pg_switch_wal();
527+
insert into retain_test values(1);
528+
checkpoint;");
529+
530+
# Wait for the standby to catch up
531+
$node_primary->wait_for_replay_catchup($node_standby);
532+
533+
# Request a checkpoint on the standby to trigger the WAL file(s) removal
534+
$node_standby->safe_psql('postgres','checkpoint;');
535+
536+
# Verify that the WAL file has not been retained on the standby
537+
my$standby_walfile =$node_standby->data_dir .'/pg_wal/' .$walfile_name;
538+
ok(!-f"$standby_walfile",
539+
"invalidated logical slots do not lead to retaining WAL");
506540

507541
##################################################
508542
# Recovery conflict: Invalidate conflicting slots, including in-use slots

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp