-
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
Use LOCK TABLES during SwitchWrites to prevent lost writes #9481
Use LOCK TABLES during SwitchWrites to prevent lost writes #9481
Conversation
e2cffa8
to
47e5156
Compare
47e5156
to
86d563d
Compare
86d563d
to
47929eb
Compare
c1738e3
to
6e08248
Compare
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com> Signed-off-by: Matt Lord <mattalord@gmail.com>
6e08248
to
121aec8
Compare
And update tests Signed-off-by: Matt Lord <mattalord@gmail.com>
121aec8
to
e61e873
Compare
2970d27
to
b68b2a0
Compare
Before this implementation we found this manual workaround |
Signed-off-by: Matt Lord <mattalord@gmail.com>
70b417f
to
dd39d1c
Compare
dd39d1c
to
dc0c0c1
Compare
Signed-off-by: Matt Lord <mattalord@gmail.com>
dc0c0c1
to
f40758c
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.
looks good overall.
some nits.
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.
ltgm
Thank you for the review and comments, @rohit-nayak-ps and @harshit-gangal ! I just pushed another commit that addresses them. ❤️ |
3b17873
to
d41da4d
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.
lgtm
d41da4d
to
a78b7dc
Compare
Signed-off-by: Matt Lord <mattalord@gmail.com>
a78b7dc
to
f48a5d8
Compare
…table Use LOCK TABLES during SwitchWrites to prevent lost writes
Description
Issuing a
LOCK TABLES
statement on all of the tables that we are doing a SwitchWrites operation for as part of a MoveTables workflow ensures that no lost writes occur due to long running transactions (including long running single statement auto-commit transactions) on the source tablets committing after writes have been switched. I say this because:DenyList
on the source tablets to prevent any new writes against the tables at the tablet level in the query planner/executor.LOCK TABLES
call to return on the source mysqld's which will in turn wait for any open/running RW statements/transactions on those tables to complete or time out.Without doing this (before this PR is merged) you can not only break reverse vreplication -- which would have to be fixed manually -- but if you don't notice the errant writes and then manually reconcile the tables across keyspaces (old and new) then those writes are lost.
With this patch, when you go through the manual test here and get to the point where you attempt another
insert
orcommit
in the previously opened transaction started against the source before we switched writes, you get an error like this:Related Issue(s)
Fixes: #9400
Checklist