Disconnect slave when pos is UNSAFE

Disconnect slave when pos is UNSAFE instead of sending an error that
stops the replication
This commit is contained in:
MassimilianoPinto
2015-11-04 16:24:46 +01:00
parent 7c582f91ea
commit d51ac7ab7d
3 changed files with 52 additions and 12 deletions

View File

@ -419,7 +419,7 @@ struct stat statb;
memset(&hdbuf, '\0', BINLOG_EVENT_HDR_LEN);
/* set error indicator */
hdr->ok = 0xff;
hdr->ok = SLAVE_POS_READ_ERR;
if (!file)
{
@ -428,6 +428,11 @@ struct stat statb;
}
if (fstat(file->fd, &statb) == 0)
filelen = statb.st_size;
else
{
snprintf(errmsg, BINLOG_ERROR_MSG_LEN, "Invalide size for binlog file '%s', pos %lu", file->binlogname, pos);
return NULL;
}
if (pos > filelen)
{
@ -440,11 +445,12 @@ struct stat statb;
{
if (pos > router->binlog_position)
{
snprintf(errmsg, BINLOG_ERROR_MSG_LEN, "Requested position %lu is not available. Latest safe position %lu, end of binlog '%s' is %lu",
pos, router->binlog_position, file->binlogname, router->current_pos);
/* Unsafe position, slave will be disconnected by the calling routine */
snprintf(errmsg, BINLOG_ERROR_MSG_LEN, "Requested binlog position %lu. Position is unsafe so disconnecting. Latest safe position %lu, end of binlog file %lu", pos, router->binlog_position, router->current_pos);
hdr->ok = SLAVE_POS_READ_UNSAFE;
} else {
/* accessing last position is ok */
hdr->ok = 0x0;
hdr->ok = SLAVE_POS_READ_OK;
}
return NULL;
@ -461,7 +467,7 @@ struct stat statb;
file->binlogname, pos)));
/* set ok indicator */
hdr->ok = 0x0;
hdr->ok = SLAVE_POS_READ_OK;
break;
case -1:
@ -529,7 +535,7 @@ struct stat statb;
pos)));
/* set ok indicator */
hdr->ok = 0x0;
hdr->ok = SLAVE_POS_READ_OK;
break;
case -1:
@ -615,7 +621,7 @@ struct stat statb;
}
/* set OK indicator */
hdr->ok = 0x0;
hdr->ok = SLAVE_POS_READ_OK;
return result;
}