Re: Threading in BGWorkers (!)

Поиск
Список
Период
Сортировка
От James Sewell
Тема Re: Threading in BGWorkers (!)
Дата
Msg-id CAANVwEvSGK0AxT+9mxCQndoNDV2hkazrXGsW6T0FZDaSdZXF_A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Threading in BGWorkers (!)  (Konstantin Knizhnik <k.knizhnik@postgrespro.ru>)
Список pgsql-hackers

On Tue, 23 Jun 2020 at 17:26, Konstantin Knizhnik <k.knizhnik@postgrespro.ru> wrote:
On 23.06.2020 10:15, James Sewell wrote:
Using multithreading in bgworker is possible if you do not use any
Postgres runtime inside thread procedures or do it in exclusive critical
section.
It is not so convenient but possible. The most difficult thing from my
point of view is error reporting.

Happy to be proved wrong, but I don't think this is correct.
PostgreSQL can call sigprocmask() in your BGWorker whenever it wants, and  "The use of sigprocmask() is unspecified in a multithreaded process" [1]

Sorry, may be I missed something.
But in my bgworker I am not using Postgres runtime at all (except initial bgworker startup code).
So I am not using latches (which are based on signals), snapshots,...
In my case bgworker has no connection to Postgres at all.
Yes, it can still receives signals from Postmaster (SIGTERM, SIGHUP). But their handler are trivial and do not need to mask any signals.

So may be in general case combination of signals and threads may cause some problems,
but it doesn't mean that you can't create multithreaded bgworker.

Ah yes - sorry *I* missed something. 

A multi threaded BGWorker which accesses shared memory and database via SPI. 


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.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Konstantin Knizhnik
Дата:
Сообщение: Re: Threading in BGWorkers (!)
Следующее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: min_safe_lsn column in pg_replication_slots view