pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bossart, Nathan <bossartn@amazon.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: Stephen Frost <sfrost@snowman.net>
Cc: Magnus Hagander <magnus@hagander.net>
Subject: Re: archive modules
Date: Tue, 2 Nov 2021 16:39:48 +0000
Message-ID: <ED59AEC5-AE88-41CF-BC5E-34B32722A398@amazon.com> (raw)
In-Reply-To: <CA+TgmobM+uOL+qiuv0xDep+KeV9wkdCbkFnSeaDtaHyostqj1g@mail.gmail.com>
References: <668D2428-F73B-475E-87AE-F89D67942270@amazon.com>
	<e437bf15-9917-7b78-f326-90b9c57ba8ae@oss.nttdata.com>
	<YYDLd7vsmrYHC+9C@paquier.xyz>
	<CA+TgmoYx1hhvmm4BLSJ15XM3ALrM6wyQ4XTesgtdgofSkHXqhA@mail.gmail.com>
	<9970BE22-2BC3-49C9-AD68-51983118B701@amazon.com>
	<CA+TgmoZfft6oCGYP3agn_Y_v3KPBauBZG60tfTm=_kke+xfvaw@mail.gmail.com>
	<EEE89F96-BF41-4DE5-A0EA-8C8BD23BDEE5@amazon.com>
	<CA+TgmobM+uOL+qiuv0xDep+KeV9wkdCbkFnSeaDtaHyostqj1g@mail.gmail.com>

On 11/2/21, 9:17 AM, "Robert Haas" <robertmhaas@gmail.com> wrote:
> On Tue, Nov 2, 2021 at 12:10 PM Bossart, Nathan <bossartn@amazon.com> wrote:
>> Yes, that seems doable.  My point is that I've intentionally chosen to
>> preload the libraries at the moment so that it's possible to define
>> PGC_POSTMASTER GUCs and to use RegisterBackgroundWorker().  If we
>> think that switching archive modules without restarting is more
>> important, I believe we will need to take on a few restrictions.
>
> I guess I'm failing to understand what the problem is. You can set
> GUCs of the form foo.bar in postgresql.conf anyway, right?

I must not be explaining it well, sorry.  I'm mainly thinking about
the following code snippets.

In guc.c:
        /*
         * Only allow custom PGC_POSTMASTER variables to be created during shared
         * library preload; any later than that, we can't ensure that the value
         * doesn't change after startup.  This is a fatal elog if it happens; just
         * erroring out isn't safe because we don't know what the calling loadable
         * module might already have hooked into.
         */
        if (context == PGC_POSTMASTER &&
                !process_shared_preload_libraries_in_progress)
                elog(FATAL, "cannot create PGC_POSTMASTER variables after startup");

In bgworker.c:
        if (!process_shared_preload_libraries_in_progress &&
                strcmp(worker->bgw_library_name, "postgres") != 0)
        {
                if (!IsUnderPostmaster)
                        ereport(LOG,
                                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                         errmsg("background worker \"%s\": must be registered in shared_preload_libraries",
                                                        worker->bgw_name)));
                return;
        }

You could still introduce GUCs in _PG_init(), but they couldn't be
defined as PGC_POSTMASTER.  Also, you could still use
RegisterDynamicBackgroundWorker() to register a background worker, but
you couldn't use RegisterBackgroundWorker().  These might be
acceptable restrictions if swapping archive libraries on the fly seems
more important, but I wanted to bring that front and center to make
sure everyone understands the tradeoffs.

It's also entirely possible I'm misunderstanding something here...

Nathan



view thread (102+ messages)  latest in thread

Message-ID: <ED59AEC5-AE88-41CF-BC5E-34B32722A398@amazon.com>
Permalink:  ../ED59AEC5-AE88-41CF-BC5E-34B32722A398@amazon.com/
Also on:    postgresql.org/message-id/ED59AEC5-AE88-41CF-BC5E-34B32722A398@amazon.com

 · 

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: pgsql-hackers@postgresql.org
  Cc: bossartn@amazon.com, robertmhaas@gmail.com, michael@paquier.xyz, masao.fujii@oss.nttdata.com, sfrost@snowman.net, magnus@hagander.net
  Subject: Re: archive modules
  In-Reply-To: <ED59AEC5-AE88-41CF-BC5E-34B32722A398@amazon.com>

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

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