|
6 | 6 | use warnings;
|
7 | 7 | use PostgresNode;
|
8 | 8 | use TestLib;
|
9 |
| -use Test::More tests => 56; |
| 9 | +use Test::More tests => 62; |
10 | 10 |
|
11 | 11 | # setup
|
12 | 12 |
|
@@ -347,6 +347,46 @@ BEGIN
|
347 | 347 | $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab1 ORDER BY 1");
|
348 | 348 | is($result, qq(), 'truncate of tab1 replicated');
|
349 | 349 |
|
| 350 | +# Check that subscriber handles cases where update/delete target tuple |
| 351 | +# is missing. We have to look for the DEBUG1 log messages about that, |
| 352 | +# so temporarily bump up the log verbosity. |
| 353 | +$node_subscriber1->append_conf('postgresql.conf', |
| 354 | + "log_min_messages = debug1"); |
| 355 | +$node_subscriber1->reload; |
| 356 | + |
| 357 | +$node_publisher->safe_psql('postgres', |
| 358 | + "INSERT INTO tab1 VALUES (1, 'foo'), (4, 'bar'), (10, 'baz')"); |
| 359 | + |
| 360 | +$node_publisher->wait_for_catchup('sub1'); |
| 361 | +$node_publisher->wait_for_catchup('sub2'); |
| 362 | + |
| 363 | +$node_subscriber1->safe_psql('postgres', "DELETE FROM tab1"); |
| 364 | + |
| 365 | +$node_publisher->safe_psql('postgres', |
| 366 | + "UPDATE tab1 SET b = 'quux' WHERE a = 4"); |
| 367 | +$node_publisher->safe_psql('postgres', "DELETE FROM tab1"); |
| 368 | + |
| 369 | +$node_publisher->wait_for_catchup('sub1'); |
| 370 | +$node_publisher->wait_for_catchup('sub2'); |
| 371 | + |
| 372 | +my $logfile = slurp_file($node_subscriber1->logfile()); |
| 373 | +ok( $logfile =~ |
| 374 | + qr/logical replication did not find row to be updated in replication target relation's partition "tab1_2_2"/, |
| 375 | + 'update target row is missing in tab1_2_2'); |
| 376 | +ok( $logfile =~ |
| 377 | + qr/logical replication did not find row to be deleted in replication target relation "tab1_1"/, |
| 378 | + 'delete target row is missing in tab1_1'); |
| 379 | +ok( $logfile =~ |
| 380 | + qr/logical replication did not find row to be deleted in replication target relation "tab1_2_2"/, |
| 381 | + 'delete target row is missing in tab1_2_2'); |
| 382 | +ok( $logfile =~ |
| 383 | + qr/logical replication did not find row to be deleted in replication target relation "tab1_def"/, |
| 384 | + 'delete target row is missing in tab1_def'); |
| 385 | + |
| 386 | +$node_subscriber1->append_conf('postgresql.conf', |
| 387 | + "log_min_messages = warning"); |
| 388 | +$node_subscriber1->reload; |
| 389 | + |
350 | 390 | # Tests for replication using root table identity and schema
|
351 | 391 |
|
352 | 392 | # publisher
|
@@ -650,3 +690,32 @@ BEGIN
|
650 | 690 | pub_tab2|3|yyy
|
651 | 691 | pub_tab2|5|zzz
|
652 | 692 | xxx_c|6|aaa), 'inserts into tab2 replicated');
|
| 693 | + |
| 694 | +# Check that subscriber handles cases where update/delete target tuple |
| 695 | +# is missing. We have to look for the DEBUG1 log messages about that, |
| 696 | +# so temporarily bump up the log verbosity. |
| 697 | +$node_subscriber1->append_conf('postgresql.conf', |
| 698 | + "log_min_messages = debug1"); |
| 699 | +$node_subscriber1->reload; |
| 700 | + |
| 701 | +$node_subscriber1->safe_psql('postgres', "DELETE FROM tab2"); |
| 702 | + |
| 703 | +$node_publisher->safe_psql('postgres', |
| 704 | + "UPDATE tab2 SET b = 'quux' WHERE a = 5"); |
| 705 | +$node_publisher->safe_psql('postgres', "DELETE FROM tab2 WHERE a = 1"); |
| 706 | + |
| 707 | +$node_publisher->wait_for_catchup('sub_viaroot'); |
| 708 | +$node_publisher->wait_for_catchup('sub2'); |
| 709 | + |
| 710 | +$logfile = slurp_file($node_subscriber1->logfile()); |
| 711 | +ok( $logfile =~ |
| 712 | + qr/logical replication did not find row to be updated in replication target relation's partition "tab2_1"/, |
| 713 | + 'update target row is missing in tab2_1'); |
| 714 | +ok( $logfile =~ |
| 715 | + qr/logical replication did not find row to be deleted in replication target relation "tab2_1"/, |
| 716 | + 'delete target row is missing in tab2_1'); |
| 717 | + |
| 718 | +# No need for this until more tests are added. |
| 719 | +# $node_subscriber1->append_conf('postgresql.conf', |
| 720 | +# "log_min_messages = warning"); |
| 721 | +# $node_subscriber1->reload; |
0 commit comments