-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MoveTables: adjust datetimes when importing from non-UTC sources into UTC targets #10102
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The actual code change is some 10 lines, with a gazillion changes on top just to support the new information and to validate vdiff
.
@shlomi-noach, I just realized that we are only supporting the forward migration of data at the moment: reverse replication streams are not setup correctly. Many users do like to run reverse streams into existing setups for a while before switching over entirely to Vitess. So we will need to add a It is a simple change and I had instinctively started with that design even for forward workflows, but thought I was over-designing since we wanted to fix the target to UTC. Once this is implemented it means we can intrinsically support any time zone on source and target sides, but for now MoveTables will only allow the source time zone to be specified and default target time zone to UTC. |
Oh that's right! Sounds good. |
ed9f3d7
to
a1c088f
Compare
Added support for reverse workflows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it LGTM. Nice work on this!
I do think that we should add a test for when an invalid named time zone is specified for the flag, and I think that we should check for that and handle it in the command too.
Let's chat about it on Slack if I missed or misunderstood anything.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @rohit-nayak-ps! I had one specific request, we can clear that one up quickly and then it's good!
28cb2c6
to
755d6d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for hanging in there with me. ❤️
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
…ble plan builder and convert datetime columns if option is provided. e2e test demonstrates this works. VDiff needs to be modified Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
78a8e13
to
e60738d
Compare
Description
MoveTables
is a common technique used to import data into Vitess. Many users run their MySQL servers using theSYSTEM
timezone and/or storingdatetime
fields in local time. Vitess recommends running clusters in UTC, expecting apps to do the conversion to local time using, for example,convert_tz()
in queries,:application_timezone
in the mysql2 driver, or setting@@session.time_zone
if using onlytimestamp
data types.Datetime values are usually stored using
datetime
ortimestamp
columns. MySQL storestimestamp
s internally using UTC, butdatetime
is effectively a string value which is timezone-unaware.If you import data from a server running in a different time zone into a server using UTC.
timestamp
s will be correctly reproduced but datetimes can result in bugs which are difficult to track and fix. One such scenario is:current_timestamp
as the default.This PR adds an option to MoveTables to specify a
-source_time_zone
. If specified, VReplication will convertdatetime
values into UTC before storing it.Changes Made
User Facing
-source_time_zone
added to MoveTables.Workflow Show
now displays SourceTimeZoneInternal
SourceTimeZone
has been added toBinlogSource
(whose proto is stored in thesource
column of_vt.vreplication
).BinlogSource.SourceTimeZone
to correctly compare datetimes.TestMoveTablesTZ
reflects the supported use caseNot supported
datetime
data typesTodos
Related Issue(s)
Checklist