Fix bogus initialization of replication origin shared memory state.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 15 May 2020 23:05:39 +0000 (19:05 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 15 May 2020 23:05:39 +0000 (19:05 -0400)
commitee39a4b9e475348dd3de82781a54be82e63a3186
tree8570660c2a92422440930fd0de3475f155f356f2
parent37b5c5fde46ad3081f02668846f4d125ca4f7992
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