summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-01-11 13:16:38 +0100
committerSergei Golubchik <serg@mariadb.org>2021-01-11 21:54:47 +0100
commit66f4900b517681da2aed3b562158ef58679961e4 (patch)
tree754379508d81fb11b2405b8195fb688843b70ca2
parentfdc4b7a6b222ffdcbe355255b40e500d339fbf3b (diff)
downloadmariadb-git-66f4900b517681da2aed3b562158ef58679961e4.tar.gz
Revert "MDEV-23536 : Race condition between KILL and transaction commit"
This reverts the server part of the commit 775fccea0 but keeps InnoDB part (which reverted MDEV-17092 5530a93f4). So after this both MDEV-23536 and MDEV-17092 are reverted, and the original bug is resurrected.
-rw-r--r--sql/sql_class.cc38
-rw-r--r--sql/sql_class.h2
2 files changed, 8 insertions, 32 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 2321991d99f..2595717572a 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1357,15 +1357,12 @@ void THD::change_user(void)
/* Do operations that may take a long time */
-void THD::cleanup(bool have_mutex)
+void THD::cleanup(void)
{
DBUG_ENTER("THD::cleanup");
DBUG_ASSERT(cleanup_done == 0);
- if (have_mutex)
- set_killed_no_mutex(KILL_CONNECTION,0,0);
- else
- set_killed(KILL_CONNECTION);
+ set_killed(KILL_CONNECTION);
#ifdef ENABLE_WHEN_BINLOG_WILL_BE_ABLE_TO_PREPARE
if (transaction.xid_state.xa_state == XA_PREPARED)
{
@@ -1440,28 +1437,6 @@ void THD::cleanup(bool have_mutex)
void THD::free_connection()
{
DBUG_ASSERT(free_connection_done == 0);
- /* Check that we have already called thd->unlink() */
- DBUG_ASSERT(prev == 0 && next == 0);
-
- /*
- Other threads may have a lock on THD::LOCK_thd_data or
- THD::LOCK_thd_kill to ensure that this THD is not deleted
- while they access it. The following mutex_lock ensures
- that no one else is using this THD and it's now safe to
- continue.
-
- For example consider KILL-statement execution on
- sql_parse.cc kill_one_thread() that will use
- THD::LOCK_thd_data to protect victim thread during
- THD::awake().
- */
- mysql_mutex_lock(&LOCK_thd_data);
- mysql_mutex_lock(&LOCK_thd_kill);
-
-#ifdef WITH_WSREP
- delete wsrep_rgi;
- wsrep_rgi= 0;
-#endif /* WITH_WSREP */
my_free(db);
db= NULL;
#ifndef EMBEDDED_LIBRARY
@@ -1470,8 +1445,8 @@ void THD::free_connection()
net.vio= 0;
net_end(&net);
#endif
- if (!cleanup_done)
- cleanup(true); // We have locked THD::LOCK_thd_kill
+ if (!cleanup_done)
+ cleanup();
ha_close_connection(this);
plugin_thdvar_cleanup(this);
mysql_audit_free_thd(this);
@@ -1482,8 +1457,6 @@ void THD::free_connection()
#if defined(ENABLED_PROFILING)
profiling.restart(); // Reset profiling
#endif
- mysql_mutex_unlock(&LOCK_thd_kill);
- mysql_mutex_unlock(&LOCK_thd_data);
}
/*
@@ -1539,6 +1512,9 @@ THD::~THD()
mysql_mutex_lock(&LOCK_thd_data);
mysql_mutex_unlock(&LOCK_thd_data);
+#ifdef WITH_WSREP
+ delete wsrep_rgi;
+#endif
if (!free_connection_done)
free_connection();
diff --git a/sql/sql_class.h b/sql/sql_class.h
index a97f64c13b3..b68e3553a2d 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3194,7 +3194,7 @@ public:
void update_all_stats();
void update_stats(void);
void change_user(void);
- void cleanup(bool have_mutex=false);
+ void cleanup(void);
void cleanup_after_query();
void free_connection();
void reset_for_reuse();