pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrey Lepikhov <a.lepikhov@postgrespro.ru>
To: pgsql-bugs@lists.postgresql.org
Subject: Logical replication can be broken by domain constraint with NOT VALID option
Date: Sun, 3 Nov 2019 12:57:00 +0500
Message-ID: <4bdc6250-03c6-0090-df77-580f998c4547@postgrespro.ru> (raw)

Hi,

During patch development I ran into a small problem (see attachment, 
fail_replication.sh):
1. We have a table with logical replication to another node.
2. On the master and replica add such "NOT VALID" domain constraint on 
the table  that some tuples  violates the constraint.
3. UPDATE the table: set value of the tuple that violates constraint to 
correct value.
4. That's all!

The reason for this problem is that on UPDATE walsender sends old tuple 
value (that violates the constraint) with new version (satisfied the 
constraint).
Replication worker at replica node restores slot from transfer 
representation. During this process domain checking constraint and 
returns an ERROR.
Because we can't apply WAL record of the UPDATE command, logical 
replication will be stopped at all.
As I understand, this problem can be reproduced in all postgres versions 
with logical replication feature.
This problem can be solved by many ways and approaches. I wrote the 
patch to solve this problem (see in attachment) by the shortest way.

-- 
Andrey Lepikhov
Postgres Professional
https://postgrespro.com
The Russian Postgres Company

Attachments:

  fail_replication.sh (application/x-shellscript, 1.4K) download

  0001-Fix-the-problem-of-logical-replication-with-domain-N.patch (text/x-patch, 0B) download

view thread (5+ messages)  latest in thread

Message-ID: <4bdc6250-03c6-0090-df77-580f998c4547@postgrespro.ru>
Permalink:  ../4bdc6250-03c6-0090-df77-580f998c4547@postgrespro.ru/
Also on:    postgresql.org/message-id/4bdc6250-03c6-0090-df77-580f998c4547@postgrespro.ru

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: a.lepikhov@postgrespro.ru
  Subject: Re: Logical replication can be broken by domain constraint with NOT VALID option
  In-Reply-To: <4bdc6250-03c6-0090-df77-580f998c4547@postgrespro.ru>
  References: <4bdc6250-03c6-0090-df77-580f998c4547@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox