pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Payal Singh <payals1@umbc.edu>
Cc: Craig Ringer <ringerc@ringerc.id.au>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Problem with pg_upgrade
Date: Thu, 5 Jul 2012 23:37:00 -0400
Message-ID: <20120706033700.GB15538@momjian.us> (raw)
In-Reply-To: <1316.1341527311@sss.pgh.pa.us>
References: <CAK4ounw9CmG0_vUwwtsr2QXXhOJJ8E9g5mw-vuXAo57KSTQFDg@mail.gmail.com>
	<4FF5BD8A.5010307@ringerc.id.au>
	<CAK4ounyW7oGprZuVRv8tfVROTimeY49yL4HRcq+Yqnt0P-8PXw@mail.gmail.com>
	<1316.1341527311@sss.pgh.pa.us>

On Thu, Jul 05, 2012 at 06:28:31PM -0400, Tom Lane wrote:
> Payal Singh <payals1@umbc.edu> writes:
> > On Thu, Jul 5, 2012 at 12:15 PM, Craig Ringer <ringerc@ringerc.id.au> wrote:
> >> If you start 9.1 on a copy of the backup then cleanly stop it again, does
> >> pg_upgrade then run?
> 
> > Thank you. That worked.
> 
> ISTM that pg_upgrade should check that the old cluster was shut down
> cleanly, ie pg_control has state = "shut down".  AFAICT from some
> testing, it currently only checks that there is no postmaster.pid file,
> which is easily bypassed by users who might not realize that it's not
> safe to run pg_upgrade against a filesystem backup.

I am confused.  pg_upgrade certainly starts/stops the old and new server
with pg_ctl before copying any files --- isn't that sufficent?

> BTW, I also noticed while trying to test this that pg_upgrade is
> currently completely broken for the case of taking PGDATAOLD or
> PGDATANEW from the environment rather than switches.  This is because
> the existing coding in option.c fails to set up the "pgconfig" fields
> in such cases.

Oh, good catch.  Fixed with the attached patch, and backpatched to 9.2.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +

Attachments:

pg_upgrade.diff (text/x-diff, 2.9K) download diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c new file mode 100644 index 43394a0..960fcda *** a/contrib/pg_upgrade/option.c --- b/contrib/pg_upgrade/option.c *************** *** 21,27 **** static void usage(void); ! static void check_required_directory(char **dirpath, char *envVarName, char *cmdLineOption, char *description); --- 21,27 ---- static void usage(void); ! static void check_required_directory(char **dirpath, char **configpath, char *envVarName, char *cmdLineOption, char *description); *************** parseCommandLine(int argc, char *argv[]) *** 203,216 **** } /* Get values from env if not already set */ ! check_required_directory(&old_cluster.bindir, "PGBINOLD", "-b", "old cluster binaries reside"); ! check_required_directory(&new_cluster.bindir, "PGBINNEW", "-B", "new cluster binaries reside"); ! check_required_directory(&old_cluster.pgdata, "PGDATAOLD", "-d", ! "old cluster data resides"); ! check_required_directory(&new_cluster.pgdata, "PGDATANEW", "-D", ! "new cluster data resides"); } --- 203,216 ---- } /* Get values from env if not already set */ ! check_required_directory(&old_cluster.bindir, NULL, "PGBINOLD", "-b", "old cluster binaries reside"); ! check_required_directory(&new_cluster.bindir, NULL, "PGBINNEW", "-B", "new cluster binaries reside"); ! check_required_directory(&old_cluster.pgdata, &old_cluster.pgconfig, ! "PGDATAOLD", "-d", "old cluster data resides"); ! check_required_directory(&new_cluster.pgdata, &new_cluster.pgconfig, ! "PGDATANEW", "-D", "new cluster data resides"); } *************** or\n"), old_cluster.port, new_cluster.po *** 284,298 **** * user hasn't provided the required directory name. */ static void ! check_required_directory(char **dirpath, char *envVarName, ! char *cmdLineOption, char *description) { if (*dirpath == NULL || strlen(*dirpath) == 0) { const char *envVar; if ((envVar = getenv(envVarName)) && strlen(envVar)) *dirpath = pg_strdup(envVar); else pg_log(PG_FATAL, "You must identify the directory where the %s.\n" "Please use the %s command-line option or the %s environment variable.\n", --- 284,303 ---- * user hasn't provided the required directory name. */ static void ! check_required_directory(char **dirpath, char **configpath, ! char *envVarName, char *cmdLineOption, ! char *description) { if (*dirpath == NULL || strlen(*dirpath) == 0) { const char *envVar; if ((envVar = getenv(envVarName)) && strlen(envVar)) + { *dirpath = pg_strdup(envVar); + if (configpath) + *configpath = pg_strdup(envVar); + } else pg_log(PG_FATAL, "You must identify the directory where the %s.\n" "Please use the %s command-line option or the %s environment variable.\n",

view thread (12+ messages)  latest in thread

Message-ID: <20120706033700.GB15538@momjian.us>
Permalink:  ../20120706033700.GB15538@momjian.us/
Also on:    postgresql.org/message-id/20120706033700.GB15538@momjian.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: bruce@momjian.us, tgl@sss.pgh.pa.us, payals1@umbc.edu, ringerc@ringerc.id.au
  Subject: Re: Problem with pg_upgrade
  In-Reply-To: <20120706033700.GB15538@momjian.us>
  References: <CAK4ounw9CmG0_vUwwtsr2QXXhOJJ8E9g5mw-vuXAo57KSTQFDg@mail.gmail.com> <4FF5BD8A.5010307@ringerc.id.au> <CAK4ounyW7oGprZuVRv8tfVROTimeY49yL4HRcq+Yqnt0P-8PXw@mail.gmail.com> <1316.1341527311@sss.pgh.pa.us> <20120706033700.GB15538@momjian.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