From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | James Sewell <james(dot)sewell(at)jirotech(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Threading in BGWorkers (!) |
Date: | 2020-06-23 03:38:16 |
Message-ID: | 2124260.1592883496@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
James Sewell <james(dot)sewell(at)jirotech(dot)com> writes:
> I was talking about PostgreSQL and threading on IRC the other day - which I
> know is a frowned upon topic - and just wanted to frame the same questions
> here and hopefully get a discussion going.
I think the short answer about threading in bgworkers (or any other
backend process) is "we don't support it; if you try it and it breaks,
which it likely will, you get to keep both pieces". I'm not sure that
there's any merit in making small dents in that policy. I suspect that
at some point, somebody will try to move those goalposts a long way,
but it will be a large and controversial patch.
Why do you want threads in a bgworker anyway? You could spawn multiple
bgworkers, or you could dispatch the threaded work to a non-Postgres-ish
process as PL/Java does. The only advantage I can see of doing work in a
process that's not at arm's-length is to have access to PG computational
or IPC facilities, and none of that is likely to work safely in a threaded
context.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2020-06-23 03:57:47 | Re: Backpatch b61d161c14 (Introduce vacuum errcontext ...) |
Previous Message | Masahiko Sawada | 2020-06-23 03:33:02 | Re: Transactions involving multiple postgres foreign servers, take 2 |