Initial support for `SET SESSION TRANSACTION READ ONLY` or `READ WRITE`.
Extended `SET` parser to support also `SET SESSION TRANSACTION`.
Hostgroup Manager doesn't kill backend connections in case of error 1231.
`autocommit` is set at session level but also on MySQL client connection.
Added several debugging entries.
Several `handler_again___verify_backend_*` functions are disabled if `locked_on_hostgroup` is enabled.
Issue #2120 : Send SESSION_TRACK_GTIDS to client
Issue #2121 : Track CLIENT_FOUND_ROWS required by the client
Issue #2125 : Track CLIENT_MULTI_STATEMENTS required by the client
In `stats_mysql_free_connections`, exported:
* address of connection
* address of mysql struct
* mysql thread_id
In `stats_mysql_processlist`, exported:
* address of session
* address of data stream
* address of connection
* address of mysql struct
* mysql thread_id
* removed password from non-debug built
- generate_mysql_servers_table() is now less verbose
- update_galera_set_writer() is protected by a mutex
- update_galera_set_writer() set status to online
- fixed wording in monitor_galera_thread()
- corrected the computing of consecutive timeout in monitor_galera_thread()
aws_aurora_replicas_skipped_during_query is a status variable for better
monitoring behavior due to replication lag in AWS Aurora
Also fixed lag computing in connection pool
When shunning a node, evaluate the different between
`mysql-monitor_ping_interval` and `mysql-shun_recovery_time_sec`, and postpone
in the future when the server needs to be recovered
This functionality is enabled for:
- mysql_galera_hostgroups
- mysql_group_replication_hostgroups
If writer_is_also_reader=2 and there are servers in
backup_writer_hostgroup, only these servers will be used
in reader_hostgroup
Galera checks may first detect the status of a node and then decide if an action is needed.
This commit reduces the amount of messages logged in error log is no action will be performed.
This is to prevent cases in which only one node is left, but from its status it should be offline.
ProxySQL would normally set it offline and then back online.
This commit prevents it to change status twice.
The same applies also for:
- runtime_mysql_replication_hostgroups
- runtime_mysql_group_replication_hostgroups
- runtime_mysql_galera_hostgroups
Close#1435 and #1436
This commit also prevents shunned nodes to come back online if they are missing pings. Related to #1416
Because it reduces the number of checks, it may also be relevant to #1417
* is STMT_PREPARE failed when there is a previous status (maybe STMT_EXECUTE) disconnect the client immediately. Maybe this is related to #1366 , but I can't reproduce it yet
* purge prepared statements is also their server reference counter is 0
* initialize connections queue for purging connections
Statistics collected aboout GTID queries
Statistics displayed on HTTP server
Count number of GTID events per server
Online upgrade of all mysql_connections tables
Fixed path for libev
Handling of prepared statements changed a lot in 1.4 , as a lot of code was rewritten.
Old code was still present, and was possible to toggle it on and off based on PROXYSQL_STMT_V14 .
Because only the new code is maintained, all references to old code are now removed,
including PROXYSQL_STMT_V14
This commits adds a new variable: mysql-monitor_replication_lag_use_percona_heartbeat
This variable defines the percona heartbeat table used to check replication lag.
If set, replication lag is checked against the defined table, otherwise `SHOW SLAVE STATUS` is used.
To be set, the value should match the following regex:
```
`?([a-z\d_]+)`?\.`?([a-z\d_]+)`?
```
Variable name is `mysql-throttle_connections_per_sec_to_hostgroup` .
Curently it is a global variable and limits the number of new connections per
hostgroup, and not per specific node.
For example, if mysql-throttle_connections_per_sec_to_hostgroup=100, no more
than 100 new connections can be created on any hostgroup no matter the number
of servers in that hostgroup.
The default is very high (1000000) thus not changing default behaviour.
Tuning this variable allows to control and throttle connections spikes to the
backend servers.
Added also new status variable `Server_Connections_delayed`.
This is a counter of how many times Hostgroup Manager didn't return a
connection because the limit was reached. It is worth to note that a single
client request could make multiple requests, therefore this variable counts
the number of time a new connection wasn't created and not how many requests
were delayed.
If a user is configured with fast_forward, no connection should be taken from the connection pool.
Yet the Hostgroup Manager should know about such connection.
In `MySQL_Cluster` class added functions to sync with remote node, like:
- `pull_mysql_query_rules_from_peer()`
- `pull_mysql_servers_from_peer()`
- `pull_mysql_users_from_peer()`
- `pull_proxysql_servers_from_peer()`
Added 8 new global variables in Admin.
4 variables determine after how many different checks the remote configuration will be synced:
- cluster_mysql_query_rules_diffs_before_sync
- cluster_mysql_servers_diffs_before_sync
- cluster_mysql_users_diffs_before_sync
- cluster_proxysql_servers_diffs_before_sync
4 variables determine if after a remote sync the changes need to be written to disk:
- cluster_mysql_query_rules_save_to_disk
- cluster_mysql_servers_save_to_disk
- cluster_mysql_users_save_to_disk
- cluster_proxysql_servers_save_to_disk
Table `proxysql_servers` is now automatically loaded from disk to memory and into runtime at startup.
Added new Admin's command `LOAD PROXYSQL SERVERS FROM CONFIG` to load `proxysql_servers` from config file to memory (not runtime).
Internal structures with credentials in MySQL_Authentication moved from `unsorted_map` to `map` : this to ensure the right order when generating the checksum.
Config file supports both `address` and `hostname` for `mysql_servers` and `proxysql_servers` , #1091
`ProxySQL_Admin::load_proxysql_servers_to_runtime()` now has a lock or no lock option, to avoid deadlock
For now, Cluster module is quite verbose.
Extended class ProxySQL_Checksum_Value() in ProxySQL_Cluster module to support further metrics
Implemeted `SELECT GLOBAL_CHECKSUM()` and relative tracking of global checksums
Added variable `admin-cluster_check_status_frequency` to check peer's global status at regular intervals
This commit introduces:
2 new tables:
* `runtime_checksums_values` : stores checksums of configurations in runtime. For now for `mysql_query_rules`, `mysql_servers` and `mysql_users`
* `stats_proxysql_servers_checksums` : when clustering is enabled, it collects all metrics from `runtime_checksums_values` from all its peers
3 new global variables that defines it checksum needs to be generated during `LOAD ... TO RUNTIME`
* `admin-checksum_mysql_query_rules`
* `admin-checksum_mysql_servers`
* `admin-checksum_mysql_users`
ProxySQL Cluster connections now have timeouts:
* 1 second timeout for CONNECT and WRITE
* 60 seconds timeout for READ (useful for long poll)
Status of the server was not changed if:
* was OFFLINE_HARD
* was incorrectly present in myhgm.mysql_servers
Added also a mutex to serialize the read_only actions
If total mysql_servers.weight per hostgroup was higher than 64K, traffic was unbalanced
Conflicts:
include/gen_utils.h
lib/MySQL_HostGroups_Manager.cpp
Enforced max_writers
Enforced writer_is_also_reader
Increased the number of entries in mysql_server_group_replication_log to 100 per node
Lowered the minimum value for mysql-monitor_groupreplication_healthcheck_interval to 50ms
Lowered the minimum value for mysql-monitor_groupreplication_healthcheck_timeout to 50ms
Introduced a timeout in HGCU_thread_run()
Fixed a logical bug in MySQL_Protocol::process_pkt_COM_CHANGE_USER() that was causing to not authenticate user
The absence of the timeout and the logicl bug was causing a lot of connections to be dropped and not really reused.
But as now the connections are reused, they may present further bugs
* reduce build time by 25%;
* remove circular dependency on `cpp.h` and other headers.
* fixes issue with `my_global.h` from mariadbclient which
redefines `__attribute__`, that leads to broken STL and GCC
intrinsics if `<algorithm>` wasn't included prior including this header;
* fixes another issue with redefined `__attribute__` which leads to
`_conn_exchange_t` not being aligned to cache line size;
* removes `pthread_setstacksize` calls as `my_global.h` redefines `pthread_setstacksize`
to be `pthread_dummy(0)` which led to stack size being never adjusted;
* add missing include guards to some headers;
* remove unused proxysql_hash.h header.
A further optimization in `MySQL_HostGroups_Manager::generate_mysql_servers_table()` makes `LOAD MYSQL SERVERS TO RUNTIME` around 35 times faster than original implementation.
`SAVE MYSQL SERVERS TO MEMORY` is now over 10 times faster than the original implementation.
This commit is able to speed up LOAD MYSQL SERVERS TO RUNTIME up to 10x for very large mysql_servers table with tens of thousands of servers.
Main improvements:
* removed 1 unnecessary call to `generate_mysql_servers_table()`
* replaced 1 call to `generate_mysql_servers_table()` with UPDATE statements when necessary
* implemented new function `servers_add()` that replaces `server_add()` to perform bulk operation
* replaced calls to `sqlite3_exec()` with proper parameters bindings
* use of multirows INSERT statements (32 rows at the time)
Miror improvements:
* added new variable mysql-hostgroup_manager_verbose , 1 by default for backward compatibility and debugging
* in not debug mode, access to HGM db has no shared cache
* in not debug mode, tables in HGM have checks disabled
Further note:
* Once issue #797 is completed, `mysql_servers` in MyHGM can be simplified further
If MHM_PTHREAD_MUTEX is defined MySQL_HostGroups_Manager.h ,
MySQL_HostGroups_Manager() is compiled using pthread mutex instead od spin loop.
As a lot of computation is protected by mutex, maybe it is better not to use spin loop.
Added:
* mysql_query_rules.comment VARCHAR
* mysql_replication_hostgroups.comment VARCHAR
* mysql_servers.comment VARCHAR NOT NULL DEFAULT ''
All these tables support online upgrade from previous version (without such fields) at startup.
Introduced also a parser for escaping strings with single quotes: double quotes are allowed without extra escaping
If status=4 , MySQL_HostGroups_Manager::dump_table_mysql_servers() should return SHUNNED
Previous nothing was returned for status=4 (MYSQL_SERVER_STATUS_SHUNNED_REPLICATION_LAG) , caausing the crashing bug #619
dump_table_mysql_servers()
These two new columns will be used to:
- enable SSL on a per server basis
- define maximum latency for a server to be consider usable: this will be a key element for multi DC support
When a server isn't responding to ping, it is flagged as shunned and all the connections need to be dropped.
All the connections must be dropped before the server is brought back online
In order to understand the performance improvement related to how ProxySQL filters autocommit/commit/rollback, the follows variables were added in GLOBAL MYSQL STATUS
- Com_autocommit
- Com_autocommit_filtered
- Com_commit
- Com_commit_filtered
- Com_rollback
- Com_rollback_filtered
class MySQL_HostGroups_Manager() has now also access to admindb
added function MySQL_HostGroups_Manager::purge_mysql_servers_table() to remove entries from mysql_servers table from within MyHGM
purge_mysql_servers_table() and generate_mysql_servers_table() are called in multiple part of the code to get consistent view of mysql backends
added function MySQL_HostGroups_Manager::read_only_action(char*,int,int) responsible for triggering a traffic switch
Added status MYSQL_SERVER_STATUS_SHUNNED_REPLICATION_LAG as internal only (not configurable)
Added MySQL_HostGroups_Manager::replication_lag_action() to communicate replication lag to connection pool and take action
Status variables implemented so far:
- Client_Connections_aborted
- Client_Connections_connected
- Client_Connections_created
- Questions
- Slow_queries
Also created alias command SHOW MYSQL STATUS
If the number of free connections is greater than free_connections_pct percentage of max_connections for that specific host,
all connections idle for longer than ping_interval_server are closed instead of sending PING
Issues #215 , #216 and #217
215 : Connection pool should not return connections if server status is not ONLINE
216 : Connection pool should return connections based on weight
217 : Crash if no backend
Implemented functions:
- MySQL_HostGroups_Manager::dump_table_mysql_servers()
- MySQL_HostGroups_Manager::generate_mysql_servers_table()
- Standard_ProxySQL_Admin::save_mysql_servers_runtime_to_database() (issue #17)
Improved Standard_ProxySQL_Admin::load_mysql_servers_to_runtime() to process also status
Improved MySQL_HostGroups_Manager::commit() to modified MySrvCs
Database in MyHGM is accessible via Admin (issue #212)
Enforced debugging if specified at the command line (issue #213)
Developed class StatCounters to keep time series counters
Added 2 new instances of StatCounters:
- MySQL_Session::command_counters;
- ProxySQL_Poll::loop_counters;
Counters are dispayed in "dbg thread status"
Defined new variables mysql-connect_timeout_server_error and mysql-connect_timeout_server (issue #202 and #203) .
They are defined but not implemented yet.
Fixed two crashing bug when "gdb command" was trying to access:
- its own Query_Info if this one was not initialized
- Query_Info of another thread if this one was not initialized
Introduced new variable ProxySQL_Poll:poll_timeout that Session can overwrite to apply a timeout different than mysql_thread___poll_timeout
Added variable MySQL_Connection::last_time_used , updated at creation time and when calling push_MyConn_to_pool().
for each Connection add a "last_time_used"
Added function get_multiple_idle_connections()
Implementing Standard_MySQL_Threads_Handler::connection_manager_thread() , but doesn't seems to be a good idea
====
New attempt for connection handling
MySQL_Session has a new bool variable : connections_handler
Standard_MySQL_Thread has a new variable PtrArray : mysql_sessions_connections_handler
Added new function Standard_MySQL_Thread::register_session_connection_handler
SESSIONS_FOR_CONNECTIONS_HANDLER sessions are created in Standard_MySQL_Thread::init()
Added new function Standard_MySQL_Thread::process_all_sessions_connections_handler()
New variables in Standard_MySQL_Thread:
MySQL_Connection **my_idle_conns;
bool processing_idles;
unsigned long long last_processing_idles;
Added DSS STATE_PING_SENT
MySQL_Session::handler___status_WAITING_SERVER_DATA___STATE_PING_SENT
In MySQL_HostGroups_Manager:
- added function add() for MySrvC
- fixed few typos : poll => pool
- added locking in several functions
First cleanup of MySQL_Hostgroup_Entry
In MySQL_Protocol:
- added variable prot_status
- added variable fd
- added function process_pkt_EOF()
- variable parent is a MySrvC *
- extended functions pkt_ok() , pkt_end() and pkt_handshake_server() to update prot_status
- added function process_pkt_EOF()
- fixed warns to be uint16_t instead of uint64_t
In MySQL_Data_Stream:
- fixed bug on read_from_net()
- added function unplug_backend()
In MySQL_Session:
- attempting multiplexing if the connection has no active transactions and in case of SELECT statements
- destination_hostgroup returned in qpo is applied
MySQL_HostGroups_Manager merges the best of:
- MySQL_HostGroups_Handler
- MySQL_Connection_Pool
Still in development: will be shadowing the original Handler and ConnPool