Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-1964

Master is taken from last row of SHOW ALL SLAVES STATUS

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Done
    • 2.0.6, 2.1.17, 2.2.11
    • 2.3.0
    • mariadbmon
    • None

    Description

      When a slave has more than one configured replication source, mariadbmon will use the last one that is returned by SHOW ALL SLAVES STATUS. This causes various problems which would all be solved by only inspecting the default replication source (i.e. @@default_master_connection).

      Attachments

        Activity

          markus makela markus makela added a comment - - edited

          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.

          markus makela markus makela added a comment - - edited 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.
          markus makela markus makela added a comment -

          Solved as a part of monitor refactoring.

          markus makela markus makela added a comment - Solved as a part of monitor refactoring.

          People

            esa.korhonen Esa Korhonen
            markus makela markus makela
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.