pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Comment patch for bgworker.c
3+ messages / 2 participants
[nested] [flat]

* Comment patch for bgworker.c
@ 2014-10-25 00:51  Jim Nasby <Jim.Nasby@BlueTreble.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Jim Nasby @ 2014-10-25 00:51 UTC (permalink / raw)
  To: pgsql-hackers

The comment for the BackgroundWorkerSlot structure tripped me up reviewing Robert's background worker patch; it made it clear that you need to use a memory barrier before setting in_use, but normally you'd never need to worry about that because RegisterDynamicBackgroundWorker() handles it for you. Patch adds a comment to that effect.
-- 
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com

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

Attachments:

patch (text/plain, 809B) download diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c index 85a3b3a..e81dbc1 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -55,7 +55,8 @@ slist_head BackgroundWorkerList = SLIST_STATIC_INIT(BackgroundWorkerList); * responsibility of the postmaster. Regular backends may no longer modify it, * but the postmaster may examine it. Thus, a backend initializing a slot * must fully initialize the slot - and insert a write memory barrier - before - * marking it as in use. + * marking it as in use. Note that RegisterDynamicBackgroundWorker() handles + * in_use correctly for you. * * As an exception, however, even when the slot is in use, regular backends * may set the 'terminate' flag for a slot, telling the postmaster not
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: Comment patch for bgworker.c
@ 2015-02-02 13:49  Robert Haas <robertmhaas@gmail.com>
  parent: Jim Nasby <Jim.Nasby@BlueTreble.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Robert Haas @ 2015-02-02 13:49 UTC (permalink / raw)
  To: Jim Nasby <Jim.Nasby@bluetreble.com>; +Cc: pgsql-hackers

On Fri, Oct 24, 2014 at 8:51 PM, Jim Nasby <Jim.Nasby@bluetreble.com> wrote:
> The comment for the BackgroundWorkerSlot structure tripped me up reviewing
> Robert's background worker patch; it made it clear that you need to use a
> memory barrier before setting in_use, but normally you'd never need to worry
> about that because RegisterDynamicBackgroundWorker() handles it for you.
> Patch adds a comment to that effect.

I vote to reject this patch.  I think it's explaining something that
doesn't really need to be explained, and shouldn't be explained like
this even if it does.  It adds a comment that reads "Note that
RegisterDynamicBackgroundWorker() handles in_use correctly for you".
But the long block comment of which it is a part is entirely devoted
to explaining concerns internal to bgworker.c, from which I think it
should be inferred that all of the public APIs in that file handle all
of the things in that paragraph correctly (or are intended to,
anyway).

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Comment patch for bgworker.c
@ 2015-02-03 02:13  Jim Nasby <Jim.Nasby@BlueTreble.com>
  parent: Robert Haas <robertmhaas@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Jim Nasby @ 2015-02-03 02:13 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: pgsql-hackers

On 2/2/15 7:49 AM, Robert Haas wrote:
> On Fri, Oct 24, 2014 at 8:51 PM, Jim Nasby <Jim.Nasby@bluetreble.com> wrote:
>> The comment for the BackgroundWorkerSlot structure tripped me up reviewing
>> Robert's background worker patch; it made it clear that you need to use a
>> memory barrier before setting in_use, but normally you'd never need to worry
>> about that because RegisterDynamicBackgroundWorker() handles it for you.
>> Patch adds a comment to that effect.
>
> I vote to reject this patch.  I think it's explaining something that
> doesn't really need to be explained, and shouldn't be explained like
> this even if it does.  It adds a comment that reads "Note that
> RegisterDynamicBackgroundWorker() handles in_use correctly for you".
> But the long block comment of which it is a part is entirely devoted
> to explaining concerns internal to bgworker.c, from which I think it
> should be inferred that all of the public APIs in that file handle all
> of the things in that paragraph correctly (or are intended to,
> anyway).

At this point I don't remember what it was in your patch that tripped me 
up on this, so I'm marking the patch rejected.
-- 
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com


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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2015-02-03 02:13 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-10-25 00:51 Comment patch for bgworker.c Jim Nasby <Jim.Nasby@BlueTreble.com>
2015-02-02 13:49 ` Robert Haas <robertmhaas@gmail.com>
2015-02-03 02:13   ` Jim Nasby <Jim.Nasby@BlueTreble.com>

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