]> granicus.if.org Git - postgresql/commit
Properly terminate the array returned by GetLockConflicts().
authorAndres Freund <andres@anarazel.de>
Thu, 29 Jan 2015 16:49:03 +0000 (17:49 +0100)
committerAndres Freund <andres@anarazel.de>
Thu, 29 Jan 2015 21:48:45 +0000 (22:48 +0100)
commit76e962750f0b2557e6a356c35d7c66fe8fb263b0
tree22ff3e870b0c0f989b50a71d1c192c9932e4404d
parent28a37deab30b6946558de3cafe78daa4823e23c3
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.
src/backend/storage/lmgr/lock.c