Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.x session track system variables v2 #4164

Open
wants to merge 22 commits into
base: v2.x
Choose a base branch
from

Conversation

javsanpar
Copy link
Contributor

Related to #4141

Add hash map with system variables names and idx.

Call handler_rc0_Process_Session_Track() everytime
async_send_simple_command() finish.

Use strncasecmp to avoid out-of-bounds reads.
Also, move the comparison logic to its own function.
…variables

Add tracking for 2 new variables: session_track_state_change and
session_track_system_variables. If a client tries to set these variables
explicitly, the request from the client will be ignored.

Also, add a new ProxySQL MySQL variable
(mysql-enable_session_state_trackers) that, if enabled, the 2 MySQL
variables will be automatically set into each MySQL client connection.
ProxySQL will try to set these variables on backend connections and will
track if the SET on backend failed or succeeded.
Move it from MySQL_Session::handler() to
MySQL_Thread::create_new_session_and_client_data_stream().

This way, we ensure the code is always executed when a client connects
to ProxySQL.
MySQL_Thread::create_new_session_and_client_data_stream() to
MySQL_Session::get_pkts_from_client().

Otherwise, session track variables state is lost when changing user.
Create a helper function to set the variables an use it after the
creation of the client connection and after the reset of the client
connection.
When unable to parse a set statement, and if variables
SQL_SESSION_TRACK_STATE_CHANGE and SQL_SESSION_TRACK_SYSTEM_VARIABLES
are correctly set, ProxySQL will send the whole SET statement to the
backend. If the backend will return a list of variables with only
variables that ProxySQL parses, lock on hostgroup will not be enabled.
Otherwise lock on hostgroup will be enabled
@mirostauder
Copy link
Collaborator

retest this please

When a SET statement parse failure occurs, lock on hostgroup is enabled
and try_to_unlock_with_session_tracking variable is set to true. Due to
this, during processing of the backend response, if the session tracking
data only contains changes in variables that ProxySQL tracks, we remove
the lock on the hostgroup.

Also add some minor improvements and fixes to session tracking.
Session tracking is disabled if a system variable that is not tracked by
ProxySQL is changed. Also, if the hostgroup is not already locked, it is
locked.

If all system variable changes are tracked by ProxySQL, then we remove
the lock on hostgroup.
@mirostauder
Copy link
Collaborator

retest this please

@mirostauder
Copy link
Collaborator

retest this please

2 similar comments
@mirostauder
Copy link
Collaborator

retest this please

@mirostauder
Copy link
Collaborator

retest this please

@mirostauder
Copy link
Collaborator

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants