summaryrefslogtreecommitdiff
path: root/sql/rpl_rli.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/rpl_rli.cc')
-rw-r--r--sql/rpl_rli.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index ae3cbf789a5..42cd12bd66c 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -1187,8 +1187,7 @@ void Relay_log_info::cleanup_context(THD *thd, bool error)
end_trans(thd, ROLLBACK); // if a "real transaction"
}
m_table_map.clear_tables();
- close_thread_tables(thd);
- clear_tables_to_lock();
+ slave_close_thread_tables(thd);
clear_flag(IN_STMT);
/*
Cleanup for the flags that have been set at do_apply_event.
@@ -1200,6 +1199,13 @@ void Relay_log_info::cleanup_context(THD *thd, bool error)
void Relay_log_info::clear_tables_to_lock()
{
+ /*
+ Deallocating elements of table list below will also free memory where
+ meta-data locks are stored. So we want to be sure that we don't have
+ any references to this memory left.
+ */
+ DBUG_ASSERT(!mdl_has_locks(&(current_thd->mdl_context)));
+
while (tables_to_lock)
{
uchar* to_free= reinterpret_cast<uchar*>(tables_to_lock);
@@ -1216,4 +1222,15 @@ void Relay_log_info::clear_tables_to_lock()
DBUG_ASSERT(tables_to_lock == NULL && tables_to_lock_count == 0);
}
+void Relay_log_info::slave_close_thread_tables(THD *thd)
+{
+ /*
+ Since we use same memory chunks for allocation of metadata lock
+ objects for tables as we use for allocating corresponding elements
+ of 'tables_to_lock' list, we have to release metadata locks by
+ closing tables before calling clear_tables_to_lock().
+ */
+ close_thread_tables(thd);
+ clear_tables_to_lock();
+}
#endif