Skip to content

Commit 732adec

Browse files
committed
Removed some not needed when doing delete thd, which caused warnings about
wrong mutex usage from safe_mutex. Ensure that LOCK_status is always taken before LOCK_thread_count
1 parent b4ff645 commit 732adec

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

sql/log.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9597,9 +9597,7 @@ binlog_background_thread(void *arg __attribute__((unused)))
95979597

95989598
THD_STAGE_INFO(thd, stage_binlog_stopping_background_thread);
95999599

9600-
mysql_mutex_lock(&LOCK_thread_count);
96019600
delete thd;
9602-
mysql_mutex_unlock(&LOCK_thread_count);
96039601

96049602
my_thread_end();
96059603

sql/mysqld.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4630,6 +4630,7 @@ static int init_thread_environment()
46304630
mysql_mutex_init(key_LOCK_global_system_variables,
46314631
&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
46324632
mysql_mutex_record_order(&LOCK_active_mi, &LOCK_global_system_variables);
4633+
mysql_mutex_record_order(&LOCK_status, &LOCK_thread_count);
46334634
mysql_rwlock_init(key_rwlock_LOCK_system_variables_hash,
46344635
&LOCK_system_variables_hash);
46354636
mysql_mutex_init(key_LOCK_prepared_stmt_count,

sql/rpl_parallel.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,10 +1372,11 @@ handle_rpl_parallel_thread(void *arg)
13721372
thd->reset_db(NULL, 0);
13731373
thd_proc_info(thd, "Slave worker thread exiting");
13741374
thd->temporary_tables= 0;
1375+
13751376
mysql_mutex_lock(&LOCK_thread_count);
1376-
THD_CHECK_SENTRY(thd);
1377-
delete thd;
1377+
thd->unlink();
13781378
mysql_mutex_unlock(&LOCK_thread_count);
1379+
delete thd;
13791380

13801381
mysql_mutex_lock(&rpt->LOCK_rpl_thread);
13811382
rpt->running= false;

sql/slave.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,7 @@ handle_slave_init(void *arg __attribute__((unused)))
311311
thd->get_stmt_da()->sql_errno(),
312312
thd->get_stmt_da()->message());
313313

314-
mysql_mutex_lock(&LOCK_thread_count);
315314
delete thd;
316-
mysql_mutex_unlock(&LOCK_thread_count);
317315
thread_safe_decrement32(&service_thread_count);
318316
signal_thd_deleted();
319317
my_thread_end();
@@ -4961,8 +4959,9 @@ pthread_handler_t handle_slave_sql(void *arg)
49614959
mysql_mutex_unlock(&LOCK_active_mi);
49624960

49634961
mysql_mutex_lock(&LOCK_thread_count);
4964-
delete thd;
4962+
thd->unlink();
49654963
mysql_mutex_unlock(&LOCK_thread_count);
4964+
delete thd;
49664965
thread_safe_decrement32(&service_thread_count);
49674966
signal_thd_deleted();
49684967

0 commit comments

Comments
 (0)