mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Don't dump core when destroying an unused ParallelContext.
If a transaction or subtransaction creates a ParallelContext but ends without calling InitializeParallelDSM, the previous code would seg fault. Fix that.
This commit is contained in:
@ -513,14 +513,17 @@ DestroyParallelContext(ParallelContext *pcxt)
|
|||||||
dlist_delete(&pcxt->node);
|
dlist_delete(&pcxt->node);
|
||||||
|
|
||||||
/* Kill each worker in turn, and forget their error queues. */
|
/* Kill each worker in turn, and forget their error queues. */
|
||||||
for (i = 0; i < pcxt->nworkers; ++i)
|
if (pcxt->worker != NULL)
|
||||||
{
|
{
|
||||||
if (pcxt->worker[i].bgwhandle != NULL)
|
for (i = 0; i < pcxt->nworkers; ++i)
|
||||||
TerminateBackgroundWorker(pcxt->worker[i].bgwhandle);
|
|
||||||
if (pcxt->worker[i].error_mqh != NULL)
|
|
||||||
{
|
{
|
||||||
pfree(pcxt->worker[i].error_mqh);
|
if (pcxt->worker[i].bgwhandle != NULL)
|
||||||
pcxt->worker[i].error_mqh = NULL;
|
TerminateBackgroundWorker(pcxt->worker[i].bgwhandle);
|
||||||
|
if (pcxt->worker[i].error_mqh != NULL)
|
||||||
|
{
|
||||||
|
pfree(pcxt->worker[i].error_mqh);
|
||||||
|
pcxt->worker[i].error_mqh = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +553,7 @@ DestroyParallelContext(ParallelContext *pcxt)
|
|||||||
{
|
{
|
||||||
BgwHandleStatus status;
|
BgwHandleStatus status;
|
||||||
|
|
||||||
if (pcxt->worker[i].bgwhandle == NULL)
|
if (pcxt->worker == NULL || pcxt->worker[i].bgwhandle == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user