-
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
When the _xxxx_gho table is queried, data may be lost. #887
Comments
There seems to be a corruption in the original comment. On my mobile GitHub app, I can actually see what the question is. Copy+pasting here (as is, including typos):
This situation does not happen. First, gh-ost locks the original table, then, it waits until the |
How to repeat :
mysql> select * from a; mysql> select * from _a_del; |
https://dev.mysql.com/doc/refman/8.0/en/metadata-locking.html DDL statements, LOCK TABLES, and other similar statements try to reduce the number of possible deadlocks between concurrent DDL statements by acquiring locks on explicitly named tables in name order. |
Sorry for accidentally closed, reopen. |
when does this statement run? In
I'm not sure what this quote means to this issue's context. Can you please clarify? |
Yes. Rename statement happened after all data sync from table In our case, there are other sessions acces to the
This is the acquiring locks order of DDL statement from MySQL manual. |
Thank you, I will look into it. I'm meanwhile curious: who would be reading from |
-- We met a case two days ago which cause a table lost one row after ALTER table through gh-ost. Thanks for you reply ,waiting for your review result. |
hi Shlomi-noach , is there anly update for the case please ^_^? Sorry to bother, but we look forward fix this ASAP for there is a risk of lossing data, we run gh-ost doing DDL every day。 A fix for the case above we think is just change the Thanks. |
Hi,
I'm not sure I will be able to provide a fix in the next few days.
I'm not sure I understand exactly what you mean. Can you please paste the code change? Better yet, if you think you have the correct solution, could you create a pull request? I'm not the owner of https://github.com/github/gh-ost and will not be able to merge any changes here. But I may merge such changes in https://github.com/openark/gh-ost |
I can confirm I get the same behavior as yours, but something's strange here: At first I thought this might be related to the fact your table doesn;t have a I then tries a different table structure, and I got different results, which are good. See below. Can you please clarify what is the output of your:
I'm using the following:
Here's a different table definition which works correctly:
Still looking into why it behaves different than yours, and correctly so. |
it's not the |
Sorry, I did not execute the |
The prefix of tables' name in your test is different with me ,that's the biggest difference. The reason why tables' name affect the result is metioned in the manual:
The DEL/GHO tables' name are in different order, as follow:
In database sg2 ,the table When you use Don't know if i made it clear,the table name order affect the test result. ---the variables:
|
WOW. OK, let me digest this and see how to proceed. |
from https://dev.mysql.com/doc/refman/5.7/en/rename-table.html:
I'll keep looking at the implications. |
Hi,shlomi, is there any update here ? Look forward the fix for this case :) |
Sorry for the delays, I hope to give this a shot by end of month |
Again, sorry for the delay. I took some time to review this issue again and can confirm it is as you describe. I appreciate your findings and analysis. OK, so there's an immediate solution for you (sorry, I could have figured it out much sooner), and then we need to consider long term solutions. Immediate termuse e.g.:
This will ensure
long termIs a bit of a problem. So I'm going to bang my head a bit around fixing the problem without modifying the prefix Cross fingers. Oh, another alternative is to use |
Sorry, my suggested short term solution above will not work as I hoped, because right now |
Thanks for your solutions 👍I had discussed the short term solution with @shatianjiang , maybe there is still exists risk of lost data when there got a table named 'zzzzzXXX'(with 'zzzz' prefix...), but it would work most of time:) So look forward the long term fix for this issue. Thanks again. |
The change you'd need to make for short term solution is in: Lines 280 to 286 in c681c54
As you can see |
@zhongliangkang Even if the
@cenkore For pull code #987 , I think it is very good, but I am not sure why code not be merged? @shlomi-noach For "I'll likely add a simple option (e.g. --force-table-name-prefix or something) to control that" having any update? |
Yes. Even if no query on the _gho table, data may lost, add a query make it easy to reproduce. #987 may need more deep thinking.. |
Suppose now operating DDL on table
a
, three temporary tables_a_del
,_a_gho
, and_a_ghc
will be generated.rename operation is: rename
a
to_a_del
,_a_gho
toa
,lock table statement is: lock table
a
write,_a_del
writeAccording to the order of acquiring the lock:
Thank you!
The text was updated successfully, but these errors were encountered: