Re: pg_upgrade should truncate/remove its logs before running

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pg_upgrade should truncate/remove its logs before running
Date: 2022-01-19 08:13:18
Message-ID: YefIHrNYTNH/PML4@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 11, 2022 at 10:08:13PM -0600, Justin Pryzby wrote:
> I asked about that before. Right now, it'll exit(1) when mkdir fails.
>
> I had written a patch to allow "." by skipping mkdir (or allowing it to fail if
> errno == EEXIST), but it seems like an awfully bad idea to try to make that
> work with rmtree().

So, I have been poking at this patch, and found myself doing a couple
of modifications:
- Renaming of the option from --logdir to --outputdir, as this does
not include only logs. That matches also better with default value
assigned in previous patches, aka pg_upgrade_output.d.
- Convert the output directory to an absolute path when the various
directories are created, and use that for the whole run. pg_upgrade
is unlikely going to chdir(), but I don't really see why we should
just not use an absolute path all the time, set from the start.
- Add some sanity check about the path used, aka no parent reference
allowed and the output path should not be a direct parent of the
current working directory.
- Rather than assuming that "log/" and "dump/" are hardcoded in
various places, save more paths into log_opts.

I have noticed a couple of incorrect things in the docs, and some
other things. It is a bit late here, so I may have missed a couple of
things but I'll look at this stuff once again in a couple of days.

So, what do you think?
--
Michael

Attachment Content-Type Size
v2-0001-pg_upgrade-write-log-files-and-dumps-in-subdir.patch text/x-diff 17.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Nancarrow 2022-01-19 08:19:11 Re: row filtering for logical replication
Previous Message Julien Rouhaud 2022-01-19 08:01:17 Re: Schema variables - new implementation for Postgres 15