Re: Streaming replication and non-blocking I/O

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Streaming replication and non-blocking I/O
Date: 2009-12-21 17:31:01
Message-ID: 4B2FB0D5.5080703@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Fujii Masao wrote:
> On Tue, Dec 15, 2009 at 4:11 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Hm. Perhaps it should be a loadable plugin and not hard-linked into the
>> backend? Compare dblink.
>
> You mean that such plugin is supplied in shared_preload_libraries,
> a new process is forked and the shared-memory related to walreceiver
> is created by using shmem_startup_hook? Since this approach would
> solve the problem discussed previously, ISTM this makes sense.
> http://archives.postgresql.org/pgsql-hackers/2009-11/msg00031.php
>
> Some additional code might be required to control the termination
> of walreceiver.

I'm not sure which problem in that thread you're referring to, but I can
see two options:

1. Use dlopen()/dlsym() in walreceiver to use libpq. A bit awkward,
though we could write a bunch of macros to hide that and make the libpq
calls look normal.

2. Move walreceiver altogether into a loadable module, which is linked
as usual to libpq. Like e.g contrib/dblink.

Thoughts? Both seem reasonable to me. I tested the 2nd option (see
'replication' branch in my git repository), splitting walreceiver.c into
two: the functions that run in the walreceiver process, and the
functions that are called from other processes to control walreceiver.
That's a quite nice separation, though of course we could do that with
the 1st approach as well.

PS. I just merged with CVS HEAD. Streaming replication is pretty awesome
with Hot Standby!

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tim Bunce 2009-12-21 17:45:43 Re: Minimum perl version supported
Previous Message Heikki Linnakangas 2009-12-21 17:26:16 Re: Streaming replication and non-blocking I/O