diff options
author | Sujatha <sujatha.sivakumar@mariadb.com> | 2020-11-12 13:04:39 +0530 |
---|---|---|
committer | Sujatha <sujatha.sivakumar@mariadb.com> | 2020-11-12 13:04:39 +0530 |
commit | 984a06db2ce2b2e3c7c5028245905417f2141cd7 (patch) | |
tree | ebaa78908f2b70726492b9ac1a69c5496867d308 /sql/log.cc | |
parent | dd33a70dad2b32aa6fcdbd1f8161d5351f6dbebd (diff) | |
download | mariadb-git-984a06db2ce2b2e3c7c5028245905417f2141cd7.tar.gz |
MDEV-4633: multi_source.simple test fails sporadically
Analysis:
========
Writes to 'rli->log_space_total' needs to be synchronized, otherwise both
SQL_THREAD and IO_THREAD can try to modify the variable simultaneously
resulting in incorrect rli->log_space_total. In the current test scenario
SQL_THREAD is trying to decrement 'rli->log_space_total' in 'purge_first_log'
and IO_THREAD is trying to increment the 'rli->log_space_total' in
'queue_event' simultaneously. Hence test occasionally fails with result
mismatch.
Fix:
===
Convert 'rli->log_space_total' variable to atomic type.
Diffstat (limited to 'sql/log.cc')
-rw-r--r-- | sql/log.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/log.cc b/sql/log.cc index 54a8bd9552f..dc8df9c6fdb 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -4397,7 +4397,9 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included) 0, 0, &log_space_reclaimed); mysql_mutex_lock(&rli->log_space_lock); - rli->log_space_total-= log_space_reclaimed; + my_atomic_add64_explicit((volatile int64*)(&rli->log_space_total), + (-(int64)log_space_reclaimed), + MY_MEMORY_ORDER_RELAXED); mysql_cond_broadcast(&rli->log_space_cond); mysql_mutex_unlock(&rli->log_space_lock); |