-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
MDEV-36684 - main.mdl_sync fails under valgrind (test for Bug#42643) #4009
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -901,6 +901,7 @@ TABLE_SHARE *tdc_acquire_share(THD *thd, TABLE_LIST *tl, uint flags, | |
{ | ||
mysql_mutex_unlock(&element->LOCK_table_share); | ||
lf_hash_search_unpin(thd->tdc_hash_pins); | ||
std::this_thread::yield(); | ||
goto retry; | ||
} | ||
lf_hash_search_unpin(thd->tdc_hash_pins); | ||
Comment on lines
903
to
907
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would the following be a correct optimization? mysql_mutex_lock(&element->LOCK_table_share);
lf_hash_search_unpin(thd->tdc_hash_pins);
if (!(share= element->share))
{
mysql_mutex_unlock(&element->LOCK_table_share);
std::this_thread::yield();
goto retry;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, depending on what you're trying to achieve. Speaking of correctness: What we get if we do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What we would gain is avoiding some code duplication and instruction cache bloat. Another variant would avoid the potential race condition: mysql_mutex_lock(&element->LOCK_table_share);
share= element->share;
lf_hash_search_unpin(thd->tdc_hash_pins);
if (!share)
{
mysql_mutex_unlock(&element->LOCK_table_share);
std::this_thread::yield();
goto retry;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It won't work either: I can foresee your question "Why it is safe to unpin right after this block?" Presence of I understand your concern, I'd have implemented it as you suggested originally (back 10+ years ago), but I didn't see the way to arrange code better. Nor do I see it now. |
||
|
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.
This is duplicating the section of code 63 lines earlier. In fact, a wider section of the code block starting with
if (unlikely(error))
is being duplicated. I think that a follow-up fix would be useful where we’d do the following:and there would be a new function
ATTRIBUTE_COLD static bool open_tables_error_handler(bool, …)
that would include the duplicated code, including the call tostd::this_thread::yield()
.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.
Right. There was a change in 10.11 though, that makes it different by one line at least. I wouldn't dare doing it in GA versions though.