| From: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
|---|---|
| To: | Aleksander Alekseev <aleksander(at)tigerdata(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Andres Freund <andres(at)anarazel(dot)de> |
| Subject: | Re: Write skew observed under serializable isolation |
| Date: | 2026-09-23 08:29:20 |
| Message-ID: | CAN4CZFOfQL_nOs2ukYf-CkcdP6EOQHu0dx2A+a90F+KDqajLKg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello!
- /* one of SO_TYPE_* may be specified */
+ /*
+ * One of SO_TYPE_* may be specified. When adding a scan type, check
+ * whether it must take predicate locks to be safe under SERIALIZABLE: see
+ * the flag test in heap_beginscan() and "Heap locking" in
+ * src/backend/storage/lmgr/README-SSI.
+ */
A wider llm-audit based on this claim pointed out that there's one
more preexisting issue: a tid scan that probes a tid holding no tuple
takes no predicate lock of any kind, so a concurrent INSERT that
materialises a tuple at exactly that TID creates no rw-conflict.
I'm not sure what's the proper solution for this, and if it even
should be part of this patch or something separate (as this patch is a
clear improvement even with this leftover issue), but it seems to be
at least worth a mention in a comment/commit message to state the
limitation?
An isolation test reproducing the problem:
setup
{
create table ta (id int);
insert into ta values (1), (2);
create table tb (id int);
insert into tb values (1), (2);
}
teardown { drop table ta; drop table tb; }
session s1
setup { begin isolation level serializable; set enable_seqscan = off; }
step r1 { select count(*) from tb where ctid = '(0,3)'; }
step w1 { insert into ta values (100); }
step c1 { commit; }
session s2
setup { begin isolation level serializable; set enable_seqscan = off; }
step r2 { select count(*) from ta where ctid = '(0,3)'; }
step w2 { insert into tb values (200); }
step c2 { commit; }
permutation r1 r2 w1 w2 c1 c2
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Álvaro Herrera | 2026-09-23 08:36:10 | Re: [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs |
| Previous Message | Thom Brown | 2026-09-23 08:26:22 | Re: REPACK (CONCURRENTLY) can silently lose updates when the toast table is rewritten |