Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6f9a9da

Browse files
Correctly init/deinit recovery xact environment.
Previously we performed VirtualXactLockTableInsertbut didn't set MyProc->lxid for Startup process.pg_locks now correctly shows "1/1" for vxidof Startup process during Hot Standby.At end of Hot Standby the Virtual Transactionwas not deleted, leading to problems afterpromoting to normal running for some commands,such as CREATE INDEX CONCURRENTLY.
1 parent1da5bef commit6f9a9da

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

‎src/backend/storage/ipc/standby.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ InitRecoveryTransactionEnvironment(void)
8181
* hold AccessShareLocks so never block while we write or lock new rows.
8282
*/
8383
vxid.backendId=MyBackendId;
84-
vxid.localTransactionId=GetNextLocalTransactionId();
84+
vxid.localTransactionId=MyProc->lxid=GetNextLocalTransactionId();
8585
VirtualXactLockTableInsert(vxid);
8686

8787
standbyState=STANDBY_INITIALIZED;
@@ -97,11 +97,18 @@ InitRecoveryTransactionEnvironment(void)
9797
void
9898
ShutdownRecoveryTransactionEnvironment(void)
9999
{
100+
VirtualTransactionIdvxid;
101+
100102
/* Mark all tracked in-progress transactions as finished. */
101103
ExpireAllKnownAssignedTransactionIds();
102104

103105
/* Release all locks the tracked transactions were holding */
104106
StandbyReleaseAllLocks();
107+
108+
/* Cleanup our VirtualTransaction */
109+
vxid.backendId=MyBackendId;
110+
vxid.localTransactionId=MyProc->lxid;
111+
VirtualXactLockTableDelete(vxid);
105112
}
106113

107114

‎src/backend/storage/lmgr/lmgr.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,24 @@ VirtualXactLockTableInsert(VirtualTransactionId vxid)
534534
(void)LockAcquire(&tag,ExclusiveLock, false, false);
535535
}
536536

537+
/*
538+
*VirtualXactLockTableDelete
539+
*
540+
* Release a Virtual Transaction lock. Only called by Startup process
541+
* at end of Hot Standby.
542+
*/
543+
void
544+
VirtualXactLockTableDelete(VirtualTransactionIdvxid)
545+
{
546+
LOCKTAGtag;
547+
548+
Assert(VirtualTransactionIdIsValid(vxid));
549+
550+
SET_LOCKTAG_VIRTUALTRANSACTION(tag,vxid);
551+
552+
(void)LockRelease(&tag,ExclusiveLock, false);
553+
}
554+
537555
/*
538556
*VirtualXactLockTableWait
539557
*

‎src/include/storage/lmgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ extern bool ConditionalXactLockTableWait(TransactionId xid);
5858

5959
/* Lock a VXID (used to wait for a transaction to finish) */
6060
externvoidVirtualXactLockTableInsert(VirtualTransactionIdvxid);
61+
externvoidVirtualXactLockTableDelete(VirtualTransactionIdvxid);
6162
externvoidVirtualXactLockTableWait(VirtualTransactionIdvxid);
6263
externboolConditionalVirtualXactLockTableWait(VirtualTransactionIdvxid);
6364

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp