mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
Ensure that process "State" is properly cleaned after query execution
In some cases "SHOW PROCESSLIST" could show "Reset for next command" as State, even if the previous query had finished properly. Fixed by clearing State after end of command and also setting the State for the "Connect" command. Other things: - Changed usage of 'thd->set_command(COM_SLEEP)' to 'thd->mark_connection_idle()'. - Changed thread_state_info() to return "" instead of NULL. This is just a safety measurement and in line with the logic of the rest of the function.
This commit is contained in:
parent
01623ac9ea
commit
2447172afb
10 changed files with 22 additions and 12 deletions
|
@ -708,8 +708,7 @@ void *create_embedded_thd(int client_flag)
|
|||
|
||||
if (thd->variables.max_join_size == HA_POS_ERROR)
|
||||
thd->variables.option_bits |= OPTION_BIG_SELECTS;
|
||||
thd->proc_info=0; // Remove 'login'
|
||||
thd->set_command(COM_SLEEP);
|
||||
thd->mark_connection_idle();
|
||||
thd->set_time();
|
||||
thd->init_for_queries();
|
||||
thd->client_capabilities= client_flag;
|
||||
|
|
|
@ -97,8 +97,8 @@ static int prepare_for_fill(TABLE_LIST *tables)
|
|||
|
||||
thd->mysys_var->current_cond= &sleep_condition;
|
||||
thd->mysys_var->current_mutex= &sleep_mutex;
|
||||
thd->mark_connection_idle();
|
||||
thd->proc_info="feedback";
|
||||
thd->set_command(COM_SLEEP);
|
||||
thd->system_thread= SYSTEM_THREAD_EVENT_WORKER; // whatever
|
||||
thd->set_time();
|
||||
thd->init_for_queries();
|
||||
|
|
|
@ -1630,6 +1630,7 @@ void THD::reset_for_reuse()
|
|||
abort_on_warning= 0;
|
||||
free_connection_done= 0;
|
||||
m_command= COM_CONNECT;
|
||||
proc_info= "login"; // Same as in THD::THD()
|
||||
transaction.on= 1;
|
||||
#if defined(ENABLED_PROFILING)
|
||||
profiling.reset();
|
||||
|
|
|
@ -4630,13 +4630,24 @@ public:
|
|||
public:
|
||||
/** Overloaded to guard query/query_length fields */
|
||||
virtual void set_statement(Statement *stmt);
|
||||
void set_command(enum enum_server_command command)
|
||||
inline void set_command(enum enum_server_command command)
|
||||
{
|
||||
DBUG_ASSERT(command != COM_SLEEP);
|
||||
m_command= command;
|
||||
#ifdef HAVE_PSI_THREAD_INTERFACE
|
||||
PSI_STATEMENT_CALL(set_thread_command)(m_command);
|
||||
#endif
|
||||
}
|
||||
/* As sleep needs a bit of special handling, we have a special case for it */
|
||||
inline void mark_connection_idle()
|
||||
{
|
||||
proc_info= 0;
|
||||
m_command= COM_SLEEP;
|
||||
#ifdef HAVE_PSI_THREAD_INTERFACE
|
||||
PSI_STATEMENT_CALL(set_thread_command)(m_command);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline enum enum_server_command get_command() const
|
||||
{ return m_command; }
|
||||
|
||||
|
|
|
@ -1249,8 +1249,7 @@ void prepare_new_connection_state(THD* thd)
|
|||
embedded server library.
|
||||
TODO: refactor this to avoid code duplication there
|
||||
*/
|
||||
thd->proc_info= 0;
|
||||
thd->set_command(COM_SLEEP);
|
||||
thd->mark_connection_idle();
|
||||
thd->init_for_queries();
|
||||
|
||||
if (opt_init_connect.length && !(sctx->master_access & SUPER_ACL))
|
||||
|
|
|
@ -2465,7 +2465,7 @@ dispatch_end:
|
|||
/* Performance Schema Interface instrumentation, end */
|
||||
MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da());
|
||||
thd->set_examined_row_count(0); // For processlist
|
||||
thd->set_command(COM_SLEEP);
|
||||
thd->mark_connection_idle();
|
||||
|
||||
thd->m_statement_psi= NULL;
|
||||
thd->m_digest= NULL;
|
||||
|
@ -7903,6 +7903,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
|
|||
thd->wsrep_retry_query = NULL;
|
||||
thd->wsrep_retry_query_len = 0;
|
||||
thd->wsrep_retry_command = COM_CONNECT;
|
||||
thd->proc_info= 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2818,7 +2818,7 @@ static const char *thread_state_info(THD *tmp)
|
|||
if (cond)
|
||||
return "Waiting on cond";
|
||||
}
|
||||
return NULL;
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ enum wsrep::provider::status Wsrep_client_service::replay()
|
|||
replayer_thd->real_id= pthread_self();
|
||||
replayer_thd->prior_thr_create_utime=
|
||||
replayer_thd->start_utime= microsecond_interval_timer();
|
||||
replayer_thd->set_command(COM_SLEEP);
|
||||
replayer_thd->mark_connection_idle();
|
||||
replayer_thd->reset_for_next_command(true);
|
||||
|
||||
enum wsrep::provider::status ret;
|
||||
|
|
|
@ -3015,8 +3015,7 @@ void* start_wsrep_THD(void *arg)
|
|||
thd->security_ctx->skip_grants();
|
||||
|
||||
/* handle_one_connection() again... */
|
||||
thd->proc_info= 0;
|
||||
thd->set_command(COM_SLEEP);
|
||||
thd->mark_connection_idle();
|
||||
thd->init_for_queries();
|
||||
mysql_mutex_lock(&LOCK_wsrep_slave_threads);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ static void init_service_thd(THD* thd, char* thread_stack)
|
|||
thd->thread_stack= thread_stack;
|
||||
thd->real_id= pthread_self();
|
||||
thd->prior_thr_create_utime= thd->start_utime= microsecond_interval_timer();
|
||||
thd->set_command(COM_SLEEP);
|
||||
thd->mark_connection_idle();
|
||||
thd->reset_for_next_command(true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue