pgsql: Allow snapshot references to still work during transaction abort

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Allow snapshot references to still work during transaction abort
Date: 2011-09-27 02:25:59
Message-ID: E1R8NMt-0000iG-5t@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Allow snapshot references to still work during transaction abort.

In REPEATABLE READ (nee SERIALIZABLE) mode, an attempt to do
GetTransactionSnapshot() between AbortTransaction and CleanupTransaction
failed, because GetTransactionSnapshot would recompute the transaction
snapshot (which is already wrong, given the isolation mode) and then
re-register it in the TopTransactionResourceOwner, leading to an Assert
because the TopTransactionResourceOwner should be empty of resources after
AbortTransaction. This is the root cause of bug #6218 from Yamamoto
Takashi. While changing plancache.c to avoid requesting a snapshot when
handling a ROLLBACK masks the problem, I think this is really a snapmgr.c
bug: it's lower-level than the resource manager mechanism and should not be
shutting itself down before we unwind resource manager resources. However,
just postponing the release of the transaction snapshot until cleanup time
didn't work because of the circular dependency with
TopTransactionResourceOwner. Fix by managing the internal reference to
that snapshot manually instead of depending on TopTransactionResourceOwner.
This saves a few cycles as well as making the module layering more
straightforward. predicate.c's dependencies on TopTransactionResourceOwner
go away too.

I think this is a longstanding bug, but there's no evidence that it's more
than a latent bug, so it doesn't seem worth any risk of back-patching.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/57eb009092684e6e1788dd0dae641ccee1668b10

Modified Files
--------------
src/backend/access/transam/xact.c | 8 +---
src/backend/storage/lmgr/predicate.c | 39 ++++++++++-------
src/backend/utils/time/snapmgr.c | 74 +++++++++++++++++++---------------
src/include/storage/predicate.h | 2 +-
src/include/utils/snapmgr.h | 1 -
5 files changed, 67 insertions(+), 57 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2011-09-27 03:58:59 pgsql: Fix window functions that sort by expressions involving aggregat
Previous Message Tom Lane 2011-09-26 19:38:23 pgsql: Speed up array element assignment in plpgsql by caching type inf