Re: BackgroundWorkerInitializeConnection(NULL, ...) doesn't work

From: Andrew Tipton <andrew(at)kiwidrew(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: BackgroundWorkerInitializeConnection(NULL, ...) doesn't work
Date: 2013-08-10 18:30:01
Message-ID: CA+M2pVULSPLFK7JUqf0u1XYX-09x3s6kVUBSD8-zkvrX5hsx1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Aug 10, 2013 at 10:40 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> > Hmm, the intention is that this code path mimics what the autovacuum
> > launcher does to establish its connection. It did work at some point;
> > maybe I broke this before commit. I will give it a look next week.
>
> I'm pretty sure InitPostgres skips a bunch of stuff if
> IsAutoVacuumLauncherProcess(). If you just want to make an environment
> equivalent to that process's, maybe those tests should be replaced with
> "if (dbname == NULL)". But the claim that you have access to shared
> catalogs in this state is still wrong.
>

I've written up a quick proof-of-concept that splits InitPostgres(dbname,
username) into two phases; InitPostgresPhase1() is equivalent to what was
set up prior to the autovacuum launcher bailing out, while
InitPostgresPhase2(dbname, username) contains all of the authentication and
database selection logic.

After calling InitPostgresPhase1(), certain accesses to shared catalogs
*do* work. For example, ClientAuthentication() searches the AUTHNAME
syscache. Later, a call to InitPostgresPhase2() with the dbname and
username brings things to a state where normal SPI can be used. This
behaviour would be quite useful for certain classes of bgworker.

Documentation-wise, it would be helpful to specify precisely what is/isn't
allowed in this "shared catalogs only" mode.

See the attached patch -- which is just a proof-of-concept -- for the
details.

Regards,
Andrew Tipton

Attachment Content-Type Size
bgworker-shared-catalogs-v1.patch application/octet-stream 9.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Gudeman 2013-08-10 19:50:02 Re: pass-through queries to foreign servers
Previous Message Noah Misch 2013-08-10 16:35:39 Re: Proposal: leave a hint when switching logging away from stderr