Fix bogus initialization of replication origin shared memory state.
authorTom Lane <[email protected]>
Fri, 15 May 2020 23:05:40 +0000 (19:05 -0400)
committerTom Lane <[email protected]>
Fri, 15 May 2020 23:05:40 +0000 (19:05 -0400)
commit594ba7f79d32ad1e915c3acb53d84b6e57884ce5
treebd27d0976c302b5f9c495d4745e0ac5e25e90ab5
parent4649eb91916b9906fe2604af4c7157852700403f
Fix bogus initialization of replication origin shared memory state.

The previous coding zeroed out offsetof(ReplicationStateCtl, states)
more bytes than it was entitled to, as a consequence of starting the
zeroing from the wrong pointer (or, if you prefer, using the wrong
calculation of how much to zero).

It's unsurprising that this has not caused any reported problems,
since it can be expected that the newly-allocated block is at the end
of what we've used in shared memory, and we always make the shmem
block substantially bigger than minimally necessary.  Nonetheless,
this is wrong and it could bite us someday; plus it's a dangerous
model for somebody to copy.

This dates back to the introduction of this code (commit 5aa235042),
so back-patch to all supported branches.
src/backend/replication/logical/origin.c