Re: pg_upgrade allows itself to be run twice - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: pg_upgrade allows itself to be run twice
Date
Msg-id 20221101130717.GV16921@telsasoft.com
Whole thread Raw
In response to Re: pg_upgrade allows itself to be run twice  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
Responses Re: pg_upgrade allows itself to be run twice
List pgsql-hackers
On Tue, Nov 01, 2022 at 01:54:35PM +0100, Peter Eisentraut wrote:
> On 07.07.22 08:22, Justin Pryzby wrote:
> > > This one comes from NextOID in the control data file after a fresh
> > > initdb, and GetNewObjectId() would enforce that in a postmaster
> > > environment to be FirstNormalObjectId when assigning the first user
> > > OID.  Would you imply an extra step at the end of initdb to update the
> > > control data file of the new cluster to reflect FirstNormalObjectId?
> > I added a call to reset xlog, similar to what's in pg_upgrade.
> > Unfortunately, I don't see an easy way to silence it.
> 
> I think it would be better to update the control file directly instead of
> going through pg_resetwal.  (See src/include/common/controldata_utils.h for
> the required functions.)
> 
> However, I don't know whether we need to add special provisions that guard
> against people using postgres --single in complicated ways.  Many consider
> the single-user mode deprecated outside of initdb use.

Thanks for looking.

One other thing I noticed (by accident!) is that pg_upgrade doesn't
prevent itself from trying to upgrade a cluster on top of itself:

| $ /usr/pgsql-15/bin/initdb -D pg15.dat -N
| $ /usr/pgsql-15/bin/pg_upgrade -D pg15.dat -d pg15.dat -b /usr/pgsql-15/bin
| Performing Upgrade
| ------------------
| Analyzing all rows in the new cluster                       ok
| Freezing all rows in the new cluster                        ok
| Deleting files from new pg_xact                             ok
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Copying old pg_xact to new server
| *failure*
| 
| Consult the last few lines of "pg15.dat/pg_upgrade_output.d/20221101T055916.486/log/pg_upgrade_utility.log" for
>>
| command: cp -Rf "pg15.dat/pg_xact" "pg15.dat/pg_xact" >>
"pg15.dat/pg_upgrade_output.d/20221101T055916.486/log/pg_upgrade_utility.log"2>&1
 
| cp: cannot stat 'pg15.dat/pg_xact': No such file or directory

This may be of little concern since it's upgrading a version to itself, which
only applies to developers.

-- 
Justin



pgsql-hackers by date:

Previous
From: 赵其桂
Date:
Subject: BUG #17663:Connect to the database through jdbc, call the stored procedure containing the rollback statement,the database triggers an assertion, and the database is in recovery mode.
Next
From: Justin Pryzby
Date:
Subject: Re: pg15 inherited stats expressions: cache lookup failed for statistics object