summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund2016-08-17 20:15:03 +0000
committerAndres Freund2016-08-17 20:15:03 +0000
commit2d7e591007a6f44e5e27e2b6c1098483105c0d10 (patch)
tree8539581696520ed15c3f5b581d9bb49c3bdbfb2c
parent6657acc0100ec79304b868a6346db4d8eb2f6b83 (diff)
Properly re-initialize replication slot shared memory upon creation.
Slot creation did not clear all fields upon creation. After start the memory is zeroed, but when a physical replication slot was created in the shared memory of a previously existing logical slot, catalog_xmin would not be cleared. That in turn would prevent vacuum from doing its duties. To fix initialize all the fields. To make similar future bugs less likely, zero all of ReplicationSlotPersistentData, and re-order the rest of the initialization to be in struct member order. Analysis: Andrew Gierth Reported-By: [email protected] Author: Michael Paquier Discussion: <[email protected]> Backpatch: 9.4, where replication slots were introduced
-rw-r--r--src/backend/replication/slot.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index 2fb7c17d7d..0b2575ee9d 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -272,12 +272,22 @@ ReplicationSlotCreate(const char *name, bool db_specific,
*/
Assert(!slot->in_use);
Assert(slot->active_pid == 0);
- slot->data.persistency = persistency;
- slot->data.xmin = InvalidTransactionId;
- slot->effective_xmin = InvalidTransactionId;
+
+ /* first initialize persistent data */
+ memset(&slot->data, 0, sizeof(ReplicationSlotPersistentData));
StrNCpy(NameStr(slot->data.name), name, NAMEDATALEN);
slot->data.database = db_specific ? MyDatabaseId : InvalidOid;
- slot->data.restart_lsn = InvalidXLogRecPtr;
+ slot->data.persistency = persistency;
+
+ /* and then data only present in shared memory */
+ slot->just_dirtied = false;
+ slot->dirty = false;
+ slot->effective_xmin = InvalidTransactionId;
+ slot->effective_catalog_xmin = InvalidTransactionId;
+ slot->candidate_catalog_xmin = InvalidTransactionId;
+ slot->candidate_xmin_lsn = InvalidXLogRecPtr;
+ slot->candidate_restart_valid = InvalidXLogRecPtr;
+ slot->candidate_restart_lsn = InvalidXLogRecPtr;
/*
* Create the slot on disk. We haven't actually marked the slot allocated