diff options
Diffstat (limited to 'sql/ha_ndbcluster_binlog.cc')
-rw-r--r-- | sql/ha_ndbcluster_binlog.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 4f8bb66fcb0..26fdb8e1425 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -36,6 +36,7 @@ #include "lock.h" // MYSQL_LOCK_IGNORE_FLUSH, // mysql_unlock_tables #include "sql_parse.h" // mysql_parse +#include "transaction.h" #ifdef ndb_dynamite #undef assert @@ -298,13 +299,6 @@ static void run_query(THD *thd, char *buf, char *end, thd_ndb->m_error_code, (int) thd->is_error(), thd->is_slave_error); } - - /* - After executing statement we should unlock and close tables open - by it as well as release meta-data locks obtained by it. - */ - close_thread_tables(thd); - /* XXX: this code is broken. mysql_parse()/mysql_reset_thd_for_next_command() can not be called from within a statement, and @@ -2422,7 +2416,11 @@ int ndb_add_ndb_binlog_index(THD *thd, void *_row) } add_ndb_binlog_index_err: + thd->stmt_da->can_overwrite_status= TRUE; + thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd); + thd->stmt_da->can_overwrite_status= FALSE; close_thread_tables(thd); + thd->mdl_context.release_transactional_locks(); ndb_binlog_index= 0; thd->variables.option_bits= saved_options; return error; @@ -3969,7 +3967,9 @@ restart: { if (ndb_binlog_index->s->needs_reopen()) { + trans_commit_stmt(thd); close_thread_tables(thd); + thd->mdl_context.release_transactional_locks(); ndb_binlog_index= 0; } } @@ -4280,7 +4280,9 @@ restart: if (do_ndbcluster_binlog_close_connection == BCCC_restart) { ndb_binlog_tables_inited= FALSE; + trans_commit_stmt(thd); close_thread_tables(thd); + thd->mdl_context.release_transactional_locks(); ndb_binlog_index= 0; goto restart; } @@ -4288,7 +4290,11 @@ err: sql_print_information("Stopping Cluster Binlog"); DBUG_PRINT("info",("Shutting down cluster binlog thread")); thd->proc_info= "Shutting down"; + thd->stmt_da->can_overwrite_status= TRUE; + thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd); + thd->stmt_da->can_overwrite_status= FALSE; close_thread_tables(thd); + thd->mdl_context.release_transactional_locks(); mysql_mutex_lock(&injector_mutex); /* don't mess with the injector_ndb anymore from other threads */ injector_thd= 0; |