Skip to content

Commit

Permalink
Master_info counters transition to Atomic_counter
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Vojtovich committed Dec 29, 2018
1 parent 656a702 commit d2bdd78
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 23 deletions.
3 changes: 3 additions & 0 deletions include/my_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down
10 changes: 3 additions & 7 deletions sql/log_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions sql/mysqld.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
6 changes: 3 additions & 3 deletions sql/rpl_mi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 3 additions & 10 deletions sql/slave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 0 additions & 1 deletion sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 0 additions & 1 deletion sql/sql_statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion sql/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d2bdd78

Please sign in to comment.