MySQL 9.1.0
Source Code Documentation
Transaction_consistency_manager Class Reference

The consistency information of all ongoing transactions which have consistency GROUP_REPLICATION_CONSISTENCY_BEFORE, GROUP_REPLICATION_CONSISTENCY_AFTER or GROUP_REPLICATION_CONSISTENCY_BEFORE_AND_AFTER. More...

#include <consistency_manager.h>

Inheritance diagram for Transaction_consistency_manager:
[legend]

Public Member Functions

 Transaction_consistency_manager ()
 Constructor. More...
 
 ~Transaction_consistency_manager () override
 
void clear ()
 Clear all information. More...
 
int after_certification (std::unique_ptr< Transaction_consistency_info > transaction_info)
 Call action after a transaction is certified. More...
 
int after_applier_prepare (rpl_sidno sidno, rpl_gno gno, my_thread_id thread_id, Group_member_info::Group_member_status member_status)
 Call action after a transaction being prepared on this member applier. More...
 
int handle_remote_prepare (const gr::Gtid_tsid &tsid, bool is_tsid_specified, rpl_gno gno, const Gcs_member_identifier &gcs_member_id)
 Call action after a transaction being prepared by other member. More...
 
int handle_member_leave (const std::vector< Gcs_member_identifier > &leaving_members)
 Call action after members leave the group. More...
 
int after_commit (my_thread_id thread_id, rpl_sidno sidno, rpl_gno gno) override
 Call action after commit a transaction on this member. More...
 
int before_transaction_begin (my_thread_id thread_id, ulong gr_consistency_level, ulong timeout, enum_rpl_channel_type rpl_channel_type, const THD *thd) override
 Call action before a transaction starts. More...
 
int handle_sync_before_execution_message (my_thread_id thread_id, const Gcs_member_identifier &gcs_member_id) const
 Call action once a Sync_before_execution_message is received, this will allow fetch the group transactions set ordered with the message order. More...
 
bool has_local_prepared_transactions ()
 Are there local prepared transactions waiting for prepare acknowledge from other members? More...
 
int schedule_view_change_event (Pipeline_event *pevent)
 Schedule a View_change_log_event log into the relay to after the local prepared transactions are complete, since those transactions belong to the previous view and as such must be logged before this view. More...
 
void plugin_started ()
 Inform that plugin did start. More...
 
void plugin_is_stopping ()
 Inform that plugin is stopping. More...
 
void register_transaction_observer ()
 Register an observer for transactions. More...
 
void unregister_transaction_observer ()
 Unregister the observer for transactions. More...
 
int before_commit (my_thread_id thread_id, Group_transaction_listener::enum_transaction_origin origin) override
 Executed before commit. More...
 
int before_rollback (my_thread_id thread_id, Group_transaction_listener::enum_transaction_origin origin) override
 Executed before rollback. More...
 
int after_rollback (my_thread_id thread_id) override
 Executed after rollback. More...
 
void enable_primary_election_checks ()
 Tells the consistency manager that a primary election is running so it shall enable primary election checks. More...
 
void disable_primary_election_checks ()
 Tells the consistency manager that a primary election ended so it shall disable primary election checks. More...
 
- Public Member Functions inherited from Group_transaction_listener
virtual ~Group_transaction_listener ()
 Class destructor. More...
 

Private Member Functions

int transaction_begin_sync_before_execution (my_thread_id thread_id, enum_group_replication_consistency_level consistency_level, ulong timeout, const THD *thd) const
 Help method called by transaction begin action that, for transactions with consistency GROUP_REPLICATION_CONSISTENCY_BEFORE or GROUP_REPLICATION_CONSISTENCY_BEFORE_AND_AFTER will: 1) send a message to all members; 2) when that message is received and processed in-order, w.r.t. More...
 
