Re: pg_dump/pg_restore seem broken on hamerkop

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: pg_dump/pg_restore seem broken on hamerkop
Date: 2014-10-26 23:56:20
Message-ID: 20141026235620.GT1791@alvin.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tatsuo Ishii wrote:
> > Buildfarm member hamerkop has been failing in the pg_upgrade regression
> > test for the last several days. The problem looks like this:
> >
> > command: "C:/buildfarm/build_root/HEAD/pgsql.build/contrib/pg_upgrade/tmp_check/install/bin/pg_restore" --port 50432 --username "Administrator" --exit-on-error --verbose --dbname "postgres" "pg_upgrade_dump_12145.custom" >> "pg_upgrade_dump_12145.log" 2>&1
> > pg_restore: connecting to database for restore
> > pg_restore: [archiver (db)] Error while INITIALIZING:
> > pg_restore: [archiver (db)] could not execute query: ERROR: invalid byte sequence for encoding "UTF8": 0x93
> >
> > I can't help noticing that this started immediately after commit
> > 0eea804 "pg_dump: Reduce use of global variables". No idea why
> > the issue is only showing up on this one animal.
>
> I guess one of possibilities is there's garbage in memory which is
> related to restore the process.

That sounds most likely. The complete error in hamerkop's log is:

pg_restore: connecting to database for restore
pg_restore: [archiver (db)] Error while INITIALIZING:
pg_restore: [archiver (db)] could not execute query: ERROR: invalid byte sequence for encoding "UTF8": 0x93
Command was: -- Started on 2014-10-26 03:06:00 “Œ‹ž (•W€Žž)

This "Started on" business comes from pg_backup_archiver.c, which has

if (AH->public.verbose)
dumpTimestamp(AH, "Started on", AH->createDate);

where dumpTimestamp is

/*
* dumpTimestamp
*/
static void
dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim)
{
char buf[64];

if (strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %z", localtime(&tim)) != 0)
ahprintf(AH, "-- %s %s\n\n", msg, buf);
}

So this seems related to the %z part of the strftime() call. I have no
explanation for this failure ATM; maybe pg_restore is failing to set the
locale properly? I also notice pg_restore.c previously included
pg_backup_archiver.h (which in turn includes <time.h>); strftime
requires <time.h> so maybe this is causing a problem, but since
pg_restore.c itself is not calling strftime, I don't see how this would
be related.

[Some more code and git-log reading later] I see that the %z is a very
recent addition: it only got there as of commit ad5d46a449, of September
5th ... and now I also see that hamerkop's last green run before the
failure, on Oct 13rd, did *not* include the pg_upgrade check. So I'm
thinking this was broken much earlier than 0eea804.

--
Álvaro Herrera 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-10-27 00:11:49 Re: pg_dump/pg_restore seem broken on hamerkop
Previous Message Tom Lane 2014-10-26 23:20:14 Re: pset_quoted_string is broken