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

Commit70c56a0

Browse files
committed
Fix NULL pointer access in logical replication workers
From: Petr Jelinek <pjmodos@pjmodos.net>
1 parent6cffe54 commit70c56a0

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

‎src/backend/replication/logical/launcher.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,21 @@ logicalrep_worker_stop(Oid subid)
349349

350350
ResetLatch(&MyProc->procLatch);
351351

352-
/* Checkif theworkerhas started. */
352+
/* Check workerstatus. */
353353
LWLockAcquire(LogicalRepWorkerLock,LW_SHARED);
354-
worker=logicalrep_worker_find(subid);
355-
if (!worker||worker->proc)
354+
355+
/*
356+
* Worker is no longer associated with subscription. It must have
357+
* exited, nothing more for us to do.
358+
*/
359+
if (worker->subid==InvalidOid)
360+
{
361+
LWLockRelease(LogicalRepWorkerLock);
362+
return;
363+
}
364+
365+
/* Worker has assigned proc, so it has started. */
366+
if (worker->proc)
356367
break;
357368
}
358369

‎src/backend/replication/logical/worker.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,45 +1219,45 @@ reread_subscription(void)
12191219
newsub=GetSubscription(MyLogicalRepWorker->subid, true);
12201220

12211221
/*
1222-
* Exit if connection string was changed. The launcher will start
1223-
* new worker.
1222+
* Exit if the subscription was removed.
1223+
* This normally should not happen as the worker gets killed
1224+
* during DROP SUBSCRIPTION.
12241225
*/
1225-
if (strcmp(newsub->conninfo,MySubscription->conninfo)!=0)
1226+
if (!newsub)
12261227
{
12271228
ereport(LOG,
12281229
(errmsg("logical replication worker for subscription \"%s\" will "
1229-
"restart because theconnection informationwaschanged",
1230+
"stop because thesubscriptionwasremoved",
12301231
MySubscription->name)));
12311232

12321233
walrcv_disconnect(wrconn);
12331234
proc_exit(0);
12341235
}
12351236

12361237
/*
1237-
* Exit ifpublication list was changed. The launcher will start
1238+
* Exit ifconnection string was changed. The launcher will start
12381239
* new worker.
12391240
*/
1240-
if (!equal(newsub->publications,MySubscription->publications))
1241+
if (strcmp(newsub->conninfo,MySubscription->conninfo)!=0)
12411242
{
12421243
ereport(LOG,
12431244
(errmsg("logical replication worker for subscription \"%s\" will "
1244-
"restart becausesubscription's publications were changed",
1245+
"restart becausethe connection information was changed",
12451246
MySubscription->name)));
12461247

12471248
walrcv_disconnect(wrconn);
12481249
proc_exit(0);
12491250
}
12501251

12511252
/*
1252-
* Exit if the subscription was removed.
1253-
* This normally should not happen as the worker gets killed
1254-
* during DROP SUBSCRIPTION.
1253+
* Exit if publication list was changed. The launcher will start
1254+
* new worker.
12551255
*/
1256-
if (!newsub)
1256+
if (!equal(newsub->publications,MySubscription->publications))
12571257
{
12581258
ereport(LOG,
12591259
(errmsg("logical replication worker for subscription \"%s\" will "
1260-
"stop becausethesubscription was removed",
1260+
"restart because subscription's publications were changed",
12611261
MySubscription->name)));
12621262

12631263
walrcv_disconnect(wrconn);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp