mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Fix NULL pointer access in logical replication workers
From: Petr Jelinek <pjmodos@pjmodos.net>
This commit is contained in:
@ -349,10 +349,21 @@ logicalrep_worker_stop(Oid subid)
|
|||||||
|
|
||||||
ResetLatch(&MyProc->procLatch);
|
ResetLatch(&MyProc->procLatch);
|
||||||
|
|
||||||
/* Check if the worker has started. */
|
/* Check worker status. */
|
||||||
LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
|
LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
|
||||||
worker = logicalrep_worker_find(subid);
|
|
||||||
if (!worker || worker->proc)
|
/*
|
||||||
|
* Worker is no longer associated with subscription. It must have
|
||||||
|
* exited, nothing more for us to do.
|
||||||
|
*/
|
||||||
|
if (worker->subid == InvalidOid)
|
||||||
|
{
|
||||||
|
LWLockRelease(LogicalRepWorkerLock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Worker has assigned proc, so it has started. */
|
||||||
|
if (worker->proc)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,6 +1218,22 @@ reread_subscription(void)
|
|||||||
|
|
||||||
newsub = GetSubscription(MyLogicalRepWorker->subid, true);
|
newsub = GetSubscription(MyLogicalRepWorker->subid, true);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exit if the subscription was removed.
|
||||||
|
* This normally should not happen as the worker gets killed
|
||||||
|
* during DROP SUBSCRIPTION.
|
||||||
|
*/
|
||||||
|
if (!newsub)
|
||||||
|
{
|
||||||
|
ereport(LOG,
|
||||||
|
(errmsg("logical replication worker for subscription \"%s\" will "
|
||||||
|
"stop because the subscription was removed",
|
||||||
|
MySubscription->name)));
|
||||||
|
|
||||||
|
walrcv_disconnect(wrconn);
|
||||||
|
proc_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exit if connection string was changed. The launcher will start
|
* Exit if connection string was changed. The launcher will start
|
||||||
* new worker.
|
* new worker.
|
||||||
@ -1248,22 +1264,6 @@ reread_subscription(void)
|
|||||||
proc_exit(0);
|
proc_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Exit if the subscription was removed.
|
|
||||||
* This normally should not happen as the worker gets killed
|
|
||||||
* during DROP SUBSCRIPTION.
|
|
||||||
*/
|
|
||||||
if (!newsub)
|
|
||||||
{
|
|
||||||
ereport(LOG,
|
|
||||||
(errmsg("logical replication worker for subscription \"%s\" will "
|
|
||||||
"stop because the subscription was removed",
|
|
||||||
MySubscription->name)));
|
|
||||||
|
|
||||||
walrcv_disconnect(wrconn);
|
|
||||||
proc_exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exit if the subscription was disabled.
|
* Exit if the subscription was disabled.
|
||||||
* This normally should not happen as the worker gets killed
|
* This normally should not happen as the worker gets killed
|
||||||
|
Reference in New Issue
Block a user