Re: Replication vs. float timestamps is a disaster
Chapman Flack <chap@anastigmatix.net>
From: Chapman Flack <chap@anastigmatix.net>
To: Omar Kilani <omar.kilani@gmail.com>, Andres Freund <andres@anarazel.de>
Cc: "Joshua D. Drake" <jd@commandprompt.com>, Tom Lane <tgl@sss.pgh.pa.us>,
Jim Nasby <Jim.Nasby@bluetreble.com>,
Petr Jelinek <petr.jelinek@2ndquadrant.com>,
Robert Haas <robertmhaas@gmail.com>,
"pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2017-09-07T02:55:26Z
Lists: pgsql-hackers
On 09/06/17 18:33, Omar Kilani wrote: > Is there anything people using float datetimes can do that isn't a > pg_dumpall | pg_restore to do a less painful update? > > We have several TB of data still using float datetimes and I'm trying > to figure out how we can move to 10 (currently on 9.6.x) without > massive amounts of $ in duplicated hardware or downtime. I ran into an analogous issue with endianness of PL/Java-defined datatypes, and ended up devising a procedure [1] for treating the type one way on output and another way on input, and then constructing an UPDATE query that just assigns the column to itself using a function that's essentially identity, but forces the output-input conversion (and doesn't look like a simple identity function to the query optimizer, which otherwise might optimize the whole update away). While the details of that were specific to PL/Java and byte order, something similar might work in your case if you can afford some period, either just before or just after migration, when your normal workload is blocked, long enough to run such updates on your several TB of data. Or if that's too big a chunk of downtime, you might be able to add a column in advance, of some user-defined type the same width as an integer datetime, populate that in advance, migrate, then do a quick catalog switcheroo of the column names and types. I've never done that, so someone else might have comments on its feasibility or the best way of doing it. > the exact crash, but the datetime values were either too small or too > large to fit into the integer datetimes field -- I can retry this if That does seem important to get the details on. If the integer datetime column won't represent your stuff (and the too-large or too-small values are necessary to represent), then some schema change might be necessary. Or, if the outlying values were sentinel values of some kind (I wonder, how else would you even have datetimes outside of the int64 range?), maybe they can be replaced with others that fit. -Chap [1]: https://tada.github.io/pljava/use/byteordermigrate.html
Commits
-
Consistently declare timestamp variables as TimestampTz.
- c29aff959dc6 10.0 landed
-
Remove now-dead code for !HAVE_INT64_TIMESTAMP.
- b9d092c962ea 10.0 landed
-
Remove pg_control's enableIntTimes field.
- d28aafb6dda3 10.0 landed
-
De-support floating-point timestamps.
- b6aa17e0ae36 10.0 landed
-
Make integer_datetimes the default for MSVC even if not mentioned in config.pl.
- fcf053d7829f 8.4.0 cited
-
Enable 64-bit integer datetimes by default, per previous discussion.
- 2169e42bef9d 8.4.0 cited