MXS-1703 Fix uninitialized pointer in manual switchover
If the current master was given by user, maxscale would crash.
This commit is contained in:
@ -18,16 +18,17 @@
|
|||||||
#include <maxscale/hk_heartbeat.h>
|
#include <maxscale/hk_heartbeat.h>
|
||||||
#include <maxscale/mysql_utils.h>
|
#include <maxscale/mysql_utils.h>
|
||||||
|
|
||||||
bool MariaDBMonitor::manual_switchover(MXS_MONITORED_SERVER* new_master, MXS_MONITORED_SERVER* current_master,
|
bool MariaDBMonitor::manual_switchover(MXS_MONITORED_SERVER* new_master,
|
||||||
|
MXS_MONITORED_SERVER* given_current_master,
|
||||||
json_t** error_out)
|
json_t** error_out)
|
||||||
{
|
{
|
||||||
// Autoselect current master if not given as parameter.
|
// Autoselect current master if not given as parameter.
|
||||||
MXS_MONITORED_SERVER* selected_current_master;
|
MXS_MONITORED_SERVER* current_master = given_current_master;
|
||||||
if (current_master == NULL)
|
if (given_current_master == NULL)
|
||||||
{
|
{
|
||||||
if (m_master)
|
if (m_master)
|
||||||
{
|
{
|
||||||
selected_current_master = m_master;
|
current_master = m_master;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -47,7 +48,7 @@ bool MariaDBMonitor::manual_switchover(MXS_MONITORED_SERVER* new_master, MXS_MON
|
|||||||
MXS_NOTICE("Monitor %s already stopped, switchover can proceed.", m_monitor_base->name);
|
MXS_NOTICE("Monitor %s already stopped, switchover can proceed.", m_monitor_base->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool current_ok = switchover_check_current(selected_current_master, error_out);
|
bool current_ok = switchover_check_current(current_master, error_out);
|
||||||
bool new_ok = switchover_check_new(new_master, error_out);
|
bool new_ok = switchover_check_new(new_master, error_out);
|
||||||
// Check that all slaves are using gtid-replication
|
// Check that all slaves are using gtid-replication
|
||||||
bool gtid_ok = true;
|
bool gtid_ok = true;
|
||||||
@ -65,9 +66,9 @@ bool MariaDBMonitor::manual_switchover(MXS_MONITORED_SERVER* new_master, MXS_MON
|
|||||||
bool rval = false;
|
bool rval = false;
|
||||||
if (current_ok && new_ok && gtid_ok)
|
if (current_ok && new_ok && gtid_ok)
|
||||||
{
|
{
|
||||||
bool switched = do_switchover(selected_current_master, new_master, error_out);
|
bool switched = do_switchover(current_master, new_master, error_out);
|
||||||
|
|
||||||
const char* curr_master_name = selected_current_master->server->unique_name;
|
const char* curr_master_name = current_master->server->unique_name;
|
||||||
const char* new_master_name = new_master->server->unique_name;
|
const char* new_master_name = new_master->server->unique_name;
|
||||||
|
|
||||||
if (switched)
|
if (switched)
|
||||||
|
|||||||
@ -101,7 +101,7 @@ public:
|
|||||||
* Handle switchover
|
* Handle switchover
|
||||||
*
|
*
|
||||||
* @new_master The specified new master
|
* @new_master The specified new master
|
||||||
* @current_master The specified current master
|
* @current_master The specified current master. If NULL, monitor will autoselect.
|
||||||
* @output Pointer where to place output object
|
* @output Pointer where to place output object
|
||||||
*
|
*
|
||||||
* @return True, if switchover was performed, false otherwise.
|
* @return True, if switchover was performed, false otherwise.
|
||||||
|
|||||||
Reference in New Issue
Block a user