[BUG] Crash of logical replica with trigger.
Anton A. Melnikov <aamelnikov@inbox.ru>
From: "Anton A. Melnikov" <aamelnikov@inbox.ru>
To: pgsql-bugs@lists.postgresql.org
Date: 2022-08-14T19:47:57Z
Lists: pgsql-bugs
Attachments
- trigger.sql (application/sql)
- bt.txt (text/plain)
Hello!
There is a crash during logical replication.
Reproduction on current master:
A) on master (wal_level = logical): create table rul_rule_set that will be replicated:
CREATE TABLE public.rul_rule_set (id smallint NOT NULL, description text, stage_id integer,
condition text, condition_compiled text);
ALTER TABLE ONLY public.rul_rule_set ADD CONSTRAINT rul_rule_set_pkey PRIMARY KEY (id);
CREATE PUBLICATION test_pub FOR TABLE rul_rule_set;
B) on replica
1. Create tables doc_attribute and rul_rule_set for incoming changes:
CREATE TABLE public.doc_attribute (id integer NOT NULL, attr_name text, attr_desc text, attr_type text,
attr_order integer, is_system boolean, used_by_slice boolean);
INSERT INTO doc_attribute VALUES ('1','name','Имя','text','1','t','t');
CREATE TABLE public.rul_rule_set (id smallint NOT NULL, description text, stage_id integer,
condition text, condition_compiled text);
ALTER TABLE ONLY public.doc_attribute ADD CONSTRAINT doc_attribute_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.rul_rule_set ADD CONSTRAINT rul_rule_set_pkey PRIMARY KEY (id);
2.Create procedure and trigger that will be fired on lines inserting into the rul_rule_set table:
Execute trigger.sql attached.
3. Create suscription:
CREATE SUBSCRIPTION test_sub CONNECTION 'port=5116 user=postgres dbname=postgres' PUBLICATION test_pub;
C) on master: insert row in table rul_rule_set:
INSERT INTO rul_rule_set VALUES ('1', 'name','1','age','true');
The replica will crash with:
TRAP: FailedAssertion("ActivePortal && ActivePortal->status == PORTAL_ACTIVE", File: "pg_proc.c", Line: 1038, PID: 310502)
as ActivePortal is NULL because logical replication worker was forked before any active command.
The backtrace is attached.
I thought to pass the text of the request as a parameter, but most likely, it will be wrong.
Please suggest the best way to solve this problem, would be very grateful.
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