Fix to allow rotate of files without explicit rotate events when the master is offline
This commit is contained in:
@ -62,7 +62,7 @@ static void blr_log_header(logfile_id_t file, char *msg, uint8_t *ptr);
|
||||
|
||||
/**
|
||||
* Initialise the binlog file for this instance. MaxScale will look
|
||||
* for all the binlogs that it has on local disk, determien the next
|
||||
* for all the binlogs that it has on local disk, determine the next
|
||||
* binlog to use and initialise it for writing, determining the
|
||||
* next record to be fetched from the real master.
|
||||
*
|
||||
@ -695,3 +695,26 @@ GWBUF *buf;
|
||||
close(fd);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the next binlog file in the sequence for the slave exist.
|
||||
*
|
||||
* @param router The router instance
|
||||
* @param slave The slave in question
|
||||
* @retuen 0 if the next file does not exist
|
||||
*/
|
||||
int
|
||||
blr_file_next_exists(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
||||
{
|
||||
char *sptr, buf[80], bigbuf[4096];
|
||||
int filenum;
|
||||
|
||||
if ((sptr = strrchr(slave->binlogfile, '.')) == NULL)
|
||||
return 0;
|
||||
filenum = atoi(sptr + 1);
|
||||
sprintf(buf, BINLOG_NAMEFMT, router->fileroot, filenum + 1);
|
||||
sprintf(bigbuf, "%s/%s", router->binlogdir, buf);
|
||||
if (access(bigbuf, R_OK) == -1)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
@ -1440,7 +1440,8 @@ if (hkheartbeat - beat1 > 1) LOGIF(LE, (skygw_log_write(
|
||||
if (slave->binlog_pos >= blr_file_size(slave->file)
|
||||
&& router->rotating == 0
|
||||
&& strcmp(router->binlog_name, slave->binlogfile) != 0
|
||||
&& blr_master_connected(router))
|
||||
&& (blr_master_connected(router)
|
||||
|| blr_file_next_exists(router, slave)))
|
||||
{
|
||||
/* We may have reached the end of file of a non-current
|
||||
* binlog file.
|
||||
@ -1470,7 +1471,7 @@ if (hkheartbeat - beat1 > 1) LOGIF(LE, (skygw_log_write(
|
||||
dcb_close(slave->dcb);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (blr_master_connected(router))
|
||||
{
|
||||
spinlock_acquire(&slave->catch_lock);
|
||||
slave->cstate |= CS_EXPECTCB;
|
||||
|
Reference in New Issue
Block a user