Re: serializable anomaly - duplicate primary keys

From: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Bryan Green <dbryan(dot)green(at)gmail(dot)com>, Jacob Brazeal <jacob(dot)brazeal(at)gmail(dot)com>
Subject: Re: serializable anomaly - duplicate primary keys
Date: 2026-10-08 14:58:03
Message-ID: CAJ7c6TMJ1ChMgfyY+_pT4ncAC9tf7TO1c3wuErhg-aUHqF74Pg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> The root cause is that unique checks use a dirty snapshot. They can
> decide a key is unused because of a deletion the transaction cannot
> see. The fix might be to ask our own snapshot the same question, and
> fail if it still sees the key in use. I don't think this will require
> an ABI change.

I prepared a PoC patch that shows how this could be archived. Also it
includes regression tests for everything discussed above.

One drawback I discovered is that the patch introduces a
false-positive conflict detection that causes the existing
partition-key-update-3.spec to fail. I'm not 100% certain what to do
about it. Given the fact that SSI generally has false-positives, maybe
we should just rewrite the test? This seems to be better compared to
what we currently have and personally I don't have better proposals at
the moment.

Thoughts?

--
Best regards,
Aleksander Alekseev

Attachment Content-Type Size
v1-0001-PoC-bugfix-by-a.alekseev-v1.patch text/x-patch 15.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2026-10-08 15:15:39 Re: Adding init-po and update-po targets to the meson build system
Previous Message Greg Burd 2026-10-08 14:25:34 Re: Let an ordering index scan hand its ORDER BY value to the target list