Skip to content

Commit

Permalink
MDEV-34071: Failure during the galera_3nodes_sr.GCF-336 test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sysprg committed May 6, 2024
1 parent 4045a87 commit 52c4533
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions mysql-test/suite/galera_3nodes_sr/r/GCF-336.result
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ SET SESSION wsrep_sync_wait=0;
connection node_2;
INSERT INTO t1 VALUES (2);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
connection node_2a;
connection node_2;
COMMIT;
ERROR 08S01: WSREP has not yet prepared node for application use
connection node_2a;
Expand Down
6 changes: 6 additions & 0 deletions mysql-test/suite/galera_3nodes_sr/t/GCF-336.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ SET SESSION wsrep_sync_wait=0;
--connection node_2
--error ER_LOCK_DEADLOCK
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
COMMIT;

Expand Down
2 changes: 1 addition & 1 deletion sql/slave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
((rli->mi->using_parallel() &&
rli->mi->parallel_mode <= SLAVE_PARALLEL_CONSERVATIVE) ||
wsrep_ready == 0)) {
!wsrep_ready_get())) {
rli->abort_slave= 1;
rli->report(ERROR_LEVEL, ER_UNKNOWN_COM_ERROR, rgi->gtid_info(),
"Node has dropped from cluster");
Expand Down
2 changes: 1 addition & 1 deletion sql/wsrep_mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3456,7 +3456,7 @@ void wsrep_ready_set(bool ready_value)
mysql_mutex_lock(&LOCK_wsrep_ready);
wsrep_ready= ready_value;
// Signal if we have reached ready state
if (wsrep_ready)
if (ready_value)
mysql_cond_signal(&COND_wsrep_ready);
mysql_mutex_unlock(&LOCK_wsrep_ready);
}
Expand Down
2 changes: 1 addition & 1 deletion sql/wsrep_notify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void wsrep_notify_status(enum wsrep::server_state::state status,
if (!view)
{
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;
}

Expand Down
1 change: 0 additions & 1 deletion sql/wsrep_server_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ void Wsrep_server_service::log_state_change(
switch (current_state)
{
case Wsrep_server_state::s_synced:
wsrep_ready= TRUE;
WSREP_INFO("Synchronized with group, ready for connections");
wsrep_ready_set(true);
/* fall through */
Expand Down

0 comments on commit 52c4533

Please sign in to comment.