Commit c6659345 authored by Daniele Sciascia's avatar Daniele Sciascia Committed by Nirbhay Choubey

refs codership/mysql-wsrep#201

Fix remaining issues with wsrep_sync_wait and query cache.

- Fixes misplaced call to invalidate query cache in
  Rows_log_event::do_apply_event().
  Query cache was invalidated too early, and allowed old
  entries to be inserted to the cache.

- Reset thd->wsrep_sync_wait_gtid on query cache hit.
  THD->cleanup_after_query is not called in such cases,
  and thd->wsrep_sync_wait_gtid remained initialized.
parent c05d85f4
...@@ -9892,7 +9892,18 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) ...@@ -9892,7 +9892,18 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
} }
#ifdef HAVE_QUERY_CACHE #ifdef HAVE_QUERY_CACHE
#ifdef WITH_WSREP
/*
Moved invalidation right before the call to rows_event_stmt_cleanup(),
to avoid query cache being polluted with stale entries.
*/
if (! (WSREP(thd) && (thd->wsrep_exec_mode == REPL_RECV)))
{
#endif /* WITH_WSREP */
query_cache.invalidate_locked_for_write(thd, rgi->tables_to_lock); query_cache.invalidate_locked_for_write(thd, rgi->tables_to_lock);
#ifdef WITH_WSREP
}
#endif /* WITH_WSREP */
#endif #endif
} }
...@@ -10080,6 +10091,14 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) ...@@ -10080,6 +10091,14 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
/* remove trigger's tables */ /* remove trigger's tables */
if (slave_run_triggers_for_rbr) if (slave_run_triggers_for_rbr)
restore_empty_query_table_list(thd->lex); restore_empty_query_table_list(thd->lex);
#if defined(WITH_WSREP) && defined(HAVE_QUERY_CACHE)
if (WSREP(thd) && thd->wsrep_exec_mode == REPL_RECV)
{
query_cache.invalidate_locked_for_write(thd, rgi->tables_to_lock);
}
#endif /* WITH_WSREP && HAVE_QUERY_CACHE */
if (get_flags(STMT_END_F) && (error= rows_event_stmt_cleanup(rgi, thd))) if (get_flags(STMT_END_F) && (error= rows_event_stmt_cleanup(rgi, thd)))
slave_rows_error_report(ERROR_LEVEL, slave_rows_error_report(ERROR_LEVEL,
thd->is_error() ? 0 : error, thd->is_error() ? 0 : error,
......
...@@ -7247,6 +7247,12 @@ void mysql_parse(THD *thd, char *rawbuf, uint length, ...@@ -7247,6 +7247,12 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
sql_statement_info[SQLCOM_SELECT].m_key); sql_statement_info[SQLCOM_SELECT].m_key);
status_var_increment(thd->status_var.com_stat[SQLCOM_SELECT]); status_var_increment(thd->status_var.com_stat[SQLCOM_SELECT]);
thd->update_stats(); thd->update_stats();
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd))
{
thd->wsrep_sync_wait_gtid= WSREP_GTID_UNDEFINED;
}
#endif /* WITH_WSREP */
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
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