diff --git a/Makefile b/Makefile index fb0c3b2c1..23f948989 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,11 @@ DEBUG=${ALL_DEBUG} #export EXTRALINK CURVER=1.2.3 DISTRO := $(shell gawk -F= '/^NAME/{print $$2}' /etc/os-release) +ifeq ($(wildcard /usr/lib/systemd/systemd), /usr/lib/systemd/systemd) + SYSTEMD=1 +else + SYSTEMD=0 +endif .PHONY: default default: build_deps build_lib build_src @@ -354,8 +359,13 @@ cleanall: install: src/proxysql install -m 0755 src/proxysql /usr/local/bin install -m 0600 etc/proxysql.cnf /etc - install -m 0755 etc/init.d/proxysql /etc/init.d if [ ! -d /var/lib/proxysql ]; then mkdir /var/lib/proxysql ; fi +ifeq ($(SYSTEMD), 1) + install -m 0644 systemd/proxysql.service /usr/lib/systemd/system/ + systemctl daemon-reload + systemctl enable proxysql.service +else + install -m 0755 etc/init.d/proxysql /etc/init.d ifeq ($(DISTRO),"CentOS Linux") chkconfig --level 0123456 proxysql on else @@ -365,12 +375,17 @@ else update-rc.d proxysql defaults endif endif +endif .PHONY: install uninstall: rm /etc/proxysql.cnf rm /usr/local/bin/proxysql rmdir /var/lib/proxysql 2>/dev/null || true +ifeq ($(SYSTEMD), 1) + systemctl stop proxysql.service + rm /usr/lib/systemd/system/proxysql.service +else ifeq ($(DISTRO),"CentOS Linux") chkconfig --level 0123456 proxysql off rm /etc/init.d/proxysql @@ -383,4 +398,5 @@ else update-rc.d proxysql remove endif endif +endif .PHONY: uninstall diff --git a/doc/release_notes/ProxySQL_v1.2.3.md b/doc/release_notes/ProxySQL_v1.2.3.md new file mode 100644 index 000000000..cd1b9c213 --- /dev/null +++ b/doc/release_notes/ProxySQL_v1.2.3.md @@ -0,0 +1,37 @@ +# ProxySQL v1.2.3 + +Release date: 2016-09-20 + +## Performance improvement + +None + + +## Usability improvement + +* Admin: introduced new table `runtime_mysql_users` [#691](../../../../issues/691) +* Compile: new packages avaiable for Fedora24 +* Compile: new packages avaiable for Ubuntu16 +* Doc: updated documentation on passwords +* General: added suppot for systemd (yet not included in binaries) + + +## New features + +* Admin: introduced new variable `admin-hash_passwords` to automatically hash mysql passwords [#676](../../../../issues/676) +* Query Cache: aggressive memory purging when 90% of memory limit is reached [#690](../../../../issues/690) +* Query Processor: added parsing for several SQL commands + + +## Bug fixes + +* Mirroring: fixes several bugs related to errors handling +* Mirroring: fixes crashing bug +* Query Cache: memory used was computed incorrectly +* Connection Pool: a failed `CHANGE_USER` could cause a crash [#682](../../../../issues/682) + + +## Contributors + +Thanks to contributors, in alphabetical order: +* @dveeden diff --git a/include/proxysql.h b/include/proxysql.h index 3397ef58d..268337bc1 100644 --- a/include/proxysql.h +++ b/include/proxysql.h @@ -99,7 +99,7 @@ #else #define DEB "" #endif /* DEBUG */ -#define PROXYSQL_VERSION "1.2.3-RC" DEB +#define PROXYSQL_VERSION "1.2.3" DEB #define PROXYSQL_CODENAME "Truls" #ifndef PROXYSQL_FUNC_DEFS diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 375678747..53c2b6954 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -1583,8 +1583,16 @@ handler_again: case CONNECTING_SERVER: //fprintf(stderr,"CONNECTING_SERVER\n"); + if (mirror) { + mybe->server_myds->connect_retries_on_failure=0; // no try for mirror + mybe->server_myds->wait_until=thread->curtime+mysql_thread___connect_timeout_server*1000; + pause_until=0; + } if (mybe->server_myds->max_connect_time) { if (thread->curtime >= mybe->server_myds->max_connect_time) { + if (mirror) { + PROXY_TRACE(); + } char buf[256]; sprintf(buf,"Max connect timeout reached while reaching hostgroup %d after %llums", current_hostgroup, (thread->curtime - CurrentQuery.start_time)/1000 ); client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"#28000",buf); @@ -1600,6 +1608,10 @@ handler_again: if (mybe->server_myds->myconn) { //mybe->server_myds->destroy_MySQL_Connection(); mybe->server_myds->destroy_MySQL_Connection_From_Pool(false); + if (mirror) { + PROXY_TRACE(); + NEXT_IMMEDIATE(WAITING_CLIENT_DATA); + } } mybe->server_myds->max_connect_time=0; NEXT_IMMEDIATE(WAITING_CLIENT_DATA); @@ -1607,6 +1619,12 @@ handler_again: } if (mybe->server_myds->myconn==NULL) { handler___client_DSS_QUERY_SENT___server_DSS_NOT_INITIALIZED__get_connection(); + } + if (mybe->server_myds->myconn==NULL) { + if (mirror) { + PROXY_TRACE(); + NEXT_IMMEDIATE(WAITING_CLIENT_DATA); + } } if (mybe->server_myds->myconn==NULL) { pause_until=thread->curtime+mysql_thread___connect_retries_delay*1000; @@ -1633,10 +1651,16 @@ handler_again: /* */ assert(myconn->async_state_machine!=ASYNC_IDLE); rc=myconn->async_connect(myds->revents); + if (mirror) { + PROXY_TRACE(); + } if (myds->mypolls==NULL) { // connection yet not in mypolls myds->assign_fd_from_mysql_conn(); thread->mypolls.add(POLLIN|POLLOUT, mybe->server_myds->fd, mybe->server_myds, curtime); + if (mirror) { + PROXY_TRACE(); + } } switch (rc) { case 0: @@ -1660,6 +1684,9 @@ handler_again: if (myds->connect_retries_on_failure >0 ) { myds->connect_retries_on_failure--; //myds->destroy_MySQL_Connection(); + if (mirror) { + PROXY_TRACE(); + } myds->destroy_MySQL_Connection_From_Pool(false); NEXT_IMMEDIATE(CONNECTING_SERVER); } else { @@ -1682,6 +1709,9 @@ handler_again: previous_status.pop(); } //myds->destroy_MySQL_Connection(); + if (mirror) { + PROXY_TRACE(); + } myds->destroy_MySQL_Connection_From_Pool( myerr ? true : false ); myds->max_connect_time=0; NEXT_IMMEDIATE(WAITING_CLIENT_DATA); diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 198766370..6d924a924 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -4,6 +4,10 @@ #include "cpp.h" #include "MySQL_Thread.h" +#ifdef DEBUG +MySQL_Session *sess_stopat; +#endif + #define PROXYSQL_LISTEN_LEN 1024 extern Query_Processor *GloQPro; @@ -1984,6 +1988,11 @@ void MySQL_Thread::process_all_sessions() { } for (n=0; nlen; n++) { MySQL_Session *sess=(MySQL_Session *)mysql_sessions->index(n); +#ifdef DEBUG + if(sess==sess_stopat) { + sess_stopat=sess; + } +#endif if (sess->mirror==true) { // this is a mirror session if (sess->status==WAITING_CLIENT_DATA) { // the mirror session has completed unregister_session(n); diff --git a/systemd/proxysql.service b/systemd/proxysql.service new file mode 100644 index 000000000..7ea7df229 --- /dev/null +++ b/systemd/proxysql.service @@ -0,0 +1,12 @@ +[Unit] +Description=High Performance Advanced Proxy for MySQL +After=network.target + +[Service] +LimitNOFILE=102400 +LimitCORE=1073741824 +ExecStart=/usr/local/bin/proxysql -f +Restart=always + +[Install] +WantedBy=default.target