Fixed rotate events never being distributed
The check for rotate event conditions was wrong which led to false error message about unexpected binlog file and position combinations. The position of the last event was reset every time a file was opened which caused problems when the binlog file was rotated. The slave's current positions were compared to the position where the last event started and because the last_event_pos variable didn't point to the rotate event of the previous binlog, the slave's never got the rotate event.
This commit is contained in:
parent
440bc049c0
commit
6988c0bfed
@ -278,6 +278,7 @@ createInstance(SERVICE *service, char **options)
|
||||
inst->trx_safe = 1;
|
||||
inst->pending_transaction = 0;
|
||||
inst->last_safe_pos = 0;
|
||||
inst->last_event_pos = 0;
|
||||
|
||||
inst->set_master_version = NULL;
|
||||
inst->set_master_hostname = NULL;
|
||||
|
@ -253,7 +253,6 @@ blr_file_create(ROUTER_INSTANCE *router, char *file)
|
||||
router->binlog_position = BINLOG_MAGIC_SIZE;
|
||||
router->current_safe_event = BINLOG_MAGIC_SIZE;
|
||||
router->last_written = BINLOG_MAGIC_SIZE;
|
||||
router->last_event_pos = 0;
|
||||
spinlock_release(&router->binlog_lock);
|
||||
|
||||
created = 1;
|
||||
@ -317,7 +316,6 @@ blr_file_append(ROUTER_INSTANCE *router, char *file)
|
||||
router->binlog_position = BINLOG_MAGIC_SIZE;
|
||||
router->current_safe_event = BINLOG_MAGIC_SIZE;
|
||||
router->last_written = BINLOG_MAGIC_SIZE;
|
||||
router->last_event_pos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1916,7 +1916,7 @@ blr_distribute_binlog_record(ROUTER_INSTANCE *router, REP_HEADER *hdr, uint8_t *
|
||||
slave_event_action_t slave_action = SLAVE_FORCE_CATCHUP;
|
||||
const bool same_file = strcmp(slave->binlogfile, router->binlog_name) == 0;
|
||||
const bool rotate = hdr->event_type == ROTATE_EVENT &&
|
||||
strcmp(slave->binlogfile, router->prevbinlog);
|
||||
strcmp(slave->binlogfile, router->prevbinlog) == 0;
|
||||
|
||||
if (router->trx_safe && (same_file || rotate) &&
|
||||
slave->binlog_pos == router->current_safe_event)
|
||||
|
Loading…
x
Reference in New Issue
Block a user