pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix locking a tuple updated by an aborted (sub)transaction 5+ messages / 1 participants [nested] [flat]
* pgsql: Fix locking a tuple updated by an aborted (sub)transaction @ 2016-09-09 19:36 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 5+ messages in thread From: Alvaro Herrera @ 2016-09-09 19:36 UTC (permalink / raw) To: pgsql-committers Fix locking a tuple updated by an aborted (sub)transaction When heap_lock_tuple decides to follow the update chain, it tried to also lock any version of the tuple that was created by an update that was subsequently rolled back. This is pointless, since for all intents and purposes that tuple exists no more; and moreover it causes misbehavior, as reported independently by Marko Tiikkaja and Marti Raudsepp: some SELECT FOR UPDATE/SHARE queries may fail to return the tuples, and assertion-enabled builds crash. Fix by having heap_lock_updated_tuple test the xmin and return success immediately if the tuple was created by an aborted transaction. The condition where tuples become invisible occurs when an updated tuple chain is followed by heap_lock_updated_tuple, which reports the problem as HeapTupleSelfUpdated to its caller heap_lock_tuple, which in turn propagates that code outwards possibly leading the calling code (ExecLockRows) to believe that the tuple exists no longer. Backpatch to 9.3. Only on 9.5 and newer this leads to a visible failure, because of commit 27846f02c176; before that, heap_lock_tuple skips the whole dance when the tuple is already locked by the same transaction, because of the ancient HeapTupleSatisfiesUpdate behavior. Still, the buggy condition may also exist in more convoluted scenarios involving concurrent transactions, so it seems safer to fix the bug in the old branches too. Discussion: https://www.postgresql.org/message-id/CABRT9RC81YUf1=jsmWopcKJEro=VoeG2ou6sPwyOUTx_qteRsg@mail.gmail... https://www.postgresql.org/message-id/48d3eade-98d3-8b9a-477e-1a8dc32a724d@joh.to Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/5c609a742f294907512b946dbaf1feaa3b71ddc7 Modified Files -------------- src/backend/access/heap/heapam.c | 11 +++++++++++ src/test/regress/expected/combocid.out | 27 +++++++++++++++++++++++++++ src/test/regress/sql/combocid.sql | 18 ++++++++++++++++++ 3 files changed, 56 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix locking a tuple updated by an aborted (sub)transaction @ 2016-09-09 19:36 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 5+ messages in thread From: Alvaro Herrera @ 2016-09-09 19:36 UTC (permalink / raw) To: pgsql-committers Fix locking a tuple updated by an aborted (sub)transaction When heap_lock_tuple decides to follow the update chain, it tried to also lock any version of the tuple that was created by an update that was subsequently rolled back. This is pointless, since for all intents and purposes that tuple exists no more; and moreover it causes misbehavior, as reported independently by Marko Tiikkaja and Marti Raudsepp: some SELECT FOR UPDATE/SHARE queries may fail to return the tuples, and assertion-enabled builds crash. Fix by having heap_lock_updated_tuple test the xmin and return success immediately if the tuple was created by an aborted transaction. The condition where tuples become invisible occurs when an updated tuple chain is followed by heap_lock_updated_tuple, which reports the problem as HeapTupleSelfUpdated to its caller heap_lock_tuple, which in turn propagates that code outwards possibly leading the calling code (ExecLockRows) to believe that the tuple exists no longer. Backpatch to 9.3. Only on 9.5 and newer this leads to a visible failure, because of commit 27846f02c176; before that, heap_lock_tuple skips the whole dance when the tuple is already locked by the same transaction, because of the ancient HeapTupleSatisfiesUpdate behavior. Still, the buggy condition may also exist in more convoluted scenarios involving concurrent transactions, so it seems safer to fix the bug in the old branches too. Discussion: https://www.postgresql.org/message-id/CABRT9RC81YUf1=jsmWopcKJEro=VoeG2ou6sPwyOUTx_qteRsg@mail.gmail... https://www.postgresql.org/message-id/48d3eade-98d3-8b9a-477e-1a8dc32a724d@joh.to Branch ------ REL9_6_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/c3656c9ff3aa20ce5144ae77b5f6669f09c9362b Modified Files -------------- src/backend/access/heap/heapam.c | 11 +++++++++++ src/test/regress/expected/combocid.out | 27 +++++++++++++++++++++++++++ src/test/regress/sql/combocid.sql | 18 ++++++++++++++++++ 3 files changed, 56 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix locking a tuple updated by an aborted (sub)transaction @ 2016-09-09 19:36 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 5+ messages in thread From: Alvaro Herrera @ 2016-09-09 19:36 UTC (permalink / raw) To: pgsql-committers Fix locking a tuple updated by an aborted (sub)transaction When heap_lock_tuple decides to follow the update chain, it tried to also lock any version of the tuple that was created by an update that was subsequently rolled back. This is pointless, since for all intents and purposes that tuple exists no more; and moreover it causes misbehavior, as reported independently by Marko Tiikkaja and Marti Raudsepp: some SELECT FOR UPDATE/SHARE queries may fail to return the tuples, and assertion-enabled builds crash. Fix by having heap_lock_updated_tuple test the xmin and return success immediately if the tuple was created by an aborted transaction. The condition where tuples become invisible occurs when an updated tuple chain is followed by heap_lock_updated_tuple, which reports the problem as HeapTupleSelfUpdated to its caller heap_lock_tuple, which in turn propagates that code outwards possibly leading the calling code (ExecLockRows) to believe that the tuple exists no longer. Backpatch to 9.3. Only on 9.5 and newer this leads to a visible failure, because of commit 27846f02c176; before that, heap_lock_tuple skips the whole dance when the tuple is already locked by the same transaction, because of the ancient HeapTupleSatisfiesUpdate behavior. Still, the buggy condition may also exist in more convoluted scenarios involving concurrent transactions, so it seems safer to fix the bug in the old branches too. Discussion: https://www.postgresql.org/message-id/CABRT9RC81YUf1=jsmWopcKJEro=VoeG2ou6sPwyOUTx_qteRsg@mail.gmail... https://www.postgresql.org/message-id/48d3eade-98d3-8b9a-477e-1a8dc32a724d@joh.to Branch ------ REL9_5_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/f337658850801706334fcfec07928a804fb4e24f Modified Files -------------- src/backend/access/heap/heapam.c | 11 +++++++++++ src/test/regress/expected/combocid.out | 27 +++++++++++++++++++++++++++ src/test/regress/sql/combocid.sql | 18 ++++++++++++++++++ 3 files changed, 56 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix locking a tuple updated by an aborted (sub)transaction @ 2016-09-09 19:36 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 5+ messages in thread From: Alvaro Herrera @ 2016-09-09 19:36 UTC (permalink / raw) To: pgsql-committers Fix locking a tuple updated by an aborted (sub)transaction When heap_lock_tuple decides to follow the update chain, it tried to also lock any version of the tuple that was created by an update that was subsequently rolled back. This is pointless, since for all intents and purposes that tuple exists no more; and moreover it causes misbehavior, as reported independently by Marko Tiikkaja and Marti Raudsepp: some SELECT FOR UPDATE/SHARE queries may fail to return the tuples, and assertion-enabled builds crash. Fix by having heap_lock_updated_tuple test the xmin and return success immediately if the tuple was created by an aborted transaction. The condition where tuples become invisible occurs when an updated tuple chain is followed by heap_lock_updated_tuple, which reports the problem as HeapTupleSelfUpdated to its caller heap_lock_tuple, which in turn propagates that code outwards possibly leading the calling code (ExecLockRows) to believe that the tuple exists no longer. Backpatch to 9.3. Only on 9.5 and newer this leads to a visible failure, because of commit 27846f02c176; before that, heap_lock_tuple skips the whole dance when the tuple is already locked by the same transaction, because of the ancient HeapTupleSatisfiesUpdate behavior. Still, the buggy condition may also exist in more convoluted scenarios involving concurrent transactions, so it seems safer to fix the bug in the old branches too. Discussion: https://www.postgresql.org/message-id/CABRT9RC81YUf1=jsmWopcKJEro=VoeG2ou6sPwyOUTx_qteRsg@mail.gmail... https://www.postgresql.org/message-id/48d3eade-98d3-8b9a-477e-1a8dc32a724d@joh.to Branch ------ REL9_4_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/8778da2af0f4dac23b8d1ef3436b6bb0954bc013 Modified Files -------------- src/backend/access/heap/heapam.c | 11 +++++++++++ src/test/regress/expected/combocid.out | 27 +++++++++++++++++++++++++++ src/test/regress/sql/combocid.sql | 18 ++++++++++++++++++ 3 files changed, 56 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix locking a tuple updated by an aborted (sub)transaction @ 2016-09-09 19:36 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 5+ messages in thread From: Alvaro Herrera @ 2016-09-09 19:36 UTC (permalink / raw) To: pgsql-committers Fix locking a tuple updated by an aborted (sub)transaction When heap_lock_tuple decides to follow the update chain, it tried to also lock any version of the tuple that was created by an update that was subsequently rolled back. This is pointless, since for all intents and purposes that tuple exists no more; and moreover it causes misbehavior, as reported independently by Marko Tiikkaja and Marti Raudsepp: some SELECT FOR UPDATE/SHARE queries may fail to return the tuples, and assertion-enabled builds crash. Fix by having heap_lock_updated_tuple test the xmin and return success immediately if the tuple was created by an aborted transaction. The condition where tuples become invisible occurs when an updated tuple chain is followed by heap_lock_updated_tuple, which reports the problem as HeapTupleSelfUpdated to its caller heap_lock_tuple, which in turn propagates that code outwards possibly leading the calling code (ExecLockRows) to believe that the tuple exists no longer. Backpatch to 9.3. Only on 9.5 and newer this leads to a visible failure, because of commit 27846f02c176; before that, heap_lock_tuple skips the whole dance when the tuple is already locked by the same transaction, because of the ancient HeapTupleSatisfiesUpdate behavior. Still, the buggy condition may also exist in more convoluted scenarios involving concurrent transactions, so it seems safer to fix the bug in the old branches too. Discussion: https://www.postgresql.org/message-id/CABRT9RC81YUf1=jsmWopcKJEro=VoeG2ou6sPwyOUTx_qteRsg@mail.gmail... https://www.postgresql.org/message-id/48d3eade-98d3-8b9a-477e-1a8dc32a724d@joh.to Branch ------ REL9_3_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/dfe7121dfbeec0eb13b09b04eaf9c6ca1d1f21be Modified Files -------------- src/backend/access/heap/heapam.c | 11 +++++++++++ src/test/regress/expected/combocid.out | 27 +++++++++++++++++++++++++++ src/test/regress/sql/combocid.sql | 18 ++++++++++++++++++ 3 files changed, 56 insertions(+) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2016-09-09 19:36 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2016-09-09 19:36 pgsql: Fix locking a tuple updated by an aborted (sub)transaction Alvaro Herrera <alvherre@alvh.no-ip.org> 2016-09-09 19:36 pgsql: Fix locking a tuple updated by an aborted (sub)transaction Alvaro Herrera <alvherre@alvh.no-ip.org> 2016-09-09 19:36 pgsql: Fix locking a tuple updated by an aborted (sub)transaction Alvaro Herrera <alvherre@alvh.no-ip.org> 2016-09-09 19:36 pgsql: Fix locking a tuple updated by an aborted (sub)transaction Alvaro Herrera <alvherre@alvh.no-ip.org> 2016-09-09 19:36 pgsql: Fix locking a tuple updated by an aborted (sub)transaction Alvaro Herrera <alvherre@alvh.no-ip.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox