Thread

Commits

  1. Add missing binary-upgrade guard.

  2. pg_upgrade: Preserve relfilenodes and tablespace OIDs.

  1. pgsql: pg_upgrade: Preserve relfilenodes and tablespace OIDs.

    Robert Haas <rhaas@postgresql.org> — 2022-01-17T19:05:34Z

    pg_upgrade: Preserve relfilenodes and tablespace OIDs.
    
    Currently, database OIDs, relfilenodes, and tablespace OIDs can all
    change when a cluster is upgraded using pg_upgrade. It seems better
    to preserve them, because (1) it makes troubleshooting pg_upgrade
    easier, since you don't have to do a lot of work to match up files
    in the old and new clusters, (2) it allows 'rsync' to save bandwidth
    when used to re-sync a cluster after an upgrade, and (3) if we ever
    encrypt or sign blocks, we would likely want to use a nonce that
    depends on these values.
    
    This patch only arranges to preserve relfilenodes and tablespace
    OIDs. The task of preserving database OIDs is left for another patch,
    since it involves some complexities that don't exist in these cases.
    
    Database OIDs have a similar issue, but there are some tricky points
    in that case that do not apply to these cases, so that problem is left
    for another patch.
    
    Shruthi KC, based on an earlier patch from Antonin Houska, reviewed
    and with some adjustments by me.
    
    Discussion: http://postgr.es/m/CA+TgmoYgTwYcUmB=e8+hRHOFA0kkS6Kde85+UNdon6q7bt1niQ@mail.gmail.com
    
    Branch
    ------
    master
    
    Details
    -------
    https://git.postgresql.org/pg/commitdiff/9a974cbcba005256a19991203583a94b4f9a21a9
    
    Modified Files
    --------------
    src/backend/bootstrap/bootparse.y                  |   3 +-
    src/backend/catalog/heap.c                         |  63 ++++++++++---
    src/backend/catalog/index.c                        |  23 ++++-
    src/backend/commands/tablespace.c                  |  17 +++-
    src/backend/utils/adt/pg_upgrade_support.c         |  44 +++++++++
    src/bin/pg_dump/pg_dump.c                          | 104 ++++++++++++++-------
    src/bin/pg_dump/pg_dumpall.c                       |   3 +
    src/bin/pg_upgrade/info.c                          |  31 +-----
    src/bin/pg_upgrade/pg_upgrade.c                    |  13 +--
    src/bin/pg_upgrade/pg_upgrade.h                    |  10 +-
    src/bin/pg_upgrade/relfilenode.c                   |   6 +-
    src/include/catalog/binary_upgrade.h               |   5 +
    src/include/catalog/catversion.h                   |   2 +-
    src/include/catalog/heap.h                         |   3 +-
    src/include/catalog/pg_proc.dat                    |  16 ++++
    .../spgist_name_ops/expected/spgist_name_ops.out   |  12 ++-
    16 files changed, 247 insertions(+), 108 deletions(-)
    
    
  2. Re: pgsql: pg_upgrade: Preserve relfilenodes and tablespace OIDs.

    Christoph Berg <myon@debian.org> — 2022-02-13T11:51:10Z

    Re: Robert Haas
    > pg_upgrade: Preserve relfilenodes and tablespace OIDs.
    
    > src/bin/pg_dump/pg_dumpall.c                       |   3 +
    
    --- a/src/bin/pg_dump/pg_dumpall.c
    +++ b/src/bin/pg_dump/pg_dumpall.c
    @@ -1066,6 +1066,9 @@ dumpTablespaces(PGconn *conn)
                    /* needed for buildACLCommands() */
                    fspcname = pg_strdup(fmtId(spcname));
    
    +               appendPQExpBufferStr(buf, "\n-- For binary upgrade, must preserve pg_table
    +               appendPQExpBuffer(buf, "SELECT pg_catalog.binary_upgrade_set_next_pg_table
    
    This needs to be guarded with "if (binary_upgrade)".
    
    Error message during a Debian pg_upgradecluster (-m dump) from 14 to 15:
    
    2022-02-13 12:44:01.272 CET [168032] postgres@template1 LOG:  statement: SELECT pg_catalog.binary_upgrade_set_next_pg_tablespace_oid('16408'::pg_catalog.oid);
    2022-02-13 12:44:01.272 CET [168032] postgres@template1 ERROR:  function can only be called when server is in binary upgrade mode
    2022-02-13 12:44:01.272 CET [168032] postgres@template1 STATEMENT:  SELECT pg_catalog.binary_upgrade_set_next_pg_tablespace_oid('16408'::pg_catalog.oid);
    
    Christoph
    
    
    
    
  3. Re: pgsql: pg_upgrade: Preserve relfilenodes and tablespace OIDs.

    Robert Haas <robertmhaas@gmail.com> — 2022-02-17T15:59:37Z

    On Sun, Feb 13, 2022 at 6:51 AM Christoph Berg <myon@debian.org> wrote:
    > Re: Robert Haas
    > > pg_upgrade: Preserve relfilenodes and tablespace OIDs.
    >
    > > src/bin/pg_dump/pg_dumpall.c                       |   3 +
    >
    > --- a/src/bin/pg_dump/pg_dumpall.c
    > +++ b/src/bin/pg_dump/pg_dumpall.c
    > @@ -1066,6 +1066,9 @@ dumpTablespaces(PGconn *conn)
    >                 /* needed for buildACLCommands() */
    >                 fspcname = pg_strdup(fmtId(spcname));
    >
    > +               appendPQExpBufferStr(buf, "\n-- For binary upgrade, must preserve pg_table
    > +               appendPQExpBuffer(buf, "SELECT pg_catalog.binary_upgrade_set_next_pg_table
    >
    > This needs to be guarded with "if (binary_upgrade)".
    
    Right. Sorry about that, and sorry for not responding sooner also. Fix
    pushed now.
    
    -- 
    Robert Haas
    EDB: http://www.enterprisedb.com
    
    
    
    
  4. Re: pgsql: pg_upgrade: Preserve relfilenodes and tablespace OIDs.

    Christoph Berg <myon@debian.org> — 2022-02-18T09:39:09Z

    Re: Robert Haas
    > > This needs to be guarded with "if (binary_upgrade)".
    > 
    > Right. Sorry about that, and sorry for not responding sooner also. Fix
    > pushed now.
    
    Thanks, the 14-15 upgrade test is passing again here.
    
    Christoph