In ExecLockRows() and ri_LockPKTuple(), the TM_Deleted code path was
using the same "could not serialize access due to concurrent update"
message as the TM_Updated path. Use "concurrent delete" instead, since
the tuple was deleted, not updated. The ExecLockRows() instance was
likely a copy-paste error per Andres; the ri_LockPKTuple() instance
was carried over from the same pattern in commit
2da86c1ef9.
Update affected isolation test expected files accordingly and add
a new test to fk-concurrent-pk-upd.spec with concurrent delete of the
PK row.
The ExecLockRows() change is master-only for lack of user complaints
and to avoid breaking anything that might match on the error text.
Reported-by: Jian He <jian.universality@gmail.com>
Author: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/CACJufxEG1JTCq4A1gnNAu-bGAq9Xn=Xkf7kC3TRWFz6iuUOuRA@mail.gmail.com
if (IsolationUsesXactSnapshot())
ereport(ERROR,
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
- errmsg("could not serialize access due to concurrent update")));
+ errmsg("could not serialize access due to concurrent delete")));
/* tuple was deleted so don't return it */
goto lnext;
if (IsolationUsesXactSnapshot())
ereport(ERROR,
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
- errmsg("could not serialize access due to concurrent update")));
+ errmsg("could not serialize access due to concurrent delete")));
return false;
case TM_Updated:
(0 rows)
+starting permutation: s2b s2dkey s3b s3i s2c s3c s2s s3s
+step s2b: BEGIN;
+step s2dkey: DELETE FROM parent WHERE parent_key = 1;
+step s3b: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s3i: INSERT INTO child VALUES (2, 1); <waiting ...>
+step s2c: COMMIT;
+step s3i: <... completed>
+ERROR: could not serialize access due to concurrent delete
+step s3c: COMMIT;
+step s2s: SELECT * FROM parent;
+parent_key|aux
+----------+---
+(0 rows)
+
+step s3s: SELECT * FROM child;
+child_key|parent_key
+---------+----------
+(0 rows)
+
+
starting permutation: s2b s2uaux s3b s3i s2c s3c s2s s3s
step s2b: BEGIN;
step s2uaux: UPDATE parent SET aux = 'bar' WHERE parent_key = 1;
step s2i: insert into pfk values (1); <waiting ...>
step s1c: commit;
step s2i: <... completed>
-ERROR: could not serialize access due to concurrent update
+ERROR: could not serialize access due to concurrent delete
step s2c: commit;
starting permutation: s1b s2b s1d s2i s1c s2c
step s2i: insert into pfk values (1); <waiting ...>
step s1c: commit;
step s2i: <... completed>
-ERROR: could not serialize access due to concurrent update
+ERROR: could not serialize access due to concurrent delete
step s2c: commit;
starting permutation: s1b s2b s2i s1d s2c s1c
step s2ins: INSERT INTO child VALUES (1, 1); <waiting ...>
step s1c: COMMIT;
step s2ins: <... completed>
-ERROR: could not serialize access due to concurrent update
+ERROR: could not serialize access due to concurrent delete
step s2c: COMMIT;
starting permutation: s1rc s2rc s2ins s1del s2c s1c
step s2ins: INSERT INTO child VALUES (1, 1); <waiting ...>
step s1c: COMMIT;
step s2ins: <... completed>
-ERROR: could not serialize access due to concurrent update
+ERROR: could not serialize access due to concurrent delete
step s2c: COMMIT;
<waiting ...>
step s1c: COMMIT;
step s2ins: <... completed>
-ERROR: could not serialize access due to concurrent update
+ERROR: could not serialize access due to concurrent delete
step s2c: COMMIT;
starting permutation: s1rc s2rc s2ins s1del s2c s1c
<waiting ...>
step s1c: COMMIT;
step s2ins: <... completed>
-ERROR: could not serialize access due to concurrent update
+ERROR: could not serialize access due to concurrent delete
step s2c: COMMIT;
starting permutation: s1rc s2rc s2ins s1upok s2c s1c
step s2ukey { UPDATE parent SET parent_key = 2 WHERE parent_key = 1; }
step s2uaux { UPDATE parent SET aux = 'bar' WHERE parent_key = 1; }
step s2ukey2 { UPDATE parent SET parent_key = 1 WHERE parent_key = 2; }
+step s2dkey { DELETE FROM parent WHERE parent_key = 1; }
step s2c { COMMIT; }
step s2s { SELECT * FROM parent; }
# RR: key update -> serialization failure
permutation s2b s2ukey s3b s3i s2c s3c s2s s3s
+# RR: key delete -> serialization failure
+permutation s2b s2dkey s3b s3i s2c s3c s2s s3s
# RR: non-key update -> old version visible via transaction snapshot
permutation s2b s2uaux s3b s3i s2c s3c s2s s3s