int transaction_begin_sync_prepared_transactions (my_thread_id thread_id, ulong timeout)
 Help method called by transaction begin action that, if there are precedent prepared transactions with consistency GROUP_REPLICATION_CONSISTENCY_AFTER or GROUP_REPLICATION_CONSISTENCY_BEFORE_AND_AFTER, will hold the this transaction until the prepared are committed. More...
 
int remove_prepared_transaction (Transaction_consistency_manager_key key)
 Help method that cleans prepared transactions and releases transactions waiting on them. More...
 

Private Attributes

Checkable_rwlockm_map_lock
 
Transaction_consistency_manager_map m_map
 
Checkable_rwlockm_prepared_transactions_on_my_applier_lock
 
std::list< Transaction_consistency_manager_key, Malloc_allocator< Transaction_consistency_manager_key > > m_prepared_transactions_on_my_applier
 
std::list< my_thread_id, Malloc_allocator< my_thread_id > > m_new_transactions_waiting
 
std::list< Transaction_consistency_manager_pevent_pair, Malloc_allocator< Transaction_consistency_manager_pevent_pair > > m_delayed_view_change_events
 
Transaction_consistency_manager_key m_last_local_transaction
 
std::atomic< bool > m_plugin_stopping
 
std::atomic< bool > m_primary_election_active
 
Hold_transactions m_hold_transactions
 Hold transaction mechanism. More...
 

Additional Inherited Members

- Public Types inherited from Group_transaction_listener
enum  enum_transaction_origin { GROUP_APPLIER_TRANSACTION = 0 , GROUP_RECOVERY_TRANSACTION = 1 , GROUP_LOCAL_TRANSACTION = 2 }
 Enum for transaction origins. More...
 

Detailed Description

The consistency information of all ongoing transactions which have consistency GROUP_REPLICATION_CONSISTENCY_BEFORE, GROUP_REPLICATION_CONSISTENCY_AFTER or GROUP_REPLICATION_CONSISTENCY_BEFORE_AND_AFTER.

Constructor & Destructor Documentation

◆ Transaction_consistency_manager()

Transaction_consistency_manager::Transaction_consistency_manager ( )

Constructor.

◆ ~Transaction_consistency_manager()

Transaction_consistency_manager::~Transaction_consistency_manager ( )
override

Member Function Documentation

◆ after_applier_prepare()

int Transaction_consistency_manager::after_applier_prepare ( rpl_sidno  sidno,
rpl_gno  gno,
my_thread_id  thread_id,
Group_member_info::Group_member_status  member_status 
)

Call action after a transaction being prepared on this member applier.

Parameters
[in]sidnothe transaction sidno
[in]gnothe transaction gno
[in]thread_idthe applier thread id
[in]member_statusthis member status
Returns
Operation status
Return values
0OK
!=0error

◆ after_certification()

int Transaction_consistency_manager::after_certification ( std::unique_ptr< Transaction_consistency_info transaction_info)

Call action after a transaction is certified.

The transaction coordination among the members will start on this point.

Parameters
[in]transaction_infothe transaction info
Returns
Operation status
Return values
0OK
!=0error

◆ after_commit()

int Transaction_consistency_manager::after_commit ( my_thread_id  thread_id,
rpl_sidno  sidno,
rpl_gno  gno 
)
overridevirtual

Call action after commit a transaction on this member.

If new transactions are waiting for this prepared transaction to be committed, they will be released.

Parameters
[in]thread_idthe transaction thread id
[in]sidnothe transaction sidno
[in]gnothe transaction gno
Returns
Operation status
Return values
0OK
!=0error

Implements Group_transaction_listener.

◆ after_rollback()

int Transaction_consistency_manager::after_rollback ( my_thread_id  thread_id)
overridevirtual

Executed after rollback.

Parameters
thread_idthe transaction thread id

Implements Group_transaction_listener.

◆ before_commit()

int Transaction_consistency_manager::before_commit ( my_thread_id  thread_id,
Group_transaction_listener::enum_transaction_origin  origin 
)
overridevirtual

