diff --git a/BUILD/install_build_deps.sh b/BUILD/install_build_deps.sh index beac9fa0c..ec347e853 100755 --- a/BUILD/install_build_deps.sh +++ b/BUILD/install_build_deps.sh @@ -139,7 +139,7 @@ git clone https://github.com/alanxz/rabbitmq-c.git if [ $? != 0 ] then echo "Error cloning rabbitmq-c" - rm -rf $tmpdir + sudo rm -rf $tmpdir exit 1 fi @@ -157,7 +157,7 @@ wget -q --no-check-certificate http://prdownloads.sourceforge.net/tcl/tcl8.6.5-s if [ $? != 0 ] then echo "Error getting tcl" - rm -rf $tmpdir + sudo rm -rf $tmpdir exit 1 fi @@ -173,7 +173,7 @@ git clone https://github.com/akheron/jansson.git if [ $? != 0 ] then echo "Error cloning jansson" - rm -rf $tmpdir + sudo rm -rf $tmpdir exit 1 fi @@ -191,7 +191,7 @@ wget -q -r -l1 -nH --cut-dirs=2 --no-parent -A.tar.gz --no-directories http://mi if [ $? != 0 ] then echo "Error getting avro-c" - rm -rf $tmpdir + sudo rm -rf $tmpdir exit 1 fi avro_filename=`ls -1 avro*.tar.gz` @@ -209,4 +209,4 @@ wget --quiet https://nodejs.org/dist/v6.11.2/node-v6.11.2-linux-x64.tar.xz tar -axf node-v6.11.2-linux-x64.tar.xz sudo cp -t /usr -r node-v6.11.2-linux-x64/* -rm -rf $tmpdir +sudo rm -rf $tmpdir diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index cb66968c5..a3aa38e1e 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -198,7 +198,7 @@ add_test_executable(different_size_rwsplit.cpp different_size_rwsplit replicatio add_test_executable(encrypted_passwords.cpp encrypted_passwords replication LABELS maxscale LIGHT REPL_BACKEND) # Basic MaxCtrl test -add_test_executable(maxctrl_basic.cpp maxctrl_basic replication LABELS maxctrl REPL_BACKEND) +add_test_executable(maxctrl_basic.cpp maxctrl_basic maxctrl_basic LABELS maxctrl REPL_BACKEND) # MXS-2167: Monitors should be able to use extra_port add_test_executable(mxs2167_extra_port.cpp mxs2167_extra_port mxs2167_extra_port LABELS REPL_BACKEND) diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.maxctrl_basic b/maxscale-system-test/cnf/maxscale.cnf.template.maxctrl_basic new file mode 100644 index 000000000..1f2e045e2 --- /dev/null +++ b/maxscale-system-test/cnf/maxscale.cnf.template.maxctrl_basic @@ -0,0 +1,95 @@ +[maxscale] +threads=###threads### + +[MySQL Monitor] +type=monitor +module=mysqlmon +servers=server1,server2,server3,server4 +user=maxskysql +password=skysql +monitor_interval=1000 +detect_stale_master=false +detect_standalone_master=false + +[RW Split Router] +type=service +router=readwritesplit +servers=server1,server2,server3,server4 +user=maxskysql +password=skysql +slave_selection_criteria=LEAST_GLOBAL_CONNECTIONS +max_slave_connections=1 + +[Read Connection Router Slave] +type=service +router=readconnroute +router_options=slave +servers=server1,server2,server3,server4 +user=maxskysql +password=skysql + +[Read Connection Router Master] +type=service +router=readconnroute +router_options=master +servers=server1,server2,server3,server4 +user=maxskysql +password=skysql +filters=qla + +[RW Split Listener] +type=listener +service=RW Split Router +protocol=MySQLClient +port=4006 + +[Read Connection Listener Slave] +type=listener +service=Read Connection Router Slave +protocol=MySQLClient +port=4009 + +[Read Connection Listener Master] +type=listener +service=Read Connection Router Master +protocol=MySQLClient +port=4008 + +[qla] +type=filter +module=qlafilter +filebase=/tmp/QueryLog + +[CLI] +type=service +router=cli + +[CLI Listener] +type=listener +service=CLI +protocol=maxscaled +socket=default + +[server1] +type=server +address=###node_server_IP_1### +port=###node_server_port_1### +protocol=MySQLBackend + +[server2] +type=server +address=###node_server_IP_2### +port=###node_server_port_2### +protocol=MySQLBackend + +[server3] +type=server +address=###node_server_IP_3### +port=###node_server_port_3### +protocol=MySQLBackend + +[server4] +type=server +address=###node_server_IP_4### +port=###node_server_port_4### +protocol=MySQLBackend diff --git a/maxscale-system-test/maxctrl_basic.cpp b/maxscale-system-test/maxctrl_basic.cpp index 9ff8c3e8f..f109a2b7b 100644 --- a/maxscale-system-test/maxctrl_basic.cpp +++ b/maxscale-system-test/maxctrl_basic.cpp @@ -26,6 +26,76 @@ int main(int argc, char** argv) rc = test.maxscales->ssh_node_f(0, false, "maxctrl --tsv list servers|grep 'Maintenance'"); test.expect(rc != 0, "`list servers` should have no rows with: Maintanance"); + test.tprintf("Execute all available commands"); + test.maxscales->ssh_node_f(0, false, + "maxctrl list servers;" + "maxctrl list services;" + "maxctrl list listeners RW-Split-Router;" + "maxctrl list monitors;" + "maxctrl list sessions;" + "maxctrl list filters;" + "maxctrl list modules;" + "maxctrl list threads;" + "maxctrl list users;" + "maxctrl list commands;" + "maxctrl show server server1;" + "maxctrl show servers;" + "maxctrl show service RW-Split-Router;" + "maxctrl show services;" + "maxctrl show monitor MySQL-Monitor;" + "maxctrl show monitors;" + "maxctrl show session 1;" + "maxctrl show sessions;" + "maxctrl show filter qla;" + "maxctrl show filters;" + "maxctrl show module readwritesplit;" + "maxctrl show modules;" + "maxctrl show maxscale;" + "maxctrl show thread 1;" + "maxctrl show threads;" + "maxctrl show logging;" + "maxctrl show commands mariadbmon;" + "maxctrl drain server server1;" + "maxctrl clear server server1 maintenance;" + "maxctrl enable log-priority info;" + "maxctrl enable account vagrant;" + "maxctrl disable log-priority info;" + "maxctrl disable account vagrant;" + "maxctrl create server server5 127.0.0.1 3306;" + "maxctrl create monitor mon1 mariadbmon user=skysql password=skysql;" + "maxctrl create service svc1 readwritesplit user=skysql password=skysql;" + "maxctrl create filter qla2 qlafilter filebase=/tmp/qla2.log;" + "maxctrl create listener svc1 listener1 9999;" + "maxctrl create user maxuser maxpwd;" + "maxctrl link service svc1 server5;" + "maxctrl link monitor mon1 server5;" + "maxctrl alter service-filters svc1 qla2" + "maxctrl unlink service svc1 server5;" + "maxctrl unlink monitor mon1 server5;" + "maxctrl alter service-filters svc1" + "maxctrl destroy server server5;" + "maxctrl destroy listener svc1 listener1;" + "maxctrl destroy monitor mon1;" + "maxctrl destroy filter qla2;" + "maxctrl destroy service svc1;" + "maxctrl destroy user maxuser;" + "maxctrl stop service RW-Split-Router;" + "maxctrl stop monitor MySQL-Monitor;" + "maxctrl stop maxscale;" + "maxctrl start service RW-Split-Router;" + "maxctrl start monitor MySQL-Monitor;" + "maxctrl start maxscale;" + "maxctrl alter server server1 port 3307;" + "maxctrl alter server server1 port 3306;" + "maxctrl alter monitor MySQL-Monitor auto_failover true;" + "maxctrl alter service RW-Split-Router max_slave_connections=3;" + "maxctrl alter logging highprecision true;" + "maxctrl alter maxscale passive true;" + "maxctrl rotate logs;" + "maxctrl call command mariadbmon reset-replication MySQL-Monitor;" + "maxctrl api get servers;" + "maxctrl classify 'select 1';"); + test.check_maxscale_alive(); return test.global_result; } diff --git a/server/core/filter.cc b/server/core/filter.cc index 457817c75..77718419d 100644 --- a/server/core/filter.cc +++ b/server/core/filter.cc @@ -256,10 +256,10 @@ void dprintAllFilters(DCB* dcb) * Designed to be called within a debug CLI in order * to display all active filters in MaxScale */ -void dprintFilter(DCB* dcb, const SFilterDef& filter) +void dprintFilter(DCB* dcb, const FilterDef* filter) { mxb_assert(filter); - dcb_printf(dcb, "FilterDef %p (%s)\n", filter.get(), filter->name.c_str()); + dcb_printf(dcb, "FilterDef %p (%s)\n", filter, filter->name.c_str()); dcb_printf(dcb, "\tModule: %s\n", filter->module.c_str()); if (filter->obj && filter->filter) { diff --git a/server/core/internal/filter.hh b/server/core/internal/filter.hh index 3f43ddaf9..339df3622 100644 --- a/server/core/internal/filter.hh +++ b/server/core/internal/filter.hh @@ -93,7 +93,7 @@ void filter_destroy_instances(); bool filter_serialize(const SFilterDef& filter); void dprintAllFilters(DCB*); -void dprintFilter(DCB*, const SFilterDef&); +void dprintFilter(DCB*, const FilterDef*); void dListFilters(DCB*); /** diff --git a/server/core/query_classifier.cc b/server/core/query_classifier.cc index 8947563b0..aeeb25e1b 100644 --- a/server/core/query_classifier.cc +++ b/server/core/query_classifier.cc @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "internal/config_runtime.h" #include "internal/modules.h" diff --git a/server/modules/routing/avrorouter/avro_converter.cc b/server/modules/routing/avrorouter/avro_converter.cc index a0c9bd4cc..9d196feae 100644 --- a/server/modules/routing/avrorouter/avro_converter.cc +++ b/server/modules/routing/avrorouter/avro_converter.cc @@ -353,15 +353,17 @@ bool AvroConverter::open_table(const STableMapEvent& map, const STableCreateEven return rval; } -bool AvroConverter::prepare_table(std::string database, std::string table) +bool AvroConverter::prepare_table(const STableMapEvent& map, const STableCreateEvent& create) { bool rval = false; - auto it = m_open_tables.find(database + "." + table); + auto it = m_open_tables.find(map->database + "." + map->table); if (it != m_open_tables.end()) { m_writer_iface = it->second->avro_writer_iface; m_avro_file = &it->second->avro_file; + m_map = map; + m_create = create; rval = true; } diff --git a/server/modules/routing/avrorouter/avro_converter.hh b/server/modules/routing/avrorouter/avro_converter.hh index fdbab4241..3dbd6e83f 100644 --- a/server/modules/routing/avrorouter/avro_converter.hh +++ b/server/modules/routing/avrorouter/avro_converter.hh @@ -49,7 +49,7 @@ public: AvroConverter(std::string avrodir, uint64_t block_size, mxs_avro_codec_type codec); bool open_table(const STableMapEvent& map, const STableCreateEvent& create); - bool prepare_table(std::string database, std::string table); + bool prepare_table(const STableMapEvent& map, const STableCreateEvent& create); void flush_tables(); void prepare_row(const gtid_pos_t& gtid, const REP_HEADER& hdr, int event_type); bool commit(const gtid_pos_t& gtid); diff --git a/server/modules/routing/avrorouter/avro_rbr.cc b/server/modules/routing/avrorouter/avro_rbr.cc index 0b720aea6..ac3629e00 100644 --- a/server/modules/routing/avrorouter/avro_rbr.cc +++ b/server/modules/routing/avrorouter/avro_rbr.cc @@ -243,6 +243,7 @@ uint8_t* process_row_event_data(STableMapEvent map, uint8_t* columns_present, uint8_t* end) { + mxb_assert(create->database == map->database && create->table == map->table); int npresent = 0; long ncolumns = map->columns(); uint8_t* metadata = &map->column_metadata[0]; @@ -624,11 +625,17 @@ bool Rpl::handle_row_event(REP_HEADER* hdr, uint8_t* ptr) return true; } - bool ok = m_handler->prepare_table(map->database, map->table); auto create = m_created_tables.find(table_ident); + bool ok = false; - if (ok && create != m_created_tables.end() - && ncolumns == map->columns() && create->second->columns.size() == map->columns()) + if (create != m_created_tables.end() && ncolumns == map->columns() + && create->second->columns.size() == map->columns() + && m_handler->prepare_table(map, create->second)) + { + ok = true; + } + + if (ok) { /** Each event has one or more rows in it. The number of rows is not known * beforehand so we must continue processing them until we reach the end diff --git a/server/modules/routing/avrorouter/rpl.hh b/server/modules/routing/avrorouter/rpl.hh index 7eaebb5fc..3728af8a6 100644 --- a/server/modules/routing/avrorouter/rpl.hh +++ b/server/modules/routing/avrorouter/rpl.hh @@ -183,8 +183,8 @@ public: return true; } - // Prepare a new row for processing - virtual bool prepare_table(std::string database, std::string table) + // Prepare a table for row processing + virtual bool prepare_table(const STableMapEvent& map, const STableCreateEvent& create) { return true; } diff --git a/server/modules/routing/binlogrouter/blr.cc b/server/modules/routing/binlogrouter/blr.cc index d43dd94c0..01660c047 100644 --- a/server/modules/routing/binlogrouter/blr.cc +++ b/server/modules/routing/binlogrouter/blr.cc @@ -807,7 +807,7 @@ static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params { {"address", "_none_"}, {"port", "3306"}, - {"protocol", "MySQLBackend"}, + {"protocol", "mariadbbackend"}, {"authenticator", "MySQLBackendAuth"} }, config_server_params);