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

Commit93a028f

Browse files
committed
Properly remove ephemeral replication slots after a crash restart.
Ephemeral slots - slots that shouldn't survive database restarts -weren't properly cleaned up after a immediate/crash restart. They wereignored in the sense that they weren't restored into memory and thusdidn't cause unwanted resource retention; but they prevented a newslot with the same name from being created.Now ephemeral slots are fully removed during startup.Backpatch to 9.4 where replication slots where added.
1 parent32d7889 commit93a028f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

‎src/backend/replication/slot.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,24 @@ RestoreSlotFromDisk(const char *name)
11921192
(errmsg("replication slot file %s: checksum mismatch, is %u, should be %u",
11931193
path,checksum,cp.checksum)));
11941194

1195+
/*
1196+
* If we crashed with an ephemeral slot active, don't restore but delete
1197+
* it.
1198+
*/
1199+
if (cp.slotdata.persistency!=RS_PERSISTENT)
1200+
{
1201+
sprintf(path,"pg_replslot/%s",name);
1202+
1203+
if (!rmtree(path, true))
1204+
{
1205+
ereport(WARNING,
1206+
(errcode_for_file_access(),
1207+
errmsg("could not remove directory \"%s\"",path)));
1208+
}
1209+
fsync_fname("pg_replslot", true);
1210+
return;
1211+
}
1212+
11951213
/* nothing can be active yet, don't lock anything */
11961214
for (i=0;i<max_replication_slots;i++)
11971215
{
@@ -1206,10 +1224,6 @@ RestoreSlotFromDisk(const char *name)
12061224
memcpy(&slot->data,&cp.slotdata,
12071225
sizeof(ReplicationSlotPersistentData));
12081226

1209-
/* Don't restore the slot if it's not parked as persistent. */
1210-
if (slot->data.persistency!=RS_PERSISTENT)
1211-
return;
1212-
12131227
/* initialize in memory state */
12141228
slot->effective_xmin=cp.slotdata.xmin;
12151229
slot->effective_catalog_xmin=cp.slotdata.catalog_xmin;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp