Re: PostmasterContext survives into parallel workers!?
От | Tom Lane |
---|---|
Тема | Re: PostmasterContext survives into parallel workers!? |
Дата | |
Msg-id | 758.1470163099@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: PostmasterContext survives into parallel workers!? (Alvaro Herrera <alvherre@2ndquadrant.com>) |
Ответы |
Re: PostmasterContext survives into parallel workers!?
|
Список | pgsql-hackers |
Alvaro Herrera <alvherre@2ndquadrant.com> writes: > Tom Lane wrote: >> It looks to me like the reason for it is simply not having bothered to >> copy the rw->rw_worker data to somewhere that would survive deletion >> of the PostmasterContext. I wonder though if anyone remembers a more >> fundamental reason? Surely the bgworker is not supposed to touch any >> of the rest of the BackgroundWorkerList? > I just checked BDR, which is the more complex code using workers I know > of, and I don't see any reason why this cannot be changed. The attached patch passes "make check-world" for me. Can you check it against BDR? (I'd be hesitant to back-patch it in any case, but I think it's okay for HEAD unless we can easily find something it breaks.) regards, tom lane diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 19d11e0..e48703a 100644 *** a/src/backend/postmaster/postmaster.c --- b/src/backend/postmaster/postmaster.c *************** do_start_bgworker(RegisteredBgWorker *rw *** 5529,5537 **** /* Close the postmaster's sockets */ ClosePostmasterPorts(false); ! /* Do NOT release postmaster's working memory context */ - MyBgworkerEntry = &rw->rw_worker; StartBackgroundWorker(); break; #endif --- 5529,5547 ---- /* Close the postmaster's sockets */ ClosePostmasterPorts(false); ! /* ! * Before blowing away PostmasterContext, save this bgworker's ! * data where it can find it. ! */ ! MyBgworkerEntry = (BackgroundWorker *) ! MemoryContextAlloc(TopMemoryContext, sizeof(BackgroundWorker)); ! memcpy(MyBgworkerEntry, &rw->rw_worker, sizeof(BackgroundWorker)); ! ! /* Release postmaster's working memory context */ ! MemoryContextSwitchTo(TopMemoryContext); ! MemoryContextDelete(PostmasterContext); ! PostmasterContext = NULL; StartBackgroundWorker(); break; #endif
В списке pgsql-hackers по дате отправления: