pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #10911: pg_upgrade appears to lose the transaction id epoch
4+ messages / 3 participants
[nested] [flat]
* BUG #10911: pg_upgrade appears to lose the transaction id epoch
@ 2014-07-08 21:17 gregburek@heroku.com
0 siblings, 2 replies; 4+ messages in thread
From: gregburek@heroku.com @ 2014-07-08 21:17 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 10911
Logged by: Greg Burek
Email address: gregburek@heroku.com
PostgreSQL version: 9.0.17
Operating system: Ubuntu Linux
Description:
When upgrading a 9.0.17 db to 9.3.4 via pg_upgrade, the transaction ids
appear to fall backward in time:
From before the upgrade:
=> SELECT txid_snapshot_xmax(txid_current_snapshot());
txid_snapshot_xmax
--------------------
66329538555
(1 row)
After the upgrade:
=> SELECT txid_snapshot_xmax(txid_current_snapshot());
txid_snapshot_xmax
--------------------
1905029395
(1 row)
Looking at pg_control before the upgrade:
$ pg_controldata /database/ | grep -i nextxid
Latest checkpoint's NextXID: 15/1905728256
After the upgrade:
$ pg_controldata /database/ | grep -i nextxid
Latest checkpoint's NextXID: 0/1905029398
This is an unexpected loss of the higher order bits when the upgrade is
performed. Is it possible to preserve the epoch across the upgrade?
thanks,
Greg
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #10911: pg_upgrade appears to lose the transaction id epoch
@ 2014-07-08 22:48 Bruce Momjian <bruce@momjian.us>
parent: gregburek@heroku.com
1 sibling, 1 reply; 4+ messages in thread
From: Bruce Momjian @ 2014-07-08 22:48 UTC (permalink / raw)
To: gregburek@heroku.com; +Cc: pgsql-bugs
On Tue, Jul 8, 2014 at 09:17:05PM +0000, gregburek@heroku.com wrote:
> The following bug has been logged on the website:
>
> Bug reference: 10911
> Logged by: Greg Burek
> Email address: gregburek@heroku.com
> PostgreSQL version: 9.0.17
> Operating system: Ubuntu Linux
> Description:
>
> When upgrading a 9.0.17 db to 9.3.4 via pg_upgrade, the transaction ids
> appear to fall backward in time:
>
> >From before the upgrade:
> => SELECT txid_snapshot_xmax(txid_current_snapshot());
> txid_snapshot_xmax
> --------------------
> 66329538555
> (1 row)
>
> After the upgrade:
>
> => SELECT txid_snapshot_xmax(txid_current_snapshot());
> txid_snapshot_xmax
> --------------------
> 1905029395
> (1 row)
>
> Looking at pg_control before the upgrade:
> $ pg_controldata /database/ | grep -i nextxid
> Latest checkpoint's NextXID: 15/1905728256
>
> After the upgrade:
> $ pg_controldata /database/ | grep -i nextxid
> Latest checkpoint's NextXID: 0/1905029398
>
>
> This is an unexpected loss of the higher order bits when the upgrade is
> performed. Is it possible to preserve the epoch across the upgrade?
Yes, this was reported in April 2014:
http://www.postgresql.org/message-id/CAJ2ymdgTEQ8AETJnQUeEuGjk-OGPWQn_MXgEY5urJpXbJNcohg@mail.gmail....
I will try to fix it for 9.5, due in 2015.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #10911: pg_upgrade appears to lose the transaction id epoch
@ 2014-07-08 23:46 Greg Stark <stark@mit.edu>
parent: gregburek@heroku.com
1 sibling, 0 replies; 4+ messages in thread
From: Greg Stark @ 2014-07-08 23:46 UTC (permalink / raw)
To: gregburek@heroku.com; +Cc: pgsql-bugs
On Tue, Jul 8, 2014 at 10:17 PM, <gregburek@heroku.com> wrote:
> Looking at pg_control before the upgrade:
> $ pg_controldata /database/ | grep -i nextxid
> Latest checkpoint's NextXID: 15/1905728256
>
> After the upgrade:
> $ pg_controldata /database/ | grep -i nextxid
> Latest checkpoint's NextXID: 0/1905029398
You could just do "pg_resetxlog -e 15" to work around the problem
(after a clean shutdown).
--
greg
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #10911: pg_upgrade appears to lose the transaction id epoch
@ 2014-07-09 10:54 Greg Stark <stark@mit.edu>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 4+ messages in thread
From: Greg Stark @ 2014-07-09 10:54 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: gregburek <gregburek@heroku.com>; pgsql-bugs
I think all that's required is to read the epoch at the same time as
the xid and set it at the same time.
I tested this only using the harness so that's a 9.4->9.4 pg_upgrade.
It would be worth testing on older versions but I don't see any
changes to pg_controldata that would be relevant since 8.2 when the
epoch was added.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
pg_upgrade_epoch.diff (text/plain, 3.1K) download
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;
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2014-07-09 10:54 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-07-08 21:17 BUG #10911: pg_upgrade appears to lose the transaction id epoch gregburek@heroku.com
2014-07-08 22:48 ` Bruce Momjian <bruce@momjian.us>
2014-07-09 10:54 ` Greg Stark <stark@mit.edu>
2014-07-08 23:46 ` Greg Stark <stark@mit.edu>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox