Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitde396a1

Browse files
committed
Properly re-initialize replication slot shared memory upon creation.
Slot creation did not clear all fields upon creation. After start thememory is zeroed, but when a physical replication slot was created inthe shared memory of a previously existing logical slot, catalog_xminwould not be cleared. That in turn would prevent vacuum from doing itsduties.To fix initialize all the fields. To make similar future bugs lesslikely, zero all of ReplicationSlotPersistentData, and re-order therest of the initialization to be in struct member order.Analysis: Andrew GierthReported-By: md@chewy.comAuthor: Michael PaquierDiscussion: <20160705173502.1398.70934@wrigleys.postgresql.org>Backpatch: 9.4, where replication slots were introduced
1 parent509815e commitde396a1

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

‎src/backend/replication/slot.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,22 @@ ReplicationSlotCreate(const char *name, bool db_specific,
263263
*/
264264
Assert(!slot->in_use);
265265
Assert(slot->active_pid==0);
266-
slot->data.persistency=persistency;
267-
slot->data.xmin=InvalidTransactionId;
268-
slot->effective_xmin=InvalidTransactionId;
266+
267+
/* first initialize persistent data */
268+
memset(&slot->data,0,sizeof(ReplicationSlotPersistentData));
269269
StrNCpy(NameStr(slot->data.name),name,NAMEDATALEN);
270270
slot->data.database=db_specific ?MyDatabaseId :InvalidOid;
271-
slot->data.restart_lsn=InvalidXLogRecPtr;
271+
slot->data.persistency=persistency;
272+
273+
/* and then data only present in shared memory */
274+
slot->just_dirtied= false;
275+
slot->dirty= false;
276+
slot->effective_xmin=InvalidTransactionId;
277+
slot->effective_catalog_xmin=InvalidTransactionId;
278+
slot->candidate_catalog_xmin=InvalidTransactionId;
279+
slot->candidate_xmin_lsn=InvalidXLogRecPtr;
280+
slot->candidate_restart_valid=InvalidXLogRecPtr;
281+
slot->candidate_restart_lsn=InvalidXLogRecPtr;
272282

273283
/*
274284
* Create the slot on disk. We haven't actually marked the slot allocated

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp