Re: Logical replication and multimaster

Поиск
Список
Период
Сортировка
От Petr Jelinek
Тема Re: Logical replication and multimaster
Дата
Msg-id 56605A90.2010306@2ndquadrant.com
обсуждение исходный текст
Ответ на Re: Logical replication and multimaster  (Craig Ringer <craig@2ndquadrant.com>)
Список pgsql-hackers
On 2015-12-03 14:32, Craig Ringer wrote:
> On 3 December 2015 at 15:27, konstantin knizhnik
> <k.knizhnik@postgrespro.ru <mailto:k.knizhnik@postgrespro.ru>> wrote:
>
>     3. What is the right way of creation of background worker requiring
>     access to shared memory, i.e. having control structure in main memory?
>
>
> This is documented and well established.
>
>     As far as I understand background workers have to be registered
>     either PG_init, either outside Postmaster environment.
>     If extension requires access to shared memory, then it should be
>     registered in shared_preload_libraries list and should be
>     initialized using shmem_startup hook.
>
>
> Correct.
>
> You can use dynamic shmem instead, but there are some issues there IIRC.
> Petr may have more to say there.
> Take a look at the BDR code for some examples, and there are some in
> contrib too I think.
>

If you have your own flock of dynamic workers that you manage yourself, 
it's probably easier to use dynamic shared memory. You can see some 
examples in the tests and also in the parallel query code for how to do 
it. The only real issue we faced with using dynamic shared memory was 
that we needed to do IPC from normal backends and that gets complicated 
when you don't have the worker info in the normal shmem.


The registration timing and working with normal shmem is actually not a 
problem. Just register shmem start hook in _PG_init and if you are 
registering any bgworkers there as well make sure you set bgw_start_time 
correctly (usually what you want is BgWorkerStart_RecoveryFinished). 
Then you'll have the shmem hook called before the bgworker is actually 
started.

--  Petr Jelinek                  http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training &
Services



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

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: proposal: add 'waiting for replication' to pg_stat_activity.state
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: Fwd: Another little thing about psql wrapped expanded output