diff options
-rw-r--r-- | include/my_counter.h | 3 | ||||
-rw-r--r-- | sql/log_event.cc | 10 | ||||
-rw-r--r-- | sql/mysqld.h | 1 | ||||
-rw-r--r-- | sql/rpl_mi.h | 6 | ||||
-rw-r--r-- | sql/slave.cc | 13 | ||||
-rw-r--r-- | sql/sql_class.cc | 1 | ||||
-rw-r--r-- | sql/sql_statistics.cc | 1 | ||||
-rw-r--r-- | sql/table.cc | 1 |
8 files changed, 13 insertions, 23 deletions
diff --git a/include/my_counter.h b/include/my_counter.h index 00fbf8cef91..68c04fb3f1d 100644 --- a/include/my_counter.h +++ b/include/my_counter.h @@ -28,6 +28,9 @@ template <typename Type> class Atomic_counter Type sub(Type i) { return m_counter.fetch_sub(i, std::memory_order_relaxed); } public: + Atomic_counter(Type val): m_counter(val) {} + Atomic_counter() {} + Type operator++(int) { return add(1); } Type operator--(int) { return sub(1); } diff --git a/sql/log_event.cc b/sql/log_event.cc index 3ea6be95dda..7a0d0beb5ad 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -53,7 +53,6 @@ #include "rpl_constants.h" #include "sql_digest.h" #include "zlib.h" -#include "my_atomic.h" #define my_b_write_string(A, B) my_b_write((A), (uchar*)(B), (uint) (sizeof(B) - 1)) @@ -8055,16 +8054,13 @@ Gtid_log_event::do_apply_event(rpl_group_info *rgi) switch (flags2 & (FL_DDL | FL_TRANSACTIONAL)) { case FL_TRANSACTIONAL: - my_atomic_add64_explicit((volatile int64 *)&mi->total_trans_groups, 1, - MY_MEMORY_ORDER_RELAXED); + mi->total_trans_groups++; break; case FL_DDL: - my_atomic_add64_explicit((volatile int64 *)&mi->total_ddl_groups, 1, - MY_MEMORY_ORDER_RELAXED); + mi->total_ddl_groups++; break; default: - my_atomic_add64_explicit((volatile int64 *)&mi->total_non_trans_groups, 1, - MY_MEMORY_ORDER_RELAXED); + mi->total_non_trans_groups++; } if (flags2 & FL_STANDALONE) diff --git a/sql/mysqld.h b/sql/mysqld.h index c84e1d08efe..22c572b19fa 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -23,6 +23,7 @@ #include "my_decimal.h" /* my_decimal */ #include "mysql_com.h" /* SERVER_VERSION_LENGTH */ #include "my_atomic.h" +#include "my_counter.h" #include "mysql/psi/mysql_file.h" /* MYSQL_FILE */ #include "mysql/psi/mysql_socket.h" /* MYSQL_SOCKET */ #include "sql_list.h" /* I_List */ diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h index 54d6b5be592..5de73254ed9 100644 --- a/sql/rpl_mi.h +++ b/sql/rpl_mi.h @@ -329,13 +329,13 @@ class Master_info : public Slave_reporting_capability /* No of DDL event group */ - volatile uint64 total_ddl_groups; + Atomic_counter<uint64> total_ddl_groups; /* No of non-transactional event group*/ - volatile uint64 total_non_trans_groups; + Atomic_counter<uint64> total_non_trans_groups; /* No of transactional event group*/ - volatile uint64 total_trans_groups; + Atomic_counter<uint64> total_trans_groups; /* domain-id based filter */ Domain_id_filter domain_id_filter; diff --git a/sql/slave.cc b/sql/slave.cc index 03b730b2b00..5fbe0c77661 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3407,16 +3407,9 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full, // Slave_SQL_Running_State protocol->store(slave_sql_running_state, &my_charset_bin); - uint64 events; - events= (uint64)my_atomic_load64_explicit((volatile int64 *) - &mi->total_ddl_groups, MY_MEMORY_ORDER_RELAXED); - protocol->store(events); - events= (uint64)my_atomic_load64_explicit((volatile int64 *) - &mi->total_non_trans_groups, MY_MEMORY_ORDER_RELAXED); - protocol->store(events); - events= (uint64)my_atomic_load64_explicit((volatile int64 *) - &mi->total_trans_groups, MY_MEMORY_ORDER_RELAXED); - protocol->store(events); + protocol->store(mi->total_ddl_groups); + protocol->store(mi->total_non_trans_groups); + protocol->store(mi->total_trans_groups); if (full) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 2292587bbd0..db805479b65 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -68,7 +68,6 @@ #include "wsrep_mysqld.h" #include "wsrep_thd.h" #include "sql_connect.h" -#include "my_atomic.h" #ifdef HAVE_SYS_SYSCALL_H #include <sys/syscall.h> diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 6f4474860a9..db214a1fe28 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -29,7 +29,6 @@ #include "sql_statistics.h" #include "opt_range.h" #include "uniques.h" -#include "my_atomic.h" #include "sql_show.h" #include "sql_partition.h" diff --git a/sql/table.cc b/sql/table.cc index 6737e57d728..0a40c5fb341 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -44,7 +44,6 @@ #include "sql_cte.h" #include "ha_sequence.h" #include "sql_show.h" -#include <atomic> /* For MySQL 5.7 virtual fields */ #define MYSQL57_GENERATED_FIELD 128 |