Skip to content

Commit 2c40c11

Browse files
author
Mikael Ronstrom
committed
Added support in DEBUG_SYNC framework for actions when THD object isn't actively executed, that is when mysys_var == NULL
1 parent 414e92f commit 2c40c11

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

sql/debug_sync.cc

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,10 +1746,15 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
17461746
mutex and cond. This would prohibit the use of DEBUG_SYNC
17471747
between other places of enter_cond() and exit_cond().
17481748
*/
1749-
old_mutex= thd->mysys_var->current_mutex;
1750-
old_cond= thd->mysys_var->current_cond;
1751-
thd->mysys_var->current_mutex= &debug_sync_global.ds_mutex;
1752-
thd->mysys_var->current_cond= &debug_sync_global.ds_cond;
1749+
if (thd->mysys_var)
1750+
{
1751+
old_mutex= thd->mysys_var->current_mutex;
1752+
old_cond= thd->mysys_var->current_cond;
1753+
thd->mysys_var->current_mutex= &debug_sync_global.ds_mutex;
1754+
thd->mysys_var->current_cond= &debug_sync_global.ds_cond;
1755+
}
1756+
else
1757+
old_mutex= NULL;
17531758

17541759
set_timespec(abstime, action->timeout);
17551760
DBUG_EXECUTE("debug_sync_exec", {
@@ -1804,11 +1809,16 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
18041809
is locked. (See comment in THD::exit_cond().)
18051810
*/
18061811
mysql_mutex_unlock(&debug_sync_global.ds_mutex);
1807-
mysql_mutex_lock(&thd->mysys_var->mutex);
1808-
thd->mysys_var->current_mutex= old_mutex;
1809-
thd->mysys_var->current_cond= old_cond;
1810-
thd_proc_info(thd, old_proc_info);
1811-
mysql_mutex_unlock(&thd->mysys_var->mutex);
1812+
if (old_mutex)
1813+
{
1814+
mysql_mutex_lock(&thd->mysys_var->mutex);
1815+
thd->mysys_var->current_mutex= old_mutex;
1816+
thd->mysys_var->current_cond= old_cond;
1817+
thd_proc_info(thd, old_proc_info);
1818+
mysql_mutex_unlock(&thd->mysys_var->mutex);
1819+
}
1820+
else
1821+
thd_proc_info(thd, old_proc_info);
18121822
}
18131823
else
18141824
{

0 commit comments

Comments
 (0)