diff --git a/server/modules/monitor/mariadbmon/mariadbmon.cc b/server/modules/monitor/mariadbmon/mariadbmon.cc
|
index 8d9fe779e..dc2972db4 100644
|
--- a/server/modules/monitor/mariadbmon/mariadbmon.cc
|
+++ b/server/modules/monitor/mariadbmon/mariadbmon.cc
|
@@ -1407,6 +1407,29 @@ static enum mysql_server_version get_server_version(MXS_MONITORED_SERVER* db)
|
return MYSQL_SERVER_VERSION_51;
|
}
|
|
+std::string get_result(MYSQL* conn, const char* query)
|
+{
|
+ std::string rval;
|
+
|
+ if (mxs_mysql_query(conn, query) == 0)
|
+ {
|
+ if (MYSQL_RES* result = mysql_store_result(conn))
|
+ {
|
+ if (MYSQL_ROW row = mysql_fetch_row(result))
|
+ {
|
+ if (row[0])
|
+ {
|
+ rval = row[0];
|
+ }
|
+ }
|
+
|
+ mysql_free_result(result);
|
+ }
|
+ }
|
+
|
+ return rval;
|
+}
|
+
|
static bool do_show_slave_status(MYSQL_MONITOR* mon,
|
MySqlServerInfo* serv_info,
|
MXS_MONITORED_SERVER* database)
|
@@ -1443,6 +1466,8 @@ static bool do_show_slave_status(MYSQL_MONITOR* mon,
|
int nconfigured = 0;
|
int nrunning = 0;
|
|
+ std::string source_name = get_result(database->con, "SELECT @@default_master_connection");
|
+
|
if (mxs_mysql_query(database->con, query) == 0
|
&& (result = mysql_store_result(database->con)) != NULL)
|
{
|
@@ -1454,14 +1479,20 @@ static bool do_show_slave_status(MYSQL_MONITOR* mon,
|
return false;
|
}
|
|
- MYSQL_ROW row = mysql_fetch_row(result);
|
-
|
- if (row)
|
+ if (mysql_num_rows(result) > 0)
|
{
|
serv_info->slave_configured = true;
|
|
- do
|
+ while (MYSQL_ROW row = mysql_fetch_row(result))
|
{
|
+ ss_dassert(row[0]);
|
+
|
+ if (source_name != row[0])
|
+ {
|
+ // Not the default replication configuration, skip it
|
+ continue;
|
+ }
|
+
|
/* get Slave_IO_Running and Slave_SQL_Running values*/
|
serv_info->slave_status.slave_io_running = strncmp(row[i_slave_io_running], "Yes", 3) == 0;
|
serv_info->slave_status.slave_sql_running = strncmp(row[i_slave_sql_running], "Yes", 3) == 0;
|
@@ -1542,9 +1573,7 @@ static bool do_show_slave_status(MYSQL_MONITOR* mon,
|
}
|
|
nconfigured++;
|
- row = mysql_fetch_row(result);
|
}
|
- while (row);
|
}
|
else
|
{
|
The following patch would ignore all non-default replication configurations.
diff --git a/server/modules/monitor/mariadbmon/mariadbmon.cc b/server/modules/monitor/mariadbmon/mariadbmon.cc
index 8d9fe779e..dc2972db4 100644
--- a/server/modules/monitor/mariadbmon/mariadbmon.cc
+++ b/server/modules/monitor/mariadbmon/mariadbmon.cc
@@ -1407,6 +1407,29 @@ static enum mysql_server_version get_server_version(MXS_MONITORED_SERVER* db)
return MYSQL_SERVER_VERSION_51;
}
+std::string get_result(MYSQL* conn, const char* query)
+{
+ std::string rval;
+
+ if (mxs_mysql_query(conn, query) == 0)
+ {
+ if (MYSQL_RES* result = mysql_store_result(conn))
+ {
+ if (MYSQL_ROW row = mysql_fetch_row(result))
+ {
+ if (row[0])
+ {
+ rval = row[0];
+ }
+ }
+
+ mysql_free_result(result);
+ }
+ }
+
+ return rval;
+}
+
static bool do_show_slave_status(MYSQL_MONITOR* mon,
MySqlServerInfo* serv_info,
MXS_MONITORED_SERVER* database)
@@ -1443,6 +1466,8 @@ static bool do_show_slave_status(MYSQL_MONITOR* mon,
int nconfigured = 0;
int nrunning = 0;
+ std::string source_name = get_result(database->con, "SELECT @@default_master_connection");
+
if (mxs_mysql_query(database->con, query) == 0
&& (result = mysql_store_result(database->con)) != NULL)
{
@@ -1454,14 +1479,20 @@ static bool do_show_slave_status(MYSQL_MONITOR* mon,
return false;
}
- MYSQL_ROW row = mysql_fetch_row(result);
-
- if (row)
+ if (mysql_num_rows(result) > 0)
{
serv_info->slave_configured = true;
- do
+ while (MYSQL_ROW row = mysql_fetch_row(result))
{
+ ss_dassert(row[0]);
+
+ if (source_name != row[0])
+ {
+ // Not the default replication configuration, skip it
+ continue;
+ }
+
/* get Slave_IO_Running and Slave_SQL_Running values*/
serv_info->slave_status.slave_io_running = strncmp(row[i_slave_io_running], "Yes", 3) == 0;
serv_info->slave_status.slave_sql_running = strncmp(row[i_slave_sql_running], "Yes", 3) == 0;
@@ -1542,9 +1573,7 @@ static bool do_show_slave_status(MYSQL_MONITOR* mon,
}
nconfigured++;
- row = mysql_fetch_row(result);
}
- while (row);
}
else
As a side-effect, stopping non-default slaves would have no effect on the slave's status in MaxScale. Currently the slave would be considered broken as not all replication sources would be running. This behavior can be considered as a bug as one could expect only the default master connection to be used.