]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Improve stability of subscription/029_on_error.pl
authorMichael Paquier <michael@paquier.xyz>
Fri, 24 May 2024 02:21:31 +0000 (11:21 +0900)
committerMichael Paquier <michael@paquier.xyz>
Fri, 24 May 2024 02:21:31 +0000 (11:21 +0900)
This test was failing when using wal_debug=on and -DWAL_DEBUG because of
additional log entries that made the test grab an LSN not mapping with
the error expected in the test.

Previously the test would look for the first matching line to get the
LSN to skip up to.  This is improved by having the test scan the logs
with a regexp that checks for the expected ERROR string, ensuring that
the wanted LSN comes from the correct context.

Backpatch down to 15 where this test has been introduced.

Author: Ian Ilyasov
Discussion: https://postgr.es/m/GV1P251MB100415F17E6B2FDD7188777ECDE32@GV1P251MB1004.EURP251.PROD.OUTLOOK.COM
Backpatch-through: 15

src/test/subscription/t/029_on_error.pl

index 1bd18a62cd80d62aeed07b6bc9a8012a3875e688..c28c634b19c1639583e7a38b2f3984492ad6f038 100644 (file)
@@ -26,10 +26,11 @@ sub test_skip_lsn
                "SELECT subenabled = FALSE FROM pg_subscription WHERE subname = 'sub'"
        );
 
-       # Get the finish LSN of the error transaction.
+       # Get the finish LSN of the error transaction, mapping the expected
+       # ERROR with its CONTEXT when retrieving this information.
        my $contents = slurp_file($node_subscriber->logfile, $offset);
        $contents =~
-         qr/processing remote data for replication origin \"pg_\d+\" during message type "INSERT" for replication target relation "public.tbl" in transaction \d+, finished at ([[:xdigit:]]+\/[[:xdigit:]]+)/
+         qr/duplicate key value violates unique constraint "tbl_pkey".*\n.*DETAIL:.*\n.*CONTEXT:.* for replication target relation "public.tbl" in transaction \d+, finished at ([[:xdigit:]]+\/[[:xdigit:]]+)/m
          or die "could not get error-LSN";
        my $lsn = $1;