-
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
Use mysql 8.0 INSTANT DDL if supported #1198
Comments
@morgo thanks for this idea and branch 🙏! I'm curious if you've been able to test the performance of this on a large or active data set? The reason I ask is, while "instant" (which I read as non-blocking) to the caller, I wonder if this triggers asynchronous work in InnoDB that could impact the server 🤔. We generally throttle operations that can cause impact, but here we probably cannot |
We currently use 5.7, so not yet. We don't have many workloads that would trigger the biggest impact this will have, but more on that below.
But in terms of risks: it does require a meta data lock to change the table. This is the same metadata lock which is required at the end of the gh-ost operation to switch the tables. The time this will take is up to the length of the longest running transaction (which will have shared MDL locks preventing the table from being changed until they have finished executing). So the worst case is for users with long running transactions that involve this table (i.e. it's not based on server load, or database size - it's really p100 transaction length.) Gh-ost requires that MDL lock eventually, but the difference here is that in current usage you get to elect the cut-over time to incur that MDL lock. Here it will try and acquire it immediately. |
Awesome, thanks for clarifying @morgo. This doesn't sound too concerning 👍
Makes sense, the difference in timing of the metadata lock doesn't seem like a big deal considering the efficiency gains 👍. I think explaining this in the I suggest a PR with the branch mentioned is opened. My only thought is it might be best to try |
Sure, I'm happy to do that. I will wait a couple of days for other feedback, and then incorporate it into a PR. |
👋 @morgo Thanks for the PR, I think this is a great idea!
Agreed 👍 I'd prefer Would you mind also adding some tests? 🙇 |
SGTM.
I'm cool to add tests - I just wanted to make sure this is something that would be accepted first :-) |
@morgo does this mean an instant DDL can finish executing first, but the metadata lock is held longer until the longest running transaction at the time finishes because the lock is shared between them? |
No, step 1 is the MDL is acquired. Then for step 2 the meta data is changed. So even though it is instant, that only applies to step 2. Step 1 is typically where all time is spent. |
Hi friends,
I would like to propose a new feature (likely on by default) where gh-ost attempts to apply the DDL change first (but with an assertion that it must be
INSTANT
). This is particularly targeted at MySQL 8.0+ users, but will likely work on some earlier versions as well (Aurora 5.7 supports instant changes, although I've not specifically tested with the instant assertion..).I am happy to contribute a patch for it - but per your request I am opening an issue here first to discuss :-)
I hacked up something just now to show that it looks easy enough to add:
https://github.com/github/gh-ost/compare/master...morgo:gh-ost:attempt-instant-ddl?expand=1
For an example usage:
The text was updated successfully, but these errors were encountered: