pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: PostmasterContext survives into parallel workers!?
Date: Tue, 02 Aug 2016 14:38:19 -0400
Message-ID: <758.1470163099@sss.pgh.pa.us> (raw)
In-Reply-To: <20160802182402.GA556987@alvherre.pgsql>
References: <20160802182402.GA556987@alvherre.pgsql>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

no-postmaster-context-in-bgworkers.patch (text/x-diff, 1.1K) download 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

view thread (18+ messages)  latest in thread

Message-ID: <758.1470163099@sss.pgh.pa.us>
Permalink:  ../758.1470163099@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/758.1470163099@sss.pgh.pa.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, alvherre@2ndquadrant.com, robertmhaas@gmail.com
  Subject: Re: PostmasterContext survives into parallel workers!?
  In-Reply-To: <758.1470163099@sss.pgh.pa.us>
  References: <20160802182402.GA556987@alvherre.pgsql> <758.1470163099@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox