On Wed, Apr 23, 2014 at 12:41:41PM -0700, Sergey Konoplev wrote: > On Wed, Apr 23, 2014 at 5:26 AM, Bruce Momjian <br...@momjian.us> wrote: > > Sergey, are you seeing a problem only because you are > > interacting with other systems that didn't reset their epoch? > > I faced this after upgrading clusters with PgQ Skytools3 installed > only. They didn't interact with any other systems.
I have developed the attached patch which causes pg_upgrade to preserve the transaction epoch. I plan to apply this for PG 9.5. -- Bruce Momjian <br...@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. +
diff --git a/contrib/pg_upgrade/controldata.c b/contrib/pg_upgrade/controldata.c new file mode 100644 index cce44ba..9282b8e *** a/contrib/pg_upgrade/controldata.c --- b/contrib/pg_upgrade/controldata.c *************** get_control_data(ClusterInfo *cluster, b *** 209,224 **** } else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL) { ! char *op = strchr(p, '/'); ! if (op == NULL) ! op = strchr(p, ':'); ! if (op == NULL || strlen(op) <= 1) pg_fatal("%d: controldata retrieval problem\n", __LINE__); ! op++; /* removing ':' char */ ! cluster->controldata.chkpnt_nxtxid = str2uint(op); got_xid = true; } else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL) --- 209,228 ---- } else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL) { ! p = strchr(p, ':'); ! if (p == NULL || strlen(p) <= 1) ! pg_fatal("%d: controldata retrieval problem\n", __LINE__); ! p++; /* removing ':' char */ ! cluster->controldata.chkpnt_nxtepoch = str2uint(p); ! ! p = strchr(p, '/'); ! if (p == NULL || strlen(p) <= 1) pg_fatal("%d: controldata retrieval problem\n", __LINE__); ! p++; /* removing '/' char */ ! cluster->controldata.chkpnt_nxtxid = str2uint(p); got_xid = true; } else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL) diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c new file mode 100644 index b6f370f..3b8241b *** a/contrib/pg_upgrade/pg_upgrade.c --- b/contrib/pg_upgrade/pg_upgrade.c *************** copy_clog_xlog_xid(void) *** 420,431 **** /* copy old commit logs to new data dir */ copy_subdir_files("pg_clog"); ! /* 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, new_cluster.pgdata); check_ok(); /* --- 420,435 ---- /* copy old commit logs to new data dir */ copy_subdir_files("pg_clog"); ! /* set the next transaction id and epoch of the new cluster */ ! prep_status("Setting next transaction ID and epoch 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, new_cluster.pgdata); + exec_prog(UTILITY_LOG_FILE, NULL, true, + "\"%s/pg_resetxlog\" -f -e %u \"%s\"", + new_cluster.bindir, old_cluster.controldata.chkpnt_nxtepoch, + new_cluster.pgdata); check_ok(); /* diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h new file mode 100644 index 4b8facf..1ac3394 *** a/contrib/pg_upgrade/pg_upgrade.h --- b/contrib/pg_upgrade/pg_upgrade.h *************** typedef struct *** 190,195 **** --- 190,196 ---- char nextxlogfile[25]; uint32 chkpnt_tli; uint32 chkpnt_nxtxid; + uint32 chkpnt_nxtepoch; uint32 chkpnt_nxtoid; uint32 chkpnt_nxtmulti; uint32 chkpnt_nxtmxoff;
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers