aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2015-01-29 17:49:03 +0100
committerAndres Freund <andres@anarazel.de>2015-01-29 22:48:46 +0100
commit78f8c67054d0eb555cf7ef24aafb67f84b0fe65c (patch)
tree1e08cf7759601f91836332b664bedf947f784311
parent37e0f13f266d7dc6d9e0a5eaadbacbb01d68db61 (diff)
downloadpostgresql-78f8c67054d0eb555cf7ef24aafb67f84b0fe65c.tar.gz
postgresql-78f8c67054d0eb555cf7ef24aafb67f84b0fe65c.zip
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.
-rw-r--r--src/backend/storage/lmgr/lock.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index 3fc91740b89..eb3e5bdf253 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -1990,6 +1990,8 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode)
* on this lockable object.
*/
LWLockRelease(partitionLock);
+ vxids[count].backendId = InvalidBackendId;
+ vxids[count].localTransactionId = InvalidLocalTransactionId;
return vxids;
}
@@ -2035,6 +2037,8 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode)
if (count > MaxBackends) /* should never happen */
elog(PANIC, "too many conflicting locks found");
+ vxids[count].backendId = InvalidBackendId;
+ vxids[count].localTransactionId = InvalidLocalTransactionId;
return vxids;
}