Go to file
Alvaro Herrera dfe7121dfb 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.com
	https://www.postgresql.org/message-id/48d3eade-98d3-8b9a-477e-1a8dc32a724d@joh.to
2016-09-09 15:54:29 -03:00
config Fix configure's incorrect version tests for flex and perl. 2016-05-02 11:18:11 -04:00
contrib Fix -e option in contrib/intarray/bench/bench.pl. 2016-08-17 15:51:10 -04:00
doc Don't require dynamic timezone abbreviations to match underlying time zone. 2016-09-02 17:29:32 -04:00
src Fix locking a tuple updated by an aborted (sub)transaction 2016-09-09 15:54:29 -03:00
.gitignore Add pkg-config files for libpq and ecpg libraries 2013-03-31 16:58:40 -04:00
aclocal.m4
configure Stamp 9.3.14. 2016-08-08 16:31:43 -04:00
configure.in Stamp 9.3.14. 2016-08-08 16:31:43 -04:00
COPYRIGHT Update copyright for 2016 2016-01-02 13:33:39 -05:00
GNUmakefile.in Don't generate plain-text HISTORY and src/test/regress/README anymore. 2014-02-10 20:48:12 -05:00
HISTORY Improve text of stub HISTORY file. 2014-02-12 18:16:27 -05:00
Makefile
README Don't generate plain-text HISTORY and src/test/regress/README anymore. 2014-02-10 20:48:12 -05:00
README.git Don't generate plain-text HISTORY and src/test/regress/README anymore. 2014-02-10 20:48:12 -05:00

PostgreSQL Database Management System
=====================================

This directory contains the source code distribution of the PostgreSQL
database management system.

PostgreSQL is an advanced object-relational database management system
that supports an extended subset of the SQL standard, including
transactions, foreign keys, subqueries, triggers, user-defined types
and functions.  This distribution also contains C language bindings.

PostgreSQL has many language interfaces, many of which are listed here:

	http://www.postgresql.org/download

See the file INSTALL for instructions on how to build and install
PostgreSQL.  That file also lists supported operating systems and
hardware platforms and contains information regarding any other
software packages that are required to build or run the PostgreSQL
system.  Copyright and license information can be found in the
file COPYRIGHT.  A comprehensive documentation set is included in this
distribution; it can be read as described in the installation
instructions.

The latest version of this software may be obtained at
http://www.postgresql.org/download/.  For more information look at our
web site located at http://www.postgresql.org/.