pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Heikki Linnakangas <hlinnakangas@vmware.com>
Cc: timo.gurr@gmail.com
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: BUG #8532: postgres fails to start with timezone-data >=2013e
Date: Sun, 10 Nov 2013 20:57:15 -0500
Message-ID: <10389.1384135035@sss.pgh.pa.us> (raw)
In-Reply-To: <52652C9C.1080306@vmware.com>
References: <E1VWO2i-0003Fk-TC@wrigleys.postgresql.org>
	<52652C9C.1080306@vmware.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Heikki Linnakangas <hlinnakangas@vmware.com> writes:
> On 16.10.2013 13:09, timo.gurr@gmail.com wrote:
>> # ls -la /usr/share/zoneinfo/
>> lrwxrwxrwx  1 root root     1 Oct 16 12:06 posix ->  .

> That patch conflicts with the upstream Makefile change to create the 
> "other" directory as a symlink. With the vanilla zoneinfo sources, the 
> symlink is fine, but by putting 'posix' inside 'zoneinfo' directory, the 
> Gentoo-specific patch creates that infinite recursion situation.

I agree, this is an egregious packaging bug.  Programs should be able to
enumerate the timezone database without running into infinite recursion.

> That said, the error message you get from PostgreSQL isn't very 
> user-friendly. There is a check on recursion depth in the timezone 
> traversing code, but apparently it trips on another limit first, on the 
> number of directory handles that can be open at a time.

> Also, I don't understand how this is preventing PostgreSQL from starting 
> up. AFAICS the traversal of the timezones is only done when you query 
> the pg_timezone_names system view. Not at startup.

Keep in mind that in 9.2 and later, we traverse the timezone tree in
initdb to set the timezone GUC.  Before that, we would do it in postmaster
startup --- but only if we didn't find a TZ variable in the environment
nor a setting in postgresql.conf.

I tried to reproduce this in HEAD by inserting a bogus symlink into
the installation timezone tree and running initdb.  Curiously, it did not
fail, though initdb took rather longer than expected.  After debugging
I realized that scan_available_timezones() was in fact recursing deeper
and deeper into the posix/posix/posix/posix/... nest --- but eventually,
the constructed filename exceeds MAXPGPATH, and we truncate it, and
fail to open the truncated filename, so the recursion stops.
(And you don't get any error message, unless you compiled with
DEBUG_IDENTIFY_TIMEZONE.)  Also, the implementation in initdb isn't
vulnerable to running out of descriptors because it sucks in an entire
directory at a time with pgfnames(), so it doesn't have a descriptor
open when it recurses.  (Instead, it consumes a lot of memory --- but
it looks like still only about 10MB worth.)

In 9.1, the reason you see the maxAllocatedDescs complaint is that the
postmaster tries to set the timezone before it's increased max_safe_fds,
so it won't increase maxAllocatedDescs past 16.  Enumerating the zones
in a regular backend would almost certainly report the timezone recursion
error instead.  (I am kinda wondering why maxAllocatedDescs == 16 isn't
enough to get to a recursion error at depth 10, but maybe there are a
few other files open when this happens.)

Basically, I don't think we should do anything about this.  Packaging
the TZ database like that is completely brain-dead, and Gentoo needs
to fix it, not tell us we're doing something wrong.  The consequences
of their bug aren't too serious in modern PG releases anyway.  (Given
what I know of their packaging policies, I have to wonder why they're
still shipping 9.1 rather than the bleeding edge...)

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (4+ messages)  latest in thread

Message-ID: <10389.1384135035@sss.pgh.pa.us>
Permalink:  ../10389.1384135035@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10389.1384135035@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, hlinnakangas@vmware.com, timo.gurr@gmail.com
  Subject: Re: BUG #8532: postgres fails to start with timezone-data >=2013e
  In-Reply-To: <10389.1384135035@sss.pgh.pa.us>
  References: <E1VWO2i-0003Fk-TC@wrigleys.postgresql.org> <52652C9C.1080306@vmware.com> <10389.1384135035@sss.pgh.pa.us>

* 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