diff --git a/server/modules/routing/binlogrouter/blr.c b/server/modules/routing/binlogrouter/blr.c index 16feed1fb..ed8b58053 100644 --- a/server/modules/routing/binlogrouter/blr.c +++ b/server/modules/routing/binlogrouter/blr.c @@ -2734,6 +2734,7 @@ static void mariadb_gtid_info_free(MARIADB_GTID_INFO *in) if (in) { MXS_FREE(in->gtid); + MXS_FREE(in->file); MXS_FREE(in); } } @@ -2753,9 +2754,11 @@ static MARIADB_GTID_INFO *mariadb_gtid_info_dup(const MARIADB_GTID_INFO *in) { MXS_FREE(rval); MXS_FREE(gtid); + MXS_FREE(file); return NULL; } rval->gtid = gtid; + rval->file = file; rval->start = in-> start; rval->end = in->end; diff --git a/server/modules/routing/binlogrouter/blr_file.c b/server/modules/routing/binlogrouter/blr_file.c index 56cd61e3d..8163090bc 100644 --- a/server/modules/routing/binlogrouter/blr_file.c +++ b/server/modules/routing/binlogrouter/blr_file.c @@ -3311,6 +3311,7 @@ bool blr_save_mariadb_gtid(ROUTER_INSTANCE *inst) MARIADB_GTID_INFO gtid_info; gtid_info.gtid = inst->pending_transaction.gtid; + gtid_info.file = inst->binlog_name; gtid_info.start = inst->pending_transaction.start_pos; gtid_info.end = inst->pending_transaction.end_pos; @@ -3333,3 +3334,23 @@ bool blr_save_mariadb_gtid(ROUTER_INSTANCE *inst) return true; } + +/** + * Get MariaDB GTID frim repo + * + * @param inst The router instance + * @return Found data or NULL + */ + +MARIADB_GTID_INFO *blr_fetch_mariadb_gtid(ROUTER_INSTANCE *inst, char *gtid) +{ + if (!gtid) + { + return NULL; + } + else + { + return (MARIADB_GTID_INFO *)hashtable_fetch(inst->gtid_repo, + gtid); + } +} diff --git a/server/modules/routing/binlogrouter/blr_slave.c b/server/modules/routing/binlogrouter/blr_slave.c index c7f3354f0..49385fcd0 100644 --- a/server/modules/routing/binlogrouter/blr_slave.c +++ b/server/modules/routing/binlogrouter/blr_slave.c @@ -166,6 +166,7 @@ static int blr_slave_send_heartbeat(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave static int blr_set_master_ssl(ROUTER_INSTANCE *router, CHANGE_MASTER_OPTIONS config, char *error_message); static int blr_slave_read_ste(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, uint32_t fde_end_pos); static GWBUF *blr_slave_read_fde(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave); +extern MARIADB_GTID_INFO *blr_fetch_mariadb_gtid(ROUTER_INSTANCE *inst, char *gtid); void poll_fake_write_event(DCB *dcb); @@ -2297,8 +2298,9 @@ blr_slave_binlog_dump(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue /* Shall we avoid the lookup if file & pos is set? */ /* Fetch the GTID from the storage */ - MARIADB_GTID_INFO *f_gtid = hashtable_fetch(router->gtid_repo, - slave->mariadb_gtid); + MARIADB_GTID_INFO *f_gtid = blr_fetch_mariadb_gtid(router, + slave->mariadb_gtid); + /* Not Found */ if (!f_gtid) {