Skip to content

Commit d2bdd78

Browse files
committed
Master_info counters transition to Atomic_counter
1 parent 656a702 commit d2bdd78

File tree

8 files changed

+13
-23
lines changed

8 files changed

+13
-23
lines changed

include/my_counter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ template <typename Type> class Atomic_counter
2828
Type sub(Type i) { return m_counter.fetch_sub(i, std::memory_order_relaxed); }
2929

3030
public:
31+
Atomic_counter(Type val): m_counter(val) {}
32+
Atomic_counter() {}
33+
3134
Type operator++(int) { return add(1); }
3235
Type operator--(int) { return sub(1); }
3336

sql/log_event.cc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
#include "rpl_constants.h"
5454
#include "sql_digest.h"
5555
#include "zlib.h"
56-
#include "my_atomic.h"
5756

5857
#define my_b_write_string(A, B) my_b_write((A), (uchar*)(B), (uint) (sizeof(B) - 1))
5958

@@ -8055,16 +8054,13 @@ Gtid_log_event::do_apply_event(rpl_group_info *rgi)
80558054
switch (flags2 & (FL_DDL | FL_TRANSACTIONAL))
80568055
{
80578056
case FL_TRANSACTIONAL:
8058-
my_atomic_add64_explicit((volatile int64 *)&mi->total_trans_groups, 1,
8059-
MY_MEMORY_ORDER_RELAXED);
8057+
mi->total_trans_groups++;
80608058
break;
80618059
case FL_DDL:
8062-
my_atomic_add64_explicit((volatile int64 *)&mi->total_ddl_groups, 1,
8063-
MY_MEMORY_ORDER_RELAXED);
8060+
mi->total_ddl_groups++;
80648061
break;
80658062
default:
8066-
my_atomic_add64_explicit((volatile int64 *)&mi->total_non_trans_groups, 1,
8067-
MY_MEMORY_ORDER_RELAXED);
8063+
mi->total_non_trans_groups++;
80688064
}
80698065

80708066
if (flags2 & FL_STANDALONE)

sql/mysqld.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "my_decimal.h" /* my_decimal */
2424
#include "mysql_com.h" /* SERVER_VERSION_LENGTH */
2525
#include "my_atomic.h"
26+
#include "my_counter.h"
2627
#include "mysql/psi/mysql_file.h" /* MYSQL_FILE */
2728
#include "mysql/psi/mysql_socket.h" /* MYSQL_SOCKET */
2829
#include "sql_list.h" /* I_List */

sql/rpl_mi.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,13 @@ class Master_info : public Slave_reporting_capability
329329

330330

331331
/* No of DDL event group */
332-
volatile uint64 total_ddl_groups;
332+
Atomic_counter<uint64> total_ddl_groups;
333333

334334
/* No of non-transactional event group*/
335-
volatile uint64 total_non_trans_groups;
335+
Atomic_counter<uint64> total_non_trans_groups;
336336

337337
/* No of transactional event group*/
338-
volatile uint64 total_trans_groups;
338+
Atomic_counter<uint64> total_trans_groups;
339339

340340
/* domain-id based filter */
341341
Domain_id_filter domain_id_filter;

sql/slave.cc

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,16 +3407,9 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
34073407
// Slave_SQL_Running_State
34083408
protocol->store(slave_sql_running_state, &my_charset_bin);
34093409

3410-
uint64 events;
3411-
events= (uint64)my_atomic_load64_explicit((volatile int64 *)
3412-
&mi->total_ddl_groups, MY_MEMORY_ORDER_RELAXED);
3413-
protocol->store(events);
3414-
events= (uint64)my_atomic_load64_explicit((volatile int64 *)
3415-
&mi->total_non_trans_groups, MY_MEMORY_ORDER_RELAXED);
3416-
protocol->store(events);
3417-
events= (uint64)my_atomic_load64_explicit((volatile int64 *)
3418-
&mi->total_trans_groups, MY_MEMORY_ORDER_RELAXED);
3419-
protocol->store(events);
3410+
protocol->store(mi->total_ddl_groups);
3411+
protocol->store(mi->total_non_trans_groups);
3412+
protocol->store(mi->total_trans_groups);
34203413

34213414
if (full)
34223415
{

sql/sql_class.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
#include "wsrep_mysqld.h"
6969
#include "wsrep_thd.h"
7070
#include "sql_connect.h"
71-
#include "my_atomic.h"
7271

7372
#ifdef HAVE_SYS_SYSCALL_H
7473
#include <sys/syscall.h>

sql/sql_statistics.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "sql_statistics.h"
3030
#include "opt_range.h"
3131
#include "uniques.h"
32-
#include "my_atomic.h"
3332
#include "sql_show.h"
3433
#include "sql_partition.h"
3534

sql/table.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "sql_cte.h"
4545
#include "ha_sequence.h"
4646
#include "sql_show.h"
47-
#include <atomic>
4847

4948
/* For MySQL 5.7 virtual fields */
5049
#define MYSQL57_GENERATED_FIELD 128

0 commit comments

Comments
 (0)