25#ifndef SEMISYNC_SOURCE_H
26#define SEMISYNC_SOURCE_H
38#ifdef HAVE_PSI_INTERFACE
91#define BLOCK_TRANX_NODES 16
112 while (block !=
nullptr) {
145 trx_node->
next_ =
nullptr;
173 Block *prev_block =
nullptr;
178 if (&(block->
nodes[0]) <= node &&
249 block->
next =
nullptr;
379 const char *log_file_name2,
my_off_t log_file_pos2);
441 for (
unsigned i = 0; i <
m_size; ++i) {
504 for (i = 0; i <
m_size; i++) {
528 for (i = 0; i <
m_size; i++) {
555 for (i = 0; i <
m_size; i++) {
825 const AckInfo *ackinfo =
nullptr;
828 if (ackinfo !=
nullptr)
AckContainer stores received acks internally and tell the caller the ack's position when a transactio...
Definition: semisync_source.h:431
AckContainer & operator=(const AckContainer &container)
const AckInfo * insert(const AckInfo &ackinfo)
Definition: semisync_source.h:475
AckInfo m_greatest_ack
Definition: semisync_source.h:481
bool full()
Definition: semisync_source.h:493
unsigned int m_empty_slot
Definition: semisync_source.h:487
unsigned int m_size
Definition: semisync_source.h:485
unsigned int updateIfExist(int server_id, const char *log_file_name, my_off_t log_file_pos)
Update a slave's ack into the container if another ack of the slave is already in it.
Definition: semisync_source.h:523
void clear()
Clear the content of the ack array.
Definition: semisync_source.h:439
const AckInfo * insert(int server_id, const char *log_file_name, my_off_t log_file_pos)
Insert an ack's information into the container and report the minimum ack to semisync master if it is...
Definition: semisync_source.cc:1193
unsigned int size()
Definition: semisync_source.h:494
~AckContainer()
Definition: semisync_source.h:434
AckInfo * minAck(const char *log_file_name, my_off_t log_file_pos)
Find the minimum ack which is smaller than given position.
Definition: semisync_source.h:551
AckInfo * m_ack_array
Definition: semisync_source.h:483
AckContainer(AckContainer &container)
void remove_all(const char *log_file_name, my_off_t log_file_pos)
Remove all acks which equal to the given position.
Definition: semisync_source.h:502
AckContainer()
Definition: semisync_source.h:433
int resize(unsigned int size, const AckInfo **ackinfo)
Adjust capacity for the container and report the ack to semisync master, if it is full.
Definition: semisync_source.cc:1242
This class manages memory for active transaction list.
Definition: semisync_source.h:312
int compare(const TranxNode *node1, const TranxNode *node2)
Definition: semisync_source.h:338
bool is_tranx_end_pos(const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.cc:196
TranxNode * trx_front_
Definition: semisync_source.h:316
int compare(const char *log_file_name1, my_off_t log_file_pos1, const TranxNode *node2)
Definition: semisync_source.h:328
int num_entries_
Definition: semisync_source.h:320
unsigned int get_hash_value(const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.cc:116
ActiveTranx(mysql_mutex_t *lock, unsigned long trace_level)
Definition: semisync_source.cc:79
TranxNode * trx_rear_
Definition: semisync_source.h:316
unsigned int calc_hash(const unsigned char *key, unsigned int length)
Definition: semisync_source.cc:103
int insert_tranx_node(const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.cc:139
TranxNode ** trx_htb_
Definition: semisync_source.h:318
TranxNodeAllocator allocator_
Definition: semisync_source.h:314
mysql_mutex_t * lock_
Definition: semisync_source.h:321
bool is_empty()
Definition: semisync_source.h:387
int compare(const TranxNode *node1, const char *log_file_name2, my_off_t log_file_pos2)
Definition: semisync_source.h:333
int signal_waiting_sessions_all()
Definition: semisync_source.cc:218
~ActiveTranx()
Definition: semisync_source.cc:97
int signal_waiting_sessions_up_to(const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.cc:227
int clear_active_tranx_nodes(const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.cc:263
TranxNode * find_active_tranx_node(const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.cc:246
Base class for semi-sync master and slave classes.
Definition: semisync.h:83
The extension class for the master of semi-synchronous replication.
Definition: semisync_source.h:567
int reserveSyncHeader(unsigned char *header, unsigned long size)
Definition: semisync_source.cc:914
mysql_mutex_t LOCK_binlog_
Definition: semisync_source.h:581
my_off_t wait_file_pos_
Definition: semisync_source.h:604
int initObject()
Definition: semisync_source.cc:407
int reportReplyPacket(uint32 server_id, const uchar *packet, ulong packet_len)
Definition: semisync_source.cc:337
int resetMaster()
Definition: semisync_source.cc:1125
bool is_on()
Definition: semisync_source.h:634
unsigned long wait_timeout_
Definition: semisync_source.h:624
AckContainer ack_container_
Definition: semisync_source.h:628
bool state_
Definition: semisync_source.h:626
int setWaitSlaveCount(unsigned int new_value)
Definition: semisync_source.cc:1173
void force_switch_on()
Definition: semisync_source.cc:845
volatile bool master_enabled_
Definition: semisync_source.h:622
char reply_file_name_[FN_REFLEN]
Definition: semisync_source.h:587
void setTraceLevel(unsigned long trace_level)
Definition: semisync_source.h:651
my_off_t commit_file_pos_
Definition: semisync_source.h:619
int commitTrx(const char *trx_wait_binlog_name, my_off_t trx_wait_binlog_pos)
Definition: semisync_source.cc:636
int switch_off()
Definition: semisync_source.cc:865
void setWaitTimeout(unsigned long wait_timeout)
Definition: semisync_source.h:661
bool wait_file_name_inited_
Definition: semisync_source.h:593
void add_slave()
Definition: semisync_source.cc:517
int updateSyncHeader(unsigned char *packet, const char *log_file_name, my_off_t log_file_pos, uint32 server_id)
Definition: semisync_source.cc:937
ReplSemiSyncMaster()
Definition: semisync_source.cc:401
ActiveTranx * active_tranxs_
Definition: semisync_source.h:569
void set_wait_no_replica(const void *val)
Definition: semisync_source.cc:834
void lock()
Definition: semisync_source.cc:513
void set_master_enabled(bool enabled)
Definition: semisync_source.h:636
my_off_t reply_file_pos_
Definition: semisync_source.h:590
char wait_file_name_[FN_REFLEN]
Definition: semisync_source.h:598
int skipSlaveReply(const char *event_buf, uint32 server_id, const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.cc:1071
int writeTranxInBinlog(const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.cc:1017
bool reply_file_name_inited_
Definition: semisync_source.h:584
~ReplSemiSyncMaster()
Definition: semisync_source.cc:505
void setExportStats()
Definition: semisync_source.cc:1155
int try_switch_on(const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.cc:882
bool init_done_
Definition: semisync_source.h:574
int readSlaveReply(NET *net, const char *event_buf)
Definition: semisync_source.cc:1095
int disableMaster()
Definition: semisync_source.cc:475
bool is_semi_sync_slave()
Definition: semisync_source.cc:551
char commit_file_name_[FN_REFLEN]
Definition: semisync_source.h:616
void reportReplyBinlog(const char *log_file_name, my_off_t end_offset)
Definition: semisync_source.cc:558
int enableMaster()
Definition: semisync_source.cc:439
void remove_slave()
Definition: semisync_source.cc:523
bool commit_file_name_inited_
Definition: semisync_source.h:613
void handleAck(int server_id, const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.h:819
bool getMasterEnabled()
Definition: semisync_source.h:650
void unlock()
Definition: semisync_source.cc:515
This class is used to trace function calls and other process information.
Definition: semisync.h:43
unsigned long trace_level_
Definition: semisync.h:50
static const unsigned long kTraceDetail
Definition: semisync.h:47
This class provides memory allocating and freeing methods for TranxNode.
Definition: semisync_source.h:92
~TranxNodeAllocator()
Definition: semisync_source.h:110
TranxNodeAllocator(uint reserved_nodes)
Definition: semisync_source.h:101
int last_node
It always points to the last node which has been allocated in the current_block.
Definition: semisync_source.h:235
uint block_num
How many Blocks are in the Block link table.
Definition: semisync_source.h:240
Block * last_block
The 'last_block' is the rear of the Block link table;.
Definition: semisync_source.h:222
int free_nodes_before(TranxNode *node)
All Blocks before the given 'node' are free Block and moved into the rear of the Block link table.
Definition: semisync_source.h:171
TranxNode * allocate_node()
The pointer of the first node after 'last_node' in current_block is returned.
Definition: semisync_source.h:127
Block * current_block
current_block always points the Block in the Block link table in which the last allocated node is.
Definition: semisync_source.h:229
uint reserved_blocks
Definition: semisync_source.h:200
int allocate_block()
Allocate a block and then assign it to current_block.
Definition: semisync_source.h:245
void free_block(Block *block)
Free a given Block.
Definition: semisync_source.h:275
int free_all_nodes()
All nodes are freed.
Definition: semisync_source.h:156
Block * first_block
The 'first_block' is the head of the Block link table;.
Definition: semisync_source.h:218
void free_blocks()
If there are some free Blocks and the total number of the Blocks in the Block link table is larger th...
Definition: semisync_source.h:289
#define mysql_cond_destroy(C)
Definition: mysql_cond.h:45
#define mysql_cond_init(K, C)
Definition: mysql_cond.h:42
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
MYSQL_PLUGIN_IMPORT ulong server_id
Definition: log_event.h:112
unsigned int PSI_cond_key
Instrumented cond key.
Definition: psi_cond_bits.h:44
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:52
std::string log_file_name(const Log_files_context &ctx, Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0files_io.cc:737
#define LogErr(severity, ecode,...)
Definition: log_builtins.h:843
Some integer typedefs for easier portability.
ulonglong my_off_t
Definition: my_inttypes.h:72
unsigned char uchar
Definition: my_inttypes.h:52
#define MYF(v)
Definition: my_inttypes.h:97
uint32_t uint32
Definition: my_inttypes.h:67
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:83
@ INFORMATION_LEVEL
Definition: my_loglevel.h:45
void * my_malloc(PSI_memory_key key, size_t size, int flags)
Allocates size bytes of memory.
Definition: my_memory.cc:57
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
Definition: atomics_array.h:39
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
bool empty(const Histogram &histogram)
Return true if 'histogram' was built on an empty table.
Definition: histogram.h:672
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79
required string key
Definition: replication_asynchronous_connection_failover.proto:60
required bool enabled
Definition: replication_group_member_actions.proto:33
unsigned int rpl_semi_sync_source_wait_for_replica_count
Definition: semisync_source.cc:64
PSI_mutex_key key_ss_mutex_LOCK_binlog_
Definition: semisync_source_plugin.cc:489
unsigned long rpl_semi_sync_source_off_times
Definition: semisync_source.cc:51
unsigned long rpl_semi_sync_source_trace_level
Definition: semisync_source.cc:47
bool rpl_semi_sync_source_wait_no_replica
Definition: semisync_source.cc:63
PSI_cond_key key_ss_cond_COND_binlog_send_
Definition: semisync_source_plugin.cc:497
unsigned long long rpl_semi_sync_source_net_wait_time
Definition: semisync_source.cc:61
unsigned long rpl_semi_sync_source_wait_timeouts
Definition: semisync_source.cc:53
PSI_stage_info stage_waiting_for_semi_sync_replica
Definition: semisync_source_plugin.cc:526
unsigned long rpl_semi_sync_source_clients
Definition: semisync_source.cc:60
PSI_stage_info stage_reading_semi_sync_ack
Definition: semisync_source_plugin.cc:529
unsigned long rpl_semi_sync_source_timeout
Definition: semisync_source.cc:46
unsigned long rpl_semi_sync_source_num_timeouts
bool rpl_semi_sync_source_enabled
Definition: semisync_source.cc:45
unsigned long rpl_semi_sync_source_avg_net_wait_time
Definition: semisync_source.cc:58
unsigned long rpl_semi_sync_source_yes_transactions
Definition: semisync_source.cc:49
unsigned long rpl_semi_sync_source_no_transactions
Definition: semisync_source.cc:50
unsigned long rpl_semi_sync_source_wait_sessions
Definition: semisync_source.cc:54
unsigned long rpl_semi_sync_source_wait_pos_backtraverse
Definition: semisync_source.cc:55
unsigned long rpl_semi_sync_source_timefunc_fails
Definition: semisync_source.cc:52
unsigned long long rpl_semi_sync_source_trx_wait_time
Definition: semisync_source.cc:62
unsigned long long rpl_semi_sync_source_net_wait_num
Definition: semisync_source.cc:59
PSI_memory_key key_ss_memory_TranxNodeAllocator_block
Definition: semisync_source_plugin.cc:534
PSI_stage_info stage_waiting_for_semi_sync_ack_from_replica
Definition: semisync_source_plugin.cc:523
#define BLOCK_TRANX_NODES
Definition: semisync_source.h:91
unsigned long long rpl_semi_sync_source_trx_wait_num
Definition: semisync_source.cc:57
char rpl_semi_sync_source_status
Definition: semisync_source.cc:48
unsigned long rpl_semi_sync_source_avg_trx_wait_time
Definition: semisync_source.cc:56
AckInfo is a POD.
Definition: semisync_source.h:396
void update(const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.h:420
int server_id
Definition: semisync_source.h:397
bool is_server(int server_id) const
Definition: semisync_source.h:405
unsigned long long binlog_pos
Definition: semisync_source.h:399
void clear()
Definition: semisync_source.h:403
bool less_than(const char *log_file_name, my_off_t log_file_pos) const
Definition: semisync_source.h:411
void set(int server_id, const char *log_file_name, my_off_t log_file_pos)
Definition: semisync_source.h:416
bool empty() const
Definition: semisync_source.h:404
AckInfo()
Definition: semisync_source.h:401
bool equal_to(const char *log_file_name, my_off_t log_file_pos) const
Definition: semisync_source.h:407
char binlog_name[FN_REFLEN]
Definition: semisync_source.h:398
Definition: mysql_com.h:913
Stage instrument information.
Definition: psi_stage_bits.h:74
A sequence memory which contains BLOCK_TRANX_NODES TranxNodes.
Definition: semisync_source.h:210
Block * next
Definition: semisync_source.h:211
TranxNode nodes[BLOCK_TRANX_NODES]
Definition: semisync_source.h:212
Definition: semisync_source.h:49
struct TranxNode * hash_next_
Definition: semisync_source.h:55
char log_name_[FN_REFLEN]
Definition: semisync_source.h:50
my_off_t log_pos_
Definition: semisync_source.h:51
struct TranxNode * next_
Definition: semisync_source.h:54
mysql_cond_t cond
Definition: semisync_source.h:52
int n_waiters
Definition: semisync_source.h:53
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
unsigned int uint
Definition: uca9-dump.cc:75