Commit be5fce16 authored by Jan Lindström's avatar Jan Lindström

MDEV-24596 : Assertion `state_ == s_exec || state_ == s_quitting' failed in...

MDEV-24596 : Assertion `state_ == s_exec || state_ == s_quitting' failed in wsrep::client_state::disable_streaming

There were multiple problems here
* wsrep_trx_fragment_size should not be set when wsrep is disabled or provider is not loaded
* wsrep_trx_fragment_unit should not be set when wsrep is disabled or provider is not loaded
* wsrep_debug has no effect if wsrep is disabled or provider is not loaded
* wsrep_start_position should not be set when wsrep is disabled or provider is not loaded any other value than default
* wsrep_start_position should be changed only when we are joiner or initialized
* wsrep_start_position should be allowed to set only a value that exits, thus
we need to add error handling to wsrep_sst_complete
parent 9377e9ba
......@@ -23,6 +23,7 @@ galera_binlog_stmt_autoinc : MDEV-19959 Galera test failure on galera_binlog_stm
galera_encrypt_tmp_files : Get error failed to enable encryption of temporary files
galera_ftwrl : MDEV-21525 galera.galera_ftwrl
galera_gcache_recover_manytrx : MDEV-18834 Galera test failure
galera_ist_mysqldump : MDEV-24463 galera.galera_sst_mysqldump_with_key MTR failed: 'INSERT failed: 1213: Deadlock found when trying to get lock
galera_kill_largechanges : MDEV-18179 Galera test failure on galera.galera_kill_largechanges
galera_kill_nochanges : MDEV-18280 Galera test failure on galera_split_brain and galera_kill_nochanges
galera_many_tables_nopk : MDEV-18182 Galera test failure on galera.galera_many_tables_nopk
......@@ -33,6 +34,8 @@ galera_shutdown_nonprim : MDEV-21493 galera.galera_shutdown_nonprim
galera_split_brain : MDEV-18280 Galera test failure on galera_split_brain and galera_kill_nochanges
galera_ssl_upgrade : MDEV-19950 Galera test failure on galera_ssl_upgrade
galera_sst_mariabackup_encrypt_with_key : MDEV-21484 galera_sst_mariabackup_encrypt_with_key
galera_sst_mysqldump : MDEV-24463 galera.galera_sst_mysqldump_with_key MTR failed: 'INSERT failed: 1213: Deadlock found when trying to get lock
galera_sst_mysqldump_with_key : MDEV-24463 galera.galera_sst_mysqldump_with_key MTR failed: 'INSERT failed: 1213: Deadlock found when trying to get lock
galera_toi_ddl_nonconflicting : MDEV-21518 galera.galera_toi_ddl_nonconflicting
galera_toi_truncate : MDEV-22996 Hang on galera_toi_truncate test case
galera_var_node_address : MDEV-20485 Galera test failure
......
connection node_2;
connection node_1;
#
# wsrep_start_position
#
CALL mtr.add_suppression("WSREP: SST failed for position .*");
SET @wsrep_start_position_global_saved = @@global.wsrep_start_position;
# default
SELECT @@global.wsrep_start_position;
......@@ -15,20 +18,22 @@ SELECT @@global.wsrep_start_position;
00000000-0000-0000-0000-000000000000:-1
# valid values
SET @@global.wsrep_start_position='12345678-1234-1234-1234-123456789012:100';
SET @@global.wsrep_start_position='00000000-0000-0000-0000-000000000000:-1';
SELECT @@global.wsrep_start_position;
@@global.wsrep_start_position
12345678-1234-1234-1234-123456789012:100
00000000-0000-0000-0000-000000000000:-1
SET @@global.wsrep_start_position='00000000-0000-0000-0000-000000000000:0';
ERROR 42000: Variable 'wsrep_start_position' can't be set to the value of '00000000-0000-0000-0000-000000000000:0'
SELECT @@global.wsrep_start_position;
@@global.wsrep_start_position
00000000-0000-0000-0000-000000000000:0
SET @@global.wsrep_start_position='00000000-0000-0000-0000-000000000000:-1';
00000000-0000-0000-0000-000000000000:-1
# invalid values
SET @@global.wsrep_start_position='12345678-1234-1234-1234-123456789012:100';
ERROR 42000: Variable 'wsrep_start_position' can't be set to the value of '12345678-1234-1234-1234-123456789012:100'
SELECT @@global.wsrep_start_position;
@@global.wsrep_start_position
00000000-0000-0000-0000-000000000000:-1
# invalid values
SET @@global.wsrep_start_position='00000000-0000-0000-0000-000000000000:-2';
ERROR 42000: Variable 'wsrep_start_position' can't be set to the value of '00000000-0000-0000-0000-000000000000:-2'
SELECT @@global.wsrep_start_position;
......
--source include/have_wsrep.inc
--source include/galera_cluster.inc
--echo #
--echo # wsrep_start_position
--echo #
SET @wsrep_start_position_global_saved = @@global.wsrep_start_position;
CALL mtr.add_suppression("WSREP: SST failed for position .*");
SET @wsrep_start_position_global_saved = @@global.wsrep_start_position;
--echo # default
SELECT @@global.wsrep_start_position;
......@@ -15,19 +16,20 @@ SELECT @@global.wsrep_start_position;
SELECT @@session.wsrep_start_position;
SELECT @@global.wsrep_start_position;
--echo
--echo # valid values
SET @@global.wsrep_start_position='12345678-1234-1234-1234-123456789012:100';
SELECT @@global.wsrep_start_position;
SET @@global.wsrep_start_position='00000000-0000-0000-0000-000000000000:0';
SELECT @@global.wsrep_start_position;
SET @@global.wsrep_start_position='00000000-0000-0000-0000-000000000000:-1';
SELECT @@global.wsrep_start_position;
--echo
--error ER_WRONG_VALUE_FOR_VAR
SET @@global.wsrep_start_position='00000000-0000-0000-0000-000000000000:0';
SELECT @@global.wsrep_start_position;
--echo # invalid values
--error ER_WRONG_VALUE_FOR_VAR
SET @@global.wsrep_start_position='12345678-1234-1234-1234-123456789012:100';
SELECT @@global.wsrep_start_position;
--error ER_WRONG_VALUE_FOR_VAR
SET @@global.wsrep_start_position='00000000-0000-0000-0000-000000000000:-2';
SELECT @@global.wsrep_start_position;
--error ER_WRONG_VALUE_FOR_VAR
......
......@@ -16,9 +16,11 @@ SELECT @@global.wsrep_debug;
@@global.wsrep_debug
NONE
SET @@global.wsrep_debug=1;
Warnings:
Warning 1231 Setting 'wsrep_debug' has no effect because wsrep is switched off
SELECT @@global.wsrep_debug;
@@global.wsrep_debug
SERVER
NONE
# valid values
SET @@global.wsrep_debug=NONE;
......@@ -26,9 +28,11 @@ SELECT @@global.wsrep_debug;
@@global.wsrep_debug
NONE
SET @@global.wsrep_debug=SERVER;
Warnings:
Warning 1231 Setting 'wsrep_debug' has no effect because wsrep is switched off
SELECT @@global.wsrep_debug;
@@global.wsrep_debug
SERVER
NONE
SET @@global.wsrep_debug=default;
SELECT @@global.wsrep_debug;
@@global.wsrep_debug
......
SELECT @@wsrep_on;
@@wsrep_on
1
SET @wsrep_slave_threads_global_saved = @@global.wsrep_slave_threads;
SET @wsrep_debug_saved = @@global.wsrep_debug;
SET @wsrep_provider_options_saved= @@global.wsrep_provider_options;
SET @wsrep_cluster_address_saved= @@global.wsrep_cluster_address;
SET GLOBAL wsrep_provider=none;
SET SESSION wsrep_trx_fragment_size=DEFAULT;
ERROR HY000: Incorrect arguments to SET
SELECT @@session.wsrep_trx_fragment_size;
@@session.wsrep_trx_fragment_size
0
SET GLOBAL wsrep_start_position='12345678-1234-1234-1234-123456789012:100';
ERROR 42000: Variable 'wsrep_start_position' can't be set to the value of '12345678-1234-1234-1234-123456789012:100'
SHOW WARNINGS;
Level Code Message
Warning 1231 Cannot set 'wsrep_start_position' because wsrep is switched off or provider is not loaded
Error 1231 Variable 'wsrep_start_position' can't be set to the value of '12345678-1234-1234-1234-123456789012:100'
SELECT @@global.wsrep_start_position;
@@global.wsrep_start_position
00000000-0000-0000-0000-000000000000:-1
SET GLOBAL wsrep_debug=1;
Warnings:
Warning 1231 Setting 'wsrep_debug' has no effect because wsrep is switched off
SELECT @@global.wsrep_debug;
@@global.wsrep_debug
NONE
SET GLOBAL wsrep_slave_threads=5;
SELECT @@global.wsrep_slave_threads;
@@global.wsrep_slave_threads
5
SET GLOBAL wsrep_desync=1;
ERROR HY000: WSREP (galera) not started
SELECT @@global.wsrep_desync;
@@global.wsrep_desync
0
SET SESSION wsrep_trx_fragment_unit='rows';
ERROR HY000: Incorrect arguments to SET
SELECT @@session.wsrep_trx_fragment_unit;
@@session.wsrep_trx_fragment_unit
rows
SET @@global.wsrep_slave_threads = @wsrep_slave_threads_global_saved;
SET @@global.wsrep_debug = @wsrep_debug_saved;
SELECT @@wsrep_on;
@@wsrep_on
0
SET @wsrep_slave_threads_global_saved = @@global.wsrep_slave_threads;
SET @wsrep_debug_saved = @@global.wsrep_debug;
SET SESSION wsrep_trx_fragment_size=DEFAULT;
ERROR HY000: Incorrect arguments to SET
SELECT @@session.wsrep_trx_fragment_size;
@@session.wsrep_trx_fragment_size
0
SET GLOBAL wsrep_start_position='12345678-1234-1234-1234-123456789012:100';
ERROR 42000: Variable 'wsrep_start_position' can't be set to the value of '12345678-1234-1234-1234-123456789012:100'
SHOW WARNINGS;
Level Code Message
Warning 1231 Cannot set 'wsrep_start_position' because wsrep is switched off or provider is not loaded
Error 1231 Variable 'wsrep_start_position' can't be set to the value of '12345678-1234-1234-1234-123456789012:100'
SELECT @@global.wsrep_start_position;
@@global.wsrep_start_position
00000000-0000-0000-0000-000000000000:-1
SET GLOBAL wsrep_debug=1;
Warnings:
Warning 1231 Setting 'wsrep_debug' has no effect because wsrep is switched off
SELECT @@global.wsrep_debug;
@@global.wsrep_debug
NONE
SET GLOBAL wsrep_slave_threads=5;
SELECT @@global.wsrep_slave_threads;
@@global.wsrep_slave_threads
5
SET GLOBAL wsrep_desync=1;
ERROR HY000: WSREP (galera) not started
SELECT @@global.wsrep_desync;
@@global.wsrep_desync
0
SET SESSION wsrep_trx_fragment_unit='rows';
ERROR HY000: Incorrect arguments to SET
SELECT @@session.wsrep_trx_fragment_unit;
@@session.wsrep_trx_fragment_unit
rows
# Use default setting for mysqld processes
!include include/default_mysqld.cnf
[mysqld.1]
wsrep-on=ON
binlog-format=ROW
wsrep-provider=@ENV.WSREP_PROVIDER
wsrep-cluster-address='gcomm://'
#galera_port=@OPT.port
#ist_port=@OPT.port
#sst_port=@OPT.port
--source include/have_wsrep.inc
--source include/have_innodb.inc
SELECT @@wsrep_on;
SET @wsrep_slave_threads_global_saved = @@global.wsrep_slave_threads;
SET @wsrep_debug_saved = @@global.wsrep_debug;
SET @wsrep_provider_options_saved= @@global.wsrep_provider_options;
SET @wsrep_cluster_address_saved= @@global.wsrep_cluster_address;
SET GLOBAL wsrep_provider=none;
--error ER_WRONG_ARGUMENTS
SET SESSION wsrep_trx_fragment_size=DEFAULT;
SELECT @@session.wsrep_trx_fragment_size;
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL wsrep_start_position='12345678-1234-1234-1234-123456789012:100';
SHOW WARNINGS;
SELECT @@global.wsrep_start_position;
SET GLOBAL wsrep_debug=1;
SELECT @@global.wsrep_debug;
SET GLOBAL wsrep_slave_threads=5;
SELECT @@global.wsrep_slave_threads;
--error ER_WRONG_ARGUMENTS
SET GLOBAL wsrep_desync=1;
SELECT @@global.wsrep_desync;
--error ER_WRONG_ARGUMENTS
SET SESSION wsrep_trx_fragment_unit='rows';
SELECT @@session.wsrep_trx_fragment_unit;
--disable_query_log
eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER';
SET GLOBAL wsrep_cluster_address= @wsrep_cluster_address_saved;
SET GLOBAL wsrep_provider_options= @wsrep_provider_options_saved;
--source include/galera_wait_ready.inc
SET @@global.wsrep_slave_threads = @wsrep_slave_threads_global_saved;
SET @@global.wsrep_debug = @wsrep_debug_saved;
--enable_query_log
# Use default setting for mysqld processes
!include include/default_mysqld.cnf
[mysqld]
wsrep-on=OFF
[mysqld.1]
wsrep-on=OFF
#galera_port=@OPT.port
#ist_port=@OPT.port
#sst_port=@OPT.port
--source include/have_wsrep.inc
--source include/have_innodb.inc
SELECT @@wsrep_on;
SET @wsrep_slave_threads_global_saved = @@global.wsrep_slave_threads;
SET @wsrep_debug_saved = @@global.wsrep_debug;
--error ER_WRONG_ARGUMENTS
SET SESSION wsrep_trx_fragment_size=DEFAULT;
SELECT @@session.wsrep_trx_fragment_size;
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL wsrep_start_position='12345678-1234-1234-1234-123456789012:100';
SHOW WARNINGS;
SELECT @@global.wsrep_start_position;
SET GLOBAL wsrep_debug=1;
SELECT @@global.wsrep_debug;
SET GLOBAL wsrep_slave_threads=5;
SELECT @@global.wsrep_slave_threads;
--error ER_WRONG_ARGUMENTS
SET GLOBAL wsrep_desync=1;
SELECT @@global.wsrep_desync;
--error ER_WRONG_ARGUMENTS
SET SESSION wsrep_trx_fragment_unit='rows';
SELECT @@session.wsrep_trx_fragment_unit;
--disable_query_log
SET @@global.wsrep_slave_threads = @wsrep_slave_threads_global_saved;
SET @@global.wsrep_debug = @wsrep_debug_saved;
--enable_query_log
......@@ -42,7 +42,7 @@ extern wsrep_seqno_t local_seqno;
extern Wsrep_schema* wsrep_schema;
// a helper function
void wsrep_sst_received(THD*, const wsrep_uuid_t&, wsrep_seqno_t,
bool wsrep_sst_received(THD*, const wsrep_uuid_t&, wsrep_seqno_t,
const void*, size_t);
void wsrep_notify_status(enum wsrep::server_state::state status,
......
......@@ -308,12 +308,37 @@ bool wsrep_before_SE()
}
// Signal end of SST
static void wsrep_sst_complete (THD* thd,
int const rcode)
static bool wsrep_sst_complete (THD* thd,
int const rcode,
wsrep::gtid const sst_gtid)
{
Wsrep_client_service client_service(thd, thd->wsrep_cs());
Wsrep_server_state::instance().sst_received(client_service, rcode);
Wsrep_server_state& server_state= Wsrep_server_state::instance();
enum wsrep::server_state::state state= server_state.state();
bool failed= false;
// Do not call sst_received if we are not in joiner or
// initialized state on server. This is because it
// assumes we are on those states. Give error if we are
// in incorrect state.
if ((state == Wsrep_server_state::s_joiner ||
state == Wsrep_server_state::s_initialized))
Wsrep_server_state::instance().sst_received(client_service,
rcode);
else
{
char start_pos_buf[FN_REFLEN];
ssize_t len= wsrep::print_to_c_str(sst_gtid, start_pos_buf, FN_REFLEN-1);
start_pos_buf[len]='\0';
WSREP_ERROR("SST failed for position %s initialized %d server_state %s",
start_pos_buf,
server_state.is_initialized(),
wsrep::to_c_string(state));
failed= true;
}
wsrep_joiner_monitor_end();
return failed;
}
/*
......@@ -325,13 +350,15 @@ static void wsrep_sst_complete (THD* thd,
@param seqno [IN] Initial state sequence number
@param state [IN] Always NULL, also ignored by wsrep provider (?)
@param state_len [IN] Always 0, also ignored by wsrep provider (?)
@return true when successful, false if error
*/
void wsrep_sst_received (THD* thd,
bool wsrep_sst_received (THD* thd,
const wsrep_uuid_t& uuid,
wsrep_seqno_t const seqno,
const void* const state,
size_t const state_len)
{
bool error= false;
/*
To keep track of whether the local uuid:seqno should be updated. Also, note
that local state (uuid:seqno) is updated/checkpointed only after we get an
......@@ -371,8 +398,10 @@ void wsrep_sst_received (THD* thd,
if (WSREP_ON)
{
int const rcode(seqno < 0 ? seqno : 0);
wsrep_sst_complete(thd,rcode);
error= wsrep_sst_complete(thd,rcode, sst_gtid);
}
return error;
}
static int sst_scan_uuid_seqno (const char* str,
......@@ -653,7 +682,7 @@ static void* sst_joiner_thread (void* a)
/* Read committed isolation to avoid gap locking */
thd->variables.tx_isolation= ISO_READ_COMMITTED;
wsrep_sst_complete (thd, -err);
wsrep_sst_complete (thd, -err, ret_gtid);
delete thd;
my_thread_end();
......
......@@ -234,7 +234,7 @@ bool wsrep_set_local_position(THD* thd, const char* const value,
wsrep_seqno_t const seqno= strtoll(value + uuid_len + 1, NULL, 10);
if (sst) {
wsrep_sst_received (thd, uuid, seqno, NULL, 0);
return (wsrep_sst_received (thd, uuid, seqno, NULL, 0));
} else {
local_uuid= uuid;
local_seqno= seqno;
......@@ -258,15 +258,28 @@ bool wsrep_start_position_check (sys_var *self, THD* thd, set_var* var)
// Verify the format.
if (wsrep_start_position_verify(start_pos_buf)) return true;
// Give error if position is updated when wsrep is not enabled or
// provider is not loaded.
if ((!WSREP_ON || !Wsrep_server_state::instance().is_provider_loaded())
&& strcmp(start_pos_buf, WSREP_START_POSITION_ZERO))
{
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR,
"Cannot set 'wsrep_start_position' because "
"wsrep is switched off or provider is not loaded");
goto err;
}
/*
As part of further verification, we try to update the value and catch
errors (if any).
errors (if any) only when value actually has been changed.
*/
if (wsrep_set_local_position(thd, var->save_result.string_value.str,
if (strcmp(start_pos_buf, wsrep_start_position))
{
if (wsrep_set_local_position(thd, var->save_result.string_value.str,
var->save_result.string_value.length,
true))
{
goto err;
goto err;
}
return false;
......@@ -289,7 +302,7 @@ bool wsrep_start_position_init (const char* val)
{
if (NULL == val || wsrep_start_position_verify (val))
{
WSREP_ERROR("Bad initial value for wsrep_start_position: %s",
WSREP_ERROR("Bad initial value for wsrep_start_position: %s",
(val ? val : ""));
return true;
}
......@@ -403,8 +416,8 @@ bool wsrep_provider_update (sys_var *self, THD* thd, enum_var_type type)
void wsrep_provider_init (const char* value)
{
WSREP_DEBUG("wsrep_provider_init: %s -> %s",
(wsrep_provider) ? wsrep_provider : "null",
WSREP_DEBUG("wsrep_provider_init: %s -> %s",
(wsrep_provider) ? wsrep_provider : "null",
(value) ? value : "null");
if (NULL == value || wsrep_provider_verify (value))
{
......@@ -443,7 +456,7 @@ bool wsrep_provider_options_update(sys_var *self, THD* thd, enum_var_type type)
void wsrep_provider_options_init(const char* value)
{
if (wsrep_provider_options && wsrep_provider_options != value)
if (wsrep_provider_options && wsrep_provider_options != value)
my_free((void *)wsrep_provider_options);
wsrep_provider_options= (value) ? my_strdup(value, MYF(0)) : NULL;
}
......@@ -472,8 +485,21 @@ bool wsrep_reject_queries_update(sys_var *self, THD* thd, enum_var_type type)
bool wsrep_debug_update(sys_var *self, THD* thd, enum_var_type type)
{
// Give warnings if wsrep_debug is set and wsrep is disabled or
// provider is not loaded, it will not have any effect
if ((!WSREP_ON || !Wsrep_server_state::instance().is_provider_loaded())
&& wsrep_debug)
{
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR,
"Setting 'wsrep_debug' has no effect because "
"wsrep is switched off");
wsrep_debug= 0;
}
else
Wsrep_server_state::instance().debug_log_level(wsrep_debug);
return false;
return false;
}
static int wsrep_cluster_address_verify (const char* cluster_address_str)
......@@ -511,11 +537,11 @@ bool wsrep_cluster_address_update (sys_var *self, THD* thd, enum_var_type type)
return false;
}
/* stop replication is heavy operation, and includes closing all client
/* stop replication is heavy operation, and includes closing all client
connections. Closing clients may need to get LOCK_global_system_variables
at least in MariaDB.
Note: releasing LOCK_global_system_variables may cause race condition, if
Note: releasing LOCK_global_system_variables may cause race condition, if
there can be several concurrent clients changing wsrep_provider
*/
WSREP_DEBUG("wsrep_cluster_address_update: %s", wsrep_cluster_address);
......@@ -544,8 +570,8 @@ bool wsrep_cluster_address_update (sys_var *self, THD* thd, enum_var_type type)
void wsrep_cluster_address_init (const char* value)
{
WSREP_DEBUG("wsrep_cluster_address_init: %s -> %s",
(wsrep_cluster_address) ? wsrep_cluster_address : "null",
WSREP_DEBUG("wsrep_cluster_address_init: %s -> %s",
(wsrep_cluster_address) ? wsrep_cluster_address : "null",
(value) ? value : "null");
my_free((void*) wsrep_cluster_address);
......@@ -745,6 +771,18 @@ bool wsrep_trx_fragment_size_update(sys_var* self, THD *thd, enum_var_type)
{
WSREP_DEBUG("wsrep_trx_fragment_size_update: %llu",
thd->variables.wsrep_trx_fragment_size);
// Give error if wsrep_trx_fragment_size is set and wsrep is disabled or
// provider is not loaded
if (!WSREP_ON || !Wsrep_server_state::instance().is_provider_loaded())
{
push_warning (thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR,
"Cannot set 'wsrep_trx_fragment_size' because "
"wsrep is switched off");
return true;
}
if (thd->variables.wsrep_trx_fragment_size)
{
return thd->wsrep_cs().enable_streaming(
......@@ -762,6 +800,18 @@ bool wsrep_trx_fragment_unit_update(sys_var* self, THD *thd, enum_var_type)
{
WSREP_DEBUG("wsrep_trx_fragment_unit_update: %lu",
thd->variables.wsrep_trx_fragment_unit);
// Give error if wsrep_trx_fragment_unit is set and wsrep is disabled or
// provider is not loaded
if (!WSREP_ON || !Wsrep_server_state::instance().is_provider_loaded())
{
push_warning (thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR,
"Cannot set 'wsrep_trx_fragment_unit' because "
"wsrep is switched off");
return true;
}
if (thd->variables.wsrep_trx_fragment_size)
{
return thd->wsrep_cs().enable_streaming(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment