Changed behaviour for a slave requesting master_log_pos beyond binlog file size
Slave request for a log_pos behind binlog file size may result in a disconnection or replication error: if binlog file is latest one slave get disconnected otherwise an error message is returned and replication stops
This commit is contained in:
@ -185,6 +185,7 @@
|
|||||||
#define SLAVE_POS_READ_ERR 0xff
|
#define SLAVE_POS_READ_ERR 0xff
|
||||||
#define SLAVE_POS_READ_UNSAFE 0xfe
|
#define SLAVE_POS_READ_UNSAFE 0xfe
|
||||||
#define SLAVE_POS_BAD_FD 0xfd
|
#define SLAVE_POS_BAD_FD 0xfd
|
||||||
|
#define SLAVE_POS_BEYOND_EOF 0xfc
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some useful macros for examining the MySQL Response packets
|
* Some useful macros for examining the MySQL Response packets
|
||||||
|
@ -432,8 +432,28 @@ struct stat statb;
|
|||||||
|
|
||||||
if (pos > filelen)
|
if (pos > filelen)
|
||||||
{
|
{
|
||||||
snprintf(errmsg, BINLOG_ERROR_MSG_LEN, "Requested position %lu is beyond end of the binlog file '%s', size %lu",
|
spinlock_acquire(&router->binlog_lock);
|
||||||
pos, file->binlogname, filelen);
|
spinlock_acquire(&file->lock);
|
||||||
|
|
||||||
|
if (strcmp(router->binlog_name, file->binlogname) != 0)
|
||||||
|
{
|
||||||
|
snprintf(errmsg, BINLOG_ERROR_MSG_LEN, "Requested position %lu is beyond "
|
||||||
|
"'closed' binlog file '%s', size %lu. Generating Error '1236'",
|
||||||
|
pos, file->binlogname, filelen);
|
||||||
|
} else {
|
||||||
|
snprintf(errmsg, BINLOG_ERROR_MSG_LEN, "Requested position %lu is beyond "
|
||||||
|
"end of the latest binlog file '%s', size %lu. Disconnecting",
|
||||||
|
pos, file->binlogname, filelen);
|
||||||
|
|
||||||
|
/* Slave will be disconnected by the calling routine */
|
||||||
|
hdr->ok = SLAVE_POS_BEYOND_EOF;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
spinlock_release(&file->lock);
|
||||||
|
spinlock_release(&router->binlog_lock);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2034,6 +2034,27 @@ char read_errmsg[BINLOG_ERROR_MSG_LEN+1];
|
|||||||
read_errmsg);
|
read_errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hdr.ok == SLAVE_POS_BEYOND_EOF) {
|
||||||
|
MXS_ERROR("%s Slave %s:%i, server-id %d, binlog '%s', %s",
|
||||||
|
router->service->name,
|
||||||
|
slave->dcb->remote,
|
||||||
|
ntohs((slave->dcb->ipv4).sin_port),
|
||||||
|
slave->serverid,
|
||||||
|
slave->binlogfile,
|
||||||
|
read_errmsg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close the slave session and socket
|
||||||
|
* The slave will try to reconnect
|
||||||
|
*/
|
||||||
|
dcb_close(slave->dcb);
|
||||||
|
|
||||||
|
#ifndef BLFILE_IN_SLAVE
|
||||||
|
blr_close_binlog(router, file);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (hdr.ok == SLAVE_POS_READ_ERR) {
|
if (hdr.ok == SLAVE_POS_READ_ERR) {
|
||||||
MXS_ERROR("%s Slave %s:%i, server-id %d, binlog '%s', %s",
|
MXS_ERROR("%s Slave %s:%i, server-id %d, binlog '%s', %s",
|
||||||
router->service->name,
|
router->service->name,
|
||||||
|
Reference in New Issue
Block a user