mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-6156: Parallel replication incorrectly caches charset between worker threads
The previous patch for this bug was unfortunately completely wrong. The purpose of cached_charset is to remember which character set we have installed currently in the THD, so that in the common case where charset does not change between queries, we do not need to update it in the THD. Thus, it is important that the cached_charset field is tightly coupled to the THD for which it handles caching. Thus the right place to put cached_charset seems to be in the THD. This patch introduces a field THD:system_thread_info where such info in general can be placed without further inflating the THD with unused data for other threads (THD is already far too big as it is). It then moves the cached_charset into this slot for the SQL driver thread and for the parallel replication worker threads. The THD::rpl_filter field is also moved inside system_thread_info, to keep the size of THD unchanged. Moving further fields in to reduce the size of THD is a separate task, filed as MDEV-6164.
This commit is contained in:
@@ -2891,7 +2891,7 @@ void set_slave_thread_default_charset(THD* thd, rpl_group_info *rgi)
|
||||
global_system_variables.collation_server;
|
||||
thd->update_charset();
|
||||
|
||||
rgi->cached_charset_invalidate();
|
||||
thd->system_thread_info.rpl_sql_info->cached_charset_invalidate();
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@@ -3768,6 +3768,7 @@ pthread_handler_t handle_slave_io(void *arg)
|
||||
uint retry_count;
|
||||
bool suppress_warnings;
|
||||
int ret;
|
||||
rpl_io_thread_info io_info;
|
||||
#ifndef DBUG_OFF
|
||||
uint retry_count_reg= 0, retry_count_dump= 0, retry_count_event= 0;
|
||||
#endif
|
||||
@@ -3801,6 +3802,7 @@ pthread_handler_t handle_slave_io(void *arg)
|
||||
sql_print_error("Failed during slave I/O thread initialization");
|
||||
goto err_during_init;
|
||||
}
|
||||
thd->system_thread_info.rpl_io_info= &io_info;
|
||||
mysql_mutex_lock(&LOCK_thread_count);
|
||||
threads.append(thd);
|
||||
mysql_mutex_unlock(&LOCK_thread_count);
|
||||
@@ -4367,6 +4369,7 @@ pthread_handler_t handle_slave_sql(void *arg)
|
||||
Relay_log_info* rli = &mi->rli;
|
||||
const char *errmsg;
|
||||
rpl_group_info *serial_rgi;
|
||||
rpl_sql_thread_info sql_info(mi->rpl_filter);
|
||||
|
||||
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
|
||||
my_thread_init();
|
||||
@@ -4378,7 +4381,7 @@ pthread_handler_t handle_slave_sql(void *arg)
|
||||
serial_rgi= new rpl_group_info(rli);
|
||||
thd = new THD; // note that contructor of THD uses DBUG_ !
|
||||
thd->thread_stack = (char*)&thd; // remember where our stack is
|
||||
thd->rpl_filter = mi->rpl_filter;
|
||||
thd->system_thread_info.rpl_sql_info= &sql_info;
|
||||
|
||||
DBUG_ASSERT(rli->inited);
|
||||
DBUG_ASSERT(rli->mi == mi);
|
||||
@@ -4676,7 +4679,7 @@ err_during_init:
|
||||
mysql_cond_broadcast(&rli->data_cond);
|
||||
rli->ignore_log_space_limit= 0; /* don't need any lock */
|
||||
/* we die so won't remember charset - re-update them on next thread start */
|
||||
serial_rgi->cached_charset_invalidate();
|
||||
thd->system_thread_info.rpl_sql_info->cached_charset_invalidate();
|
||||
|
||||
/*
|
||||
TODO: see if we can do this conditionally in next_event() instead
|
||||
|
Reference in New Issue
Block a user