Re: Threading in BGWorkers (!) - Mailing list pgsql-hackers

From James Sewell
Subject Re: Threading in BGWorkers (!)
Date
Msg-id CAANVwEvRTK2EXa8e5wg6pEj+LyAv8u3SD+xDJNm=vc2eY6N0Pg@mail.gmail.com
Whole thread Raw
In response to Re: Threading in BGWorkers (!)  (Chapman Flack <chap@anastigmatix.net>)
Responses Re: Threading in BGWorkers (!)  (Thomas Munro <thomas.munro@gmail.com>)
List pgsql-hackers
Hackers,

In the hope of this not being derailed by larger/more unpopular pieces of work, I'm attaching a tiny patch which I don't believe will have any negative impact - but will remove one blocker for $subject (sigprocmask usage is "unspecified" in multithreaded code [1]).

The patch replaces sigprocmask with pthread_sigmask. They have identical APIs ("[pthread_sigmask] shall be equivalent to sigprocmask(), without the restriction that the call be made in a single-threaded process"[1])

The rationale here is that as far as I can tell this is the *only* blocker to using multithreaded code in a BGWorker which can't be avoided by adhering to strict code rules (eg: no PG calls from non-main threads, no interaction with signals from non-main threads).

Before this went in the rules would need to be agreed upon and documented - but hopefully it's at least a way forward / a way to progress this discussion.

Cheers,
James









The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.
Attachment

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: SQL-standard function body
Next
From: Simon Riggs
Date:
Subject: Re: A patch for get origin from commit_ts.