diff --git a/contrib/pg_upgrade/controldata.c b/contrib/pg_upgrade/controldata.c index 13c95a2..3d53b4f 100644 --- a/contrib/pg_upgrade/controldata.c +++ b/contrib/pg_upgrade/controldata.c @@ -37,6 +37,7 @@ get_control_data(ClusterInfo *cluster, bool live_check) char bufin[MAX_STRING]; FILE *output; char *p; + bool got_xidepoch = false; bool got_xid = false; bool got_oid = false; bool got_nextxlogfile = false; @@ -233,10 +234,23 @@ get_control_data(ClusterInfo *cluster, bool live_check) } else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL) { - char *op = strchr(p, '/'); + char *op = strchr(p, ':'); + char *op_slash = strchr(p, '/'); - if (op == NULL) - op = strchr(p, ':'); + /* The epoch has been here since 8.2 so we could probably make + * this mandatory but it's not hard to deal with it missing */ + if (op_slash != NULL) + { + /* epoch is present and xid is something like 0/100 */ + if (op == NULL || strlen(op) <= 1) + pg_fatal("%d: controldata retrieval problem\n", __LINE__); + + op++; /* removing ':' char */ + cluster->controldata.chkpnt_nxtxidepoch = str2uint(op); + got_xidepoch = true; + + op = op_slash; + } if (op == NULL || strlen(op) <= 1) pg_fatal("%d: controldata retrieval problem\n", __LINE__); @@ -487,7 +501,7 @@ get_control_data(ClusterInfo *cluster, bool live_check) } /* verify that we got all the mandatory pg_control data */ - if (!got_xid || !got_oid || + if (!got_xidepoch || !got_xid || !got_oid || !got_multi || !got_mxoff || (!got_oldestmulti && cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) || @@ -501,6 +515,9 @@ get_control_data(ClusterInfo *cluster, bool live_check) "The %s cluster lacks some required control information:\n", CLUSTER_NAME(cluster)); + if (!got_xidepoch) + pg_log(PG_REPORT, " checkpoint next XID Epoch\n"); + if (!got_xid) pg_log(PG_REPORT, " checkpoint next XID\n"); diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c index 3e97b66..b81d8c4 100644 --- a/contrib/pg_upgrade/pg_upgrade.c +++ b/contrib/pg_upgrade/pg_upgrade.c @@ -423,8 +423,10 @@ copy_clog_xlog_xid(void) /* set the next transaction id of the new cluster */ prep_status("Setting next transaction ID for new cluster"); exec_prog(UTILITY_LOG_FILE, NULL, true, - "\"%s/pg_resetxlog\" -f -x %u \"%s\"", - new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid, + "\"%s/pg_resetxlog\" -f -e %u -x %u \"%s\"", + new_cluster.bindir, + old_cluster.controldata.chkpnt_nxtxidepoch, + old_cluster.controldata.chkpnt_nxtxid, new_cluster.pgdata); check_ok(); diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h index 0410b02..c29c1cf 100644 --- a/contrib/pg_upgrade/pg_upgrade.h +++ b/contrib/pg_upgrade/pg_upgrade.h @@ -189,6 +189,7 @@ typedef struct uint32 cat_ver; char nextxlogfile[25]; uint32 chkpnt_tli; + uint32 chkpnt_nxtxidepoch; uint32 chkpnt_nxtxid; uint32 chkpnt_nxtoid; uint32 chkpnt_nxtmulti;