Skip to content

Commit 3950491

Browse files
santoshbandaFacebook Github Bot
authored and
Facebook Github Bot
committed
Fix test failures
Summary: During recovery thd is null, so we need to guard against this. I think it is also better to check for the current we are resetting thd query value which was set when applying the same rows query log event. Squash with: 42bdfc8 Closes #367 Reviewed By: lth Differential Revision: D4099803 Pulled By: santoshbanda fbshipit-source-id: 4b4a041
1 parent 42bdfc8 commit 3950491

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

sql/log_event.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -14119,7 +14119,12 @@ Rows_query_log_event::~Rows_query_log_event()
1411914119
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
1412014120
// reset the the query set during do_apply_event() before freeing up
1412114121
// the m_rows_query.
14122-
thd->reset_query();
14122+
if (thd) {
14123+
mysql_mutex_lock(&thd->LOCK_thd_data);
14124+
if (thd->query() == m_rows_query)
14125+
thd->set_query(CSET_STRING(), false);
14126+
mysql_mutex_unlock(&thd->LOCK_thd_data);
14127+
}
1412314128
#endif
1412414129
my_free(m_rows_query);
1412514130
}

sql/sql_class.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -4919,11 +4919,13 @@ void THD::set_command(enum enum_server_command command)
49194919

49204920
/** Assign a new value to thd->query. */
49214921

4922-
void THD::set_query(const CSET_STRING &string_arg)
4922+
void THD::set_query(const CSET_STRING &string_arg, bool need_lock)
49234923
{
4924-
mysql_mutex_lock(&LOCK_thd_data);
4924+
if (need_lock)
4925+
mysql_mutex_lock(&LOCK_thd_data);
49254926
set_query_inner(string_arg);
4926-
mysql_mutex_unlock(&LOCK_thd_data);
4927+
if (need_lock)
4928+
mysql_mutex_unlock(&LOCK_thd_data);
49274929

49284930
#ifdef HAVE_PSI_THREAD_INTERFACE
49294931
PSI_THREAD_CALL(set_thread_info)(query(), query_length());

sql/sql_class.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -4427,7 +4427,8 @@ class THD :public MDL_context_owner,
44274427
{
44284428
set_query(CSET_STRING(query_arg, query_length_arg, charset()));
44294429
}
4430-
void set_query(const CSET_STRING &str); /* Mutex protected */
4430+
void set_query(const CSET_STRING &str,
4431+
bool need_lock = true); /* Mutex protected */
44314432
void reset_query() /* Mutex protected */
44324433
{ set_query(CSET_STRING()); }
44334434
void set_query_and_id(char *query_arg, uint32 query_length_arg,

0 commit comments

Comments
 (0)