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

Commit29eedd3

Browse files
Adjust GetLockConflicts() so that it uses TopMemoryContext when
executed InHotStandby. Cleaner solution than using malloc or pallocdepending upon situation, as proposed by Tom.
1 parent6d2bc0a commit29eedd3

File tree

1 file changed

+9
-15
lines changed
  • src/backend/storage/lmgr

1 file changed

+9
-15
lines changed

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.192 2010/01/28 10:05:37 sriggs Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.193 2010/01/29 19:45:12 sriggs Exp $
1212
*
1313
* NOTES
1414
* A lock table is a shared memory hash table. When
@@ -1790,7 +1790,7 @@ LockReassignCurrentOwner(void)
17901790
VirtualTransactionId*
17911791
GetLockConflicts(constLOCKTAG*locktag,LOCKMODElockmode)
17921792
{
1793-
staticVirtualTransactionId*vxids=NULL;
1793+
staticVirtualTransactionId*vxids;
17941794
LOCKMETHODIDlockmethodid=locktag->locktag_lockmethodid;
17951795
LockMethodlockMethodTable;
17961796
LOCK*lock;
@@ -1810,24 +1810,18 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode)
18101810
/*
18111811
* Allocate memory to store results, and fill with InvalidVXID. We only
18121812
* need enough space for MaxBackends + a terminator, since prepared xacts
1813-
* don't count.
1813+
* don't count. InHotStandby allocate once in TopMemoryContext.
18141814
*/
1815-
if (!InHotStandby)
1816-
vxids= (VirtualTransactionId*)
1817-
palloc0(sizeof(VirtualTransactionId)* (MaxBackends+1));
1818-
else
1815+
if (InHotStandby)
18191816
{
18201817
if (vxids==NULL)
1821-
{
18221818
vxids= (VirtualTransactionId*)
1823-
malloc(sizeof(VirtualTransactionId)* (MaxBackends+1));
1824-
if (vxids==NULL)
1825-
ereport(ERROR,
1826-
(errcode(ERRCODE_OUT_OF_MEMORY),
1827-
errmsg("out of memory")));
1828-
1829-
}
1819+
MemoryContextAlloc(TopMemoryContext,
1820+
sizeof(VirtualTransactionId)* (MaxBackends+1));
18301821
}
1822+
else
1823+
vxids= (VirtualTransactionId*)
1824+
palloc0(sizeof(VirtualTransactionId)* (MaxBackends+1));
18311825

18321826
/*
18331827
* Look up the lock object matching the tag.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp