Commit 52c45332 authored by Julius Goryavsky's avatar Julius Goryavsky

MDEV-34071: Failure during the galera_3nodes_sr.GCF-336 test

This commit fixes sporadic failures in galera_3nodes_sr.GCF-336
test. The following changes have been made here:

1) A small addition to the test itself which should make
   it more deterministic by waiting for non-primary state
   before COMMIT;
2) More careful handling of the wsrep_ready variable in
   the server code (it should always be protected with mutex).

No additional tests are required.
parent 4045a87b
...@@ -25,6 +25,8 @@ SET SESSION wsrep_sync_wait=0; ...@@ -25,6 +25,8 @@ SET SESSION wsrep_sync_wait=0;
connection node_2; connection node_2;
INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (2);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
connection node_2a;
connection node_2;
COMMIT; COMMIT;
ERROR 08S01: WSREP has not yet prepared node for application use ERROR 08S01: WSREP has not yet prepared node for application use
connection node_2a; connection node_2a;
......
...@@ -27,6 +27,12 @@ SET SESSION wsrep_sync_wait=0; ...@@ -27,6 +27,12 @@ SET SESSION wsrep_sync_wait=0;
--connection node_2 --connection node_2
--error ER_LOCK_DEADLOCK --error ER_LOCK_DEADLOCK
INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (2);
--connection node_2a
--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc
--connection node_2
--error ER_UNKNOWN_COM_ERROR --error ER_UNKNOWN_COM_ERROR
COMMIT; COMMIT;
......
...@@ -3895,7 +3895,7 @@ apply_event_and_update_pos_apply(Log_event* ev, THD* thd, rpl_group_info *rgi, ...@@ -3895,7 +3895,7 @@ apply_event_and_update_pos_apply(Log_event* ev, THD* thd, rpl_group_info *rgi,
if (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL && if (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL &&
((rli->mi->using_parallel() && ((rli->mi->using_parallel() &&
rli->mi->parallel_mode <= SLAVE_PARALLEL_CONSERVATIVE) || rli->mi->parallel_mode <= SLAVE_PARALLEL_CONSERVATIVE) ||
wsrep_ready == 0)) { !wsrep_ready_get())) {
rli->abort_slave= 1; rli->abort_slave= 1;
rli->report(ERROR_LEVEL, ER_UNKNOWN_COM_ERROR, rgi->gtid_info(), rli->report(ERROR_LEVEL, ER_UNKNOWN_COM_ERROR, rgi->gtid_info(),
"Node has dropped from cluster"); "Node has dropped from cluster");
......
...@@ -3456,7 +3456,7 @@ void wsrep_ready_set(bool ready_value) ...@@ -3456,7 +3456,7 @@ void wsrep_ready_set(bool ready_value)
mysql_mutex_lock(&LOCK_wsrep_ready); mysql_mutex_lock(&LOCK_wsrep_ready);
wsrep_ready= ready_value; wsrep_ready= ready_value;
// Signal if we have reached ready state // Signal if we have reached ready state
if (wsrep_ready) if (ready_value)
mysql_cond_signal(&COND_wsrep_ready); mysql_cond_signal(&COND_wsrep_ready);
mysql_mutex_unlock(&LOCK_wsrep_ready); mysql_mutex_unlock(&LOCK_wsrep_ready);
} }
......
...@@ -24,7 +24,7 @@ void wsrep_notify_status(enum wsrep::server_state::state status, ...@@ -24,7 +24,7 @@ void wsrep_notify_status(enum wsrep::server_state::state status,
if (!view) if (!view)
{ {
WSREP_DEBUG("wsrep_notify_status server not yet ready : wsrep_ready=%d status %d", WSREP_DEBUG("wsrep_notify_status server not yet ready : wsrep_ready=%d status %d",
wsrep_ready, (int)status); (int) wsrep_ready_get(), (int)status);
return; return;
} }
......
...@@ -340,7 +340,6 @@ void Wsrep_server_service::log_state_change( ...@@ -340,7 +340,6 @@ void Wsrep_server_service::log_state_change(
switch (current_state) switch (current_state)
{ {
case Wsrep_server_state::s_synced: case Wsrep_server_state::s_synced:
wsrep_ready= TRUE;
WSREP_INFO("Synchronized with group, ready for connections"); WSREP_INFO("Synchronized with group, ready for connections");
wsrep_ready_set(true); wsrep_ready_set(true);
/* fall through */ /* fall through */
......
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