diff --git a/sql/rpl_slave.cc b/sql/rpl_slave.cc index fdd8f1527a1..cf01968da7a 100644 --- a/sql/rpl_slave.cc +++ b/sql/rpl_slave.cc @@ -5335,6 +5335,8 @@ extern "C" void *handle_slave_io(void *arg) { struct PSI_thread *psi = PSI_THREAD_CALL(get_thread)(); thd_set_psi(mi->info_thd, psi); #endif + mysql_thread_set_psi_id(thd->thread_id()); + mysql_thread_set_psi_THD(thd); thd->thread_stack = (char *)&thd; // remember where our stack is mi->clear_error(); @@ -5801,6 +5803,7 @@ ignore_log_space_limit=%d", Therefore thd must only be deleted after info_thd is set to NULL. */ + mysql_thread_set_psi_THD(nullptr); delete thd; /* @@ -5912,6 +5915,8 @@ static void *handle_slave_worker(void *arg) { psi = PSI_THREAD_CALL(get_thread)(); thd_set_psi(w->info_thd, psi); #endif + mysql_thread_set_psi_id(thd->thread_id()); + mysql_thread_set_psi_THD(thd); if (init_slave_thread(thd, SLAVE_THD_WORKER)) { // todo make SQL thread killed @@ -6063,6 +6068,7 @@ err: THD_CHECK_SENTRY(thd); if (thd_added) thd_manager->remove_thd(thd); + mysql_thread_set_psi_THD(nullptr); delete thd; } @@ -6939,6 +6945,8 @@ extern "C" void *handle_slave_sql(void *arg) { struct PSI_thread *psi = PSI_THREAD_CALL(get_thread)(); thd_set_psi(rli->info_thd, psi); #endif + mysql_thread_set_psi_id(thd->thread_id()); + mysql_thread_set_psi_THD(thd); if (rli->channel_mts_submode != MTS_PARALLEL_TYPE_DB_NAME) rli->current_mts_submode = new Mts_submode_logical_clock(); @@ -7349,6 +7357,7 @@ extern "C" void *handle_slave_sql(void *arg) { Therefore thd must only be deleted after info_thd is set to NULL. */ + mysql_thread_set_psi_THD(nullptr); delete thd; /*