diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.bug664 b/maxscale-system-test/cnf/maxscale.cnf.template.bug664 index 7ef697b69..df627b191 100755 --- a/maxscale-system-test/cnf/maxscale.cnf.template.bug664 +++ b/maxscale-system-test/cnf/maxscale.cnf.template.bug664 @@ -1,6 +1,6 @@ [maxscale] threads=###threads### -log_warning=1 +log_info=1 [MySQL Monitor] type=monitor diff --git a/maxscale-system-test/local_address.cpp b/maxscale-system-test/local_address.cpp index 35ae9d2c9..74e30f372 100644 --- a/maxscale-system-test/local_address.cpp +++ b/maxscale-system-test/local_address.cpp @@ -224,6 +224,16 @@ string get_local_ip(TestConnections& test) return trim(output); } +string get_gateway_ip(TestConnections& test) +{ + int exit_code; + char* output = test.maxscales->ssh_node_output(0, "echo $SSH_CLIENT", false, &exit_code); + *strchr(output, ' ') = '\0'; + string rval(output); + free(output); + return rval; +} + void start_maxscale_with_local_address(TestConnections& test, const string& replace, const string& with) @@ -281,6 +291,7 @@ void run_test(TestConnections& test, const vector& ips) string ip2 = (ips.size() > 1) ? ips[1] : string("42.42.42.42"); string local_ip = get_local_ip(test); + string gateway_ip = get_gateway_ip(test); const char* zUser1 = "alice"; const char* zUser2 = "bob"; @@ -289,8 +300,10 @@ void run_test(TestConnections& test, const vector& ips) create_user_and_grants(test, zUser1, zPassword1, ip1); create_user_and_grants(test, zUser1, zPassword1, local_ip); + create_user_and_grants(test, zUser1, zPassword1, gateway_ip); create_user_and_grants(test, zUser2, zPassword2, ip2); create_user_and_grants(test, zUser2, zPassword2, local_ip); + create_user_and_grants(test, zUser2, zPassword2, gateway_ip); test.repl->sync_slaves(); test.tprintf("\n"); diff --git a/server/modules/monitor/galeramon/galeramon.cc b/server/modules/monitor/galeramon/galeramon.cc index 773529585..f421e434c 100644 --- a/server/modules/monitor/galeramon/galeramon.cc +++ b/server/modules/monitor/galeramon/galeramon.cc @@ -352,7 +352,7 @@ static bool using_xtrabackup(MXS_MONITORED_SERVER* database, const char* server_ while ((row = mysql_fetch_row(result))) { - if (row[1] && strncmp(row[1], "xtrabackup", 10) == 0) + if (row[1] && (strcmp(row[1], "xtrabackup") == 0 || strcmp(row[1], "mariabackup"))) { rval = true; } diff --git a/server/modules/routing/avrorouter/avro_schema.cc b/server/modules/routing/avrorouter/avro_schema.cc index eeb375825..c64d45368 100644 --- a/server/modules/routing/avrorouter/avro_schema.cc +++ b/server/modules/routing/avrorouter/avro_schema.cc @@ -73,7 +73,6 @@ bool json_extract_field_names(const char* filename, std::vector& columns if (json_is_object(val)) { - json_t* name = json_object_get(val, "name"); if (name && json_is_string(name)) diff --git a/server/modules/routing/binlogrouter/blr.cc b/server/modules/routing/binlogrouter/blr.cc index fd181a99e..857d2b1b1 100644 --- a/server/modules/routing/binlogrouter/blr.cc +++ b/server/modules/routing/binlogrouter/blr.cc @@ -1206,6 +1206,7 @@ static MXS_ROUTER_SESSION* newSession(MXS_ROUTER* instance, MXS_SESSION* session slave->gtid_maps = NULL; memset(&slave->f_info, 0, sizeof(MARIADB_GTID_INFO)); slave->annotate_rows = false; + slave->warning_msg = NULL; /** * Add this session to the list of active sessions. @@ -1291,6 +1292,7 @@ static void freeSession(MXS_ROUTER* router_instance, { MXS_FREE(slave->mariadb_gtid); } + MXS_FREE(slave->warning_msg); MXS_FREE(slave); } @@ -1395,7 +1397,9 @@ static int routeQuery(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_session, ROUTER_INSTANCE* router = (ROUTER_INSTANCE*)instance; ROUTER_SLAVE* slave = (ROUTER_SLAVE*)router_session; - return blr_slave_request(router, slave, queue); + int rc = blr_slave_request(router, slave, queue); + gwbuf_free(queue); + return rc; } static const char* event_names[] = diff --git a/server/modules/routing/binlogrouter/blr_file.cc b/server/modules/routing/binlogrouter/blr_file.cc index 57c4384cc..f427c57d1 100644 --- a/server/modules/routing/binlogrouter/blr_file.cc +++ b/server/modules/routing/binlogrouter/blr_file.cc @@ -1413,6 +1413,7 @@ GWBUF* blr_read_binlog(ROUTER_INSTANCE* router, */ void blr_close_binlog(ROUTER_INSTANCE* router, BLFILE* file) { + mxb_assert(file); spinlock_acquire(&router->fileslock); file->refcnt--; if (file->refcnt == 0) @@ -4366,6 +4367,7 @@ bool blr_save_mariadb_gtid(ROUTER_INSTANCE* inst) { if (sql_ret == SQLITE_CONSTRAINT) { + sqlite3_free(errmsg); /* Prepare UPDATE SQL */ snprintf(sql_stmt, GTID_SQL_BUFFER_SIZE, @@ -4413,6 +4415,8 @@ bool blr_save_mariadb_gtid(ROUTER_INSTANCE* inst) } } + sqlite3_free(errmsg); + MXS_DEBUG("Saved/udated MariaDB GTID '%s', %s:%lu,%lu, SQL [%s]", gtid_info.gtid, inst->binlog_name, diff --git a/server/modules/routing/binlogrouter/blr_master.cc b/server/modules/routing/binlogrouter/blr_master.cc index e7fdea7f3..b9fd95843 100644 --- a/server/modules/routing/binlogrouter/blr_master.cc +++ b/server/modules/routing/binlogrouter/blr_master.cc @@ -132,6 +132,8 @@ static void blr_start_master(void* data) if (router->client) { + MXS_FREE(router->client->data); + router->client->data = NULL; dcb_close(router->client); router->client = NULL; } @@ -1518,13 +1520,13 @@ int blr_check_heartbeat(ROUTER_INSTANCE* router) static void blr_log_identity(ROUTER_INSTANCE* router) { - char* master_uuid; - char* master_hostname; - char* master_version; + char* master_uuid = NULL; + char* master_hostname = NULL; + char* master_version = NULL; if (router->set_master_version) { - master_version = router->set_master_version; + master_version = MXS_STRDUP(router->set_master_version); } else { @@ -1533,16 +1535,16 @@ static void blr_log_identity(ROUTER_INSTANCE* router) if (router->set_master_hostname) { - master_hostname = router->set_master_hostname; + master_hostname = MXS_STRDUP(router->set_master_hostname); } else { master_hostname = blr_extract_column(router->saved_master.selecthostname, 1); } - if (router->set_master_uuid) + if (router->set_master_uuid && router->master_uuid) { - master_uuid = router->master_uuid; + master_uuid = MXS_STRDUP(router->master_uuid); } else { @@ -1583,6 +1585,10 @@ static void blr_log_identity(ROUTER_INSTANCE* router) (master_hostname == NULL ? "not available" : master_hostname), (master_version == NULL ? "not available" : master_version)); } + + MXS_FREE(master_version); + MXS_FREE(master_hostname); + MXS_FREE(master_uuid); } /** diff --git a/server/modules/routing/binlogrouter/blr_slave.cc b/server/modules/routing/binlogrouter/blr_slave.cc index 6372bbc00..aacbfd8d3 100644 --- a/server/modules/routing/binlogrouter/blr_slave.cc +++ b/server/modules/routing/binlogrouter/blr_slave.cc @@ -383,7 +383,7 @@ int blr_slave_request(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave, GWBUF* queue { MXS_ERROR("Invalid slave state machine state (%d) for binlog router.", slave->state); - gwbuf_consume(queue, gwbuf_length(queue)); + gwbuf_free(queue); return 0; } @@ -466,6 +466,7 @@ int blr_slave_request(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave, GWBUF* queue MYSQL_COMMAND(queue)); break; } + return rv; } @@ -2146,6 +2147,7 @@ static int blr_slave_binlog_dump(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave, G blr_slave_abort_dump_request(slave, errmsg); slave->state = BLRS_ERRORED; dcb_close(slave->dcb); + gwbuf_free(fde); return 1; } } @@ -2190,6 +2192,7 @@ static int blr_slave_binlog_dump(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave, G blr_slave_abort_dump_request(slave, errmsg); slave->state = BLRS_ERRORED; dcb_close(slave->dcb); + gwbuf_free(fde); return 1; } slave->lastEventReceived = MARIADB10_GTID_GTID_LIST_EVENT; @@ -2211,6 +2214,7 @@ static int blr_slave_binlog_dump(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave, G /* Force the slave to call catchup routine */ poll_fake_write_event(slave->dcb); + gwbuf_free(fde); return 1; } @@ -2773,6 +2777,7 @@ int blr_slave_catchup(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave, bool large) slave->stats.n_events - events_before, router->current_safe_event, read_errmsg); + hdr.ok = SLAVE_POS_READ_OK; } } @@ -3046,6 +3051,9 @@ int blr_slave_catchup(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave, bool large) * Fake rotate just written to client, * no need to call poll_fake_write_event() */ + + // blr_slave_fake_rotate closes the file on success + file = NULL; } else { @@ -6521,6 +6529,7 @@ static int blr_slave_read_ste(ROUTER_INSTANCE* router, if (!new_encryption_ctx) { + gwbuf_free(record); return 0; } record_ptr += BINLOG_EVENT_HDR_LEN; @@ -6557,9 +6566,11 @@ static int blr_slave_read_ste(ROUTER_INSTANCE* router, * Note: if the requested pos is equal to MXS_START_ENCRYPTION_EVENT pos * the event will be skipped by blr_read_binlog() routine */ + gwbuf_free(record); return 1; } + gwbuf_free(record); return 0; }