MySQL 9.1.0
Source Code Documentation
Session_consistency_gtids_ctx Class Reference

This class is an interface for session consistency instrumentation in the server. More...

#include <rpl_context.h>

Classes

class  Ctx_change_listener
 This is an interface to be implemented by classes that want to listen to changes to this context. More...
 

Public Member Functions

 Session_consistency_gtids_ctx ()
 Simple constructor. More...
 
virtual ~Session_consistency_gtids_ctx ()
 The destructor. More...
 
void register_ctx_change_listener (Session_consistency_gtids_ctx::Ctx_change_listener *listener, THD *thd)
 Registers the listener. More...
 
void unregister_ctx_change_listener (Session_consistency_gtids_ctx::Ctx_change_listener *listener)
 Unregisters the listener. More...
 
Gtid_setstate ()
 This member function MUST return a reference to the set of collected GTIDs so far. More...
 
virtual bool notify_after_response_packet (const THD *thd)
 This function MUST be called after the response packet is set to the client connected. More...
 
virtual bool notify_after_gtid_executed_update (const THD *thd)
 This function SHALL be called once the GTID for the given transaction has has been added to GTID_EXECUTED. More...
 
virtual bool notify_after_transaction_commit (const THD *thd)
 This function MUST be called after a transaction is committed in the server. More...
 
virtual bool notify_after_xa_prepare (const THD *thd)
 
void update_tracking_activeness_from_session_variable (const THD *thd)
 Update session tracker (m_curr_session_track_gtids) from thd. More...
 

Protected Member Functions

bool shall_collect (const THD *thd)
 
void notify_ctx_change_listener ()
 Auxiliary function that allows notification of ctx change listeners. More...
 

Private Member Functions

 Session_consistency_gtids_ctx (const Session_consistency_gtids_ctx &rsc)
 
Session_consistency_gtids_ctxoperator= (const Session_consistency_gtids_ctx &rsc)
 

Private Attributes

Tsid_mapm_tsid_map
 
Gtid_setm_gtid_set
 Set holding the transaction identifiers of the gtids to reply back on the response packet. More...
 
Session_consistency_gtids_ctx::Ctx_change_listenerm_listener
 If a listener is registered, e.g., the session track gtids, then this points to an instance of such listener. More...
 
ulong m_curr_session_track_gtids
 Keeps track of the current session track gtids, so that we capture according to what was set before. More...
 

Detailed Description

This class is an interface for session consistency instrumentation in the server.

It holds the context information for a given session.

It does not require locking since access to this content is mutually exclusive by design (only one thread reading or writing to this object at a time).

Constructor & Destructor Documentation

◆ Session_consistency_gtids_ctx() [1/2]

Session_consistency_gtids_ctx::Session_consistency_gtids_ctx ( )

Simple constructor.

◆ ~Session_consistency_gtids_ctx()

Session_consistency_gtids_ctx::~Session_consistency_gtids_ctx ( )
virtual

The destructor.

Deletes the m_gtid_set and the tsid_map.

◆ Session_consistency_gtids_ctx() [2/2]

Session_consistency_gtids_ctx::Session_consistency_gtids_ctx ( const Session_consistency_gtids_ctx rsc)
private

Member Function Documentation

◆ notify_after_gtid_executed_update()

bool Session_consistency_gtids_ctx::notify_after_gtid_executed_update ( const THD thd)
virtual

This function SHALL be called once the GTID for the given transaction has has been added to GTID_EXECUTED.

This function SHALL store the data if the thd->variables.session_track_gtids is set to a value other than NONE.

Parameters
thdThe thread context.
Returns
true on error, false otherwise.

◆ notify_after_response_packet()

bool Session_consistency_gtids_ctx::notify_after_response_packet ( const THD thd)
virtual

This function MUST be called after the response packet is set to the client connected.

The implementation may act on the collected state for instance to do garbage collection.

Parameters
thdThe thread context.
Returns
true on error, false otherwise.

◆ notify_after_transaction_commit()

bool Session_consistency_gtids_ctx::notify_after_transaction_commit ( const THD thd)
virtual

This function MUST be called after a transaction is committed in the server.

It should be called regardless whether it is a RO or RW transaction. Also, DDLs, DDS are considered transaction for what is worth.

This function SHALL store relevant data for the session consistency.

Parameters
thdThe thread context.
Returns
true on error, false otherwise.

◆ notify_after_xa_prepare()

virtual bool Session_consistency_gtids_ctx::notify_after_xa_prepare ( const THD thd)
inlinevirtual

◆ notify_ctx_change_listener()

void Session_consistency_gtids_ctx::notify_ctx_change_listener ( )
inlineprotected

Auxiliary function that allows notification of ctx change listeners.

◆ operator=()

Session_consistency_gtids_ctx & Session_consistency_gtids_ctx::operator= ( const Session_consistency_gtids_ctx rsc)
private

◆ register_ctx_change_listener()

void Session_consistency_gtids_ctx::register_ctx_change_listener ( Session_consistency_gtids_ctx::Ctx_change_listener listener,
THD thd 
)

Registers the listener.

The pointer MUST not be NULL.

Parameters
listenera pointer to the listener to register.
thdTHD context associated to this listener.

◆ shall_collect()

bool Session_consistency_gtids_ctx::shall_collect ( const THD thd)
inlineprotected

◆ state()

Gtid_set * Session_consistency_gtids_ctx::state ( )
inline

This member function MUST return a reference to the set of collected GTIDs so far.

Returns
the set of collected GTIDs so far.

◆ unregister_ctx_change_listener()

void Session_consistency_gtids_ctx::unregister_ctx_change_listener ( Session_consistency_gtids_ctx::Ctx_change_listener listener)

Unregisters the listener.

The listener MUST have registered previously.

Parameters
listenera pointer to the listener to register.

◆ update_tracking_activeness_from_session_variable()

void Session_consistency_gtids_ctx::update_tracking_activeness_from_session_variable ( const THD thd)

Update session tracker (m_curr_session_track_gtids) from thd.

Member Data Documentation

◆ m_curr_session_track_gtids

ulong Session_consistency_gtids_ctx::m_curr_session_track_gtids
private

Keeps track of the current session track gtids, so that we capture according to what was set before.

For instance, if the user does: SET @SESSION.SESSION_TRACK_GTIDS='ALL_GTIDS'; ... SET @SESSION.SESSION_TRACK_GTIDS='OWN_GTID';

The last statement should return a set of GTIDs.

◆ m_gtid_set

Gtid_set* Session_consistency_gtids_ctx::m_gtid_set
private

Set holding the transaction identifiers of the gtids to reply back on the response packet.

Lifecycle: Emptied after the reply is sent back to the application. Remains empty until:

  • a RW transaction commits and a GTID is written to the binary log.
  • a RO transaction is issued, the consistency level is set to "Check Potential Writes" and the transaction is committed.

◆ m_listener

Session_consistency_gtids_ctx::Ctx_change_listener* Session_consistency_gtids_ctx::m_listener
private

If a listener is registered, e.g., the session track gtids, then this points to an instance of such listener.

Since this context is valid only for one session, there is no need to protect this with locks.

◆ m_tsid_map

Tsid_map* Session_consistency_gtids_ctx::m_tsid_map
private

The documentation for this class was generated from the following files: