Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1116108

Browse files
committed
Handle change of slot name in logical replication apply
Since change of slot name is a supported operation, handle it more gracefully, instead of in the this-should-not-happen way. Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
1 parent 70da87d commit 1116108

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/backend/replication/logical/worker.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,21 @@ reread_subscription(void)
13501350
proc_exit(0);
13511351
}
13521352

1353+
/*
1354+
* We need to make new connection to new slot if slot name has changed
1355+
* so exit here as well if that's the case.
1356+
*/
1357+
if (strcmp(newsub->slotname, MySubscription->slotname) != 0)
1358+
{
1359+
ereport(LOG,
1360+
(errmsg("logical replication worker for subscription \"%s\" will "
1361+
"restart because the replication slot name was changed",
1362+
MySubscription->name)));
1363+
1364+
walrcv_disconnect(wrconn);
1365+
proc_exit(0);
1366+
}
1367+
13531368
/*
13541369
* Exit if publication list was changed. The launcher will start
13551370
* new worker.
@@ -1382,8 +1397,7 @@ reread_subscription(void)
13821397
}
13831398

13841399
/* Check for other changes that should never happen too. */
1385-
if (newsub->dbid != MySubscription->dbid ||
1386-
strcmp(newsub->slotname, MySubscription->slotname) != 0)
1400+
if (newsub->dbid != MySubscription->dbid)
13871401
{
13881402
elog(ERROR, "subscription %u changed unexpectedly",
13891403
MyLogicalRepWorker->subid);

0 commit comments

Comments
 (0)