Commit 0371dc74 authored by Sergei Golubchik's avatar Sergei Golubchik Committed by Alexander Barkov

MDEV-11896 thd_get_error_context_description race condition

Change the semantics of thd_get_error_context_description().
It no longer expects the caller to lock LOCK_thread_count
(no caller ever did that anyway), but takes care of it internally.

(cherry-pick)
parent c8282dde
......@@ -556,6 +556,8 @@ char *thd_get_error_context_description(THD *thd, char *buffer,
char header[256];
int len;
mysql_mutex_lock(&LOCK_thread_count);
/*
The pointers thd->query and thd->proc_info might change since they are
being modified concurrently. This is acceptable for proc_info since its
......@@ -611,6 +613,7 @@ char *thd_get_error_context_description(THD *thd, char *buffer,
}
mysql_mutex_unlock(&thd->LOCK_thd_data);
}
mysql_mutex_unlock(&LOCK_thread_count);
if (str.c_ptr_safe() == buffer)
return buffer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment