summaryrefslogtreecommitdiff
path: root/src/backend/storage/ipc
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2012-11-29 23:46:54 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2012-11-29 23:46:54 +0000
commitf4a3e679306ebfbd150d8af3cdd481bea1619c52 (patch)
tree96476c97c567d3385c882c62561e652a4277e6f9 /src/backend/storage/ipc
parent1dbd02dc37efb74b770aa834b2cb65dae2446640 (diff)
Correctly init/deinit recovery xact environment.
Previously we performed VirtualXactLockTableInsert but didn't set MyProc->lxid for Startup process. pg_locks now correctly shows "1/1" for vxid of Startup process during Hot Standby. At end of Hot Standby the Virtual Transaction was not deleted, leading to problems after promoting to normal running for some commands, such as CREATE INDEX CONCURRENTLY.
Diffstat (limited to 'src/backend/storage/ipc')
-rw-r--r--src/backend/storage/ipc/standby.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index df9a9a495b6..9d0c27219b9 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -82,7 +82,7 @@ InitRecoveryTransactionEnvironment(void)
* hold AccessShareLocks so never block while we write or lock new rows.
*/
vxid.backendId = MyBackendId;
- vxid.localTransactionId = GetNextLocalTransactionId();
+ vxid.localTransactionId = MyProc->lxid = GetNextLocalTransactionId();
VirtualXactLockTableInsert(vxid);
standbyState = STANDBY_INITIALIZED;
@@ -98,11 +98,18 @@ InitRecoveryTransactionEnvironment(void)
void
ShutdownRecoveryTransactionEnvironment(void)
{
+ VirtualTransactionId vxid;
+
/* Mark all tracked in-progress transactions as finished. */
ExpireAllKnownAssignedTransactionIds();
/* Release all locks the tracked transactions were holding */
StandbyReleaseAllLocks();
+
+ /* Cleanup our VirtualTransaction */
+ vxid.backendId = MyBackendId;
+ vxid.localTransactionId = MyProc->lxid;
+ VirtualXactLockTableDelete(vxid);
}