Re: Logical replication failing when foreign key present

From: Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>
To: Thom Brown <thom(at)linux(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Logical replication failing when foreign key present
Date: 2017-01-22 23:07:27
Message-ID: 33f8d9f3-c259-cd4b-712c-2c318a17274a@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 22/01/17 18:50, Thom Brown wrote:
> Hi,
>
> There's an issue which I haven't seen documented as expected
> behaviour, where replicating data to a table which has a foreign key
> results in a replication failure. This produces the following log
> entries:
>
> LOG: starting logical replication worker for subscription "contacts_sub"
> LOG: logical replication apply for subscription "contacts_sub" has started
> ERROR: AfterTriggerSaveEvent() called outside of query
> LOG: worker process: logical replication worker for subscription
> 16408 (PID 19201) exited with exit code 1
>
>

Hi, thanks for report.

Looks like I missed AfterTriggerBeginQuery/AfterTriggerEndQuery when
moving the executor stuff around. Attached should fix it.

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
0001-Fix-after-trigger-execution-in-logical-replication.patch application/x-patch 1.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2017-01-22 23:26:10 Re: [WIP]Vertical Clustered Index (columnar store extension)
Previous Message Tom Lane 2017-01-22 23:03:41 Re: Protect syscache from bloating with negative cache entries