Added function MySQL_Session::detected_broken_connection() that unifies the way broken connections are logged.
It also logs username, and last time used.
Added also a new macro proxy_error_inline()
When a cluster node (client) connects to another cluster node, it
advertises its UUID but also exports its `admin-mysql_ifaces` .
The receiving cluster can use this information to try to guess how
to connect to the node that initialized the connection, for example
to collect metrics.
This is visible in table `stats_proxysql_servers_clients_status` .
HostGroups are stored in an array of pointers.
This commit allows the lookup using an unordered_map if the number of
Hostgroups is greater than 100.
For less number of hostgroups, a sequential scan seems more efficient.
This also introduce a test for micro benchmark.
This commit rewrites MySQL_HostGroups_Manager::read_only_action() in way to
reduce the calls to SQLite. It relies on two new std::set() :
- read_only_set1: if the server is already in a writer hostgroup
- read_only_set2: a cache to track the first time that a server has RO=0
Added also an index on MySQL_HostGroups_Manager,
ON mysql_servers (hostname,port)
ProxySQL will now automatically generate a UUID during start up.
The UUID can be either passed through the command line using -U or --uuid,
or saved on disk in a new table named global_settings.
The new table is used to distinguish it from global_variables that is replicated.
Table global_settings isn't replicated by Cluster.
If UUID is not present, it is automatically generated and saved.
`generate_pkt_field2` is a less generic version of `generate_pkt_field`
and it is meant to be used only for queries executed on backend.
The function takes a `MYSQL_FIELD` as one of its arguments, thus a lot of
lengths do not need to be computed
* MySQL_ResultSet() stores a pointer to the PS
* MySQL_ResultSet::init_with_stmt() doesn't need anymore the pointer to the PS
Furthermore, it isn't anymore an "init" but an end (we will rename it)
* Added MySQL_ResultSet::add_row(MYSQL_ROWS *rows) for PS only
* MySQL_Protocol::generate_pkt_row3() accepts an optional row length.
If passed, it will know the length of the row without computing it
* MyRS initialized during ASYNC_STMT_EXECUTE_STORE_RESULT_START
* Implemented throttling during ASYNC_STMT_EXECUTE_STORE_RESULT_START
* MySQL_Connection::process_rows_in_ASYNC_STMT_EXECUTE_STORE_RESULT_CONT() always
generates a heartbeat. For now unnecessary, and we will better tune it later
* test_ps_async-t.cpp tunes mysql-threshold_resultset_size to trigger buffering
More testing is required
This new function is meant to split MySQL_ResultSet::init() to later
remove all code specific to prepared statements because it assumes
it is pre-buffered
Few special queries are handled separately in ProxySQL
1. select @@version_comment limit 1
2. SHOW WARNINGS
3. SELECT USER()
4. PROXYSQL INTERNAL SESSION
5. SELECT LAST_INSERT_ID()
6. SELECT CONNECTION_ID()
7. C code mysql_set_server_option(mysql, MYSQL_OPTION_MULTI_STATEMENTS_ON)
We now remove EOF1 for these and respond with OK packets intead of EOF2
When CLIENT_DEPRECATE_EOF flag is supported by client, the first EOF
packet after Metadata is not sent anymore. The EOF packet after each
ResultSet is replaced by an OK packet.
Signed-off-by: Bibek Shrestha <bibekshrestha@gmail.com>
* Added forgotten metric increase in case of 'sync conflict' on proxysql_servers
* Added support for 'global_variables' sync in proxysql_cluster
- Added several for getting the peers to be sync.
- Added function to pull the target 'global_variables' to sync.
- Added metrics for 'global_variables' sync:
+ Number of syncs done / failed.
+ Sync conflicts.
+ Sync warnings.
* Removed unnecesary escaping for '%' char
* Fixed issue due to 'flush_mysql_variables___runtime_to_database' being called without proper locking
* Added simple helper function to get the output from a command execution
* Multiple changes to 'cluster_synct' test
+ Spawned proxysql instance now runs inside a docker container.
+ Simplified launching and logging of spawned proxysql instance.
+ Added more verbose logging about the tables state.
+ Added new tests for 'global_variables' synchronization.
* Commented several variables known to not-sync and fixed port for replica 'proxysql_server'
* Removed deprecated and non-syncable variables from 'test_cluster_sync-t'
* Added extra logging for variables sync for 'test_cluster_sync-t'
- Labelling has been simplified to group metrics which
are part of a common group.
- Help has been fixed to reflect this labelling change.
- Doxygen doc and comment marks has been added to signal
metrics grouping.
This commit also add support for including more gauge metrics based on
'MySQL_Thread_status_variables', using the same approach previously used
for the 'counter' metrics.
- Metrics now follow prometheus base unit convention.
- Many metrics now make use of labels instead of enconding
the info in the metric name.
- Almost all metrics now have a meaningful 'help' message.
Former max_transaction_time is now renamed to max_transaction_idle_time.
mysql-max_transaction_idle_time defines the maximum time a transaction can stay idle.
mysql-max_transaction_time defines the maximum time of a transaction since its start.
In handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY_qpo()
Changing the default of exit_after_SetParse from false to true.
If a variable isn't parsed or it needs to be forwarded, exit_after_SetParse is set to false
Renamed variable mysql-monitor_replication_lag_retries to mysql-monitor_replication_lag_count to match other variables naming convention.
As it is a counter, it minimum value is changed to 1.
Maximum value sets to 10.
Use of thread storage variable mysql_thread___monitor_replication_lag_count instead of GloMTH->variables.monitor_replication_lag_retries to avoid dirty reads .
Changing the mapping logic in SESSION_TRACK_GTIDS in frontend and backend connections.
Up to now, frontend and backend `SESSION_TRACK_GTIDSs match.
This is now changed:
* backend connections are by default set to `mysql-default_session_track_gtids`
* if `mysql-default_session_track_gtids=OFF` (the default) , `session_track_gtids` is not changed on backend
* if the client asks for `session_track_gtids=OFF` , proxysql ignores it (it just acknowledge it)
* if the client asks for `session_track_gtids=OWN_GTID` , proxysql will apply it
* if the client asks for `session_track_gtids=ALL_GTIDS` , proxysql will switch to OWN_GTID and generate a warning
* if the backend doesn't support `session_track_gtids` (for example in MySQL 5.5 and MySQL 5.6), proxysql won't apply it. It knows checking server capabilities
This commit also deprecates function `MySQL_Session::handler_again___verify_backend__generic_variable()`
ProxySQL is now also able to know when proxysql binlog reader is perhaps in use tracking all gtid_port in mysql_servers.
This feature in future will be used to deprecate `mysql-default_session_track_gtids`
Extended `mysql_variable_st` to add a new variable `is_global_variable`.
Using this variable we define the global variables.
Modified `mysql_tracked_variables[]` to also specify `is_global_variable`.
Removed `default_charset` from `MySQL_Threads_Handler::variables` to use `mysql_tracked_variables[]` instead.
Removed `default_charset` also from `mysql_thread_variables_names[]`.
Fixed `MySQL_Threads_Handler::get_variable_string()` : it was *not* returning `mysql-default_` variables.
`MySQL_Threads_Handler::set_variable()` adds `mysql-default_` variables only if `is_global_variable` is set.
In `MySQL_Threads_Handler::set_variable()` replaced a `strcasecmp()` with `strcmp()` for `mysql-default_` variables.
`MySQL_Threads_Handler::get_variables_list()` returns only `mysql-default_` variables with `is_global_variable` enabled.
`MySQL_Threads_Handler::has_variable()` for `mysql-default_` variables returns true only if variable has `is_global_variable` enabled.
`MySQL_Thread::refresh_variables()` does not refresh `mysql-default_` variables if `is_global_variable` is not enabled.
`MySQL_Thread::MySQL_Thread()` initializes to NULL all `mysql_thread___default_variables[]` variables.
Completely disabled in `ProxySQL_Admin::flush_mysql_variables___database_to_runtime()` the logic applied to all charset variables.
In the same methos was implemented the logic described in #1785 :
`mysql-default_charset` and `mysql-default_collation_connection` must be compatible:
* if only one is present, the other is configured automatically
* if not compatible, `mysql-default_charset` is configured from `mysql-default_collation_connection`
- Added extra doc about the 'status_flags' and 'server_status'.
- Added 'sql_log_bin0' and 'prepared_statement' to the 'conn.status'
from PROXYSQL SESSION INFO.
- When configuration rules specify NOT to save the config to disk.
- When synchronization isn't going to happen because both servers
hold the same epoch values for two configurations with different
checksums.
This commit prepares proxysql for further development related to SQLite3.
Specifically, it allows to either use built-in SQLite3 library, or to load it from a plugin.
- Implements synchronization for the mentioned tables.
- Creates new version of 'proxy_info' that accepts a 'const char*'
as a parameter, instead of a 'string literal'.
Added admin variables:
* cluster_mysql_variables_save_to_disk
* cluster_admin_variables_save_to_disk
* cluster_mysql_variables_diffs_before_sync
* cluster_admin_variables_diffs_before_sync
When flush_admin_variables___database_to_runtime() is executed, flush_admin_variables___runtime_to_database() is also called to update admin variable checksum.
When flush_mysql_variables___database_to_runtime() is executed, flush_mysql_variables___runtime_to_database() is also called to update mysql variable checksum.
flush_mysql_variables___runtime_to_database() was also modified to avoid locking twice.
Adding the following methods:
* handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_STMT_RESET()
* handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_STMT_CLOSE()
* handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_STMT_SEND_LONG_DATA()
The two main blocks are:
* get_pkts_from_client() : handling the main loop around label __get_pkts_from_client
* handler() : handling the main loop around label handler_again
First commit to simplify MySQL_Session::handler()
It handles the following statuses:
* CHANGING_USER_SERVER
* CHANGING_AUTOCOMMIT
* SETTING_MULTI_STMT
* SETTING_SESSION_TRACK_GTIDS
* SETTING_SET_NAMES
From 1.3.0 till 2.0.x , when COM_STMT_PREPARE is executed and Query Processor is executed, metadata are stored in MySQL_STMT_Global_info().
These metadata include routing information.
Is a prepared statement is prepared on a specific hostgroup, it will always be executed on the same hostgroup.
This causes negative consequences, like the one reported in issue #2691 .
This commit:
* remove hostgroup_id from MySQL_STMT_Global_info() and other metadata
* Query Processor is called also during COM_STMT_EXECUTE
* removes hostgroup from table stats_mysql_prepared_statements_info
* Query Processor do not perform any query rewrite ruding COM_STMT_EXECUTE
- Added new helper function to simplify ''prometheus::counters' update
and removed code duplication using it.
- 'hostgroup_manager' now exposes the same method 'p_update_metrics' as
the other modules.
- GCC 4.8 and 5 have issues with uniform initialization syntax, for
this reason, all it's uses have been replaced with assignements.
- Per-module metrics initialization functions are no longer required,
they have been replaced with the new generic ones.
* removed 14 statuses
* configured the MySQL_Session status to SETTING_VARIABLE for 14 session variables
* extended MySQL_Session to introduce a new variable that tracks the session variable to change
* MySQL_Threads_Handler::SQL3_Processlist() can handle all variables
* removed unnecessary loops
* improved performance removing unnecessary function calls
Added new array mysql_tracked_variables[] that defines the tracked variables.
Ideally, tracking a new session variable will requires adding only a couple of lines of code.
Removed session variables from mysql_thread_variables_names:
- now both MySQL_Threads_Handler::get_variables_list() and MySQL_Threads_Handler::has_variable() rely on mysql_tracked_variables[]
Simplified MySQL_Variables, as it now also uses mysql_tracked_variables[] .
Simplify parser in MySQL_Session
Generalized code to handle two variables together:
- sql_auto_is_null
- sql_safe_updates
Migrating more session variables to new algorithm
- collation_connection
- net_write_timeout
- max_join_size
Migrating more session variables to new algorithm
- collation_connection
- net_write_timeout
- max_join_size
Added new array mysql_tracked_variables[] that defines the tracked variables.
Ideally, tracking a new session variable will requires adding only a couple of lines of code.
Removed session variables from mysql_thread_variables_names:
- now both MySQL_Threads_Handler::get_variables_list() and MySQL_Threads_Handler::has_variable() rely on mysql_tracked_variables[]
Simplified MySQL_Variables, as it now also uses mysql_tracked_variables[] .
Simplify parser in MySQL_Session
Generalized code to handle two variables together:
- sql_auto_is_null
- sql_safe_updates
Migrating more session variables to new algorithm
- collation_connection
- net_write_timeout
- max_join_size
Migrating more session variables to new algorithm
- collation_connection
- net_write_timeout
- max_join_size