| From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
|---|---|
| To: | Andrey Borodin <x4mmm(at)yandex-team(dot)ru> |
| Cc: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers mailing list <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Nathan Bossart <nathandbossart(at)gmail(dot)com> |
| Subject: | Re: SSI: ON CONFLICT DO SELECT takes no predicate lock on the returned row |
| Date: | 2026-09-12 10:34:21 |
| Message-ID: | CAEZATCVxtwMvvV-HgF64cdL2oN+JvOK8PNT0aNN6nSoexj2ZKg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, 10 Sept 2026 at 11:24, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>
> I'll take
> another couple of days to think it over more thoroughly, before
> pushing it (probably at the weekend).
>
I've been thinking about this some more, and I think that it's
possible to fix this without a potentially expensive re-fetch.
The attached v5 patch modifies the predicate locking code so that it
takes predicate locks during the arbiter index probe, even though it's
still using a dirty snapshot, so the read is recorded during the
probe, as it would be for an MVCC index scan.
It does this using a new special snapshot, SnapshotDirtySerializable,
which is a dirty snapshot, obeying the same tuple visibility rules,
but is special-cased for predicate locking. Technically, this is not
properly re-entrant safe, since it's a global datastructure, but I
think if user-defined operators or index expressions are recursively
calling INSERT ... ON CONFLICT here, then there are bigger problems
than getting incorrect serialization results.
This approach eliminates any window between probe and re-fetch (there
is no re-fetch), so there's no need to worry about that gap, which
makes the patch simpler, while still passing all the other tests.
Regards,
Dean
| Attachment | Content-Type | Size |
|---|---|---|
| v5-0001-Fix-missing-SIREAD-lock-on-the-row-found-by-ON-CO.patch | text/x-patch | 15.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alexander Lakhin | 2026-09-12 11:00:00 | Re: Internal error codes triggered by regression tests and user queries, take 2 |
| Previous Message | Pierre Forstmann | 2026-09-12 09:15:11 | Re: BUG #19631: currtid2() on a view with GROUP BY ctid crashes with XX000 |