From 26a13b72421f6d54077db23200326536ece2cf7c Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Mon, 23 Nov 2009 09:59:11 +0000 Subject: Fix an old bug in multixact and two-phase commit. Prepared transactions can be part of multixacts, so allocate a slot for each prepared transaction in the "oldest member" array in multixact.c. On PREPARE TRANSACTION, transfer the oldest member value from the current backends slot to the prepared xact slot. Also save and recover the value from the 2pc state file. The symptom of the bug was that after a transaction prepared, a shared lock still held by the prepared transaction was sometimes ignored by other transactions. Fix back to 8.1, where both 2PC and multixact were introduced. --- src/backend/access/transam/twophase_rmgr.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/backend/access/transam/twophase_rmgr.c') diff --git a/src/backend/access/transam/twophase_rmgr.c b/src/backend/access/transam/twophase_rmgr.c index b2f670db71a..034f0d80cdc 100644 --- a/src/backend/access/transam/twophase_rmgr.c +++ b/src/backend/access/transam/twophase_rmgr.c @@ -8,12 +8,13 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.3 2006/03/05 15:58:22 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.3.2.1 2009/11/23 09:59:11 heikki Exp $ * *------------------------------------------------------------------------- */ #include "postgres.h" +#include "access/multixact.h" #include "access/twophase_rmgr.h" #include "commands/async.h" #include "storage/lock.h" @@ -27,7 +28,8 @@ const TwoPhaseCallback twophase_recover_callbacks[TWOPHASE_RM_MAX_ID + 1] = lock_twophase_recover, /* Lock */ NULL, /* Inval */ NULL, /* flat file update */ - NULL /* notify/listen */ + NULL, /* notify/listen */ + multixact_twophase_recover /* MultiXact */ }; const TwoPhaseCallback twophase_postcommit_callbacks[TWOPHASE_RM_MAX_ID + 1] = @@ -36,8 +38,9 @@ const TwoPhaseCallback twophase_postcommit_callbacks[TWOPHASE_RM_MAX_ID + 1] = lock_twophase_postcommit, /* Lock */ inval_twophase_postcommit, /* Inval */ flatfile_twophase_postcommit, /* flat file update */ - notify_twophase_postcommit /* notify/listen */ -}; + notify_twophase_postcommit, /* notify/listen */ + multixact_twophase_postcommit /* MultiXact */ + }; const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID + 1] = { @@ -45,5 +48,6 @@ const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID + 1] = lock_twophase_postabort, /* Lock */ NULL, /* Inval */ NULL, /* flat file update */ - NULL /* notify/listen */ + NULL, /* notify/listen */ + multixact_twophase_postabort /* MultiXact */ }; -- cgit v1.2.3