Executed before commit.

Parameters
thread_idthe transaction thread id
originwho applied it

Implements Group_transaction_listener.

◆ before_rollback()

int Transaction_consistency_manager::before_rollback ( my_thread_id  thread_id,
Group_transaction_listener::enum_transaction_origin  origin 
)
overridevirtual

Executed before rollback.

Parameters
thread_idthe transaction thread id
originwho applied it

Implements Group_transaction_listener.

◆ before_transaction_begin()

int Transaction_consistency_manager::before_transaction_begin ( my_thread_id  thread_id,
ulong  gr_consistency_level,
ulong  timeout,
enum_rpl_channel_type  rpl_channel_type,
const THD thd 
)
overridevirtual

Call action before a transaction starts.

It will handle transactions with GROUP_REPLICATION_CONSISTENCY_BEFORE consistency and any others that need to wait for preceding prepared transactions to commit.

Parameters
[in]thread_idthe thread that is executing the transaction
[in]gr_consistency_levelthe transaction consistency
[in]timeoutmaximum time to wait
[in]rpl_channel_typetype of the channel that receives the transaction
[in]thdserver thd represent client connection
Returns
Operation status
Return values
0OK
!=0error

Implements Group_transaction_listener.

◆ clear()

void Transaction_consistency_manager::clear ( )

Clear all information.

◆ disable_primary_election_checks()

void Transaction_consistency_manager::disable_primary_election_checks ( )

Tells the consistency manager that a primary election ended so it shall disable primary election checks.

◆ enable_primary_election_checks()

void Transaction_consistency_manager::enable_primary_election_checks ( )

Tells the consistency manager that a primary election is running so it shall enable primary election checks.

◆ handle_member_leave()

int Transaction_consistency_manager::handle_member_leave ( const std::vector< Gcs_member_identifier > &  leaving_members)

Call action after members leave the group.

If any of these members are on the prepare wait lists, they will be removed. If any those lists become empty, those transactions proceed to commit.

Parameters
[in]leaving_membersthe members that left
Returns
Operation status
Return values
0OK
!=0error

◆ handle_remote_prepare()

int Transaction_consistency_manager::handle_remote_prepare ( const gr::Gtid_tsid tsid,
bool  is_tsid_specified,
rpl_gno  gno,
const Gcs_member_identifier gcs_member_id 
)

Call action after a transaction being prepared by other member.

If this sid is NULL that means this transaction sid is the group name.

Parameters
[in]tsidthe transaction tsid
[in]is_tsid_specifiedinformation on whether tsid is specified
[in]gnothe transaction gno
[in]gcs_member_idthe member id
Returns
Operation status
Return values
0OK
!=0error

◆ handle_sync_before_execution_message()

int Transaction_consistency_manager::handle_sync_before_execution_message ( my_thread_id  thread_id,
const Gcs_member_identifier gcs_member_id 
) const

Call action once a Sync_before_execution_message is received, this will allow fetch the group transactions set ordered with the message order.

Parameters
[in]thread_idthe thread that is executing the transaction
[in]gcs_member_idthe member id
Returns
Operation status
Return values
0OK
!=0error

◆ has_local_prepared_transactions()

bool Transaction_consistency_manager::has_local_prepared_transactions ( )

Are there local prepared transactions waiting for prepare acknowledge from other members?

Returns
true yes false otherwise

◆ plugin_is_stopping()

void Transaction_consistency_manager::plugin_is_stopping ( )

Inform that plugin is stopping.

New consistent transactions are not allowed to start. On after_applier_prepare the transactions do not wait for other prepares.

◆ plugin_started()

void Transaction_consistency_manager::plugin_started ( )

Inform that plugin did start.

◆ register_transaction_observer()

void Transaction_consistency_manager::register_transaction_observer ( )

Register an observer for transactions.

◆ remove_prepared_transaction()

int Transaction_consistency_manager::remove_prepared_transaction ( Transaction_consistency_manager_key  key)
private

