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

Commit34653bc

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 parent1597948 commit34653bc

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
@@ -388,8 +388,6 @@ void
388388
ReinitializeParallelDSM(ParallelContext*pcxt)
389389
{
390390
FixedParallelState*fps;
391-
char*error_queue_space;
392-
inti;
393391

394392
/* Wait for any old workers to exit. */
395393
if (pcxt->nworkers_launched>0)
@@ -409,18 +407,23 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
409407
fps->last_xlog_end=0;
410408

411409
/* Recreate error queues (if they exist). */
412-
error_queue_space=
413-
shm_toc_lookup(pcxt->toc,PARALLEL_KEY_ERROR_QUEUE, true);
414-
Assert(pcxt->nworkers==0||error_queue_space!=NULL);
415-
for (i=0;i<pcxt->nworkers;++i)
410+
if (pcxt->nworkers>0)
416411
{
417-
char*start;
418-
shm_mq*mq;
412+
char*error_queue_space;
413+
inti;
419414

420-
start=error_queue_space+i*PARALLEL_ERROR_QUEUE_SIZE;
421-
mq=shm_mq_create(start,PARALLEL_ERROR_QUEUE_SIZE);
422-
shm_mq_set_receiver(mq,MyProc);
423-
pcxt->worker[i].error_mqh=shm_mq_attach(mq,pcxt->seg,NULL);
415+
error_queue_space=
416+
shm_toc_lookup(pcxt->toc,PARALLEL_KEY_ERROR_QUEUE, false);
417+
for (i=0;i<pcxt->nworkers;++i)
418+
{
419+
char*start;
420+
shm_mq*mq;
421+
422+
start=error_queue_space+i*PARALLEL_ERROR_QUEUE_SIZE;
423+
mq=shm_mq_create(start,PARALLEL_ERROR_QUEUE_SIZE);
424+
shm_mq_set_receiver(mq,MyProc);
425+
pcxt->worker[i].error_mqh=shm_mq_attach(mq,pcxt->seg,NULL);
426+
}
424427
}
425428
}
426429

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp