Re: pg_upgrade: fail early if a tablespace dir already exists for new cluster version

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_upgrade: fail early if a tablespace dir already exists for new cluster version
Date: 2020-10-27 02:17:19
Message-ID: 20201027021719.GE4951@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 21, 2020 at 06:54:17AM -0500, Justin Pryzby wrote:
> On Tue, Oct 20, 2020 at 09:17:22PM -0400, Tom Lane wrote:
> > Justin Pryzby <pryzby(at)telsasoft(dot)com> writes:
> > > I wonder if pg_upgrade should try to rmdir() the tablespace dirs before
> > > restoring global objects, allowing it to succeed, rather than just "failing
> > > early".
> >
> > I'm a little confused about that. If the directories aren't empty,
> > that will fail,
>
> You mean rmdir() will fail, returning -1, which my patch will ignore, and the
> pg_upgrade will fail, same as it would have before. The goal of the patch is
> to improve the "empty" case, only.
>
> > but if they are, shouldn't the upgrade just work?
>
> It fails in "Restoring global objects", which runs "CREATE TABLESPACE".
> | errmsg("directory \"%s\" already in use as a tablespace",
>
> I considered the possibility of changing that, but it seems like this is
> specific to pg_upgrade. I wouldn't want to change the core server just for
> that, and it has a good reason for failing in that case:
> | * The creation of the version directory prevents more than one tablespace
> | * in a single location.

I think it is best to report an error --- pg_upgrade rarely tries to fix
things because that adds complexity, and perhaps bugs.

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EnterpriseDB https://enterprisedb.com

The usefulness of a cup is in its emptiness, Bruce Lee

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2020-10-27 03:21:01 Re: Resetting spilled txn statistics in pg_stat_replication
Previous Message Julien Rouhaud 2020-10-27 02:11:25 Re: Commitfest 2020-11