Skip to content

Commit 6b685ea

Browse files
committed
correctness assert
thd_get_ha_data() can be used without a lock, but only from the current thd thread, when calling from anoher thread it *must* be protected by thd->LOCK_thd_data * fix group commit code to take thd->LOCK_thd_data * remove innobase_close_connection() from the innodb background thread, it's not needed after 8777540 and was failing the assert with current_thd==0
1 parent de13032 commit 6b685ea

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

include/my_pthread.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ void safe_mutex_free_deadlock_data(safe_mutex_t *mp);
437437
#define my_cond_wait(A,B) safe_cond_wait((A), (B), __FILE__, __LINE__)
438438
#else
439439

440+
#define safe_mutex_is_owner(mp) (1)
440441
#define safe_mutex_assert_owner(mp) do {} while (0)
441442
#define safe_mutex_assert_not_owner(mp) do {} while (0)
442443
#define safe_mutex_setflags(mp, F) do {} while (0)

sql/log.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8512,7 +8512,11 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
85128512
++num_commits;
85138513
if (current->cache_mngr->using_xa && likely(!current->error) &&
85148514
DBUG_EVALUATE_IF("skip_commit_ordered", 0, 1))
8515+
{
8516+
mysql_mutex_lock(&current->thd->LOCK_thd_data);
85158517
run_commit_ordered(current->thd, current->all);
8518+
mysql_mutex_unlock(&current->thd->LOCK_thd_data);
8519+
}
85168520
current->thd->wakeup_subsequent_commits(current->error);
85178521

85188522
/*

sql/sql_class.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ void thd_storage_lock_wait(THD *thd, long long value)
462462
extern "C"
463463
void *thd_get_ha_data(const THD *thd, const struct handlerton *hton)
464464
{
465+
DBUG_ASSERT(thd == current_thd || mysql_mutex_is_owner(&thd->LOCK_thd_data));
465466
return thd->ha_data[hton->slot].ha_ptr;
466467
}
467468

storage/innobase/handler/ha_innodb.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,10 +1484,6 @@ innobase_destroy_background_thd(
14841484
/*============================*/
14851485
MYSQL_THD thd)
14861486
{
1487-
/* need to close the connection explicitly, the server won't do it
1488-
if innodb is in the PLUGIN_IS_DYING state */
1489-
innobase_close_connection(innodb_hton_ptr, thd);
1490-
thd_set_ha_data(thd, innodb_hton_ptr, NULL);
14911487
destroy_background_thd(thd);
14921488
}
14931489

0 commit comments

Comments
 (0)