Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
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
  • Loading branch information
santoshbanda authored and Facebook Github Bot committed Oct 29, 2016
1 parent 42bdfc8 commit 3950491
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion sql/log_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14119,7 +14119,12 @@ Rows_query_log_event::~Rows_query_log_event()
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
// reset the the query set during do_apply_event() before freeing up
// the m_rows_query.
thd->reset_query();
if (thd) {
mysql_mutex_lock(&thd->LOCK_thd_data);
if (thd->query() == m_rows_query)
thd->set_query(CSET_STRING(), false);
mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif
my_free(m_rows_query);
}
Expand Down
8 changes: 5 additions & 3 deletions sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4919,11 +4919,13 @@ void THD::set_command(enum enum_server_command command)

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

void THD::set_query(const CSET_STRING &string_arg)
void THD::set_query(const CSET_STRING &string_arg, bool need_lock)
{
mysql_mutex_lock(&LOCK_thd_data);
if (need_lock)
mysql_mutex_lock(&LOCK_thd_data);
set_query_inner(string_arg);
mysql_mutex_unlock(&LOCK_thd_data);
if (need_lock)
mysql_mutex_unlock(&LOCK_thd_data);

#ifdef HAVE_PSI_THREAD_INTERFACE
PSI_THREAD_CALL(set_thread_info)(query(), query_length());
Expand Down
3 changes: 2 additions & 1 deletion sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -4427,7 +4427,8 @@ class THD :public MDL_context_owner,
{
set_query(CSET_STRING(query_arg, query_length_arg, charset()));
}
void set_query(const CSET_STRING &str); /* Mutex protected */
void set_query(const CSET_STRING &str,
bool need_lock = true); /* Mutex protected */
void reset_query() /* Mutex protected */
{ set_query(CSET_STRING()); }
void set_query_and_id(char *query_arg, uint32 query_length_arg,
Expand Down

0 comments on commit 3950491

Please sign in to comment.