23#ifndef RPL_COMMIT_STAGE_MANAGER
24#define RPL_COMMIT_STAGE_MANAGER
Definition: rpl_commit_stage_manager.h:42
THD * fetch_and_empty_acquire_lock()
Fetch the entire queue for a stage.
Definition: rpl_commit_stage_manager.cc:413
THD * fetch_and_empty_skip_acquire_lock()
Fetch the entire queue for a stage.
Definition: rpl_commit_stage_manager.cc:420
std::atomic< int32 > m_size
size of the queue
Definition: rpl_commit_stage_manager.h:136
mysql_mutex_t * m_lock
Lock for protecting the queue.
Definition: rpl_commit_stage_manager.h:139
bool is_empty() const
Definition: rpl_commit_stage_manager.h:50
bool append(THD *first)
Append a linked list of threads to the queue.
Definition: rpl_commit_stage_manager.cc:41
void assert_owner()
Definition: rpl_commit_stage_manager.h:111
THD * get_leader()
Fetch the first thread of the queue.
Definition: rpl_commit_stage_manager.h:102
void init(mysql_mutex_t *lock)
Definition: rpl_commit_stage_manager.h:48
int32 get_size()
Get number of elements in the queue.
Definition: rpl_commit_stage_manager.h:95
void unlock()
Definition: rpl_commit_stage_manager.h:109
void lock()
Definition: rpl_commit_stage_manager.h:104
THD ** m_last
Pointer to the location holding the end of the queue.
Definition: rpl_commit_stage_manager.h:133
THD * fetch_and_empty()
Fetch the entire queue for a stage.
Definition: rpl_commit_stage_manager.cc:425
Mutex_queue()
Definition: rpl_commit_stage_manager.h:46
std::pair< bool, THD * > pop_front()
Remove first member from the queue.
Definition: rpl_commit_stage_manager.cc:75
THD * m_first
Pointer to the first thread in the queue, or nullptr if the queue is empty.
Definition: rpl_commit_stage_manager.h:125
Class for maintaining the commit stages for binary log group commit.
Definition: rpl_commit_stage_manager.h:40
const Commit_stage_manager & operator=(const Commit_stage_manager &)=delete
void update_session_ticket_state(THD *thd)
Updates the THD session object underlying BGC context.
Definition: rpl_commit_stage_manager.cc:516
void init(PSI_mutex_key key_LOCK_flush_queue, PSI_mutex_key key_LOCK_sync_queue, PSI_mutex_key key_LOCK_commit_queue, PSI_mutex_key key_LOCK_after_commit_queue, PSI_mutex_key key_LOCK_done, PSI_mutex_key key_LOCK_wait_for_group_turn, PSI_cond_key key_COND_done, PSI_cond_key key_COND_flush_queue, PSI_cond_key key_COND_wait_for_group_turn)
Initializes m_stage_cond_binlog, m_stage_cond_commit_order, m_stage_cond_leader condition variables a...
Definition: rpl_commit_stage_manager.cc:100
mysql_mutex_t m_lock_done
Mutex used for the condition variable above.
Definition: rpl_commit_stage_manager.h:451
void wait_for_ticket_turn(THD *thd, bool update_ticket_manager=true)
Waits for the THD session parameter underlying BGC ticket to become active.
Definition: rpl_commit_stage_manager.cc:166
std::pair< bool, THD * > pop_front(StageID stage)
Remove first member from the queue for given stage.
Definition: rpl_commit_stage_manager.h:282
mysql_cond_t m_stage_cond_leader
The binlog leader waits on this condition variable till it is indicated to wake up.
Definition: rpl_commit_stage_manager.h:436
void deinit()
Deinitializes m_stage_cond_binlog, m_stage_cond_commit_order, m_stage_cond_leader condition variables...
Definition: rpl_commit_stage_manager.cc:149
void finish_session_ticket(THD *thd)
Waits for the session's ticket, if needed, and resets the session's ticket context.
Definition: rpl_commit_stage_manager.cc:541
bool leader_await_preempt_status
Flag is set by Leader when it starts waiting for follower's all-clear.
Definition: rpl_commit_stage_manager.h:461
mysql_cond_t m_stage_cond_binlog
Condition variable to indicate that the binlog threads can wake up and continue.
Definition: rpl_commit_stage_manager.h:442
void clear_preempt_status(THD *head)
The method ensures the follower's execution path can be preempted by the leader's thread.
Definition: rpl_commit_stage_manager.cc:561
Mutex_queue m_queue[STAGE_COUNTER]
Queues for sessions.
Definition: rpl_commit_stage_manager.h:427
Commit_stage_manager(const Commit_stage_manager &)=delete
void signal_end_of_ticket(bool force=false)
Signals threads waiting on their BGC ticket turn.
Definition: rpl_commit_stage_manager.cc:501
mysql_cond_t m_stage_cond_commit_order
Condition variable to indicate that the flush to storage engine is done and commit order threads can ...
Definition: rpl_commit_stage_manager.h:448
mysql_mutex_t m_lock_wait_for_ticket_turn
Mutex to protect the wait for a given ticket to become active.
Definition: rpl_commit_stage_manager.h:470
mysql_cond_t m_cond_wait_for_ticket_turn
Condition variable to wait for a given ticket to become active.
Definition: rpl_commit_stage_manager.h:468
bool append_to(StageID stage, THD *thd)
Appends the given THD session object to the given stage queue.
Definition: rpl_commit_stage_manager.cc:209
void update_ticket_manager(std::uint64_t sessions_count, const binlog::BgcTicket &session_ticket)
Adds the given session count to the total of processed sessions in the ticket manager active window,...
Definition: rpl_commit_stage_manager.cc:525
mysql_mutex_t m_queue_lock[STAGE_COUNTER - 1]
Mutex used for the stage level locks.
Definition: rpl_commit_stage_manager.h:454
StageID
Constants for queues for different stages.
Definition: rpl_commit_stage_manager.h:165
@ COMMIT_ORDER_FLUSH_STAGE
Definition: rpl_commit_stage_manager.h:170
@ COMMIT_STAGE
Definition: rpl_commit_stage_manager.h:168
@ BINLOG_FLUSH_STAGE
Definition: rpl_commit_stage_manager.h:166
@ SYNC_STAGE
Definition: rpl_commit_stage_manager.h:167
@ AFTER_COMMIT_STAGE
Definition: rpl_commit_stage_manager.h:169
@ STAGE_COUNTER
Definition: rpl_commit_stage_manager.h:171
static Commit_stage_manager & get_instance()
Fetch Commit_stage_manager class instance.
Definition: rpl_commit_stage_manager.cc:574
static void enable_manual_session_tickets()
Enables the ability for session BGC tickets to be set manually.
Definition: rpl_commit_stage_manager.cc:556
THD * fetch_queue_acquire_lock(StageID stage)
Fetch the entire queue and empty it.
Definition: rpl_commit_stage_manager.cc:466
bool m_is_initialized
check if Commit_stage_manager variables already initialized.
Definition: rpl_commit_stage_manager.h:409
Commit_stage_manager()
Definition: rpl_commit_stage_manager.h:148
void wait_count_or_timeout(ulong count, long usec, StageID stage)
Introduces a wait operation on the executing thread.
Definition: rpl_commit_stage_manager.cc:443
static void disable_manual_session_tickets()
Disables the ability for session BGC tickets to be set manually.
Definition: rpl_commit_stage_manager.cc:549
void lock_queue(StageID stage)
Wrapper on Mutex_queue lock(), acquires lock on stage queue.
Definition: rpl_commit_stage_manager.h:389
THD * leader_thd
Save pointer to leader thread which is used later to awake leader.
Definition: rpl_commit_stage_manager.h:458
void process_final_stage_for_ordered_commit_group(THD *first)
This function gets called after transactions are flushed to the engine i.e.
Definition: rpl_commit_stage_manager.cc:476
THD * fetch_queue_skip_acquire_lock(StageID stage)
Fetch the entire queue and empty it.
Definition: rpl_commit_stage_manager.cc:471
mysql_cond_t m_cond_preempt
Condition variable to indicate a follower started waiting for commit.
Definition: rpl_commit_stage_manager.h:464
void signal_done(THD *queue, StageID stage=BINLOG_FLUSH_STAGE)
The function is called after follower thread are processed by leader, to unblock follower threads.
Definition: rpl_commit_stage_manager.cc:484
void unlock_queue(StageID stage)
Wrapper on Mutex_queue unlock(), releases lock on stage queue.
Definition: rpl_commit_stage_manager.h:396
bool enroll_for(StageID stage, THD *first, mysql_mutex_t *stage_mutex, mysql_mutex_t *enter_mutex)
Enroll a set of sessions for a stage.
Definition: rpl_commit_stage_manager.cc:218
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
Represents the Binlog Group Commit Ticket - BGC Ticket.
Definition: bgc_ticket.h:53
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:49
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:56
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
unsigned int PSI_cond_key
Instrumented cond key.
Definition: psi_cond_bits.h:43
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:51
#define mysql_mutex_assert_not_owner(M)
Wrapper, to use safe_mutex_assert_not_owner with instrumented mutexes.
Definition: mysql_mutex.h:125
#define mysql_mutex_assert_owner(M)
Wrapper, to use safe_mutex_assert_owner with instrumented mutexes.
Definition: mysql_mutex.h:111
int32_t int32
Definition: my_inttypes.h:65
static int count
Definition: myisam_ftdump.cc:44
static QUEUE queue
Definition: myisampack.cc:209
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:78
Instrumentation helpers for conditions.
Instrumentation helpers for mutexes.
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
MySQL mutex implementation.