Help method that cleans prepared transactions and releases transactions waiting on them.

Parameters
[in]keythe transaction key
Returns
Operation status
Return values
0OK
!=0error

◆ schedule_view_change_event()

int Transaction_consistency_manager::schedule_view_change_event ( Pipeline_event pevent)

Schedule a View_change_log_event log into the relay to after the local prepared transactions are complete, since those transactions belong to the previous view and as such must be logged before this view.

Parameters
[in]peventthe pipeline event that contains the View_change_log_event
Returns
Operation status
Return values
0OK
!=0error

◆ transaction_begin_sync_before_execution()

int Transaction_consistency_manager::transaction_begin_sync_before_execution ( my_thread_id  thread_id,
enum_group_replication_consistency_level  consistency_level,
ulong  timeout,
const THD thd 
) const
private

Help method called by transaction begin action that, for transactions with consistency GROUP_REPLICATION_CONSISTENCY_BEFORE or GROUP_REPLICATION_CONSISTENCY_BEFORE_AND_AFTER will: 1) send a message to all members; 2) when that message is received and processed in-order, w.r.t.

the message stream, will fetch the Group Replication applier RECEIVED_TRANSACTION_SET, the set of remote transactions that were allowed to commit; 3) wait until all the transactions on Group Replication applier RECEIVED_TRANSACTION_SET are committed.

Parameters
[in]thread_idthe thread that is executing the transaction
[in]consistency_levelthe transaction consistency
[in]timeoutmaximum time to wait
[in]thdserver thd represent client connection
Returns
Operation status
Return values
0OK
!=0error

◆ transaction_begin_sync_prepared_transactions()

int Transaction_consistency_manager::transaction_begin_sync_prepared_transactions ( my_thread_id  thread_id,
ulong  timeout 
)
private

Help method called by transaction begin action that, if there are precedent prepared transactions with consistency GROUP_REPLICATION_CONSISTENCY_AFTER or GROUP_REPLICATION_CONSISTENCY_BEFORE_AND_AFTER, will hold the this transaction until the prepared are committed.

Parameters
[in]thread_idthe thread that is executing the transaction
[in]timeoutmaximum time to wait
Returns
Operation status
Return values
0OK
!=0error

◆ unregister_transaction_observer()

void Transaction_consistency_manager::unregister_transaction_observer ( )

Unregister the observer for transactions.

Member Data Documentation

◆ m_delayed_view_change_events

std::list<Transaction_consistency_manager_pevent_pair, Malloc_allocator<Transaction_consistency_manager_pevent_pair> > Transaction_consistency_manager::m_delayed_view_change_events
private

◆ m_hold_transactions

Hold_transactions Transaction_consistency_manager::m_hold_transactions
private

Hold transaction mechanism.

◆ m_last_local_transaction

Transaction_consistency_manager_key Transaction_consistency_manager::m_last_local_transaction
private

◆ m_map

Transaction_consistency_manager_map Transaction_consistency_manager::m_map
private

◆ m_map_lock

Checkable_rwlock* Transaction_consistency_manager::m_map_lock
private

◆ m_new_transactions_waiting

std::list<my_thread_id, Malloc_allocator<my_thread_id> > Transaction_consistency_manager::m_new_transactions_waiting
private

◆ m_plugin_stopping

std::atomic<bool> Transaction_consistency_manager::m_plugin_stopping
private

◆ m_prepared_transactions_on_my_applier

std::list<Transaction_consistency_manager_key, Malloc_allocator<Transaction_consistency_manager_key> > Transaction_consistency_manager::m_prepared_transactions_on_my_applier
private

◆ m_prepared_transactions_on_my_applier_lock

Checkable_rwlock* Transaction_consistency_manager::m_prepared_transactions_on_my_applier_lock
private

◆ m_primary_election_active

std::atomic<bool> Transaction_consistency_manager::m_primary_election_active
private

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