agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Petr Jelinek <[email protected]>
To: Craig Ringer <[email protected]>
To: konstantin knizhnik <[email protected]>
Cc: pgsql-hackers Hackers <[email protected]>
Cc: Robert Haas <[email protected]>
Subject: Re: Logical replication and multimaster
Date: Thu, 3 Dec 2015 16:06:56 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAMsr+YE+RDz-Lzj4ro7aRXKOPCb1dBisiiRbc2MbukBjMXzemA@mail.gmail.com>
References: <[email protected]>
	<CA+TgmoY1o3G0B-21zv2Pw5iEkpR8=J42GdsUOs4m0inKka3FEA@mail.gmail.com>
	<[email protected]>
	<CAMsr+YHMe=xs_E4fd2q1j7JPLpwvdU6+vY__rJTy2L4zkSSgTg@mail.gmail.com>
	<[email protected]>
	<CAMsr+YE+RDz-Lzj4ro7aRXKOPCb1dBisiiRbc2MbukBjMXzemA@mail.gmail.com>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-hackers>

On 2015-12-03 14:32, Craig Ringer wrote:
> On 3 December 2015 at 15:27, konstantin knizhnik
> <[email protected] <mailto:[email protected]>> 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


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



view thread (38+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Logical replication and multimaster
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox