Skip to content

Commit

Permalink
MDEV-24546 : AddressSanitizer: initialization-order-fiasco on address…
Browse files Browse the repository at this point in the history
… ... in Sys_var_integer from __static_initialization_and_destruction_0, possibly inside global var wsrep_gtid_server

Galera parameter wsrep_gtid_domain_id was defined using a class where
actual parameter was not a first member. Fixed this by using normal
variable and assigning this value to class member value.
  • Loading branch information
Jan Lindström committed Jan 9, 2021
1 parent fae87e0 commit 49b8774
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sql/sys_vars.cc
Expand Up @@ -6051,8 +6051,10 @@ static Sys_var_uint Sys_wsrep_gtid_domain_id(
"wsrep_gtid_domain_id", "When wsrep_gtid_mode is set, this value is "
"used as gtid_domain_id for galera transactions and also copied to the "
"joiner nodes during state transfer. It is ignored, otherwise.",
GLOBAL_VAR(wsrep_gtid_server.domain_id), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, UINT_MAX32), DEFAULT(0), BLOCK_SIZE(1));
GLOBAL_VAR(wsrep_gtid_domain_id), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, UINT_MAX32), DEFAULT(0), BLOCK_SIZE(1),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
ON_UPDATE(wsrep_gtid_domain_id_update));

static Sys_var_ulonglong Sys_wsrep_gtid_seq_no(
"wsrep_gtid_seq_no",
Expand Down
1 change: 1 addition & 0 deletions sql/wsrep_mysqld.cc
Expand Up @@ -110,6 +110,7 @@ ulong wsrep_mysql_replication_bundle;

bool wsrep_gtid_mode; // Enable WSREP native GTID support
Wsrep_gtid_server wsrep_gtid_server;
uint wsrep_gtid_domain_id=0; // Domain id on above structure

/* Other configuration variables and their default values. */
my_bool wsrep_incremental_data_collection= 0; // Incremental data collection
Expand Down
1 change: 1 addition & 0 deletions sql/wsrep_mysqld.h
Expand Up @@ -101,6 +101,7 @@ extern ulong wsrep_running_rollbacker_threads;
extern bool wsrep_new_cluster;
extern bool wsrep_gtid_mode;
extern my_bool wsrep_strict_ddl;
extern uint wsrep_gtid_domain_id;

enum enum_wsrep_reject_types {
WSREP_REJECT_NONE, /* nothing rejected */
Expand Down
8 changes: 8 additions & 0 deletions sql/wsrep_var.cc
Expand Up @@ -961,3 +961,11 @@ void wsrep_free_status (THD* thd)
{
thd->wsrep_status_vars.clear();
}

bool wsrep_gtid_domain_id_update(sys_var* self, THD *thd, enum_var_type)
{
WSREP_DEBUG("wsrep_gtid_domain_id_update: %llu",
wsrep_gtid_domain_id);
wsrep_gtid_server.domain_id= wsrep_gtid_domain_id;
return false;
}
1 change: 1 addition & 0 deletions sql/wsrep_var.h
Expand Up @@ -105,6 +105,7 @@ extern bool wsrep_debug_update UPDATE_ARGS;

extern bool wsrep_gtid_seq_no_check CHECK_ARGS;

extern bool wsrep_gtid_domain_id_update UPDATE_ARGS;
#else /* WITH_WSREP */

#define wsrep_provider_init(X)
Expand Down

0 comments on commit 49b8774

Please sign in to comment.