-
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
VReplication Workflow: manage SQL_MODE as MySQL does in mysqldump #9505
Conversation
b651876
to
f878171
Compare
ec8483a
to
d9f821f
Compare
2e5c838
to
356b44e
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.
Overall looks good! A few changes requested (bugfixes) and a couple suggestions (coding style, change at your discretion), see inline.
356b44e
to
f41a25f
Compare
THANK YOU for the great ideas/suggestions! ❤️ I've implemented all of them now. |
ead366a
to
0d3a62e
Compare
…n to the target Signed-off-by: Rohit Nayak <[email protected]>
We follow the same model that MySQL uses with mysqldump: 1. Save the original sql_mode in use 2. Set it to a permissive mode that will allow us to recreate any objects from the source 3. Reset the sql_mode back to the original value Add/update tests for permissive sql_mode in vrepl unit tests and e2e tests. Signed-off-by: Matt Lord <[email protected]>
0d3a62e
to
7dc59b0
Compare
⬆️ (rebased on |
Description
In VReplication we are tasked with taking a single logical table from a source and creating a logical copy of that on a target (typically partitioned/sharded in different ways on each side). In order to do this, we need to relax the
sql_mode
in order to ensure we can do so (the source could have had anysql_mode
configured when the data was created).Given that VReplication logically implements the same functionality in Vitess that
mysqldump
does in MySQL — generating SQL statements from a source that allow you to recreate database objects on a target — it makes sense for us to try and mimic MySQL (Vitess provides a single logical MySQL database as akeyspace
). And whatmysqldump
does is this:So it saves the old
sql_mode
, sets it to'NO_AUTO_VALUE_ON_ZERO'
in the session used to recreate the database objects (CREATE
,INSERT
), then at the end it sets thesql_mode
back to what it was (see source).We can do the same thing in VReplication. That is what this PR sets out to do.
This then not only deals with the zero date issue, but any other
sql_mode
related issue. This is a simple approach and, because we're doing the same thing MySQL does (remember that Vitess offers MySQL as a logical database spread across N nodes), we would not need a flag or anything user visible.Related Issue(s)
#7883
#6561
Checklist