Feature Request: Support session state tracking
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 443
- Avg merge
- 18h 21m
- Merged PRs (30d)
- 4
Description
Note: I may be able to work on putting together a pull request for this feature request, but I wanted to make sure you were okay with this feature request and the approach I'm taking before doing all that work, hence I am filing this feature request for discussion and approval.
MySQL has a feature enabling server tracking of client session state changes. When this is enabled on the server and client, the server can actually notify the connected client about changes to its session state. This enables the client to, for example (our use case), determine which Global Transaction ID (GTID) or GTIDs were created when the client commits a transaction.
You can read more about this here:
- https://dev.mysql.com/doc/refman/5.7/en/session-state-tracking.html
- https://dev.mysql.com/doc/refman/5.7/en/mysql-session-track-get-first.html
- https://dev.mysql.com/doc/refman/5.7/en/mysql-session-track-get-next.html
Here's what is needed to support this:
- A new constant in
MySQLdb.constants.CLIENT:SESSION_TRACK = 1 << 23 - A new method on
_mysql.connectionnamedget_session_track_gtidswhich returns a list of GTIDs using C functionsmysql_session_track_get_first/mysql_session_track_get_nextand the enum valueSESSION_TRACK_GTIDS. - A new method on
_mysql.connectionnamedget_session_track_variableswhich returns a list of namedtuples containing the session variable names and values for changed variables using the same C functions and the enum valueSESSION_TRACK_SYSTEM_VARIABLES. - A new method on
_mysql.connectionnamedget_session_track_tx_characteristicswhich returns a list of strings of the characteristics that changed using the same C functions and the enum valueSESSION_TRACK_TRANSACTION_CHARACTERISTICS. - A new method on
_mysql.connectionnamedget_session_track_tx_statewhich returns a list of namedtuples containing information parsed from the data as described in the documentation forSESSION_TRACK_TRANSACTION_STATEusing the same C functions and the enum valueSESSION_TRACK_TRANSACTION_STATE.
The bare minimum that we need is items 1 and 2, but implementing also 3 through 5 would be more complete.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with MySQLdb.constants.CLIENT and the _mysql.connection API, then review the MySQL session-tracking documentation linked in the issue. Implementing the minimum means supporting SESSION_TRACK and get_session_track_gtids; completion for the broader request also includes the three variable, transaction-characteristic, and transaction-state methods with their documented return data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100