Addition of slave transition to catchup mode in logging

Addition of slave transition to catchup mode in logging
This commit is contained in:
MassimilianoPinto 2015-12-01 16:16:14 +01:00 committed by Johan Wikman
parent 943bcf1fe9
commit 3f31f5548d
2 changed files with 48 additions and 0 deletions

View File

@ -1562,6 +1562,7 @@ GWBUF *pkt;
uint8_t *buf;
ROUTER_SLAVE *slave, *nextslave;
int action;
unsigned int cstate;
spinlock_acquire(&router->lock);
slave = router->slaves;
@ -1716,9 +1717,19 @@ int action;
case SLAVE_FORCE_CATCHUP:
spinlock_acquire(&slave->catch_lock);
cstate = slave->cstate;
slave->cstate &= ~(CS_UPTODATE|CS_BUSY);
slave->cstate |= CS_EXPECTCB;
spinlock_release(&slave->catch_lock);
if ((cstate & CS_UPTODATE) == CS_UPTODATE)
{
MXS_NOTICE("%s: Slave %s:%d, server-id %d transition from up to date to catch-up in blr_distribute_binlog_record, binlog file '%s', position %lu.",
router->service->name,
slave->dcb->remote,
ntohs((slave->dcb->ipv4).sin_port),
slave->serverid,
slave->binlogfile, (unsigned long)slave->binlog_pos);
}
poll_fake_write_event(slave->dcb);
break;
}

View File

@ -2102,9 +2102,12 @@ char read_errmsg[BINLOG_ERROR_MSG_LEN+1];
strcmp(slave->binlogfile, router->binlog_name) == 0)
{
int state_change = 0;
unsigned int cstate =0;
spinlock_acquire(&router->binlog_lock);
spinlock_acquire(&slave->catch_lock);
cstate = slave->cstate;
/*
* Now check again since we hold the router->binlog_lock
* and slave->catch_lock.
@ -2116,6 +2119,17 @@ char read_errmsg[BINLOG_ERROR_MSG_LEN+1];
slave->cstate |= CS_EXPECTCB;
spinlock_release(&slave->catch_lock);
spinlock_release(&router->binlog_lock);
if ((cstate & CS_UPTODATE) == CS_UPTODATE)
{
MXS_NOTICE("%s: Slave %s:%d, server-id %d transition from up to date to catch-up in blr_slave_catchup, binlog file '%s', position %lu.",
router->service->name,
slave->dcb->remote,
ntohs((slave->dcb->ipv4).sin_port),
slave->serverid,
slave->binlogfile, (unsigned long)slave->binlog_pos);
}
poll_fake_write_event(slave->dcb);
}
else
@ -2226,6 +2240,7 @@ blr_slave_callback(DCB *dcb, DCB_REASON reason, void *data)
{
ROUTER_SLAVE *slave = (ROUTER_SLAVE *)data;
ROUTER_INSTANCE *router = slave->router;
unsigned int cstate;
if (NULL == dcb->session->router_session)
{
@ -2245,6 +2260,7 @@ ROUTER_INSTANCE *router = slave->router;
spinlock_acquire(&router->binlog_lock);
do_return = 0;
cstate = slave->cstate;
/* check for a pending transaction and not rotating */
if (router->pending_transaction && strcmp(router->binlog_name, slave->binlogfile) == 0 &&
@ -2255,6 +2271,15 @@ ROUTER_INSTANCE *router = slave->router;
spinlock_release(&router->binlog_lock);
if (do_return) {
if ((slave->cstate & CS_EXPECTCB) == CS_EXPECTCB)
{
MXS_NOTICE("%s: Slave %s:%d, server-id %d transition to expect_call_back in blr_slave_callback, binlog file '%s', position %lu.",
router->service->name,
slave->dcb->remote,
ntohs((slave->dcb->ipv4).sin_port),
slave->serverid,
slave->binlogfile, (unsigned long)slave->binlog_pos);
}
spinlock_acquire(&slave->catch_lock);
slave->cstate |= CS_EXPECTCB;
spinlock_release(&slave->catch_lock);
@ -2264,8 +2289,20 @@ ROUTER_INSTANCE *router = slave->router;
}
spinlock_acquire(&slave->catch_lock);
cstate = slave->cstate;
slave->cstate &= ~(CS_UPTODATE|CS_EXPECTCB);
spinlock_release(&slave->catch_lock);
if ((cstate & CS_UPTODATE) == CS_UPTODATE)
{
MXS_NOTICE("%s: Slave %s:%d, server-id %d transition from up to date to catch-up in blr_slave_callback, binlog file '%s', position %lu.",
router->service->name,
slave->dcb->remote,
ntohs((slave->dcb->ipv4).sin_port),
slave->serverid,
slave->binlogfile, (unsigned long)slave->binlog_pos);
}
slave->stats.n_dcb++;
blr_slave_catchup(router, slave, true);
}