Skip to content

Commit 78f8c67

Browse files
committed
Properly terminate the array returned by GetLockConflicts().
GetLockConflicts() has for a long time not properly terminated the returned array. During normal processing the returned array is zero initialized which, while not pretty, is sufficient to be recognized as a invalid virtual transaction id. But the HotStandby case is more than aesthetically broken: The allocated (and reused) array is neither zeroed upon allocation, nor reinitialized, nor terminated. Not having a terminating element means that the end of the array will not be recognized and that recovery conflict handling will thus read ahead into adjacent memory. Only terminating when hitting memory content that looks like a invalid virtual transaction id. Luckily this seems so far not have caused significant problems, besides making recovery conflict more expensive. Discussion: 20150127142713.GD29457@awork2.anarazel.de Backpatch into all supported branches.
1 parent 37e0f13 commit 78f8c67

File tree

1 file changed

+4
-0
lines changed
  • src/backend/storage/lmgr

1 file changed

+4
-0
lines changed

src/backend/storage/lmgr/lock.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,8 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode)
19901990
* on this lockable object.
19911991
*/
19921992
LWLockRelease(partitionLock);
1993+
vxids[count].backendId = InvalidBackendId;
1994+
vxids[count].localTransactionId = InvalidLocalTransactionId;
19931995
return vxids;
19941996
}
19951997

@@ -2035,6 +2037,8 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode)
20352037
if (count > MaxBackends) /* should never happen */
20362038
elog(PANIC, "too many conflicting locks found");
20372039

2040+
vxids[count].backendId = InvalidBackendId;
2041+
vxids[count].localTransactionId = InvalidLocalTransactionId;
20382042
return vxids;
20392043
}
20402044

0 commit comments

Comments
 (0)