Skip to content

Commit fad9c8e

Browse files
committed
Improve log pattern detection in recently-added TAP tests
ab55d74 has introduced some tests with rows found as missing in logical replication subscriptions for partitioned tables, relying on a logic with a lookup of the logs generated, scanning the whole file. This commit makes the logic more precise, by scanning the logs only from the position before the key queries are run to the position where we check for the logs. This will reduce the risk of issues with log patterns overlapping with each other if those tests get more complicated in the future. Per discussion with Tom Lane. Discussion: https://postgr.es/m/YMP+Gx2S8meYYHW4@paquier.xyz Backpatch-through: 13
1 parent f865d2a commit fad9c8e

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/test/subscription/t/001_rep_changes.pl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,18 @@
211211

212212
$node_subscriber->safe_psql('postgres', "DELETE FROM tab_full_pk");
213213

214+
# Note that the current location of the log file is not grabbed immediately
215+
# after reloading the configuration, but after sending one SQL command to
216+
# the node so as we are sure that the reloading has taken effect.
217+
my $log_location = -s $node_subscriber->logfile;
218+
214219
$node_publisher->safe_psql('postgres',
215220
"UPDATE tab_full_pk SET b = 'quux' WHERE a = 1");
216221
$node_publisher->safe_psql('postgres', "DELETE FROM tab_full_pk WHERE a = 2");
217222

218223
$node_publisher->wait_for_catchup('tap_sub');
219224

220-
my $logfile = slurp_file($node_subscriber->logfile());
225+
my $logfile = slurp_file($node_subscriber->logfile, $log_location);
221226
ok( $logfile =~
222227
qr/logical replication did not find row to be updated in replication target relation "tab_full_pk"/,
223228
'update target row is missing');

src/test/subscription/t/013_partition.pl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,19 @@ BEGIN
359359

360360
$node_subscriber1->safe_psql('postgres', "DELETE FROM tab1");
361361

362+
# Note that the current location of the log file is not grabbed immediately
363+
# after reloading the configuration, but after sending one SQL command to
364+
# the node so as we are sure that the reloading has taken effect.
365+
my $log_location = -s $node_subscriber1->logfile;
366+
362367
$node_publisher->safe_psql('postgres',
363368
"UPDATE tab1 SET b = 'quux' WHERE a = 4");
364369
$node_publisher->safe_psql('postgres', "DELETE FROM tab1");
365370

366371
$node_publisher->wait_for_catchup('sub1');
367372
$node_publisher->wait_for_catchup('sub2');
368373

369-
my $logfile = slurp_file($node_subscriber1->logfile());
374+
my $logfile = slurp_file($node_subscriber1->logfile(), $log_location);
370375
ok( $logfile =~
371376
qr/logical replication did not find row to be updated in replication target relation's partition "tab1_2_2"/,
372377
'update target row is missing in tab1_2_2');
@@ -697,14 +702,19 @@ BEGIN
697702

698703
$node_subscriber1->safe_psql('postgres', "DELETE FROM tab2");
699704

705+
# Note that the current location of the log file is not grabbed immediately
706+
# after reloading the configuration, but after sending one SQL command to
707+
# the node so as we are sure that the reloading has taken effect.
708+
$log_location = -s $node_subscriber1->logfile;
709+
700710
$node_publisher->safe_psql('postgres',
701711
"UPDATE tab2 SET b = 'quux' WHERE a = 5");
702712
$node_publisher->safe_psql('postgres', "DELETE FROM tab2 WHERE a = 1");
703713

704714
$node_publisher->wait_for_catchup('sub_viaroot');
705715
$node_publisher->wait_for_catchup('sub2');
706716

707-
$logfile = slurp_file($node_subscriber1->logfile());
717+
$logfile = slurp_file($node_subscriber1->logfile(), $log_location);
708718
ok( $logfile =~
709719
qr/logical replication did not find row to be updated in replication target relation's partition "tab2_1"/,
710720
'update target row is missing in tab2_1');

0 commit comments

Comments
 (0)