| From: | vignesh C <vignesh21(at)gmail(dot)com> |
|---|---|
| To: | Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com> |
| Cc: | Michael Malis <malis(at)pgrust(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Logical replication commits duplicates in DEFERRABLE unique indexes |
| Date: | 2026-11-23 12:42:08 |
| Message-ID: | CALDaNm07XVwC8wDZQ64UodJse9iWzJRMGeMW0pDJaYRscbO6FQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Mon, 23 Nov 2026 at 15:31, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com> wrote:
>
> I have attached the patches for the above approach
> 0001 patch : For DEFERRABLE constraint, create the Recheck triggers
> with TRIGGER_FIRES_ALWAYS
> 0002 patch : Reject DEFERRABLE INITIALLY IMMEDIATE constraints on
> subscription target.
>
> Thoughts?
Thanks for the patch. I tested v2 and found a case where the
duplicates still get committed.
Steps for the same:
-- publisher
CREATE TABLE t (id int PRIMARY KEY DEFERRABLE INITIALLY DEFERRED);
CREATE PUBLICATION pub FOR TABLE t;
-- subscriber
CREATE TABLE t (id int PRIMARY KEY DEFERRABLE INITIALLY DEFERRED);
INSERT INTO t VALUES (1);
CREATE SUBSCRIPTION sub CONNECTION '...' PUBLICATION pub WITH
(copy_data = false);
ALTER TABLE t ENABLE TRIGGER ALL;
-- publisher
INSERT INTO t VALUES (1);
The subscriber applies the row without an error, and the table has two
rows with id = 1 in a unique index.
I attached a small TAP test that shows the problem (the last check
fails with v2).
Regards,
Vignesh
| Attachment | Content-Type | Size |
|---|---|---|
| 039_deferrable_enable_all_simple.pl | text/x-perl-script | 2.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nisha Moond | 2026-11-23 13:10:45 | Re: Logical replication commits duplicates in DEFERRABLE unique indexes |
| Previous Message | Jesper St John | 2026-11-23 11:50:19 | Re: Timing issue in pg_basebackup |