diff --git a/.github/workflows/CI-3p-pgjdbc.yml b/.github/workflows/CI-3p-pgjdbc.yml new file mode 100644 index 000000000..d49aacee4 --- /dev/null +++ b/.github/workflows/CI-3p-pgjdbc.yml @@ -0,0 +1,29 @@ +name: CI-3p-pgjdbc +run-name: '${{ github.event.workflow_run && github.event.workflow_run.head_branch || github.ref_name }} ${{ github.workflow }} ${{ github.event.workflow_run && github.event.workflow_run.head_sha || github.sha }}' + +on: + workflow_dispatch: + inputs: + testtree: + description: 'proxysql_3p_testing treeish/branch/tag/hash' + default: main + type: string + workflow_run: + workflows: [ CI-trigger ] + types: [ completed ] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.workflow_run && github.event.workflow_run.head_branch || github.ref_name }} + cancel-in-progress: true + +jobs: + run-pgsql: + if: | + (github.event.workflow_run && github.event.workflow_run.conclusion == 'success' || ! github.event.workflow_run) && + ! startsWith((github.event.workflow_run && github.event.workflow_run.head_branch || github.ref_name), 'v2.') + uses: sysown/proxysql/.github/workflows/ci-3p-pgjdbc.yml@GH-Actions + secrets: inherit + with: + trigger: ${{ toJson(github) }} + infradb: ${{ vars.MATRIX_3P_PGJDBC_infradb_pgsql }} + connector: ${{ vars.MATRIX_3P_PGJDBC_connector_pgsql }} diff --git a/Makefile b/Makefile index 01aa57306..e34ff5629 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ O3 := -O3 -mtune=native ALL_DEBUG := $(O0) -ggdb -DDEBUG NO_DEBUG := $(O2) -ggdb DEBUG := $(ALL_DEBUG) -CURVER ?= 3.0.2 +CURVER ?= 3.0.3 #export DEBUG #export EXTRALINK export MAKE diff --git a/include/PgSQL_HostGroups_Manager.h b/include/PgSQL_HostGroups_Manager.h index 6ceff1e7f..1f44aaf11 100644 --- a/include/PgSQL_HostGroups_Manager.h +++ b/include/PgSQL_HostGroups_Manager.h @@ -46,7 +46,7 @@ #define MYHGM_PgSQL_SERVERS "CREATE TABLE pgsql_servers ( hostgroup_id INT NOT NULL DEFAULT 0 , hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 5432 , weight INT NOT NULL DEFAULT 1 , status INT NOT NULL DEFAULT 0 , compression INT NOT NULL DEFAULT 0 , max_connections INT NOT NULL DEFAULT 1000 , max_replication_lag INT NOT NULL DEFAULT 0 , use_ssl INT NOT NULL DEFAULT 0 , max_latency_ms INT UNSIGNED NOT NULL DEFAULT 0 , comment VARCHAR NOT NULL DEFAULT '' , mem_pointer INT NOT NULL DEFAULT 0 , PRIMARY KEY (hostgroup_id, hostname, port) )" #define MYHGM_PgSQL_SERVERS_INCOMING "CREATE TABLE pgsql_servers_incoming ( hostgroup_id INT NOT NULL DEFAULT 0 , hostname VARCHAR NOT NULL , port INT NOT NULL DEFAULT 5432 , weight INT NOT NULL DEFAULT 1 , status INT NOT NULL DEFAULT 0 , compression INT NOT NULL DEFAULT 0 , max_connections INT NOT NULL DEFAULT 1000 , max_replication_lag INT NOT NULL DEFAULT 0 , use_ssl INT NOT NULL DEFAULT 0 , max_latency_ms INT UNSIGNED NOT NULL DEFAULT 0 , comment VARCHAR NOT NULL DEFAULT '' , PRIMARY KEY (hostgroup_id, hostname, port))" #endif /* DEBUG */ -#define MYHGM_PgSQL_REPLICATION_HOSTGROUPS "CREATE TABLE pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only','innodb_read_only','super_read_only','read_only|innodb_read_only','read_only&innodb_read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '' , UNIQUE (reader_hostgroup))" +#define MYHGM_PgSQL_REPLICATION_HOSTGROUPS "CREATE TABLE pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '' , UNIQUE (reader_hostgroup))" #define PGHGM_GEN_ADMIN_RUNTIME_SERVERS "SELECT hostgroup_id, hostname, port, CASE status WHEN 0 THEN \"ONLINE\" WHEN 1 THEN \"SHUNNED\" WHEN 2 THEN \"OFFLINE_SOFT\" WHEN 3 THEN \"OFFLINE_HARD\" WHEN 4 THEN \"SHUNNED\" END status, weight, compression, max_connections, max_replication_lag, use_ssl, max_latency_ms, comment FROM pgsql_servers ORDER BY hostgroup_id, hostname, port" @@ -557,8 +557,6 @@ class PgSQL_HostGroups_Manager : public Base_HostGroups_Manager { SQLite3_result* incoming_pgsql_servers_v2; - //pthread_t HGCU_thread_id; - char rand_del[8]; pthread_mutex_t pgsql_errors_mutex; umap_pgsql_errors pgsql_errors_umap; diff --git a/include/ProxySQL_Admin_Tables_Definitions.h b/include/ProxySQL_Admin_Tables_Definitions.h index 3e02ec5dd..ee8b500ae 100644 --- a/include/ProxySQL_Admin_Tables_Definitions.h +++ b/include/ProxySQL_Admin_Tables_Definitions.h @@ -276,7 +276,10 @@ #define ADMIN_SQLITE_TABLE_PGSQL_FIREWALL_WHITELIST_SQLI_FINGERPRINTS "CREATE TABLE pgsql_firewall_whitelist_sqli_fingerprints (active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , fingerprint VARCHAR NOT NULL , PRIMARY KEY (fingerprint) )" #define ADMIN_SQLITE_TABLE_PGSQL_QUERY_RULES_FAST_ROUTING "CREATE TABLE pgsql_query_rules_fast_routing (username VARCHAR NOT NULL , database VARCHAR NOT NULL , flagIN INT NOT NULL DEFAULT 0 , destination_hostgroup INT CHECK (destination_hostgroup >= 0) NOT NULL , comment VARCHAR NOT NULL , PRIMARY KEY (username, database, flagIN) )" #define ADMIN_SQLITE_TABLE_PGSQL_HOSTGROUP_ATTRIBUTES "CREATE TABLE pgsql_hostgroup_attributes (hostgroup_id INT NOT NULL PRIMARY KEY , max_num_online_servers INT CHECK (max_num_online_servers>=0 AND max_num_online_servers <= 1000000) NOT NULL DEFAULT 1000000 , autocommit INT CHECK (autocommit IN (-1, 0, 1)) NOT NULL DEFAULT -1 , free_connections_pct INT CHECK (free_connections_pct >= 0 AND free_connections_pct <= 100) NOT NULL DEFAULT 10 , init_connect VARCHAR NOT NULL DEFAULT '' , multiplex INT CHECK (multiplex IN (0, 1)) NOT NULL DEFAULT 1 , connection_warming INT CHECK (connection_warming IN (0, 1)) NOT NULL DEFAULT 0 , throttle_connections_per_sec INT CHECK (throttle_connections_per_sec >= 1 AND throttle_connections_per_sec <= 1000000) NOT NULL DEFAULT 1000000 , ignore_session_variables VARCHAR CHECK (JSON_VALID(ignore_session_variables) OR ignore_session_variables = '') NOT NULL DEFAULT '' , hostgroup_settings VARCHAR CHECK (JSON_VALID(hostgroup_settings) OR hostgroup_settings = '') NOT NULL DEFAULT '' , servers_defaults VARCHAR CHECK (JSON_VALID(servers_defaults) OR servers_defaults = '') NOT NULL DEFAULT '' , comment VARCHAR NOT NULL DEFAULT '')" -#define ADMIN_SQLITE_TABLE_PGSQL_REPLICATION_HOSTGROUPS "CREATE TABLE pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only','innodb_read_only','super_read_only','read_only|innodb_read_only','read_only&innodb_read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '', UNIQUE (reader_hostgroup))" +#define ADMIN_SQLITE_TABLE_PGSQL_REPLICATION_HOSTGROUPS_V3_0_1 "CREATE TABLE pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only','innodb_read_only','super_read_only','read_only|innodb_read_only','read_only&innodb_read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '', UNIQUE (reader_hostgroup))" +#define ADMIN_SQLITE_TABLE_PGSQL_REPLICATION_HOSTGROUPS_V3_0_2 "CREATE TABLE pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '' , UNIQUE (reader_hostgroup))" + +#define ADMIN_SQLITE_TABLE_PGSQL_REPLICATION_HOSTGROUPS ADMIN_SQLITE_TABLE_PGSQL_REPLICATION_HOSTGROUPS_V3_0_2 #define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_SERVERS "CREATE TABLE runtime_pgsql_servers (hostgroup_id INT CHECK (hostgroup_id>=0) NOT NULL DEFAULT 0 , hostname VARCHAR NOT NULL , port INT CHECK (port >= 0 AND port <= 65535) NOT NULL DEFAULT 5432 , status VARCHAR CHECK (UPPER(status) IN ('ONLINE','SHUNNED','OFFLINE_SOFT', 'OFFLINE_HARD')) NOT NULL DEFAULT 'ONLINE' , weight INT CHECK (weight >= 0 AND weight <=10000000) NOT NULL DEFAULT 1 , compression INT CHECK (compression IN(0,1)) NOT NULL DEFAULT 0 , max_connections INT CHECK (max_connections >=0) NOT NULL DEFAULT 1000 , max_replication_lag INT CHECK (max_replication_lag >= 0 AND max_replication_lag <= 126144000) NOT NULL DEFAULT 0 , use_ssl INT CHECK (use_ssl IN(0,1)) NOT NULL DEFAULT 0 , max_latency_ms INT UNSIGNED CHECK (max_latency_ms>=0) NOT NULL DEFAULT 0 , comment VARCHAR NOT NULL DEFAULT '' , PRIMARY KEY (hostgroup_id, hostname, port) )" #define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_USERS "CREATE TABLE runtime_pgsql_users (username VARCHAR NOT NULL , password VARCHAR , active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , use_ssl INT CHECK (use_ssl IN (0,1)) NOT NULL DEFAULT 0 , default_hostgroup INT NOT NULL DEFAULT 0 , transaction_persistent INT CHECK (transaction_persistent IN (0,1)) NOT NULL DEFAULT 1 , fast_forward INT CHECK (fast_forward IN (0,1)) NOT NULL DEFAULT 0 , backend INT CHECK (backend IN (0,1)) NOT NULL DEFAULT 1 , frontend INT CHECK (frontend IN (0,1)) NOT NULL DEFAULT 1 , max_connections INT CHECK (max_connections >=0) NOT NULL DEFAULT 10000 , attributes VARCHAR CHECK (JSON_VALID(attributes) OR attributes = '') NOT NULL DEFAULT '', comment VARCHAR NOT NULL DEFAULT '' , PRIMARY KEY (username, backend) , UNIQUE (username, frontend))" @@ -287,7 +290,7 @@ #define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_FIREWALL_WHITELIST_SQLI_FINGERPRINTS "CREATE TABLE runtime_pgsql_firewall_whitelist_sqli_fingerprints (active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , fingerprint VARCHAR NOT NULL , PRIMARY KEY (fingerprint) )" #define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_QUERY_RULES_FAST_ROUTING "CREATE TABLE runtime_pgsql_query_rules_fast_routing (username VARCHAR NOT NULL , database VARCHAR NOT NULL , flagIN INT NOT NULL DEFAULT 0 , destination_hostgroup INT CHECK (destination_hostgroup >= 0) NOT NULL , comment VARCHAR NOT NULL , PRIMARY KEY (username, database, flagIN) )" #define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_HOSTGROUP_ATTRIBUTES "CREATE TABLE runtime_pgsql_hostgroup_attributes (hostgroup_id INT NOT NULL PRIMARY KEY , max_num_online_servers INT CHECK (max_num_online_servers>=0 AND max_num_online_servers <= 1000000) NOT NULL DEFAULT 1000000 , autocommit INT CHECK (autocommit IN (-1, 0, 1)) NOT NULL DEFAULT -1 , free_connections_pct INT CHECK (free_connections_pct >= 0 AND free_connections_pct <= 100) NOT NULL DEFAULT 10 , init_connect VARCHAR NOT NULL DEFAULT '' , multiplex INT CHECK (multiplex IN (0, 1)) NOT NULL DEFAULT 1 , connection_warming INT CHECK (connection_warming IN (0, 1)) NOT NULL DEFAULT 0 , throttle_connections_per_sec INT CHECK (throttle_connections_per_sec >= 1 AND throttle_connections_per_sec <= 1000000) NOT NULL DEFAULT 1000000 , ignore_session_variables VARCHAR CHECK (JSON_VALID(ignore_session_variables) OR ignore_session_variables = '') NOT NULL DEFAULT '' , hostgroup_settings VARCHAR CHECK (JSON_VALID(hostgroup_settings) OR hostgroup_settings = '') NOT NULL DEFAULT '' , servers_defaults VARCHAR CHECK (JSON_VALID(servers_defaults) OR servers_defaults = '') NOT NULL DEFAULT '' , comment VARCHAR NOT NULL DEFAULT '')" -#define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_REPLICATION_HOSTGROUPS "CREATE TABLE runtime_pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only','innodb_read_only','super_read_only','read_only|innodb_read_only','read_only&innodb_read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '', UNIQUE (reader_hostgroup))" +#define ADMIN_SQLITE_TABLE_RUNTIME_PGSQL_REPLICATION_HOSTGROUPS "CREATE TABLE runtime_pgsql_replication_hostgroups (writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY , reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>=0) , check_type VARCHAR CHECK (LOWER(check_type) IN ('read_only')) NOT NULL DEFAULT 'read_only' , comment VARCHAR NOT NULL DEFAULT '' , UNIQUE (reader_hostgroup))" #define STATS_SQLITE_TABLE_PGSQL_GLOBAL "CREATE TABLE stats_pgsql_global (Variable_Name VARCHAR NOT NULL PRIMARY KEY , Variable_Value VARCHAR NOT NULL)" #define STATS_SQLITE_TABLE_PGSQL_CONNECTION_POOL "CREATE TABLE stats_pgsql_connection_pool (hostgroup INT , srv_host VARCHAR , srv_port INT , status VARCHAR , ConnUsed INT , ConnFree INT , ConnOK INT , ConnERR INT , MaxConnUsed INT , Queries INT , Bytes_data_sent INT , Bytes_data_recv INT , Latency_us INT)" diff --git a/include/proxysql_admin.h b/include/proxysql_admin.h index 9a3ea69cd..786910113 100644 --- a/include/proxysql_admin.h +++ b/include/proxysql_admin.h @@ -425,6 +425,7 @@ class ProxySQL_Admin { void disk_upgrade_mysql_users(); void disk_upgrade_scheduler(); void disk_upgrade_rest_api_routes(); + void disk_upgrade_pgsql_replication_hostgroups(); #ifdef DEBUG template diff --git a/lib/Admin_Bootstrap.cpp b/lib/Admin_Bootstrap.cpp index 02eb5751e..66ef33f20 100644 --- a/lib/Admin_Bootstrap.cpp +++ b/lib/Admin_Bootstrap.cpp @@ -727,6 +727,9 @@ bool ProxySQL_Admin::init(const bootstrap_info_t& bootstrap_info) { // upgrade restapi_routes if needed (upgrade from previous version) disk_upgrade_rest_api_routes(); + // upgrade pgsql_replication_hostgroups if needed (upgrade from previous version) + disk_upgrade_pgsql_replication_hostgroups(); + check_and_build_standard_tables(admindb, tables_defs_admin); check_and_build_standard_tables(configdb, tables_defs_config); check_and_build_standard_tables(statsdb, tables_defs_stats); diff --git a/lib/PgSQL_HostGroups_Manager.cpp b/lib/PgSQL_HostGroups_Manager.cpp index c52c988be..47758aef4 100644 --- a/lib/PgSQL_HostGroups_Manager.cpp +++ b/lib/PgSQL_HostGroups_Manager.cpp @@ -740,11 +740,11 @@ PgSQL_HostGroups_Manager::PgSQL_HostGroups_Manager() { } void PgSQL_HostGroups_Manager::init() { - + // do nothing here } void PgSQL_HostGroups_Manager::shutdown() { - + // do nothing here } PgSQL_HostGroups_Manager::~PgSQL_HostGroups_Manager() { diff --git a/lib/PgSQL_Session.cpp b/lib/PgSQL_Session.cpp index f29c14a91..0b13b0d62 100644 --- a/lib/PgSQL_Session.cpp +++ b/lib/PgSQL_Session.cpp @@ -2156,7 +2156,14 @@ int PgSQL_Session::get_pkts_from_client(bool& wrong_pass, PtrSize_t& pkt) { } } if (mirror == false) { - handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY___create_mirror_session(); + if (qpo->mirror_hostgroup >= 0 || qpo->mirror_flagOUT >= 0) { + const char* query_text = CurrentQuery.get_digest_text(); + proxy_warning("ProxySQL does not currently support query mirroring for PostgreSQL. " + "The mirror flag(s) will be ignored, but other query rule conditions will still apply. " + "(mirror_hostgroup=%d, mirror_flagOUT=%d, query='%s')\n", + qpo->mirror_hostgroup, qpo->mirror_flagOUT, query_text ? query_text : ""); + } + //handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY___create_mirror_session(); } if (pgsql_thread___set_query_lock_on_hostgroup == 1) { // algorithm introduced in 2.0.6 diff --git a/lib/ProxySQL_Admin_Disk_Upgrade.cpp b/lib/ProxySQL_Admin_Disk_Upgrade.cpp index 6da7b8813..22036f229 100644 --- a/lib/ProxySQL_Admin_Disk_Upgrade.cpp +++ b/lib/ProxySQL_Admin_Disk_Upgrade.cpp @@ -608,3 +608,35 @@ void ProxySQL_Admin::disk_upgrade_rest_api_routes() { configdb->execute("PRAGMA foreign_keys = ON"); } + +void ProxySQL_Admin::disk_upgrade_pgsql_replication_hostgroups() { + configdb->execute("PRAGMA foreign_keys = OFF"); + + int rci = configdb->check_table_structure( + const_cast("pgsql_replication_hostgroups"), + const_cast(ADMIN_SQLITE_TABLE_PGSQL_REPLICATION_HOSTGROUPS_V3_0_1) + ); + + if (rci) { + // upgrade is required + proxy_warning("Detected version pre-3.0.2 of table 'pgsql_replication_hostgroups'\n"); + proxy_warning("ONLINE UPGRADE of table 'pgsql_replication_hostgroups' in progress\n"); + // drop any existing table with suffix _v301 + configdb->execute("DROP TABLE IF EXISTS pgsql_replication_hostgroups_v301"); + // rename current table to add suffix _v301 + configdb->execute("ALTER TABLE pgsql_replication_hostgroups RENAME TO pgsql_replication_hostgroups_v301"); + // create new table + configdb->build_table( + const_cast("pgsql_replication_hostgroups"), + const_cast(ADMIN_SQLITE_TABLE_PGSQL_REPLICATION_HOSTGROUPS), + false + ); + // copy fields from old table + configdb->execute( + "INSERT INTO pgsql_replication_hostgroups(writer_hostgroup, reader_hostgroup, check_type, comment)" + " SELECT writer_hostgroup, reader_hostgroup, 'read_only', comment FROM pgsql_replication_hostgroups_v301" + ); + } + + configdb->execute("PRAGMA foreign_keys = ON"); +} diff --git a/lib/ProxySQL_RESTAPI_Server.cpp b/lib/ProxySQL_RESTAPI_Server.cpp index 9aebb337f..d9a697977 100644 --- a/lib/ProxySQL_RESTAPI_Server.cpp +++ b/lib/ProxySQL_RESTAPI_Server.cpp @@ -306,15 +306,32 @@ public: } const std::shared_ptr render_POST(const http_request& req) { - std::string params=req.get_content(); - + std::string req_path = req.get_path(); + std::string req_body = req.get_content(); + std::string content_type = req.get_header(http::http_utils::http_header_content_type); + + // validate Context-Type header + // reject unsupported content types + if (!content_type.empty() && + content_type.find("application/json") == std::string::npos && + content_type.find("text/json") == std::string::npos && + content_type.find("text/plain") == std::string::npos) { #ifdef DEBUG - const char* req_path { req.get_path().c_str() }; - const char* p_params { params.c_str() }; - proxy_debug(PROXY_DEBUG_RESTAPI, 1, "Processing POST - req: '%s', params: `%s`\n", req_path, p_params); + proxy_debug(PROXY_DEBUG_RESTAPI, 1, "Rejected POST - req: '%s', content-type: '%s', req_body: `%s`\n", + req_path.c_str(), content_type.c_str(), req_body.c_str()); #endif + auto response = std::shared_ptr(new string_response( + "{\"error\": \"Unsupported Content-Type\"}", + http::http_utils::http_unsupported_media_type + )); + add_headers(response); + return response; + } - return process_request(req, params); +#ifdef DEBUG + proxy_debug(PROXY_DEBUG_RESTAPI, 1, "Processing POST - req: '%s', params: `%s`\n", req_path.c_str(), req_body.c_str()); +#endif + return process_request(req, req_body); } }; @@ -352,9 +369,15 @@ ProxySQL_RESTAPI_Server::ProxySQL_RESTAPI_Server( // in the current mode concurrency on serving requests is low, and throughput is directly related with // the time required to execute the target script, since each of the calls are blocking. #if defined(__FreeBSD__) || defined(__APPLE__) - ws = std::unique_ptr(new webserver(create_webserver(p).start_method(http::http_utils::start_method_T::THREAD_PER_CONNECTION))); + ws = std::unique_ptr(new webserver( + create_webserver(p) + .no_post_process() + .start_method(http::http_utils::start_method_T::THREAD_PER_CONNECTION) + )); #else - ws = std::unique_ptr(new webserver(create_webserver(p))); + ws = std::unique_ptr(new webserver( + create_webserver(p).no_post_process() + )); #endif // NOTE: Enable for benchmarking purposes. In this mode each request will be served by it's own thread. // ws = std::unique_ptr(new webserver(create_webserver(p).start_method(http::http_utils::start_method_T::THREAD_PER_CONNECTION))); @@ -392,4 +415,3 @@ void ProxySQL_RESTAPI_Server::init() { void ProxySQL_RESTAPI_Server::print_version() { fprintf(stderr,"Standard ProxySQL REST API Server Handler rev. %s -- %s -- %s\n", PROXYSQL_RESTAPI_SERVER_VERSION, __FILE__, __TIMESTAMP__); } - diff --git a/src/main.cpp b/src/main.cpp index 61c636aa0..0909dc8b1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1287,12 +1287,22 @@ void ProxySQL_Main_shutdown_all_modules() { std::cerr << "GloAdmin shutdown in "; #endif } + if (MyHGM) { cpu_timer t; MyHGM->shutdown(); delete MyHGM; #ifdef DEBUG - std::cerr << "GloHGM shutdown in "; + std::cerr << "GloMyHGM shutdown in "; +#endif + } + if (PgHGM) + { + cpu_timer t; + PgHGM->shutdown(); + delete PgHGM; +#ifdef DEBUG + std::cerr << "GloPgHGM shutdown in "; #endif } {