Skip to content

Commit bfd96b7

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 d8e950d commit bfd96b7

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
@@ -311,13 +311,18 @@
311311

312312
$node_subscriber->safe_psql('postgres', "DELETE FROM tab_full_pk");
313313

314+
# Note that the current location of the log file is not grabbed immediately
315+
# after reloading the configuration, but after sending one SQL command to
316+
# the node so as we are sure that the reloading has taken effect.
317+
my $log_location = -s $node_subscriber->logfile;
318+
314319
$node_publisher->safe_psql('postgres',
315320
"UPDATE tab_full_pk SET b = 'quux' WHERE a = 1");
316321
$node_publisher->safe_psql('postgres', "DELETE FROM tab_full_pk WHERE a = 2");
317322

318323
$node_publisher->wait_for_catchup('tap_sub');
319324

320-
my $logfile = slurp_file($node_subscriber->logfile());
325+
my $logfile = slurp_file($node_subscriber->logfile, $log_location);
321326
ok( $logfile =~
322327
qr/logical replication did not find row to be updated in replication target relation "tab_full_pk"/,
323328
'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
@@ -362,14 +362,19 @@ BEGIN
362362

363363
$node_subscriber1->safe_psql('postgres', "DELETE FROM tab1");
364364

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

369374
$node_publisher->wait_for_catchup('sub1');
370375
$node_publisher->wait_for_catchup('sub2');
371376

372-
my $logfile = slurp_file($node_subscriber1->logfile());
377+
my $logfile = slurp_file($node_subscriber1->logfile(), $log_location);
373378
ok( $logfile =~
374379
qr/logical replication did not find row to be updated in replication target relation's partition "tab1_2_2"/,
375380
'update target row is missing in tab1_2_2');
@@ -700,14 +705,19 @@ BEGIN
700705

701706
$node_subscriber1->safe_psql('postgres', "DELETE FROM tab2");
702707

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

707717
$node_publisher->wait_for_catchup('sub_viaroot');
708718
$node_publisher->wait_for_catchup('sub2');
709719

710-
$logfile = slurp_file($node_subscriber1->logfile());
720+
$logfile = slurp_file($node_subscriber1->logfile(), $log_location);
711721
ok( $logfile =~
712722
qr/logical replication did not find row to be updated in replication target relation's partition "tab2_1"/,
713723
'update target row is missing in tab2_1');

0 commit comments

Comments
 (0)