[BUG] Logical replica crash if there was an error in a function.
Anton A. Melnikov <aamelnikov@inbox.ru>
From: "Anton A. Melnikov" <aamelnikov@inbox.ru>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Maxim Orlov <orlovmg@gmail.com>
Date: 2022-08-21T14:33:57Z
Lists: pgsql-hackers
Attachments
- mascmd.sql (application/sql)
- repcmd.sql (application/sql)
- v1-0001-Fix-logical-replica-assert-on-func-error.patch (text/x-patch) patch v1-0001
Hello!
Here is a fix for the bug first described in:
https://www.postgresql.org/message-id/flat/adf0452f-8c6b-7def-d35e-ab516c80088e%40inbox.ru
Reproduction:
1) On master with 'wal_level = logical' execute mascmd.sql attached.
2) On replica substitute the correct port in repcmd.sql and execute it.
3) On master execute command:
INSERT INTO rul_rule_set VALUES ('1', 'name','1','age','true');
Replica will crash with:
FailedAssertion("ActivePortal && ActivePortal->status == PORTAL_ACTIVE", File: "pg_proc.c", Line: 1038, PID: 42894)
in infinite loop.
After applying this patch replica will give the correct error message instead of assertion:
2022-08-21 17:08:39.935 MSK [143171] ERROR: relation "rul_rule_set" does not exist at character 172
2022-08-21 17:08:39.935 MSK [143171] QUERY:
-- Last modified: 2022-08-21 17:08:39.930842+03
with parameters as (
<<--- skipped by me --- >>>
)
2022-08-21 17:08:39.935 MSK [143171] CONTEXT: SQL statement "create or replace function public.rule_set_selector(
<<--- skipped by me --- >>>
SQL statement "call public.rebuild_rule_set_selector()"
PL/pgSQL function public.rul_rule_set_trg() line 4 at CALL
processing remote data for replication origin "pg_16401" during "INSERT"
for replication target relation "public.rul_rule_set" in transaction 741 finished at 0/17BE180
With best regards,
--
Anton A. Melnikov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Commits
-
Avoid crash after function syntax error in a replication worker.
- dea834938005 16.0 landed
- f2dc7f9e35a2 15.1 landed
- ed019b5ef955 11.18 landed
- d9ffccf8db4b 12.13 landed
- b00f342ea0f0 13.9 landed
- 5f3cec77b1b5 10.23 landed
- 2489c38cdc58 14.6 landed