Commit 42c58b87 authored by Andrei Elkin's avatar Andrei Elkin

MDEV-18096 The server would crash when has configs...

MDEV-18096 The server would crash when has configs rpl_semi_sync_master_enabled = OFF rpl_semi_sync_master_wait_no_slave = OFF

The patch fixes a fired assert in the semisync master module. The assert
caught attempt to switch semisync off (per rpl_semi_sync_master_wait_no_slave = OFF)
when it was not even initialized (per rpl_semi_sync_master_enabled = OFF).
The switching-off execution branch is relocated under one that executes
enable_master() first.

A minor cleaup is done to remove the int return from two functions that
did not return anything but an error which could not happen in the functions.
parent 323e6cd7
include/master-slave.inc
[connection master]
connection master;
CREATE TABLE t1 (a INT);
INSERT INTO t1 SET a=1;
DROP TABLE t1;
connection slave;
include/rpl_end.inc
--rpl_semi_sync_master_enabled=0 --rpl_semi_sync_master_wait_no_slave=0
# The test verifies master crash of MDEV-18096 when the server starts with
# rpl_semi_sync_master_enabled = OFF rpl_semi_sync_master_wait_no_slave = OFF
--source include/master-slave.inc
--source include/have_binlog_format_mixed.inc
--connection master
CREATE TABLE t1 (a INT);
INSERT INTO t1 SET a=1;
DROP TABLE t1;
--sync_slave_with_master
--source include/rpl_end.inc
...@@ -228,7 +228,7 @@ bool Active_tranx::is_tranx_end_pos(const char *log_file_name, ...@@ -228,7 +228,7 @@ bool Active_tranx::is_tranx_end_pos(const char *log_file_name,
DBUG_RETURN(entry != NULL); DBUG_RETURN(entry != NULL);
} }
int Active_tranx::clear_active_tranx_nodes(const char *log_file_name, void Active_tranx::clear_active_tranx_nodes(const char *log_file_name,
my_off_t log_file_pos) my_off_t log_file_pos)
{ {
Tranx_node *new_front; Tranx_node *new_front;
...@@ -307,7 +307,7 @@ int Active_tranx::clear_active_tranx_nodes(const char *log_file_name, ...@@ -307,7 +307,7 @@ int Active_tranx::clear_active_tranx_nodes(const char *log_file_name,
m_trx_front->log_name, (ulong)m_trx_front->log_pos)); m_trx_front->log_name, (ulong)m_trx_front->log_pos));
} }
DBUG_RETURN(0); DBUG_VOID_RETURN;
} }
...@@ -371,19 +371,20 @@ int Repl_semi_sync_master::init_object() ...@@ -371,19 +371,20 @@ int Repl_semi_sync_master::init_object()
{ {
result = enable_master(); result = enable_master();
if (!result) if (!result)
result= ack_receiver.start(); /* Start the ACK thread. */
}
else
{ {
result = disable_master(); result= ack_receiver.start(); /* Start the ACK thread. */
}
/* /*
If rpl_semi_sync_master_wait_no_slave is disabled, let's temporarily If rpl_semi_sync_master_wait_no_slave is disabled, let's temporarily
switch off semisync to avoid hang if there's none active slave. switch off semisync to avoid hang if there's none active slave.
*/ */
if (!rpl_semi_sync_master_wait_no_slave) if (!rpl_semi_sync_master_wait_no_slave)
switch_off(); switch_off();
}
}
else
{
result = disable_master();
}
return result; return result;
} }
...@@ -961,17 +962,15 @@ int Repl_semi_sync_master::commit_trx(const char* trx_wait_binlog_name, ...@@ -961,17 +962,15 @@ int Repl_semi_sync_master::commit_trx(const char* trx_wait_binlog_name,
* the current sending event catches up with last wait position. If it * the current sending event catches up with last wait position. If it
* does match, semi-sync will be switched on again. * does match, semi-sync will be switched on again.
*/ */
int Repl_semi_sync_master::switch_off() void Repl_semi_sync_master::switch_off()
{ {
int result;
DBUG_ENTER("Repl_semi_sync_master::switch_off"); DBUG_ENTER("Repl_semi_sync_master::switch_off");
m_state = false; m_state = false;
/* Clear the active transaction list. */ /* Clear the active transaction list. */
assert(m_active_tranxs != NULL); assert(m_active_tranxs != NULL);
result = m_active_tranxs->clear_active_tranx_nodes(NULL, 0); m_active_tranxs->clear_active_tranx_nodes(NULL, 0);
rpl_semi_sync_master_off_times++; rpl_semi_sync_master_off_times++;
m_wait_file_name_inited = false; m_wait_file_name_inited = false;
...@@ -979,7 +978,7 @@ int Repl_semi_sync_master::switch_off() ...@@ -979,7 +978,7 @@ int Repl_semi_sync_master::switch_off()
sql_print_information("Semi-sync replication switched OFF."); sql_print_information("Semi-sync replication switched OFF.");
cond_broadcast(); /* wake up all waiting threads */ cond_broadcast(); /* wake up all waiting threads */
DBUG_RETURN(result); DBUG_VOID_RETURN;
} }
int Repl_semi_sync_master::try_switch_on(int server_id, int Repl_semi_sync_master::try_switch_on(int server_id,
......
...@@ -343,11 +343,8 @@ class Active_tranx ...@@ -343,11 +343,8 @@ class Active_tranx
* position. * position.
* If log_file_name is NULL, everything will be cleared: the sorted * If log_file_name is NULL, everything will be cleared: the sorted
* list and the hash table will be reset to empty. * list and the hash table will be reset to empty.
*
* Return:
* 0: success; non-zero: error
*/ */
int clear_active_tranx_nodes(const char *log_file_name, void clear_active_tranx_nodes(const char *log_file_name,
my_off_t log_file_pos); my_off_t log_file_pos);
/* Given a position, check to see whether the position is an active /* Given a position, check to see whether the position is an active
...@@ -449,7 +446,7 @@ class Repl_semi_sync_master ...@@ -449,7 +446,7 @@ class Repl_semi_sync_master
} }
/* Switch semi-sync off because of timeout in transaction waiting. */ /* Switch semi-sync off because of timeout in transaction waiting. */
int switch_off(); void switch_off();
/* Switch semi-sync on when slaves catch up. */ /* Switch semi-sync on when slaves catch up. */
int try_switch_on(int server_id, int try_switch_on(int server_id,
......
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