From a7c7b2320956dfea1d580f84877291014a7ae9f2 Mon Sep 17 00:00:00 2001 From: cjwright83 Date: Thu, 19 Apr 2018 12:54:45 +0100 Subject: [PATCH 01/11] amend to allow compilation to work on Darwin --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index c897b736a..1ba06c732 100644 --- a/src/Makefile +++ b/src/Makefile @@ -44,7 +44,7 @@ COREDUMPER_DIR=$(DEPS_PATH)/google-coredumper/google-coredumper COREDUMPER_IDIR=$(COREDUMPER_DIR)/src COREDUMPER_LDIR=$(COREDUMPER_DIR)/.libs -CURL_DIR=$(DEPS_PATH)/curl/curl/ +CURL_DIR=$(DEPS_PATH)/curl/curl CURL_IDIR=$(CURL_DIR)/include CURL_LDIR=$(CURL_DIR)/lib/.libs From f84bc09fc7d9397196158174f26e9eb90259a3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Minet?= Date: Tue, 24 Apr 2018 15:45:09 +0200 Subject: [PATCH 02/11] support load mysql_group_replication_hostgroups from the config file (#1050), sample config file update From e13ba850dd4063c3319796e7775dd16215e8033a Mon Sep 17 00:00:00 2001 From: Adam Stanton Date: Tue, 24 Apr 2018 16:08:30 -0700 Subject: [PATCH 03/11] Add variable client_multi_statements to address #1074 See comments in Github issue. Once applied, this change allows the user to toggle the 'client_multi_statements' flag as a global variable. From 0bafca7212178edc6fc42e4178a46d6d6ab07e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sat, 28 Apr 2018 10:47:33 +0200 Subject: [PATCH 04/11] Fix bug #1472 `enforce_autocommit_on_reads` should apply only when changing autocommit from 1 to 0 From f3feddb3020952a22219c0953d12fa2f35cef5a6 Mon Sep 17 00:00:00 2001 From: Hiroaki Nito Date: Tue, 8 May 2018 11:42:12 +0900 Subject: [PATCH 05/11] Prevent duplicate execution of proxysql_galera_checker.sh --- tools/proxysql_galera_checker.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/proxysql_galera_checker.sh b/tools/proxysql_galera_checker.sh index 198277ad8..6ecc01f89 100755 --- a/tools/proxysql_galera_checker.sh +++ b/tools/proxysql_galera_checker.sh @@ -49,6 +49,15 @@ WRITER_IS_READER="${4:-1}" ERR_FILE="${5:-/dev/null}" RELOAD_CHECK_FILE="/var/lib/proxysql/reload" +# Prevent duplicate execution +BASENAME=`basename "$0"` +pidof -x -o %PPID ${BASENAME} +ANOTHER_PROCESS_IS_RUNNING=$? +if [ ${ANOTHER_PROCESS_IS_RUNNING} -eq 0 ]; then + echo "`date` ###### Another process is already running. Abort! ######" >> ${ERR_FILE} + exit 0 +fi + echo "0" > ${RELOAD_CHECK_FILE} if [ "$1" = '-h' -o "$1" = '--help' -o -z "$1" ] From b99bee76b8dd77e367e5c7d0e155b98ba28e1fe0 Mon Sep 17 00:00:00 2001 From: Albert Vernon Date: Wed, 16 May 2018 15:30:22 -0400 Subject: [PATCH 06/11] Use correct package for g++ with RHEL and CentOS As of CentOS 7.4 and Fedora 28, the correct package name to install `g++` is `gcc-c++`. --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index e041f40f2..81133c3de 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -26,7 +26,7 @@ Make sure you have installed the equivalent for each of these packages for your Shortcut commands for installing pre-requisites: ``` # RHEL / CentOS Based: -yum install automake bzip2 cmake make g++ gcc git openssl openssl-devel patch +yum install automake bzip2 cmake make gcc-c++ gcc git openssl openssl-devel patch # Debian / Ubuntu Based: apt-get install automake bzip2 cmake make g++ gcc git openssl libssl-dev patch From 6707711cc8219d89c023c3dd8f8b98b4a28511b8 Mon Sep 17 00:00:00 2001 From: Albert Vernon Date: Wed, 16 May 2018 15:49:22 -0400 Subject: [PATCH 07/11] Grammar fix --- RUNNING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RUNNING.md b/RUNNING.md index 3dfdb098c..2c0008fd7 100644 --- a/RUNNING.md +++ b/RUNNING.md @@ -1,7 +1,7 @@ How to operate ProxySQL ======================= -First of all, ProxySQL is a daemon ran by an angel process. The angel process monitors the daemon and restarts it when it has crashed, in order to minimize downtime. The daemon accepts incoming traffic from MySQL clients and forwards it to backend MySQL servers. +First of all, ProxySQL is a daemon run by an angel process. The angel process monitors the daemon and restarts it when it has crashed, in order to minimize downtime. The daemon accepts incoming traffic from MySQL clients and forwards it to backend MySQL servers. The proxy is designed to run for as long as possible without needing to be restarted. Most configurations can be done at runtime, through a configuration system that responds to SQL-like queries (["admin interface"](https://github.com/sysown/proxysql/blob/master/doc/admin_tables.md)). Runtime parameters, server grouping and traffic-related settings can all be changed at runtime. @@ -54,4 +54,4 @@ Let us explain in more depth each individual option. * `-S, --admin-socket ARG`. Currently unused. * `-V, --version`. Print the current version of ProxySQL * `--initial`. Reset the admin database with the content from the configuration file. Refer to the [configuration system documentation](https://github.com/sysown/proxysql/blob/master/doc/configuration_system.md) for more information. -* `--reload`. Merge the configuration from the config file with the current runtime database. Refer to the [configuration system documentation](https://github.com/sysown/proxysql/blob/master/doc/configuration_system.md) for more information. \ No newline at end of file +* `--reload`. Merge the configuration from the config file with the current runtime database. Refer to the [configuration system documentation](https://github.com/sysown/proxysql/blob/master/doc/configuration_system.md) for more information. From 9081a8eb2a2bbdc6612ace047066871a2ae54106 Mon Sep 17 00:00:00 2001 From: Nick Vyzas Date: Thu, 17 May 2018 16:34:46 +0300 Subject: [PATCH 08/11] Added fix for mysqldump error in reported in https://github.com/sysown/proxysql/issues/1382 --- lib/ProxySQL_Admin.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 5bab6cd22..31b4994d1 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -2459,6 +2459,12 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) { run_query=false; goto __run_query; } + if (!strncmp("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'session_variables'", query_no_space, strlen("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'session_variables'"))) { + l_free(query_length,query); + query=l_strdup("SELECT 0 as 'COUNT(*)'"); + query_length=strlen(query)+1; + goto __run_query; + } if (!strncmp("SHOW VARIABLES LIKE 'gtid\\_mode'", query_no_space, strlen("SHOW VARIABLES LIKE 'gtid\\_mode'"))) { l_free(query_length,query); query=l_strdup("SELECT variable_name Variable_name, Variable_value Value FROM global_variables WHERE Variable_name='gtid_mode'"); From 6a20d84a2b4e62d115ed74463eca0c171e3dcb14 Mon Sep 17 00:00:00 2001 From: Albert Vernon Date: Thu, 17 May 2018 12:56:33 -0400 Subject: [PATCH 09/11] Split CentOS instructions between older and newer --- INSTALL.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 81133c3de..3d22f5ce1 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -25,7 +25,10 @@ Make sure you have installed the equivalent for each of these packages for your Shortcut commands for installing pre-requisites: ``` -# RHEL / CentOS Based: +# RHEL / CentOS < 7: +yum install automake bzip2 cmake make g++ gcc git openssl openssl-devel patch + +# CentOS 7.4+ / Fedora 28+: yum install automake bzip2 cmake make gcc-c++ gcc git openssl openssl-devel patch # Debian / Ubuntu Based: From df553136e335ab318dd4693ce7c62fc2268a4f53 Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Mon, 21 May 2018 18:12:09 +0200 Subject: [PATCH 10/11] Thread: Set m_running to 0 on successful join --- lib/thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/thread.cpp b/lib/thread.cpp index af355524a..8587a98bc 100644 --- a/lib/thread.cpp +++ b/lib/thread.cpp @@ -63,7 +63,7 @@ int Thread::join() if (m_running == 1) { result = pthread_join(m_tid, NULL); if (result == 0) { - m_detached = 0; + m_running = 0; } } return result; From 553544d412b0fab4dcc156ae8f5237b2b553aac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Wed, 23 May 2018 06:48:05 +0200 Subject: [PATCH 11/11] Better handling of SET statements from mysqldump --- lib/MySQL_Session.cpp | 63 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 5ad8761bc..45cc8a923 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -3804,6 +3804,9 @@ bool MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C if (rc && ( i==0 || i==1) ) { //fprintf(stderr,"sql_log_bin=%d\n", i); client_myds->myconn->options.sql_log_bin=i; +#ifdef DEBUG + proxy_info("Setting SQL_LOG_BIN to %d\n", i); +#endif if (command_type == _MYSQL_COM_QUERY) { client_myds->DSS=STATE_QUERY_SENT_NET; uint16_t setStatus = (nTrx ? SERVER_STATUS_IN_TRANS : 0 ); @@ -3816,8 +3819,23 @@ bool MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C return true; } } else { - proxy_error("Unable to parse query. If correct, report it as a bug: %s\n", nq.c_str()); - return false; + int kq = 0; + kq = strncmp((const char *)CurrentQuery.QueryPointer, (const char *)"SET @@SESSION.SQL_LOG_BIN = @MYSQLDUMP_TEMP_LOG_BIN;" , CurrentQuery.QueryLength); + if (kq == 0) { + client_myds->DSS=STATE_QUERY_SENT_NET; + uint16_t setStatus = (nTrx ? SERVER_STATUS_IN_TRANS : 0 ); + if (autocommit) setStatus= SERVER_STATUS_AUTOCOMMIT; + client_myds->myprot.generate_pkt_OK(true,NULL,NULL,1,0,0,setStatus,0,NULL); + client_myds->DSS=STATE_SLEEP; + status=WAITING_CLIENT_DATA; + l_free(pkt->size,pkt->ptr); + RequestEnd(NULL); + return true; + } else { + string nqn = string((char *)CurrentQuery.QueryPointer,CurrentQuery.QueryLength); + proxy_error("Unable to parse query. If correct, report it as a bug: %s\n", nqn.c_str()); + return false; + } } } if (match_regexes && match_regexes[1]->match(dig)) { @@ -3970,8 +3988,23 @@ bool MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C return true; } } else { - proxy_error("Unable to parse query. If correct, report it as a bug: %s\n", nq.c_str()); - return false; + int kq = 0; + kq = strncmp((const char *)CurrentQuery.QueryPointer, (const char *)"/*!40101 SET SQL_MODE=@OLD_SQL_MODE */" , CurrentQuery.QueryLength); + if (kq == 0) { + client_myds->DSS=STATE_QUERY_SENT_NET; + uint16_t setStatus = (nTrx ? SERVER_STATUS_IN_TRANS : 0 ); + if (autocommit) setStatus= SERVER_STATUS_AUTOCOMMIT; + client_myds->myprot.generate_pkt_OK(true,NULL,NULL,1,0,0,setStatus,0,NULL); + client_myds->DSS=STATE_SLEEP; + status=WAITING_CLIENT_DATA; + l_free(pkt->size,pkt->ptr); + RequestEnd(NULL); + return true; + } else { + string nqn = string((char *)CurrentQuery.QueryPointer,CurrentQuery.QueryLength); + proxy_error("Unable to parse query. If correct, report it as a bug: %s\n", nqn.c_str()); + return false; + } } } } @@ -3988,6 +4021,9 @@ bool MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C delete opt2; if (rc) { //fprintf(stderr,"time_zone='%s'\n", s.c_str()); +#ifdef DEBUG + proxy_info("Setting TIME_ZONE to %s\n", s.c_str()); +#endif uint32_t time_zone_int=SpookyHash::Hash32(s.c_str(),s.length(),10); if (client_myds->myconn->options.time_zone_int != time_zone_int) { //fprintf(stderr,"time_zone_int='%u'\n", time_zone_int); @@ -4009,8 +4045,23 @@ bool MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C return true; } } else { - proxy_error("Unable to parse query. If correct, report it as a bug: %s\n", nq.c_str()); - return false; + int kq = 0; + kq = strncmp((const char *)CurrentQuery.QueryPointer, (const char *)"/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */" , CurrentQuery.QueryLength); + if (kq == 0) { + client_myds->DSS=STATE_QUERY_SENT_NET; + uint16_t setStatus = (nTrx ? SERVER_STATUS_IN_TRANS : 0 ); + if (autocommit) setStatus += SERVER_STATUS_AUTOCOMMIT; + client_myds->myprot.generate_pkt_OK(true,NULL,NULL,1,0,0,setStatus,0,NULL); + client_myds->DSS=STATE_SLEEP; + status=WAITING_CLIENT_DATA; + l_free(pkt->size,pkt->ptr); + RequestEnd(NULL); + return true; + } else { + string nqn = string((char *)CurrentQuery.QueryPointer,CurrentQuery.QueryLength); + proxy_error("Unable to parse query. If correct, report it as a bug: %s\n", nqn.c_str()); + return false; + } } } }