golden hour
/usr/include/mysql/server/private
⬆️ Go Up
Upload
File/Folder
Size
Actions
aria_backup.h
1.51 KB
Del
OK
assume_aligned.h
2.29 KB
Del
OK
atomic
-
Del
OK
authors.h
9.9 KB
Del
OK
backup.h
1.21 KB
Del
OK
bounded_queue.h
6.67 KB
Del
OK
client_settings.h
1.89 KB
Del
OK
compat56.h
2.23 KB
Del
OK
config.h
14.18 KB
Del
OK
contributors.h
4.76 KB
Del
OK
create_options.h
4.42 KB
Del
OK
custom_conf.h
1.06 KB
Del
OK
datadict.h
1.53 KB
Del
OK
debug_sync.h
2 KB
Del
OK
derived_handler.h
2.32 KB
Del
OK
derror.h
980 B
Del
OK
des_key_file.h
1.21 KB
Del
OK
discover.h
1.53 KB
Del
OK
dur_prop.h
1.06 KB
Del
OK
embedded_priv.h
1.62 KB
Del
OK
event_data_objects.h
4.09 KB
Del
OK
event_db_repository.h
3.56 KB
Del
OK
event_parse_data.h
2.83 KB
Del
OK
event_queue.h
3.36 KB
Del
OK
event_scheduler.h
3.21 KB
Del
OK
events.h
4.59 KB
Del
OK
field.h
211.96 KB
Del
OK
field_comp.h
1.15 KB
Del
OK
filesort.h
6.67 KB
Del
OK
filesort_utils.h
8 KB
Del
OK
ft_global.h
3.04 KB
Del
OK
gcalc_slicescan.h
16.87 KB
Del
OK
gcalc_tools.h
11.62 KB
Del
OK
grant.h
2.69 KB
Del
OK
group_by_handler.h
3.45 KB
Del
OK
gstream.h
2.38 KB
Del
OK
ha_partition.h
62.22 KB
Del
OK
ha_sequence.h
5.94 KB
Del
OK
handle_connections_win.h
884 B
Del
OK
handler.h
188.39 KB
Del
OK
hash.h
4.34 KB
Del
OK
hash_filo.h
5.55 KB
Del
OK
heap.h
9.2 KB
Del
OK
hostname.h
5.29 KB
Del
OK
ilist.h
6.85 KB
Del
OK
init.h
852 B
Del
OK
innodb_priv.h
1.29 KB
Del
OK
item.h
263.12 KB
Del
OK
item_cmpfunc.h
128.01 KB
Del
OK
item_create.h
11.22 KB
Del
OK
item_func.h
124.59 KB
Del
OK
item_geofunc.h
34.69 KB
Del
OK
item_jsonfunc.h
19.8 KB
Del
OK
item_row.h
5.43 KB
Del
OK
item_strfunc.h
64.55 KB
Del
OK
item_subselect.h
56.19 KB
Del
OK
item_sum.h
69.2 KB
Del
OK
item_timefunc.h
57.85 KB
Del
OK
item_vers.h
3.79 KB
Del
OK
item_windowfunc.h
32.61 KB
Del
OK
item_xmlfunc.h
4.36 KB
Del
OK
key.h
2 KB
Del
OK
keycaches.h
1.95 KB
Del
OK
lex.h
28.9 KB
Del
OK
lex_ident.h
2.07 KB
Del
OK
lex_string.h
3.97 KB
Del
OK
lex_symbol.h
1.29 KB
Del
OK
lf.h
6.31 KB
Del
OK
lock.h
2.15 KB
Del
OK
log.h
44.46 KB
Del
OK
log_event.h
178.94 KB
Del
OK
log_event_data_type.h
1.85 KB
Del
OK
log_event_old.h
19.32 KB
Del
OK
log_slow.h
1.98 KB
Del
OK
maria.h
5.73 KB
Del
OK
mariadb.h
1.25 KB
Del
OK
mdl.h
36.78 KB
Del
OK
mem_root_array.h
6.94 KB
Del
OK
message.h
1.17 KB
Del
OK
multi_range_read.h
22.58 KB
Del
OK
my_alarm.h
2.37 KB
Del
OK
my_apc.h
4.62 KB
Del
OK
my_atomic.h
7.11 KB
Del
OK
my_atomic_wrapper.h
2.92 KB
Del
OK
my_base.h
26.5 KB
Del
OK
my_bit.h
6.05 KB
Del
OK
my_bitmap.h
5.22 KB
Del
OK
my_check_opt.h
2.56 KB
Del
OK
my_compare.h
10.93 KB
Del
OK
my_context.h
6.59 KB
Del
OK
my_counter.h
1.68 KB
Del
OK
my_cpu.h
4.85 KB
Del
OK
my_crypt.h
904 B
Del
OK
my_decimal.h
13.43 KB
Del
OK
my_default.h
1.84 KB
Del
OK
my_handler_errors.h
4.74 KB
Del
OK
my_json_writer.h
17.9 KB
Del
OK
my_libwrap.h
1.16 KB
Del
OK
my_md5.h
1.45 KB
Del
OK
my_minidump.h
848 B
Del
OK
my_nosys.h
1.4 KB
Del
OK
my_rdtsc.h
8.15 KB
Del
OK
my_rnd.h
1.04 KB
Del
OK
my_service_manager.h
1.47 KB
Del
OK
my_stack_alloc.h
6.2 KB
Del
OK
my_stacktrace.h
3.14 KB
Del
OK
my_time.h
10.22 KB
Del
OK
my_tree.h
3.9 KB
Del
OK
my_uctype.h
67.9 KB
Del
OK
my_user.h
1.1 KB
Del
OK
myisam.h
17.11 KB
Del
OK
myisamchk.h
4.61 KB
Del
OK
myisammrg.h
4.78 KB
Del
OK
myisampack.h
14.58 KB
Del
OK
mysql_async.h
1.77 KB
Del
OK
mysqld.h
38.7 KB
Del
OK
mysqld_default_groups.h
204 B
Del
OK
mysqld_suffix.h
1.17 KB
Del
OK
mysys_err.h
2.95 KB
Del
OK
nt_servc.h
2.94 KB
Del
OK
opt_range.h
57.58 KB
Del
OK
opt_subselect.h
14.21 KB
Del
OK
opt_trace.h
8.11 KB
Del
OK
opt_trace_context.h
3.21 KB
Del
OK
parse_file.h
4.11 KB
Del
OK
partition_element.h
5.09 KB
Del
OK
partition_info.h
18.85 KB
Del
OK
password.h
1.14 KB
Del
OK
pfs_file_provider.h
3.08 KB
Del
OK
pfs_idle_provider.h
1.35 KB
Del
OK
pfs_memory_provider.h
1.59 KB
Del
OK
pfs_metadata_provider.h
1.85 KB
Del
OK
pfs_socket_provider.h
2.21 KB
Del
OK
pfs_stage_provider.h
1.52 KB
Del
OK
pfs_statement_provider.h
4.25 KB
Del
OK
pfs_table_provider.h
2.56 KB
Del
OK
pfs_thread_provider.h
5.43 KB
Del
OK
pfs_transaction_provider.h
2.78 KB
Del
OK
privilege.h
27.9 KB
Del
OK
probes_mysql.h
973 B
Del
OK
probes_mysql_dtrace.h
32.23 KB
Del
OK
probes_mysql_nodtrace.h
4.89 KB
Del
OK
procedure.h
6.57 KB
Del
OK
protocol.h
12.32 KB
Del
OK
proxy_protocol.h
548 B
Del
OK
queues.h
3.46 KB
Del
OK
records.h
3.03 KB
Del
OK
repl_failsafe.h
1.55 KB
Del
OK
replication.h
15.73 KB
Del
OK
rijndael.h
1.67 KB
Del
OK
rowid_filter.h
15.13 KB
Del
OK
rpl_constants.h
3.28 KB
Del
OK
rpl_filter.h
4.43 KB
Del
OK
rpl_gtid.h
13.31 KB
Del
OK
rpl_injector.h
9.43 KB
Del
OK
rpl_mi.h
13.65 KB
Del
OK
rpl_parallel.h
13.57 KB
Del
OK
rpl_record.h
1.55 KB
Del
OK
rpl_record_old.h
1.37 KB
Del
OK
rpl_reporting.h
2.96 KB
Del
OK
rpl_rli.h
31.8 KB
Del
OK
rpl_tblmap.h
3.1 KB
Del
OK
rpl_utility.h
9.4 KB
Del
OK
scheduler.h
2.99 KB
Del
OK
scope.h
1.76 KB
Del
OK
select_handler.h
2.18 KB
Del
OK
semisync.h
2.23 KB
Del
OK
semisync_master.h
22.7 KB
Del
OK
semisync_master_ack_receiver.h
5.73 KB
Del
OK
semisync_slave.h
3.47 KB
Del
OK
service_versions.h
2 KB
Del
OK
session_tracker.h
13.96 KB
Del
OK
set_var.h
16.1 KB
Del
OK
slave.h
11.99 KB
Del
OK
source_revision.h
67 B
Del
OK
sp.h
22.02 KB
Del
OK
sp_cache.h
2 KB
Del
OK
sp_head.h
63.05 KB
Del
OK
sp_pcontext.h
24.31 KB
Del
OK
sp_rcontext.h
14 KB
Del
OK
span.h
3.84 KB
Del
OK
spatial.h
21.82 KB
Del
OK
sql_acl.h
13.8 KB
Del
OK
sql_admin.h
2.78 KB
Del
OK
sql_alloc.h
1.83 KB
Del
OK
sql_alter.h
11.86 KB
Del
OK
sql_analyse.h
11.23 KB
Del
OK
sql_analyze_stmt.h
11.48 KB
Del
OK
sql_array.h
6.79 KB
Del
OK
sql_audit.h
13.62 KB
Del
OK
sql_base.h
24.83 KB
Del
OK
sql_basic_types.h
9.28 KB
Del
OK
sql_binlog.h
895 B
Del
OK
sql_bitmap.h
7.66 KB
Del
OK
sql_bootstrap.h
1.63 KB
Del
OK
sql_cache.h
21.15 KB
Del
OK
sql_callback.h
1.51 KB
Del
OK
sql_class.h
250.08 KB
Del
OK
sql_cmd.h
9.13 KB
Del
OK
sql_connect.h
3.99 KB
Del
OK
sql_const.h
10.94 KB
Del
OK
sql_crypt.h
1.4 KB
Del
OK
sql_cte.h
16.15 KB
Del
OK
sql_cursor.h
2.26 KB
Del
OK
sql_db.h
2.16 KB
Del
OK
sql_debug.h
4.65 KB
Del
OK
sql_delete.h
1.31 KB
Del
OK
sql_derived.h
1.26 KB
Del
OK
sql_digest.h
3.73 KB
Del
OK
sql_digest_stream.h
1.53 KB
Del
OK
sql_do.h
954 B
Del
OK
sql_error.h
38.12 KB
Del
OK
sql_explain.h
27.1 KB
Del
OK
sql_expression_cache.h
4.26 KB
Del
OK
sql_get_diagnostics.h
7.68 KB
Del
OK
sql_handler.h
2.84 KB
Del
OK
sql_help.h
920 B
Del
OK
sql_hset.h
3.56 KB
Del
OK
sql_i_s.h
7.97 KB
Del
OK
sql_insert.h
2.39 KB
Del
OK
sql_join_cache.h
47.44 KB
Del
OK
sql_lex.h
166.31 KB
Del
OK
sql_lifo_buffer.h
9.45 KB
Del
OK
sql_limit.h
2.38 KB
Del
OK
sql_list.h
21.56 KB
Del
OK
sql_load.h
1.25 KB
Del
OK
sql_locale.h
2.64 KB
Del
OK
sql_manager.h
960 B
Del
OK
sql_mode.h
6.58 KB
Del
OK
sql_parse.h
8.26 KB
Del
OK
sql_partition.h
11.75 KB
Del
OK
sql_partition_admin.h
5.8 KB
Del
OK
sql_plist.h
7.55 KB
Del
OK
sql_plugin.h
7.39 KB
Del
OK
sql_plugin_compat.h
2.18 KB
Del
OK
sql_prepare.h
11.14 KB
Del
OK
sql_priv.h
17.67 KB
Del
OK
sql_profile.h
7.63 KB
Del
OK
sql_reload.h
1.01 KB
Del
OK
sql_rename.h
982 B
Del
OK
sql_repl.h
2.96 KB
Del
OK
sql_schema.h
3.23 KB
Del
OK
sql_select.h
86.56 KB
Del
OK
sql_sequence.h
5.06 KB
Del
OK
sql_servers.h
1.74 KB
Del
OK
sql_show.h
9.39 KB
Del
OK
sql_signal.h
3.28 KB
Del
OK
sql_sort.h
21.39 KB
Del
OK
sql_statistics.h
11.96 KB
Del
OK
sql_string.h
36.43 KB
Del
OK
sql_table.h
11.07 KB
Del
OK
sql_tablespace.h
956 B
Del
OK
sql_test.h
1.55 KB
Del
OK
sql_time.h
8.18 KB
Del
OK
sql_trigger.h
10.76 KB
Del
OK
sql_truncate.h
2.03 KB
Del
OK
sql_tvc.h
2.36 KB
Del
OK
sql_type.h
286 KB
Del
OK
sql_type_geom.h
18.53 KB
Del
OK
sql_type_int.h
9.73 KB
Del
OK
sql_type_json.h
6 KB
Del
OK
sql_type_real.h
1.23 KB
Del
OK
sql_type_string.h
1.59 KB
Del
OK
sql_udf.h
4.74 KB
Del
OK
sql_union.h
1.04 KB
Del
OK
sql_update.h
1.88 KB
Del
OK
sql_view.h
2.33 KB
Del
OK
sql_window.h
6.65 KB
Del
OK
ssl_compat.h
3.07 KB
Del
OK
strfunc.h
2.22 KB
Del
OK
structs.h
25.13 KB
Del
OK
sys_vars_shared.h
2.67 KB
Del
OK
t_ctype.h
5.51 KB
Del
OK
table.h
112.29 KB
Del
OK
table_cache.h
4.13 KB
Del
OK
thr_alarm.h
2.87 KB
Del
OK
thr_lock.h
6.7 KB
Del
OK
thr_malloc.h
1.17 KB
Del
OK
thr_timer.h
1.53 KB
Del
OK
thread_cache.h
5.77 KB
Del
OK
thread_pool_priv.h
4 KB
Del
OK
threadpool.h
4.51 KB
Del
OK
threadpool_generic.h
3.83 KB
Del
OK
transaction.h
1.43 KB
Del
OK
tzfile.h
4.9 KB
Del
OK
tztime.h
3.32 KB
Del
OK
uniques.h
4.1 KB
Del
OK
unireg.h
7.43 KB
Del
OK
vers_string.h
2.47 KB
Del
OK
violite.h
9.71 KB
Del
OK
waiting_threads.h
4.43 KB
Del
OK
welcome_copyright_notice.h
1.19 KB
Del
OK
win_tzname_data.h
6.35 KB
Del
OK
winservice.h
1.17 KB
Del
OK
wqueue.h
1.53 KB
Del
OK
wsrep.h
3.23 KB
Del
OK
wsrep_applier.h
2.64 KB
Del
OK
wsrep_binlog.h
3.36 KB
Del
OK
wsrep_client_service.h
2.5 KB
Del
OK
wsrep_client_state.h
1.53 KB
Del
OK
wsrep_condition_variable.h
1.45 KB
Del
OK
wsrep_high_priority_service.h
4.8 KB
Del
OK
wsrep_mutex.h
1.19 KB
Del
OK
wsrep_mysqld.h
19.88 KB
Del
OK
wsrep_mysqld_c.h
1.2 KB
Del
OK
wsrep_on.h
1.68 KB
Del
OK
wsrep_priv.h
1.6 KB
Del
OK
wsrep_schema.h
4.54 KB
Del
OK
wsrep_server_service.h
3.55 KB
Del
OK
wsrep_server_state.h
2.23 KB
Del
OK
wsrep_sst.h
3.86 KB
Del
OK
wsrep_storage_service.h
1.77 KB
Del
OK
wsrep_thd.h
10.58 KB
Del
OK
wsrep_trans_observer.h
17.81 KB
Del
OK
wsrep_types.h
997 B
Del
OK
wsrep_utils.h
9.07 KB
Del
OK
wsrep_var.h
4.17 KB
Del
OK
wsrep_xid.h
1.42 KB
Del
OK
xa.h
1.69 KB
Del
OK
Edit: semisync_master.h
/* Copyright (C) 2007 Google Inc. Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc. Use is subject to license terms. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SEMISYNC_MASTER_H #define SEMISYNC_MASTER_H #include "semisync.h" #include "semisync_master_ack_receiver.h" #ifdef HAVE_PSI_INTERFACE extern PSI_mutex_key key_LOCK_rpl_semi_sync_master_enabled; extern PSI_mutex_key key_LOCK_binlog; extern PSI_cond_key key_COND_binlog_send; #endif struct Tranx_node { char log_name[FN_REFLEN]; my_off_t log_pos; struct Tranx_node *next; /* the next node in the sorted list */ struct Tranx_node *hash_next; /* the next node during hash collision */ }; /** @class Tranx_node_allocator This class provides memory allocating and freeing methods for Tranx_node. The main target is performance. @section ALLOCATE How to allocate a node The pointer of the first node after 'last_node' in current_block is returned. current_block will move to the next free Block when all nodes of it are in use. A new Block is allocated and is put into the rear of the Block link table if no Block is free. The list starts up empty (ie, there is no allocated Block). After some nodes are freed, there probably are some free nodes before the sequence of the allocated nodes, but we do not reuse it. It is better to keep the allocated nodes are in the sequence, for it is more efficient for allocating and freeing Tranx_node. @section FREENODE How to free nodes There are two methods for freeing nodes. They are free_all_nodes and free_nodes_before. 'A Block is free' means all of its nodes are free. @subsection free_nodes_before As all allocated nodes are in the sequence, 'Before one node' means all nodes before given node in the same Block and all Blocks before the Block which containing the given node. As such, all Blocks before the given one ('node') are free Block and moved into the rear of the Block link table. The Block containing the given 'node', however, is not. For at least the given 'node' is still in use. This will waste at most one Block, but it is more efficient. */ #define BLOCK_TRANX_NODES 16 class Tranx_node_allocator { public: /** @param reserved_nodes The number of reserved Tranx_nodes. It is used to set 'reserved_blocks' which can contain at least 'reserved_nodes' number of Tranx_nodes. When freeing memory, we will reserve at least reserved_blocks of Blocks not freed. */ Tranx_node_allocator(uint reserved_nodes) : reserved_blocks(reserved_nodes/BLOCK_TRANX_NODES + (reserved_nodes%BLOCK_TRANX_NODES > 1 ? 2 : 1)), first_block(NULL), last_block(NULL), current_block(NULL), last_node(-1), block_num(0) {} ~Tranx_node_allocator() { Block *block= first_block; while (block != NULL) { Block *next= block->next; free_block(block); block= next; } } /** The pointer of the first node after 'last_node' in current_block is returned. current_block will move to the next free Block when all nodes of it are in use. A new Block is allocated and is put into the rear of the Block link table if no Block is free. @return Return a Tranx_node *, or NULL if an error occurred. */ Tranx_node *allocate_node() { Tranx_node *trx_node; Block *block= current_block; if (last_node == BLOCK_TRANX_NODES-1) { current_block= current_block->next; last_node= -1; } if (current_block == NULL && allocate_block()) { current_block= block; if (current_block) last_node= BLOCK_TRANX_NODES-1; return NULL; } trx_node= &(current_block->nodes[++last_node]); trx_node->log_name[0] = '\0'; trx_node->log_pos= 0; trx_node->next= 0; trx_node->hash_next= 0; return trx_node; } /** All nodes are freed. @return Return 0, or 1 if an error occurred. */ int free_all_nodes() { current_block= first_block; last_node= -1; free_blocks(); return 0; } /** All Blocks before the given 'node' are free Block and moved into the rear of the Block link table. @param node All nodes before 'node' will be freed @return Return 0, or 1 if an error occurred. */ int free_nodes_before(Tranx_node* node) { Block *block; Block *prev_block= NULL; block= first_block; while (block != current_block->next) { /* Find the Block containing the given node */ if (&(block->nodes[0]) <= node && &(block->nodes[BLOCK_TRANX_NODES]) >= node) { /* All Blocks before the given node are put into the rear */ if (first_block != block) { last_block->next= first_block; first_block= block; last_block= prev_block; last_block->next= NULL; free_blocks(); } return 0; } prev_block= block; block= block->next; } /* Node does not find should never happen */ DBUG_ASSERT(0); return 1; } private: uint reserved_blocks; /** A sequence memory which contains BLOCK_TRANX_NODES Tranx_nodes. BLOCK_TRANX_NODES The number of Tranx_nodes which are in a Block. next Every Block has a 'next' pointer which points to the next Block. These linking Blocks constitute a Block link table. */ struct Block { Block *next; Tranx_node nodes[BLOCK_TRANX_NODES]; }; /** The 'first_block' is the head of the Block link table; */ Block *first_block; /** The 'last_block' is the rear of the Block link table; */ Block *last_block; /** current_block always points the Block in the Block link table in which the last allocated node is. The Blocks before it are all in use and the Blocks after it are all free. */ Block *current_block; /** It always points to the last node which has been allocated in the current_block. */ int last_node; /** How many Blocks are in the Block link table. */ uint block_num; /** Allocate a block and then assign it to current_block. */ int allocate_block() { Block *block= (Block *)my_malloc(PSI_INSTRUMENT_ME, sizeof(Block), MYF(0)); if (block) { block->next= NULL; if (first_block == NULL) first_block= block; else last_block->next= block; /* New Block is always put into the rear */ last_block= block; /* New Block is always the current_block */ current_block= block; ++block_num; return 0; } return 1; } /** Free a given Block. @param block The Block will be freed. */ void free_block(Block *block) { my_free(block); --block_num; } /** If there are some free Blocks and the total number of the Blocks in the Block link table is larger than the 'reserved_blocks', Some free Blocks will be freed until the total number of the Blocks is equal to the 'reserved_blocks' or there is only one free Block behind the 'current_block'. */ void free_blocks() { if (current_block == NULL || current_block->next == NULL) return; /* One free Block is always kept behind the current block */ Block *block= current_block->next->next; while (block_num > reserved_blocks && block != NULL) { Block *next= block->next; free_block(block); block= next; } current_block->next->next= block; if (block == NULL) last_block= current_block->next; } }; /** This class manages memory for active transaction list. We record each active transaction with a Tranx_node, each session can have only one open transaction. Because of EVENT, the total active transaction nodes can exceed the maximum allowed connections. */ class Active_tranx :public Trace { private: Tranx_node_allocator m_allocator; /* These two record the active transaction list in sort order. */ Tranx_node *m_trx_front, *m_trx_rear; Tranx_node **m_trx_htb; /* A hash table on active transactions. */ int m_num_entries; /* maximum hash table entries */ mysql_mutex_t *m_lock; /* mutex lock */ inline void assert_lock_owner(); inline unsigned int calc_hash(const unsigned char *key, size_t length); unsigned int get_hash_value(const char *log_file_name, my_off_t log_file_pos); int compare(const char *log_file_name1, my_off_t log_file_pos1, const Tranx_node *node2) { return compare(log_file_name1, log_file_pos1, node2->log_name, node2->log_pos); } int compare(const Tranx_node *node1, const char *log_file_name2, my_off_t log_file_pos2) { return compare(node1->log_name, node1->log_pos, log_file_name2, log_file_pos2); } int compare(const Tranx_node *node1, const Tranx_node *node2) { return compare(node1->log_name, node1->log_pos, node2->log_name, node2->log_pos); } public: Active_tranx(mysql_mutex_t *lock, unsigned long trace_level); ~Active_tranx(); /* Insert an active transaction node with the specified position. * * Return: * 0: success; non-zero: error */ int insert_tranx_node(const char *log_file_name, my_off_t log_file_pos); /* Clear the active transaction nodes until(inclusive) the specified * position. * If log_file_name is NULL, everything will be cleared: the sorted * list and the hash table will be reset to empty. */ void clear_active_tranx_nodes(const char *log_file_name, my_off_t log_file_pos); /* Given a position, check to see whether the position is an active * transaction's ending position by probing the hash table. */ bool is_tranx_end_pos(const char *log_file_name, my_off_t log_file_pos); /* Given two binlog positions, compare which one is bigger based on * (file_name, file_position). */ static int compare(const char *log_file_name1, my_off_t log_file_pos1, const char *log_file_name2, my_off_t log_file_pos2); }; /** The extension class for the master of semi-synchronous replication */ class Repl_semi_sync_master :public Repl_semi_sync_base { Active_tranx *m_active_tranxs; /* active transaction list: the list will be cleared when semi-sync switches off. */ /* True when init_object has been called */ bool m_init_done; /* This cond variable is signaled when enough binlog has been sent to slave, * so that a waiting trx can return the 'ok' to the client for a commit. */ mysql_cond_t COND_binlog_send; /* Mutex that protects the following state variables and the active * transaction list. * Under no cirumstances we can acquire mysql_bin_log.LOCK_log if we are * already holding m_LOCK_binlog because it can cause deadlocks. */ mysql_mutex_t LOCK_binlog; /* This is set to true when m_reply_file_name contains meaningful data. */ bool m_reply_file_name_inited; /* The binlog name up to which we have received replies from any slaves. */ char m_reply_file_name[FN_REFLEN]; /* The position in that file up to which we have the reply from any slaves. */ my_off_t m_reply_file_pos; /* This is set to true when we know the 'smallest' wait position. */ bool m_wait_file_name_inited; /* NULL, or the 'smallest' filename that a transaction is waiting for * slave replies. */ char m_wait_file_name[FN_REFLEN]; /* The smallest position in that file that a trx is waiting for: the trx * can proceed and send an 'ok' to the client when the master has got the * reply from the slave indicating that it already got the binlog events. */ my_off_t m_wait_file_pos; /* This is set to true when we know the 'largest' transaction commit * position in the binlog file. * We always maintain the position no matter whether semi-sync is switched * on switched off. When a transaction wait timeout occurs, semi-sync will * switch off. Binlog-dump thread can use the three fields to detect when * slaves catch up on replication so that semi-sync can switch on again. */ bool m_commit_file_name_inited; /* The 'largest' binlog filename that a commit transaction is seeing. */ char m_commit_file_name[FN_REFLEN]; /* The 'largest' position in that file that a commit transaction is seeing. */ my_off_t m_commit_file_pos; /* All global variables which can be set by parameters. */ volatile bool m_master_enabled; /* semi-sync is enabled on the master */ unsigned long m_wait_timeout; /* timeout period(ms) during tranx wait */ bool m_state; /* whether semi-sync is switched */ /*Waiting for ACK before/after innodb commit*/ ulong m_wait_point; void lock(); void unlock(); void cond_broadcast(); int cond_timewait(struct timespec *wait_time); /* Is semi-sync replication on? */ bool is_on() { return (m_state); } void set_master_enabled(bool enabled) { m_master_enabled = enabled; } /* Switch semi-sync off because of timeout in transaction waiting. */ void switch_off(); /* Switch semi-sync on when slaves catch up. */ int try_switch_on(int server_id, const char *log_file_name, my_off_t log_file_pos); public: Repl_semi_sync_master(); ~Repl_semi_sync_master() = default; void cleanup(); bool get_master_enabled() { return m_master_enabled; } void set_trace_level(unsigned long trace_level) { m_trace_level = trace_level; if (m_active_tranxs) m_active_tranxs->m_trace_level = trace_level; } /* Set the transaction wait timeout period, in milliseconds. */ void set_wait_timeout(unsigned long wait_timeout) { m_wait_timeout = wait_timeout; } int sync_get_master_wait_sessions(); /* Calculates a timeout that is m_wait_timeout after start_arg and saves it in out. If start_arg is NULL, the timeout is m_wait_timeout after the current system time. */ void create_timeout(struct timespec *out, struct timespec *start_arg); /* Blocks the calling thread until the ack_receiver either receives an ACK or times out (from rpl_semi_sync_master_timeout) */ void await_slave_reply(); /*set the ACK point, after binlog sync or after transaction commit*/ void set_wait_point(unsigned long ack_point) { m_wait_point = ack_point; } ulong wait_point() //no cover line { return m_wait_point; //no cover line } /* Initialize this class after MySQL parameters are initialized. this * function should be called once at bootstrap time. */ int init_object(); /* Enable the object to enable semi-sync replication inside the master. */ int enable_master(); /* Disable the object to disable semi-sync replication inside the master. */ void disable_master(); /* Add a semi-sync replication slave */ void add_slave(); /* Remove a semi-sync replication slave */ void remove_slave(); /* It parses a reply packet and call report_reply_binlog to handle it. */ int report_reply_packet(uint32 server_id, const uchar *packet, ulong packet_len); /* In semi-sync replication, reports up to which binlog position we have * received replies from the slave indicating that it already get the events. * * Input: * server_id - (IN) master server id number * log_file_name - (IN) binlog file name * end_offset - (IN) the offset in the binlog file up to which we have * the replies from the slave * * Return: * 0: success; non-zero: error */ int report_reply_binlog(uint32 server_id, const char* log_file_name, my_off_t end_offset); /* Commit a transaction in the final step. This function is called from * InnoDB before returning from the low commit. If semi-sync is switch on, * the function will wait to see whether binlog-dump thread get the reply for * the events of the transaction. Remember that this is not a direct wait, * instead, it waits to see whether the binlog-dump thread has reached the * point. If the wait times out, semi-sync status will be switched off and * all other transaction would not wait either. * * Input: (the transaction events' ending binlog position) * trx_wait_binlog_name - (IN) ending position's file name * trx_wait_binlog_pos - (IN) ending position's file offset * * Return: * 0: success; non-zero: error */ int commit_trx(const char* trx_wait_binlog_name, my_off_t trx_wait_binlog_pos); /*Wait for ACK after writing/sync binlog to file*/ int wait_after_sync(const char* log_file, my_off_t log_pos); /*Wait for ACK after commting the transaction*/ int wait_after_commit(THD* thd, bool all); /*Wait after the transaction is rollback*/ int wait_after_rollback(THD *thd, bool all); /*Store the current binlog position in m_active_tranxs. This position should * be acked by slave*/ int report_binlog_update(THD *thd, const char *log_file,my_off_t log_pos); int dump_start(THD* thd, const char *log_file, my_off_t log_pos); void dump_end(THD* thd); /* Reserve space in the replication event packet header: * . slave semi-sync off: 1 byte - (0) * . slave semi-sync on: 3 byte - (0, 0xef, 0/1} * * Input: * packet - (IN) the header buffer * * Return: * size of the bytes reserved for header */ int reserve_sync_header(String* packet); /* Update the sync bit in the packet header to indicate to the slave whether * the master will wait for the reply of the event. If semi-sync is switched * off and we detect that the slave is catching up, we switch semi-sync on. * * Input: * THD - (IN) current dump thread * packet - (IN) the packet containing the replication event * log_file_name - (IN) the event ending position's file name * log_file_pos - (IN) the event ending position's file offset * need_sync - (IN) identify if flush_net is needed to call. * server_id - (IN) master server id number * * Return: * 0: success; non-zero: error */ int update_sync_header(THD* thd, unsigned char *packet, const char *log_file_name, my_off_t log_file_pos, bool* need_sync); /* Called when a transaction finished writing binlog events. * . update the 'largest' transactions' binlog event position * . insert the ending position in the active transaction list if * semi-sync is on * * Input: (the transaction events' ending binlog position) * log_file_name - (IN) transaction ending position's file name * log_file_pos - (IN) transaction ending position's file offset * * Return: * 0: success; non-zero: error */ int write_tranx_in_binlog(const char* log_file_name, my_off_t log_file_pos); /* Read the slave's reply so that we know how much progress the slave makes * on receive replication events. */ int flush_net(THD* thd, const char *event_buf); /* Export internal statistics for semi-sync replication. */ void set_export_stats(); /* 'reset master' command is issued from the user and semi-sync need to * go off for that. */ int after_reset_master(); /*called before reset master*/ int before_reset_master(); void check_and_switch(); /* Determines if the given thread is currently awaiting a semisync_ack. Note that the thread's value is protected by this class's LOCK_binlog, so this function (indirectly) provides safe access. */ my_bool is_thd_awaiting_semisync_ack(THD *thd) { lock(); my_bool ret= thd->is_awaiting_semisync_ack; unlock(); return ret; } /* Update the thread's value for is_awaiting_semisync_ack. LOCK_binlog (from this class) should be acquired before calling this function. */ void set_thd_awaiting_semisync_ack(THD *thd, my_bool _is_awaiting_semisync_ack) { mysql_mutex_assert_owner(&LOCK_binlog); thd->is_awaiting_semisync_ack= _is_awaiting_semisync_ack; } mysql_mutex_t LOCK_rpl_semi_sync_master_enabled; }; enum rpl_semi_sync_master_wait_point_t { SEMI_SYNC_MASTER_WAIT_POINT_AFTER_BINLOG_SYNC, SEMI_SYNC_MASTER_WAIT_POINT_AFTER_STORAGE_COMMIT, }; extern Repl_semi_sync_master repl_semisync_master; extern Ack_receiver ack_receiver; /* System and status variables for the master component */ extern my_bool rpl_semi_sync_master_enabled; extern my_bool rpl_semi_sync_master_status; extern ulong rpl_semi_sync_master_wait_point; extern ulong rpl_semi_sync_master_clients; extern ulong rpl_semi_sync_master_timeout; extern ulong rpl_semi_sync_master_trace_level; extern ulong rpl_semi_sync_master_yes_transactions; extern ulong rpl_semi_sync_master_no_transactions; extern ulong rpl_semi_sync_master_off_times; extern ulong rpl_semi_sync_master_wait_timeouts; extern ulong rpl_semi_sync_master_timefunc_fails; extern ulong rpl_semi_sync_master_num_timeouts; extern ulong rpl_semi_sync_master_wait_sessions; extern ulong rpl_semi_sync_master_wait_pos_backtraverse; extern ulong rpl_semi_sync_master_avg_trx_wait_time; extern ulong rpl_semi_sync_master_avg_net_wait_time; extern ulonglong rpl_semi_sync_master_net_wait_num; extern ulonglong rpl_semi_sync_master_trx_wait_num; extern ulonglong rpl_semi_sync_master_net_wait_time; extern ulonglong rpl_semi_sync_master_trx_wait_time; extern unsigned long long rpl_semi_sync_master_request_ack; extern unsigned long long rpl_semi_sync_master_get_ack; /* This indicates whether we should keep waiting if no semi-sync slave is available. 0 : stop waiting if detected no avaialable semi-sync slave. 1 (default) : keep waiting until timeout even no available semi-sync slave. */ extern char rpl_semi_sync_master_wait_no_slave; extern Repl_semi_sync_master repl_semisync_master; extern PSI_stage_info stage_waiting_for_semi_sync_ack_from_slave; extern PSI_stage_info stage_reading_semi_sync_ack; extern PSI_stage_info stage_waiting_for_semi_sync_slave; void semi_sync_master_deinit(); #endif /* SEMISYNC_MASTER_H */
Save