* Reinitialize the dynamic shared memory segment for a parallel context such * that we could launch workers for it again. */
| 521 | * that we could launch workers for it again. |
| 522 | */ |
| 523 | void |
| 524 | ReinitializeParallelDSM(ParallelContext *pcxt) |
| 525 | { |
| 526 | FixedParallelState *fps; |
| 527 | |
| 528 | /* Wait for any old workers to exit. */ |
| 529 | if (pcxt->nworkers_launched > 0) |
| 530 | { |
| 531 | WaitForParallelWorkersToFinish(pcxt); |
| 532 | WaitForParallelWorkersToExit(pcxt); |
| 533 | pcxt->nworkers_launched = 0; |
| 534 | if (pcxt->known_attached_workers) |
| 535 | { |
| 536 | pfree(pcxt->known_attached_workers); |
| 537 | pcxt->known_attached_workers = NULL; |
| 538 | pcxt->nknown_attached_workers = 0; |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | /* Reset a few bits of fixed parallel state to a clean state. */ |
| 543 | fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false); |
| 544 | fps->last_xlog_end = 0; |
| 545 | |
| 546 | /* Recreate error queues (if they exist). */ |
| 547 | if (pcxt->nworkers > 0) |
| 548 | { |
| 549 | char *error_queue_space; |
| 550 | int i; |
| 551 | |
| 552 | error_queue_space = |
| 553 | shm_toc_lookup(pcxt->toc, PARALLEL_KEY_ERROR_QUEUE, false); |
| 554 | for (i = 0; i < pcxt->nworkers; ++i) |
| 555 | { |
| 556 | char *start; |
| 557 | shm_mq *mq; |
| 558 | |
| 559 | start = error_queue_space + i * PARALLEL_ERROR_QUEUE_SIZE; |
| 560 | mq = shm_mq_create(start, PARALLEL_ERROR_QUEUE_SIZE); |
| 561 | shm_mq_set_receiver(mq, MyProc); |
| 562 | pcxt->worker[i].error_mqh = shm_mq_attach(mq, pcxt->seg, NULL); |
| 563 | } |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | /* |
| 568 | * Reinitialize parallel workers for a parallel context such that we could |
no test coverage detected