pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: timo.gurr@gmail.com
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: BUG #8532: postgres fails to start with timezone-data >=2013e
Date: Mon, 21 Oct 2013 16:31:08 +0300
Message-ID: <52652C9C.1080306@vmware.com> (raw)
In-Reply-To: <E1VWO2i-0003Fk-TC@wrigleys.postgresql.org>
References: <E1VWO2i-0003Fk-TC@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 16.10.2013 13:09, timo.gurr@gmail.com wrote:
> The following bug has been logged on the website:
>
> Bug reference:      8532
> Logged by:          Timo Gurr
> Email address:      timo.gurr@gmail.com
> PostgreSQL version: 9.1.10
> Operating system:   Gentoo Linux (64bit, kernel 3.11.0, glibc 2.17)
> Description:
>
>> From the timezone-data NEWS:
>
>
> Release 2013e - 2013-09-19 23:50:04 -0700
>    Changes affecting the build procedure
>      When building the 'posix' or 'right' subdirectories, if the
>      subdirectory would be a copy of the default subdirectory, it is
>      now made a symbolic link if that is supported.  This saves about
>      2 MB of file system space.
>
>
> This change breaks postgres, so then having a recent enough timezone-data
> package installed on the system postgres fails to start:
>
>
> /var/lib/postgresql/9.1/data/postmaster.log
> FATAL:  exceeded maxAllocatedDescs (16) while trying to open directory
> "/usr/share/zoneinfo"
>
>
> # ls -la /usr/share/zoneinfo/
> lrwxrwxrwx  1 root root     1 Oct 16 12:06 posix ->  .
>
>
> Gentoo has a downstream bugreport about it stating the problem should be
> fixed on the postgres side:
> https://bugs.gentoo.org/show_bug.cgi?id=486556

When you download the vanilla timezone sources and install, the 
directory layout looks different:

~/tz ((2013e))$ make -s install DESTDIR=foo TZDIR=/usr/share/zoneinfo
ar: creating foo/usr/local/lib/libtz.a
mkdir: cannot create directory 'foo/usr/local': File exists
mkdir: cannot create directory 'foo/usr/local': File exists
~/tz ((2013e))$ ls -l foo/usr/share/
total 8
drwxr-xr-x 19 heikki heikki 4096 Oct 21 12:48 zoneinfo
drwxr-xr-x 19 heikki heikki 4096 Oct 21 12:48 zoneinfo-leaps
lrwxrwxrwx  1 heikki heikki    8 Oct 21 12:48 zoneinfo-posix -> zoneinfo

There is no 'posix' symlink inside 'zoneinfo'. The zoneinfo git 
repository says that this layout was adopted in the upstream library a 
long time ago:

> commit 77e3dfe1a7b7e14e9f252fc628a5d405c35b6444
> Author: Arthur David Olson <ado@elsie>
> Date:   Mon May 25 13:04:43 1998 -0400
>
>     Eggert mod
>
>     SCCS-file: Makefile
>     SCCS-SID: 7.66
>
> diff --git a/Makefile b/Makefile
> index a8d8067..ae414b4 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -293,10 +293,19 @@ posix_only:	zic $(TDATA)
>  right_only:	zic leapseconds $(TDATA)
>  		$(ZIC) -y $(YEARISTYPE) -d $(TZDIR) -L leapseconds $(TDATA)
>
> +# In earlier versions of this makefile, the other two directories were
> +# subdirectories of $(TZDIR).  However, this led to configuration errors.
> +# For example, with posix_right under the earlier scheme,
> +# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
> +# but gmtime without leap seconds, which led to problems with applications
> +# like sendmail that subtract gmtime from localtime.
> +# Therefore, the other two directories are now siblings of $(TZDIR).
> +# You must replace all of $(TZDIR) to switch from not using leap seconds
> +# to using them, or vice versa.
>  other_two:	zic leapseconds $(TDATA)
> -		$(ZIC) -y $(YEARISTYPE) -d $(TZDIR)/posix -L /dev/null $(TDATA)
> +		$(ZIC) -y $(YEARISTYPE) -d $(TZDIR)-posix -L /dev/null $(TDATA)
>  		$(ZIC) -y $(YEARISTYPE) \
> -			-d $(TZDIR)/right -L leapseconds $(TDATA)
> +			-d $(TZDIR)-right -L leapseconds $(TDATA)
>
>  posix_right:	posix_only other_two
>

However, Gentoo seems to carry a patch that reverts that commit:

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-libs/timezone-data/files/timezone-data-2...

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.

Gentoo isn't alone in doing this: my Debian system has a similar layout, 
with 'posix' directory inside /usr/share/zoneinfo, rather than as a 
sibling. I'm not sure if Debian will have this problem, though. If I'm 
reading the debian rules file correctly, they're not relying on the 
upstream "make install" to create the 'posix' and 'right' directories, 
but calls zic directly.

In summary, I'd call this a packaging bug.

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.

- Heikki


-- 
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: <52652C9C.1080306@vmware.com>
Permalink:  ../52652C9C.1080306@vmware.com/
Also on:    postgresql.org/message-id/52652C9C.1080306@vmware.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 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: hlinnakangas@vmware.com, timo.gurr@gmail.com
  Subject: Re: BUG #8532: postgres fails to start with timezone-data >=2013e
  In-Reply-To: <52652C9C.1080306@vmware.com>
  References: <E1VWO2i-0003Fk-TC@wrigleys.postgresql.org> <52652C9C.1080306@vmware.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