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

Commite3e787c

Browse files
author
Amit Kapila
committed
Fix test failure caused by commit76b7872.
The test failed because it assumed that a newly created logicalreplication slot could be synced to the standby by the slotsync worker.However, the presence of an existing physical slot caused the new logicalslot to use a non-latest xmin. On the standby, the DDL had already beenreplayed, advancing xmin, which led to the slotsync worker failing to syncthe lagging logical slot.To resolve this, we moved the slot sync statistics tests to run after thetests that do not require the newly created slot to be sync-ready.As per buildfarm.Author: Hou Zhijie <houzj.fnst@fujitsu.com>Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>Discussion:https://postgr.es/m/OSCPR01MB14966FE0BFB6C212298BFFEDEF5D1A@OSCPR01MB14966.jpnprd01.prod.outlook.com
1 parente1405aa commite3e787c

File tree

1 file changed

+70
-58
lines changed

1 file changed

+70
-58
lines changed

‎src/test/recovery/t/040_standby_failover_slots_sync.pl‎

Lines changed: 70 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -213,75 +213,19 @@
213213
##################################################
214214
# Test that the synchronized slot will be dropped if the corresponding remote
215215
# slot on the primary server has been dropped.
216-
#
217-
# Note: Both slots need to be dropped for the next test to work
218216
##################################################
219217

220218
$primary->psql('postgres',"SELECT pg_drop_replication_slot('lsub2_slot');");
221-
$primary->psql('postgres',"SELECT pg_drop_replication_slot('lsub1_slot');");
222219

223220
$standby1->safe_psql('postgres',"SELECT pg_sync_replication_slots();");
224221

225222
is($standby1->safe_psql(
226223
'postgres',
227-
q{SELECT count(*) = 0 FROM pg_replication_slots WHERE slot_nameIN ('lsub1_slot', 'lsub2_slot');}
224+
q{SELECT count(*) = 0 FROM pg_replication_slots WHERE slot_name= 'lsub2_slot';}
228225
),
229226
"t",
230227
'synchronized slot has been dropped');
231228

