From 6988c0bfed6d105e7af0eef925ea840840a6c08b Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 12 Apr 2016 09:51:47 +0300 Subject: [PATCH] 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. --- server/modules/routing/binlog/blr.c | 1 + server/modules/routing/binlog/blr_file.c | 2 -- server/modules/routing/binlog/blr_master.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/server/modules/routing/binlog/blr.c b/server/modules/routing/binlog/blr.c index 738dfa5b5..1d1b182c6 100644 --- a/server/modules/routing/binlog/blr.c +++ b/server/modules/routing/binlog/blr.c @@ -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; diff --git a/server/modules/routing/binlog/blr_file.c b/server/modules/routing/binlog/blr_file.c index 76a5466dc..daafdc2af 100644 --- a/server/modules/routing/binlog/blr_file.c +++ b/server/modules/routing/binlog/blr_file.c @@ -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 { diff --git a/server/modules/routing/binlog/blr_master.c b/server/modules/routing/binlog/blr_master.c index 400e65925..a95851cff 100644 --- a/server/modules/routing/binlog/blr_master.c +++ b/server/modules/routing/binlog/blr_master.c @@ -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)