From 74c8b5e296053250b8add4922a76389a4d60606b Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 12 Feb 2016 10:17:50 +0200 Subject: [PATCH] Fixed events larger than 2^24 failing without transaction safety If transaction safety was disabled and a large event sent in multiple SQL packets was received, the distribution of that event to the slaves would fail. --- server/modules/routing/binlog/blr_master.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/server/modules/routing/binlog/blr_master.c b/server/modules/routing/binlog/blr_master.c index f11371bb9..a3248aaa6 100644 --- a/server/modules/routing/binlog/blr_master.c +++ b/server/modules/routing/binlog/blr_master.c @@ -1344,13 +1344,25 @@ uint32_t partialpos = 0; if (router->trx_safe == 0 || (router->trx_safe && router->pending_transaction == 0)) { + uint64_t old_pos = router->binlog_position; router->binlog_position = router->current_pos; router->current_safe_event = router->current_pos; spinlock_release(&router->binlog_lock); - /* Now distribute events */ - blr_distribute_binlog_record(router, &hdr, ptr); + if (router->master_event_state == BLR_EVENT_COMPLETE) + { + /** Read the complete event from the disk */ + GWBUF *record = blr_read_events_from_pos(router, old_pos, &hdr, hdr.next_pos); + uint8_t *data = GWBUF_DATA(record); + blr_distribute_binlog_record(router, &hdr, data); + gwbuf_free(record); + } + else + { + /* Now distribute events */ + blr_distribute_binlog_record(router, &hdr, ptr); + } } else { /** * If transaction is closed: