Re: %d in log_line_prefix doesn't work for bg/autovacuum workers

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Christoph Berg <cb(at)df7cb(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: %d in log_line_prefix doesn't work for bg/autovacuum workers
Date: 2014-05-17 21:19:30
Message-ID: 20140517211930.GA10899@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-05-17 23:10:42 +0200, Christoph Berg wrote:
> > Given that there haven't been complaints in the past ten years about how
> > you can't rename an active database, I'm OK personally with locking this
> > down forever. But I wonder if anyone wants to argue the contrary.
>
> Fwiw, we ran into exactly this question yesterday during a customer
> training session. Their plan is to provide a database with updated
> content every few hours, so their idea was to populate db_new, rename
> db to db_old, rename db_new to db, and eventually drop db_old from
> cron. This fails when sessions are connected to db. Surprisingly, it
> actually works if you do the db renaming on a master server, but let
> the (anyway readonly) client connect to a streaming slave. (On 9.2,
> didn't test 9.4.)

Ick. That's a bug imo. It should cause a recovery conflict disconnecting
active sessions with force...
I'd very much discourage your users from relying on this. Independent of
my complaint about %d this isn't something that's supported and it won't
change unless somebody puts non-neglegible resources into it.

> We also looked into the confused-client problem, but
> current_database() reports the new name correctly, and hence figured
> there shouldn't be any problem with this approach, despite it
> obviously being slightly out of spec because of the dependency on
> running on a SR slave.

At the very least log_line_prefix's %d will log the wrong thing.

> I even jokingly noted that this will probably
> get fixed in one or the other direction once I mention it on the
> mailing list ;)

Heh.

Greetings,

Andres Freund

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-05-17 21:23:58 Re: btree_gist macaddr valgrind woes
Previous Message Christoph Berg 2014-05-17 21:16:16 Re: %d in log_line_prefix doesn't work for bg/autovacuum workers