MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / remove_global_thread

Function remove_global_thread

sql/mysqld.cc:772–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

770}
771
772void remove_global_thread(THD *thd)
773{
774 DBUG_PRINT("info", ("remove_global_thread %p",
775 thd));
776 mysql_mutex_lock(&LOCK_thd_remove);
777 mysql_mutex_lock(&LOCK_thread_count);
778 DBUG_ASSERT(thd->release_resources_done());
779 /*
780 Used by binlog_reset_master. It would be cleaner to use
781 DEBUG_SYNC here, but that's not possible because the THD's debug
782 sync feature has been shut down at this point.
783 */
784 DBUG_EXECUTE_IF("sleep_after_lock_thread_count_before_delete_thd",
785 sleep(5););
786
787 const size_t num_erased= global_thread_list->erase(thd);
788 if (num_erased == 1)
789 --global_thread_count;
790 // Removing a THD that was never added is an error.
791 DBUG_ASSERT(1 == num_erased);
792
793 mysql_mutex_unlock(&LOCK_thd_remove);
794 mysql_cond_broadcast(&COND_thread_count);
795 mysql_mutex_unlock(&LOCK_thread_count);
796}
797
798uint get_thread_count()
799{

Callers

nothing calls this directly

Calls 2

eraseMethod · 0.45

Tested by

no test coverage detected