diff options
author | Monty <monty@mariadb.org> | 2020-07-22 17:57:07 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2020-07-23 10:54:33 +0300 |
commit | ce699df9050cb5c906f9382b57ea1dc928b4e6fd (patch) | |
tree | 1c410aa01852584f0965210fc875342af88e840c | |
parent | dbcd3384e0799ee99a966edaff2c0f135ef51a29 (diff) | |
download | mariadb-git-ce699df9050cb5c906f9382b57ea1dc928b4e6fd.tar.gz |
thd->m_transaction_psi was not properly cleared for new connections
This happend when using XA transactions. I also added some extra asserts
to ensure that m_transactions are properly cleared.
Other things:
- Removed set_time() from THD::init_for_queries() as dispatch_command()
is already doing that.
- Removed duplicate init_for_queries() from prepare_new_connection_state().
The init_for_queries() functions should only be called once per
connection.
-rw-r--r-- | sql/handler.cc | 4 | ||||
-rw-r--r-- | sql/sql_class.cc | 9 | ||||
-rw-r--r-- | sql/sql_connect.cc | 1 | ||||
-rw-r--r-- | sql/xa.cc | 1 |
4 files changed, 12 insertions, 3 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 48bae864125..58f1c60edf9 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1818,6 +1818,10 @@ err: ha_rollback_trans(thd, all); else { + /* + We are not really doing a rollback here, but the code in trans_commit() + requres that m_transaction_psi is 0 when we return from this function. + */ MYSQL_ROLLBACK_TRANSACTION(thd->m_transaction_psi); thd->m_transaction_psi= NULL; WSREP_DEBUG("rollback skipped %p %d",thd->rgi_slave, diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 484c90d706b..a900e485cd7 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1396,9 +1396,11 @@ void THD::update_all_stats() void THD::init_for_queries() { - set_time(); - ha_enable_transaction(this,TRUE); + DBUG_ASSERT(transaction->on); + DBUG_ASSERT(m_transaction_psi == NULL); + /* Set time for --init-file queries */ + set_time(); reset_root_defaults(mem_root, variables.query_alloc_block_size, variables.query_prealloc_size); reset_root_defaults(&transaction->mem_root, @@ -1550,6 +1552,8 @@ void THD::cleanup(void) trans_rollback(this); DBUG_ASSERT(open_tables == NULL); + DBUG_ASSERT(m_transaction_psi == NULL); + /* If the thread was in the middle of an ongoing transaction (rolled back a few lines above) or under LOCK TABLES (unlocked the tables @@ -1650,6 +1654,7 @@ void THD::reset_for_reuse() abort_on_warning= 0; free_connection_done= 0; m_command= COM_CONNECT; + transaction->on= 1; #if defined(ENABLED_PROFILING) profiling.reset(); #endif diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 420a054a1b2..83f4de1b5df 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1279,7 +1279,6 @@ void prepare_new_connection_state(THD* thd) } thd->proc_info=0; - thd->init_for_queries(); } } diff --git a/sql/xa.cc b/sql/xa.cc index 7d6d7187bce..e8e6dc43c56 100644 --- a/sql/xa.cc +++ b/sql/xa.cc @@ -843,6 +843,7 @@ bool trans_xa_detach(THD *thd) thd->transaction->all.ha_list= 0; thd->transaction->all.no_2pc= 0; + thd->m_transaction_psi= 0; return false; } |