232-
##################################################
233-
# Verify that slotsync skip statistics are correctly updated when the
234-
# slotsync operation is skipped.
235-
##################################################
236-
237-
# Create a logical replication slot and create some DDL on the primary so
238-
# that the slot lags behind the standby.
239-
$primary->safe_psql(
240-
'postgres',qq(
241-
SELECT pg_create_logical_replication_slot('lsub1_slot', 'pgoutput', false, false, true);
242-
CREATE TABLE wal_push(a int);
243-
));
244-
$primary->wait_for_replay_catchup($standby1);
245-
246-
my$log_offset =-s$standby1->logfile;
247-
248-
# Enable slot sync worker.
249-
$standby1->append_conf('postgresql.conf',qq(sync_replication_slots = on));
250-
$standby1->reload;
251-
252-
# Confirm that the slot sync worker is able to start.
253-
$standby1->wait_for_log(qr/slot sync worker started/,$log_offset);
254-
255-
# Confirm that the slot sync is skipped due to the remote slot lagging behind
256-
$standby1->wait_for_log(
257-
qr/could not synchronize replication slot\"lsub1_slot\"/,$log_offset);
258-
259-
# Confirm that the slotsync skip statistics is updated
260-
$result =$standby1->safe_psql('postgres',
261-
"SELECT slotsync_skip_count > 0 FROM pg_stat_replication_slots WHERE slot_name = 'lsub1_slot'"
262-
);
263-
is($result,'t',"check slot sync skip count increments");
264-
265-
# Clean the table
266-
$primary->safe_psql(
267-
'postgres',qq(
268-
DROP TABLE wal_push;
269-
));
270-
$primary->wait_for_replay_catchup($standby1);
271-
272-
# Re-create the logical replication slot and sync it to standby for further tests
273-
$primary->safe_psql(
274-
'postgres',qq(
275-
SELECT pg_drop_replication_slot('lsub1_slot');
276-
SELECT pg_create_logical_replication_slot('lsub1_slot', 'pgoutput', false, false, true);
277-
));
278-
$standby1->wait_for_log(
279-
qr/newly created replication slot\"lsub1_slot\" is sync-ready now/,
280-
$log_offset);
281-
282-
$standby1->append_conf('postgresql.conf',qq(sync_replication_slots = off));
283-
$standby1->reload;
284-
285229
##################################################
286230
# Test that if the synchronized slot is invalidated while the remote slot is
287231
# still valid, the slot will be dropped and re-created on the standby by
@@ -337,7 +281,7 @@
337281
# the failover slots.
338282
$primary->wait_for_replay_catchup($standby1);
339283

340-
$log_offset =-s$standby1->logfile;
284+
my$log_offset =-s$standby1->logfile;
341285

342286
# Synchronize the primary server slots to the standby.
343287
$standby1->safe_psql('postgres',"SELECT pg_sync_replication_slots();");
@@ -1043,4 +987,72 @@
1043987

1044988
is($result,'1',"data can be consumed using snap_test_slot");
1045989

990+
##################################################
991+
# Remove any unnecessary replication slots and clear pending transactions on the
992+
# primary server to ensure a clean environment.
993+
##################################################
994+
995+
$primary->psql(
996+
'postgres',qq(
997+
SELECT pg_drop_replication_slot('sb1_slot');
998+
SELECT pg_drop_replication_slot('lsub1_slot');
999+
SELECT pg_drop_replication_slot('snap_test_slot');
1000+
));
1001+
1002+
$subscriber2->safe_psql('postgres','DROP SUBSCRIPTION regress_mysub2;');
1003+
1004+
# Verify that all slots have been removed except the one necessary for standby2,
1005+
# which is needed for further testing.
1006+
is($primary->safe_psql(
1007+
'postgres',
1008+
q{SELECT count(*) = 0 FROM pg_replication_slots WHERE slot_name != 'sb2_slot';}
1009+
),
1010+
"t",
1011+
'all replication slots have been dropped except the physical slot used by standby2'
1012+
);
1013+
1014+
# Commit the pending prepared transaction
1015+
$primary->safe_psql('postgres',"COMMIT PREPARED 'test_twophase_slotsync';");
1016+
$primary->wait_for_replay_catchup($standby2);
1017+
1018+
##################################################
1019+
# Verify that slotsync skip statistics are correctly updated when the
1020+
# slotsync operation is skipped.
1021+
##################################################
1022+
1023+
# Create a logical replication slot and create some DDL on the primary so
1024+
# that the slot lags behind the standby.
1025+
$primary->safe_psql(
1026+
'postgres',qq(
1027+
SELECT pg_create_logical_replication_slot('lsub1_slot', 'pgoutput', false, false, true);
1028+
CREATE TABLE wal_push(a int);
1029+
));
1030+
$primary->wait_for_replay_catchup($standby2);
1031+
1032+
$log_offset =-s$standby2->logfile;
1033+
1034+
# Enable slot sync worker
1035+
$standby2->append_conf(
1036+
'postgresql.conf',qq(
1037+
hot_standby_feedback = on
1038+
primary_conninfo = '$connstr_1 dbname=postgres'
1039+
log_min_messages = 'debug2'
1040+
sync_replication_slots = on
1041+
));
1042+
1043+
$standby2->reload;
1044+
1045+
# Confirm that the slot sync worker is able to start.
1046+
$standby2->wait_for_log(qr/slot sync worker started/,$log_offset);
1047+
1048+
# Confirm that the slot sync is skipped due to the remote slot lagging behind
1049+
$standby2->wait_for_log(
1050+
qr/could not synchronize replication slot\"lsub1_slot\"/,$log_offset);
1051+
1052+
# Confirm that the slotsync skip statistics is updated
1053+
$result =$standby2->safe_psql('postgres',
1054+
"SELECT slotsync_skip_count > 0 FROM pg_stat_replication_slots WHERE slot_name = 'lsub1_slot'"
1055+
);
1056+
is($result,'t',"check slot sync skip count increments");
1057+
10461058
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp