Skip to content

Commit

Permalink
default_gtid_pos_table: my_atomic to std::atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Vojtovich committed Mar 21, 2020
1 parent 9394cc8 commit 4d9977e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions client/mysqlbinlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
/* That one is necessary for defines of OPTION_NO_FOREIGN_KEY_CHECKS etc */
#include "sql_priv.h"
#include "sql_basic_types.h"
#include <atomic>
#include "log_event.h"
#include "compat56.h"
#include "sql_common.h"
Expand Down
14 changes: 5 additions & 9 deletions sql/rpl_gtid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ gtid_check_rpl_slave_state_table(TABLE *table)
void
rpl_slave_state::select_gtid_pos_table(THD *thd, LEX_CSTRING *out_tablename)
{
struct gtid_pos_table *list, *table_entry, *default_entry;
struct gtid_pos_table *list, *table_entry;

/*
See comments on rpl_slave_state::gtid_pos_tables for rules around proper
Expand Down Expand Up @@ -565,9 +565,8 @@ rpl_slave_state::select_gtid_pos_table(THD *thd, LEX_CSTRING *out_tablename)
already active in the transaction, or if there is no current transaction
engines available, we return the default gtid_slave_pos table.
*/
default_entry= (struct gtid_pos_table *)
my_atomic_loadptr_explicit(&default_gtid_pos_table, MY_MEMORY_ORDER_ACQUIRE);
*out_tablename= default_entry->table_name;
*out_tablename=
default_gtid_pos_table.load(std::memory_order_acquire)->table_name;
/* Record in status that we failed to find a suitable gtid_pos table. */
if (count > 0)
{
Expand Down Expand Up @@ -840,9 +839,7 @@ rpl_slave_state::select_gtid_pos_table(void *hton)
table_entry= table_entry->next;
}

table_entry= (struct gtid_pos_table *)
my_atomic_loadptr_explicit(&default_gtid_pos_table, MY_MEMORY_ORDER_ACQUIRE);
return &table_entry->table_name;
return &default_gtid_pos_table.load(std::memory_order_acquire)->table_name;
}


Expand Down Expand Up @@ -1445,8 +1442,7 @@ rpl_slave_state::set_gtid_pos_tables_list(rpl_slave_state::gtid_pos_table *new_l
mysql_mutex_assert_owner(&LOCK_slave_state);
old_list= (struct gtid_pos_table *)gtid_pos_tables;
my_atomic_storeptr_explicit(&gtid_pos_tables, new_list, MY_MEMORY_ORDER_RELEASE);
my_atomic_storeptr_explicit(&default_gtid_pos_table, default_entry,
MY_MEMORY_ORDER_RELEASE);
default_gtid_pos_table.store(default_entry, std::memory_order_release);
free_gtid_pos_tables(old_list);
}

Expand Down
2 changes: 1 addition & 1 deletion sql/rpl_gtid.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ struct rpl_slave_state
*/
void * volatile gtid_pos_tables;
/* The default entry in gtid_pos_tables, mysql.gtid_slave_pos. */
void * volatile default_gtid_pos_table;
std::atomic<gtid_pos_table*> default_gtid_pos_table;
bool loaded;

rpl_slave_state();
Expand Down

0 comments on commit 4d9977e

Please sign in to comment.