Skip to content

Commit 022aea3

Browse files
committed
pg_upgrade: preserve the timestamp epoch
This is useful for replication tools like Slony and Skytools. This is a backpatch of a74a4aa. Report by Sergey Konoplev Backpatch through 9.3
1 parent b8b4124 commit 022aea3

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

contrib/pg_upgrade/controldata.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,20 @@ get_control_data(ClusterInfo *cluster, bool live_check)
233233
}
234234
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
235235
{
236-
char *op = strchr(p, '/');
236+
p = strchr(p, ':');
237+
238+
if (p == NULL || strlen(p) <= 1)
239+
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
237240

238-
if (op == NULL)
239-
op = strchr(p, ':');
241+
p++; /* removing ':' char */
242+
cluster->controldata.chkpnt_nxtepoch = str2uint(p);
240243

241-
if (op == NULL || strlen(op) <= 1)
244+
p = strchr(p, '/');
245+
if (p == NULL || strlen(p) <= 1)
242246
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
243247

244-
op++; /* removing ':' char */
245-
cluster->controldata.chkpnt_nxtxid = str2uint(op);
248+
p++; /* removing '/' char */
249+
cluster->controldata.chkpnt_nxtxid = str2uint(p);
246250
got_xid = true;
247251
}
248252
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)

contrib/pg_upgrade/pg_upgrade.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,16 @@ copy_clog_xlog_xid(void)
422422
/* copy old commit logs to new data dir */
423423
copy_subdir_files("pg_clog");
424424

425-
/* set the next transaction id of the new cluster */
426-
prep_status("Setting next transaction ID for new cluster");
425+
/* set the next transaction id and epoch of the new cluster */
426+
prep_status("Setting next transaction ID and epoch for new cluster");
427427
exec_prog(UTILITY_LOG_FILE, NULL, true,
428428
"\"%s/pg_resetxlog\" -f -x %u \"%s\"",
429429
new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
430430
new_cluster.pgdata);
431+
exec_prog(UTILITY_LOG_FILE, NULL, true,
432+
"\"%s/pg_resetxlog\" -f -e %u \"%s\"",
433+
new_cluster.bindir, old_cluster.controldata.chkpnt_nxtepoch,
434+
new_cluster.pgdata);
431435
check_ok();
432436

433437
/*

contrib/pg_upgrade/pg_upgrade.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ typedef struct
190190
char nextxlogfile[25];
191191
uint32 chkpnt_tli;
192192
uint32 chkpnt_nxtxid;
193+
uint32 chkpnt_nxtepoch;
193194
uint32 chkpnt_nxtoid;
194195
uint32 chkpnt_nxtmulti;
195196
uint32 chkpnt_nxtmxoff;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy