Re: pg_upgrade should truncate/remove its logs before running

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
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-20 00:05:40
Message-ID: 20220120000540.GG23027@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 19, 2022 at 05:13:18PM +0900, Michael Paquier wrote:
> 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().

I still don't know if it even needs to be configurable.

> - 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.

I'm not sure these restrictions are needed ?

+ outputpath = make_absolute_path(log_opts.basedir);
+ if (path_contains_parent_reference(outputpath))
+ pg_fatal("reference to parent directory not allowed\n");

Besides, you're passing the wrong path here.

> 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.

> + <command>pg_upgrade</command>, and is be removed after a successful

remove "be"

> + if (mkdir(log_opts.basedir, S_IRWXU | S_IRWXG | S_IRWXO))

S_IRWXG | S_IRWXO are useless due to the umask, right ?
Maybe use PG_DIR_MODE_OWNER ?

> + if (mkdir(log_opts.basedir, S_IRWXU | S_IRWXG | S_IRWXO))
> + pg_fatal("could not create directory \"%s\": %m\n", filename_path);
> + if (mkdir(log_opts.dumpdir, S_IRWXU | S_IRWXG | S_IRWXO))
> + pg_fatal("could not create directory \"%s\": %m\n", filename_path);
> + if (mkdir(log_opts.logdir, S_IRWXU | S_IRWXG | S_IRWXO))
> + pg_fatal("could not create directory \"%s\": %m\n", filename_path);

You're printing the wrong var. filename_path is not initialized.

--
Justin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bossart, Nathan 2022-01-20 00:08:07 Re: Document atthasmissing default optimization avoids verification table scan
Previous Message Tom Lane 2022-01-19 22:53:43 Re: Avoid erroring out when unable to remove or parse logical rewrite files to save checkpoint work