MXS-656: Galera nodes with index 0 can be master again
The index calculation falsely ignored nodes with node index 0 when errno was non-zero.
This commit is contained in:
@ -397,10 +397,12 @@ monitorDatabase(MONITOR *mon, MONITOR_SERVERS *database)
|
|||||||
|
|
||||||
while ((row = mysql_fetch_row(result)))
|
while ((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
local_index = strtol(row[1], NULL, 10);
|
char* endchar;
|
||||||
if ((errno == ERANGE && (local_index == LONG_MAX
|
local_index = strtol(row[1], &endchar, 10);
|
||||||
|| local_index == LONG_MIN)) || (errno != 0 && local_index == 0))
|
if (*endchar != '\0' ||
|
||||||
|
(errno == ERANGE && (local_index == LONG_MAX || local_index == LONG_MIN)))
|
||||||
{
|
{
|
||||||
|
ss_dassert(false);
|
||||||
local_index = -1;
|
local_index = -1;
|
||||||
}
|
}
|
||||||
database->server->node_id = local_index;
|
database->server->node_id = local_index;
|
||||||
|
|||||||
Reference in New Issue
Block a user