mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
bugfix: federated/replication did not increment bytes_received status variable
because mysql->net.thd was reset to NULL in mysql_real_connect() and thd_increment_bytes_received() didn't do anything. Fix: * set mysql->net.thd to current_thd instread. * remove the test for non-null THD from a very often used function thd_increment_bytes_received().
This commit is contained in:
@@ -367,6 +367,26 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
|
||||
} while(0)
|
||||
#endif /* !set_timespec_time_nsec */
|
||||
|
||||
#ifdef MYSQL_CLIENT
|
||||
#define _current_thd() NULL
|
||||
#elif defined(_WIN32)
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
MYSQL_THD _current_thd_noinline();
|
||||
#define _current_thd() _current_thd_noinline()
|
||||
#else
|
||||
/*
|
||||
THR_THD is a key which will be used to set/get THD* for a thread,
|
||||
using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
|
||||
*/
|
||||
extern pthread_key(MYSQL_THD, THR_THD);
|
||||
static inline MYSQL_THD _current_thd(void)
|
||||
{
|
||||
return my_pthread_getspecific_ptr(MYSQL_THD,THR_THD);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* safe_mutex adds checking to mutex for easier debugging */
|
||||
struct st_hash;
|
||||
typedef struct st_safe_mutex_t
|
||||
|
@@ -3408,7 +3408,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
|
||||
if (mysql->options.extension && mysql->options.extension->async_context)
|
||||
net->vio->async_context= mysql->options.extension->async_context;
|
||||
|
||||
if (my_net_init(net, net->vio, 0, MYF(0)))
|
||||
if (my_net_init(net, net->vio, _current_thd(), MYF(0)))
|
||||
{
|
||||
vio_delete(net->vio);
|
||||
net->vio = 0;
|
||||
|
@@ -6187,7 +6187,7 @@ static void bootstrap(MYSQL_FILE *file)
|
||||
thd->variables.wsrep_on= 0;
|
||||
#endif
|
||||
thd->bootstrap=1;
|
||||
my_net_init(&thd->net,(st_vio*) 0, (void*) 0, MYF(0));
|
||||
my_net_init(&thd->net,(st_vio*) 0, thd, MYF(0));
|
||||
thd->max_client_packet_length= thd->net.max_packet;
|
||||
thd->security_ctx->master_access= ~(ulong)0;
|
||||
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
|
||||
|
14
sql/mysqld.h
14
sql/mysqld.h
@@ -761,20 +761,6 @@ inline void dec_thread_running()
|
||||
|
||||
void set_server_version(void);
|
||||
|
||||
#if defined(MYSQL_DYNAMIC_PLUGIN) && defined(_WIN32)
|
||||
extern "C" THD *_current_thd_noinline();
|
||||
#define _current_thd() _current_thd_noinline()
|
||||
#else
|
||||
/*
|
||||
THR_THD is a key which will be used to set/get THD* for a thread,
|
||||
using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
|
||||
*/
|
||||
extern pthread_key(THD*, THR_THD);
|
||||
inline THD *_current_thd(void)
|
||||
{
|
||||
return my_pthread_getspecific_ptr(THD*,THR_THD);
|
||||
}
|
||||
#endif
|
||||
#define current_thd _current_thd()
|
||||
inline int set_current_thd(THD *thd)
|
||||
{
|
||||
|
@@ -369,16 +369,6 @@ void thd_close_connection(THD *thd)
|
||||
vio_close(thd->net.vio);
|
||||
}
|
||||
|
||||
/**
|
||||
Get current THD object from thread local data
|
||||
|
||||
@retval The THD object for the thread, NULL if not connection thread
|
||||
*/
|
||||
THD *thd_get_current_thd()
|
||||
{
|
||||
return current_thd;
|
||||
}
|
||||
|
||||
/**
|
||||
Lock data that needs protection in THD object
|
||||
|
||||
@@ -4074,16 +4064,12 @@ my_bool thd_net_is_killed()
|
||||
|
||||
void thd_increment_bytes_received(void *thd, ulong length)
|
||||
{
|
||||
if (unlikely(!thd)) // Called from federatedx
|
||||
thd= current_thd;
|
||||
((THD*) thd)->status_var.bytes_received+= length;
|
||||
}
|
||||
|
||||
|
||||
void thd_increment_net_big_packet_count(void *thd, ulong length)
|
||||
{
|
||||
if (unlikely(!thd)) // Called from federatedx
|
||||
thd= current_thd;
|
||||
((THD*) thd)->status_var.net_big_packet_count+= length;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user