24#ifndef RPL_COMMIT_STAGE_MANAGER
25#define RPL_COMMIT_STAGE_MANAGER
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Definition: rpl_commit_stage_manager.h:43
THD * fetch_and_empty_acquire_lock()
Fetch the entire queue for a stage.
Definition: rpl_commit_stage_manager.cc:394
THD * fetch_and_empty_skip_acquire_lock()
Fetch the entire queue for a stage.
Definition: rpl_commit_stage_manager.cc:401
std::atomic< int32 > m_size
size of the queue
Definition: rpl_commit_stage_manager.h:137
mysql_mutex_t * m_lock
Lock for protecting the queue.
Definition: rpl_commit_stage_manager.h:140
bool is_empty() const
Definition: rpl_commit_stage_manager.h:51
bool append(THD *first)
Append a linked list of threads to the queue.
Definition: rpl_commit_stage_manager.cc:42
void assert_owner()
Definition: rpl_commit_stage_manager.h:112
THD * get_leader()
Fetch the first thread of the queue.
Definition: rpl_commit_stage_manager.h:103
void init(mysql_mutex_t *lock)
Definition: rpl_commit_stage_manager.h:49
int32 get_size()
Get number of elements in the queue.
Definition: rpl_commit_stage_manager.h:96
void unlock()
Definition: rpl_commit_stage_manager.h:110
void lock()
Definition: rpl_commit_stage_manager.h:105
THD ** m_last
Pointer to the location holding the end of the queue.
Definition: rpl_commit_stage_manager.h:134
THD * fetch_and_empty()
Fetch the entire queue for a stage.
Definition: rpl_commit_stage_manager.cc:406
Mutex_queue()
Definition: rpl_commit_stage_manager.h:47
std::pair< bool, THD * > pop_front()
Remove first member from the queue.
Definition: rpl_commit_stage_manager.cc:76
THD * m_first
Pointer to the first thread in the queue, or nullptr if the queue is empty.
Definition: rpl_commit_stage_manager.h:126
Class for maintaining the commit stages for binary log group commit.
Definition: rpl_commit_stage_manager.h:41
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:497
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:101
mysql_mutex_t m_lock_done
Mutex used for the condition variable above.
Definition: rpl_commit_stage_manager.h:452
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:167
std::pair< bool, THD * > pop_front(StageID stage)
Remove first member from the queue for given stage.
Definition: rpl_commit_stage_manager.h:283
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:437
void deinit()
Deinitializes m_stage_cond_binlog, m_stage_cond_commit_order, m_stage_cond_leader condition variables...
Definition: rpl_commit_stage_manager.cc:150
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:522
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:462
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:443
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:542
Mutex_queue m_queue[STAGE_COUNTER]
Queues for sessions.
Definition: rpl_commit_stage_manager.h:428
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:482
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:449
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:471
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:469
bool append_to(StageID stage, THD *thd)
Appends the given THD session object to the given stage queue.
Definition: rpl_commit_stage_manager.cc:210
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:506
mysql_mutex_t m_queue_lock[STAGE_COUNTER - 1]
Mutex used for the stage level locks.
Definition: rpl_commit_stage_manager.h:455
StageID
Constants for queues for different stages.
Definition: rpl_commit_stage_manager.h:166
@ COMMIT_ORDER_FLUSH_STAGE
Definition: rpl_commit_stage_manager.h:171
@ COMMIT_STAGE
Definition: rpl_commit_stage_manager.h:169
@ BINLOG_FLUSH_STAGE
Definition: rpl_commit_stage_manager.h:167
@ SYNC_STAGE
Definition: rpl_commit_stage_manager.h:168
@ AFTER_COMMIT_STAGE
Definition: rpl_commit_stage_manager.h:170
@ STAGE_COUNTER
Definition: rpl_commit_stage_manager.h:172
static Commit_stage_manager & get_instance()
Fetch Commit_stage_manager class instance.
Definition: rpl_commit_stage_manager.cc:555
static void enable_manual_session_tickets()
Enables the ability for session BGC tickets to be set manually.
Definition: rpl_commit_stage_manager.cc:537
THD * fetch_queue_acquire_lock(StageID stage)
Fetch the entire queue and empty it.
Definition: rpl_commit_stage_manager.cc:447
bool m_is_initialized
check if Commit_stage_manager variables already initialized.
Definition: rpl_commit_stage_manager.h:410
Commit_stage_manager()
Definition: rpl_commit_stage_manager.h:149
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:424
static void disable_manual_session_tickets()
Disables the ability for session BGC tickets to be set manually.
Definition: rpl_commit_stage_manager.cc:530
void lock_queue(StageID stage)
Wrapper on Mutex_queue lock(), acquires lock on stage queue.
Definition: rpl_commit_stage_manager.h:390
THD * leader_thd
Save pointer to leader thread which is used later to awake leader.
Definition: rpl_commit_stage_manager.h:459
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:457
THD * fetch_queue_skip_acquire_lock(StageID stage)
Fetch the entire queue and empty it.
Definition: rpl_commit_stage_manager.cc:452
mysql_cond_t m_cond_preempt
Condition variable to indicate a follower started waiting for commit.
Definition: rpl_commit_stage_manager.h:465
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:465
void unlock_queue(StageID stage)
Wrapper on Mutex_queue unlock(), releases lock on stage queue.
Definition: rpl_commit_stage_manager.h:397
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:219
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Represents the Binlog Group Commit Ticket - BGC Ticket.
Definition: bgc_ticket.h:54
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:50
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:57
unsigned int PSI_cond_key
Instrumented cond key.
Definition: psi_cond_bits.h:44
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:52
#define mysql_mutex_assert_not_owner(M)
Wrapper, to use safe_mutex_assert_not_owner with instrumented mutexes.
Definition: mysql_mutex.h:126
#define mysql_mutex_assert_owner(M)
Wrapper, to use safe_mutex_assert_owner with instrumented mutexes.
Definition: mysql_mutex.h:112
int32_t int32
Definition: my_inttypes.h:66
static int count
Definition: myisam_ftdump.cc:45
static QUEUE queue
Definition: myisampack.cc:210
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79
Instrumentation helpers for conditions.
Instrumentation helpers for mutexes.
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
MySQL mutex implementation.