-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Atomic cutover is unsound on mysql 5.6.41 #653
Comments
Thank you for this well written report! I will proceed to test it. |
Sorry, this report does not in fact reproduce the atomic cut-over in I see you use a singular Would you like to try and reproduce using the exact |
I will try to get the same behavior with exact cut-over that gh-ost uses. I just found and reported a specific counter-example to this statement in #82
I haven't read mysql lock management code to judge how correct that statement is, but this example shows that it's not generally true. |
Agreed, and concerning. At this exact moment my availability to experiment this on my own is limited or zero. I can look into it another week, or if you are capable to reconstruct the problem with the |
@syrnick I'm able to reproduce your use case on a However, the error does not reproduce on the logic used by session 1
session 2
session 3
I will explain shortly why this flow, the one that |
Thanks! I can confirm that with this flow the cut-over works as intended. I'll try poking holes in it, but I couldn't find anything so far. |
👋 closing this as only MySQL 5.7+ is supported and this requirement is documented Let us know if you see problems on the latest-stable and MySQL 5.7+ 🙇 |
We observed gh-ost not performing migration atomically and I was investigating possible causes. I was reading the description of the atomic cutover #82 and found that it relies on undocumented MySQL internal engine behavior. I tested it on 5.6.41 and observed behavior that breaks the assumptions necessary for the cutover to be atomic. Here's a basic example.
Setup: Mysql 5.6.41 (on Mac OS), 3 interactive sessions. First session does the write lock, second session does the INSERT, third session does
ALTER TABLE RENAME
.Expected - INSERT is blocked until after RENAME goes through and errors out.
Observed - INSERT goes through before RENAME.
Session 1
Session 2
Session 3
In this example, DML was allowed to go through between WRITE lock being released and ALTER TABLE RENAME taking effect. All those DMLs would be lost by gh-ost during cutover.
Obviously, the right thing is to RENAME from the connection holding the lock. That's available in 8.x only.
For other versions, If this is specific to only some mysql versions, it needs to be documented with a giant warning sign and ideally gh-ost should explicitly assert that it runs against only supported version. It could possibly run the provided test explicitly before migration to catch change in behavior. Discussion in #82 suggests that it's a highly stable behavior, but my test contradicts that.
The text was updated successfully, but these errors were encountered: