]> granicus.if.org Git - postgresql/commitdiff
Zero padding in replication origin's checkpointed on disk-state.
authorAndres Freund <andres@anarazel.de>
Sun, 23 Apr 2017 22:48:31 +0000 (15:48 -0700)
committerAndres Freund <andres@anarazel.de>
Sun, 23 Apr 2017 22:54:53 +0000 (15:54 -0700)
This seems to be largely cosmetic, avoiding valgrind bleats and the
like. The uninitialized padding influences the CRC of the on-disk
entry, but because it's also used when verifying the CRC, that doesn't
cause spurious failures.  Backpatch nonetheless.

It's a bit unfortunate that contrib/test_decoding/sql/replorigin.sql
doesn't exercise the checkpoint path, but checkpoints are fairly
expensive on weaker machines, and we'd have to stop/start for that to
be meaningful.

Author: Andres Freund
Discussion: https://postgr.es/m/20170422183123.w2jgiuxtts7qrqaq@alap3.anarazel.de
Backpatch: 9.5, where replication origins were introduced

src/backend/replication/logical/origin.c

index 78d9e9f17bbd19cdc28038f73b4a8b25dd62b6a6..0d0aa407baa180e355e7fda281e0243007019d4e 100644 (file)
@@ -566,6 +566,9 @@ CheckPointReplicationOrigin(void)
                if (curstate->roident == InvalidRepOriginId)
                        continue;
 
+               /* zero, to avoid uninitialized padding bytes */
+               memset(&disk_state, 0, sizeof(disk_state));
+
                LWLockAcquire(&curstate->lock, LW_SHARED);
 
                disk_state.roident = curstate->roident;