postgresql/src/backend/access
Alvaro Herrera 459c64d322 Fix concurrent locking of tuple update chain
If several sessions are concurrently locking a tuple update chain with
nonconflicting lock modes using an old snapshot, and they all succeed,
it may happen that some of them fail because of restarting the loop (due
to a concurrent Xmax change) and getting an error in the subsequent pass
while trying to obtain a tuple lock that they already have in some tuple
version.

This can only happen with very high concurrency (where a row is being
both updated and FK-checked by multiple transactions concurrently), but
it's been observed in the field and can have unpleasant consequences
such as an FK check failing to see a tuple that definitely exists:
    ERROR:  insert or update on table "child_table" violates foreign key constraint "fk_constraint_name"
    DETAIL:  Key (keyid)=(123456) is not present in table "parent_table".
(where the key is observably present in the table).

Discussion: https://postgr.es/m/20170714210011.r25mrff4nxjhmf3g@alvherre.pgsql
2017-07-26 17:24:16 -04:00
..
brin Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
common Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
gin Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
gist Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
hash hash: Fix write-ahead logging bugs related to init forks. 2017-07-17 12:03:35 -04:00
heap Fix concurrent locking of tuple update chain 2017-07-26 17:24:16 -04:00
index Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
nbtree Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
rmgrdesc Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
spgist Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
tablesample Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
transam Fix double shared memory allocation. 2017-07-21 13:31:20 +03:00
Makefile TABLESAMPLE, SQL Standard and extensible 2015-05-15 14:37:10 -04:00