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

Commit957ff08

Browse files
committed
Be more wary about shm_toc_lookup failure.
Commit445dbd8 basically missed the point of commitd466335,which was that we shouldn't allow shm_toc_lookup() failure to leadto a core dump or assertion crash, because the odds of such afailure should never be considered negligible. It's correct thatwe can't expect the PARALLEL_KEY_ERROR_QUEUE TOC entry to be thereif we have no workers. But if we have no workers, we're not goingto do anything in this function with the lookup result anyway,so let's just skip it. That lets the code use the easy-to-prove-safenoError=false case, rather than anything requiring effort to review.Back-patch to v10, like the previous commit.Discussion:https://postgr.es/m/3647.1517601675@sss.pgh.pa.us
1 parentbf641d3 commit957ff08

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

‎src/backend/access/transam/parallel.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ void
434434
ReinitializeParallelDSM(ParallelContext*pcxt)
435435
{
436436
FixedParallelState*fps;
437-
char*error_queue_space;
438-
inti;
439437

440438
/* Wait for any old workers to exit. */
441439
if (pcxt->nworkers_launched>0)
@@ -456,18 +454,23 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
456454
fps->last_xlog_end=0;
457455

458456
/* Recreate error queues (if they exist). */
459-
error_queue_space=
460-
shm_toc_lookup(pcxt->toc,PARALLEL_KEY_ERROR_QUEUE, true);
461-
Assert(pcxt->nworkers==0||error_queue_space!=NULL);
462-
for (i=0;i<pcxt->nworkers;++i)
457+
if (pcxt->nworkers>0)
463458
{
464-
char*start;
465-
shm_mq*mq;
459+
char*error_queue_space;
460+
inti;
466461

467-
start=error_queue_space+i*PARALLEL_ERROR_QUEUE_SIZE;
468-
mq=shm_mq_create(start,PARALLEL_ERROR_QUEUE_SIZE);
469-
shm_mq_set_receiver(mq,MyProc);
470-
pcxt->worker[i].error_mqh=shm_mq_attach(mq,pcxt->seg,NULL);
462+
error_queue_space=
463+
shm_toc_lookup(pcxt->toc,PARALLEL_KEY_ERROR_QUEUE, false);
464+
for (i=0;i<pcxt->nworkers;++i)
465+
{
466+
char*start;
467+
shm_mq*mq;
468+
469+
start=error_queue_space+i*PARALLEL_ERROR_QUEUE_SIZE;
470+
mq=shm_mq_create(start,PARALLEL_ERROR_QUEUE_SIZE);
471+
shm_mq_set_receiver(mq,MyProc);
472+
pcxt->worker[i].error_mqh=shm_mq_attach(mq,pcxt->seg,NULL);
473+
}
471474
}
472475
}
473476

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp