Fix sync_slaves
The function did not check whether the file name was valid.
This commit is contained in:
@ -1315,19 +1315,27 @@ void Mariadb_nodes::sync_slaves(int node)
|
|||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row = mysql_fetch_row(res);
|
MYSQL_ROW row = mysql_fetch_row(res);
|
||||||
if (row && row[node] && row[1])
|
if (row && row[0] && row[1])
|
||||||
{
|
{
|
||||||
const char* file_suffix = strchr(row[node], '.') + 1;
|
const char* file_suffix = strchr(row[0], '.');
|
||||||
int filenum = atoi(file_suffix);
|
if (file_suffix)
|
||||||
int pos = atoi(row[1]);
|
|
||||||
|
|
||||||
for (int i = 0; i < this->N; i++)
|
|
||||||
{
|
{
|
||||||
if (i != node)
|
file_suffix++;
|
||||||
|
int filenum = atoi(file_suffix);
|
||||||
|
int pos = atoi(row[1]);
|
||||||
|
|
||||||
|
for (int i = 0; i < this->N; i++)
|
||||||
{
|
{
|
||||||
wait_until_pos(this->nodes[i], filenum, pos);
|
if (i != node)
|
||||||
|
{
|
||||||
|
wait_until_pos(this->nodes[i], filenum, pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Cannot sync slaves, invalid binlog file name: %s", row[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mysql_free_result(res);
|
mysql_free_result(res);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user