Ensure that slave->cstate contains meaningful value.

In blr_slave_callback the bits of slave->cstate are reset and
set as one transaction. Earlier they were reset in one and
set in another, leading to a situation where slave->cstate did
not contain a sensible value for a short period of time.

Further, it is now explicitly checked in blr_distribute_binlog_record
that slave->cstate indeed contains a meaningful value.
This commit is contained in:
Johan Wikman 2016-01-28 11:00:07 +02:00
parent 1a4fc56c67
commit 0deffbf2f2
2 changed files with 12 additions and 9 deletions

View File

@ -1602,6 +1602,11 @@ unsigned int cstate;
/* Slave is in catchup mode */
action = 3;
}
else
{
MXS_ERROR("slave->cstate does not contain a meaningful state %d", slave->cstate);
action = 0;
}
slave->stats.n_actions[action-1]++;
spinlock_release(&slave->catch_lock);

View File

@ -1965,6 +1965,7 @@ char read_errmsg[BINLOG_ERROR_MSG_LEN+1];
if (do_return) {
spinlock_acquire(&slave->catch_lock);
slave->cstate &= ~CS_BUSY;
slave->cstate |= CS_EXPECTCB;
spinlock_release(&slave->catch_lock);
poll_fake_write_event(slave->dcb);
@ -1972,15 +1973,6 @@ char read_errmsg[BINLOG_ERROR_MSG_LEN+1];
return 0;
}
spinlock_acquire(&slave->catch_lock);
if (slave->cstate & CS_BUSY)
{
spinlock_release(&slave->catch_lock);
return 0;
}
slave->cstate |= CS_BUSY;
spinlock_release(&slave->catch_lock);
BLFILE *file;
#ifdef BLFILE_IN_SLAVE
file = slave->file;
@ -2369,8 +2361,14 @@ unsigned int cstate;
if (slave->state == BLRS_DUMPING)
{
spinlock_acquire(&slave->catch_lock);
if (slave->cstate & CS_BUSY)
{
spinlock_release(&slave->catch_lock);
return 0;
}
cstate = slave->cstate;
slave->cstate &= ~(CS_UPTODATE|CS_EXPECTCB);
slave->cstate |= CS_BUSY;
spinlock_release(&slave->catch_lock);
if ((cstate & CS_UPTODATE) == CS_UPTODATE)