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:331
THD * fetch_and_empty_skip_acquire_lock()
Fetch the entire queue for a stage.
Definition: rpl_commit_stage_manager.cc:338
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:36
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:343
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:70
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
mysql_mutex_t m_lock_done
Mutex used for the condition variable above.
Definition: rpl_commit_stage_manager.h:376
std::pair< bool, THD * > pop_front(StageID stage)
Remove first member from the queue for given stage.
Definition: rpl_commit_stage_manager.h:251
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:361
void deinit()
Deinitializes m_stage_cond_binlog, m_stage_cond_commit_order, m_stage_cond_leader condition variables...
Definition: rpl_commit_stage_manager.cc:134
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:386
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:367
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:419
Mutex_queue m_queue[STAGE_COUNTER]
Queues for sessions.
Definition: rpl_commit_stage_manager.h:352
Commit_stage_manager(const Commit_stage_manager &)=delete
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:373
mysql_mutex_t m_queue_lock[STAGE_COUNTER - 1]
Mutex used for the stage level locks.
Definition: rpl_commit_stage_manager.h:379
StageID
Constants for queues for different stages.
Definition: rpl_commit_stage_manager.h:165
@ COMMIT_ORDER_FLUSH_STAGE
Definition: rpl_commit_stage_manager.h:169
@ 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
@ STAGE_COUNTER
Definition: rpl_commit_stage_manager.h:170
static Commit_stage_manager & get_instance()
Fetch Commit_stage_manager class instance.
Definition: rpl_commit_stage_manager.cc:432
THD * fetch_queue_acquire_lock(StageID stage)
Fetch the entire queue and empty it.
Definition: rpl_commit_stage_manager.cc:384
bool m_is_initialized
check if Commit_stage_manager variables already initalized.
Definition: rpl_commit_stage_manager.h:336
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:361
void lock_queue(StageID stage)
Wrapper on Mutex_queue lock(), acquires lock on stage queue.
Definition: rpl_commit_stage_manager.h:325
THD * leader_thd
Save pointer to leader thread which is used later to awake leader.
Definition: rpl_commit_stage_manager.h:383
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:394
THD * fetch_queue_skip_acquire_lock(StageID stage)
Fetch the entire queue and empty it.
Definition: rpl_commit_stage_manager.cc:389
mysql_cond_t m_cond_preempt
Condition variable to indicate a follower started waiting for commit.
Definition: rpl_commit_stage_manager.h:389
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:402
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_done, PSI_cond_key key_COND_done, PSI_cond_key key_COND_flush_queue)
Initializes m_stage_cond_binlog, m_stage_cond_commit_order, m_stage_cond_leader condition variables a...
Definition: rpl_commit_stage_manager.cc:95
void unlock_queue(StageID stage)
Wrapper on Mutex_queue unlock(), releases lock on stage queue.
Definition: rpl_commit_stage_manager.h:332
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:146
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:945
#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:42
static QUEUE queue
Definition: myisampack.cc:206
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.