MySQL 8.0.32
Source Code Documentation
rpl_replica.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2022, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef RPL_REPLICA_H
24#define RPL_REPLICA_H
25
26#include <limits.h>
27#include <sys/types.h>
28#include <atomic>
29
30#include "m_string.h"
31#include "my_bitmap.h"
32#include "my_dbug.h"
33#include "my_inttypes.h"
34#include "my_psi_config.h"
35#include "my_thread.h" // my_start_routine
36#include "mysql.h" // MYSQL
38#include "mysql_com.h"
40#include "sql/current_thd.h"
41#include "sql/debug_sync.h"
42
43class Master_info;
44class Relay_log_info;
45class THD;
46struct LEX_MASTER_INFO;
47struct mysql_cond_t;
48struct mysql_mutex_t;
50
52
53typedef enum {
59
60/**
61 MASTER_DELAY can be at most (1 << 31) - 1.
62*/
63#define MASTER_DELAY_MAX (0x7FFFFFFF)
64#if INT_MAX < 0x7FFFFFFF
65#error "don't support platforms where INT_MAX < 0x7FFFFFFF"
66#endif
67
68/**
69 @defgroup Replication Replication
70 @{
71
72 @file
73*/
74
75/**
76 Some of defines are need in parser even though replication is not
77 compiled in (embedded).
78*/
79
80/**
81 The maximum is defined as (ULONG_MAX/1000) with 4 bytes ulong
82*/
83#define SLAVE_MAX_HEARTBEAT_PERIOD 4294967
84
85#define REPLICA_NET_TIMEOUT 60
86
87#define MAX_SLAVE_ERROR 14000
88
89#define MTS_WORKER_UNDEF ((ulong)-1)
90#define MTS_MAX_WORKERS 1024
91#define MAX_SLAVE_RETRY_PAUSE 5
92
93/*
94 When using tables to store the slave workers bitmaps,
95 we use a BLOB field. The maximum size of a BLOB is:
96
97 2^16-1 = 65535 bytes => (2^16-1) * 8 = 524280 bits
98*/
99#define MTS_MAX_BITS_IN_GROUP ((1L << 19) - 8) /* 524280 */
100
101extern bool server_id_supplied;
102
103/*****************************************************************************
104
105 MySQL Replication
106
107 Replication is implemented via two types of threads:
108
109 I/O Thread - One of these threads is started for each master server.
110 They maintain a connection to their master server, read log
111 events from the master as they arrive, and queues them into
112 a single, shared relay log file. A Master_info represents
113 each of these threads.
114
115 SQL Thread - One of these threads is started and reads from the relay log
116 file, executing each event. A Relay_log_info represents this
117 thread.
118
119 Buffering in the relay log file makes it unnecessary to reread events from
120 a master server across a slave restart. It also decouples the slave from
121 the master where long-running updates and event logging are concerned--ie
122 it can continue to log new events while a slow query executes on the slave.
123
124*****************************************************************************/
125
126/*
127 # MUTEXES in replication #
128
129 JAG: TODO: This guide needs to be updated after pushing WL#10406!
130
131 ## In Multisource_info (channel_map) ##
132
133 ### m_channel_map_lock ###
134
135 This rwlock is used to protect the multi source replication data structure
136 (channel_map). Any operation reading contents from the channel_map should
137 hold the rdlock during the operation. Any operation changing the
138 channel_map (either adding/removing channels to/from the channel_map)
139 should hold the wrlock during the operation.
140
141 [init_replica() does not need it it's called early].
142
143 ## In Master_info (mi) ##
144
145 ### m_channel_lock ###
146
147 It is used to SERIALIZE ALL administrative commands of replication: START
148 SLAVE, STOP SLAVE, CHANGE MASTER, RESET SLAVE, delete_slave_info_objects
149 (when mysqld stops)
150
151 This thus protects us against a handful of deadlocks, being the know ones
152 around lock_slave_threads and the mixed order they are acquired in some
153 operations:
154
155 + consider start_slave_thread() which, when starting the I/O thread,
156 releases mi->run_lock, keeps rli->run_lock, and tries to re-acquire
157 mi->run_lock.
158
159 + Same applies to stop_slave() where a stop of the I/O thread will
160 mi->run_lock, keeps rli->run_lock, and tries to re-acquire mi->run_lock.
161 For the SQL thread, the order is the opposite.
162
163 ### run_lock ###
164
165 Protects all information about the running state: slave_running, thd
166 and the existence of the I/O thread itself (to stop/start it, you need
167 this mutex).
168 Check the above m_channel_lock about locking order.
169
170 ### data_lock ###
171
172 Protects some moving members of the struct: counters (log name,
173 position).
174
175 ### sid_lock ###
176
177 Protects the retrieved GTID set and it's SID map from updates.
178
179 ## In Relay_log_info (rli) ##
180
181 ### run_lock ###
182
183 Same as Master_info's one. However, note that run_lock does not protect
184 Relay_log_info.run_state. That is protected by data_lock.
185 Check the above m_channel_lock about locking order.
186
187 ### data_lock ###
188
189 Protects some moving members of the struct: counters (log name,
190 position).
191
192 ## In MYSQL_BIN_LOG (mysql_bin_log,relay_log) ##
193
194 ### LOCK_log ###
195
196 This mutex should be taken when going to write to a log file. Notice that it
197 does not prevent other threads from reading from the file being written (the
198 "hot" file) or any other older file.
199
200 ### LOCK_index ###
201
202 This mutex should be taken when going to create/delete a log file (as those
203 operations will update the .index file).
204
205 ### LOCK_binlog_end_pos ###
206
207 This mutex protects the access to the binlog_end_pos variable. The variable
208 it set with the position that other threads reading from the currently active
209 log file (the "hot" one) should not cross.
210
211 ## Gtid_state (gtid_state, global_sid_map) ##
212
213 ### global_sid_lock ###
214
215 Protects all Gtid_state GTID sets (lost_gtids, executed_gtids,
216 gtids_only_in_table, previous_gtids_logged, owned_gtids) and the global SID
217 map from updates.
218
219 The global_sid_lock must not be taken after LOCK_reset_gtid_table.
220
221 ## Gtid_mode (gtid_mode) ##
222
223 ### Gtid_mode::lock ###
224
225 Used to arbitrate changes on server Gtid_mode.
226
227 # Order of acquisition #
228
229 Here, we list most major functions that acquire multiple locks.
230
231 Notation: For each function, we list the locks it takes, in the
232 order it takes them. If a function holds lock A while taking lock
233 B, then we write "A, B". If a function locks A, unlocks A, then
234 locks B, then we write "A | B". If function F1 invokes function F2,
235 then we write F2's name in parentheses in the list of locks for F1.
236
237 Sys_var_gtid_mode::global_update:
238 Gtid_mode::lock.wrlock, channel_map->wrlock, binlog.LOCK_log,
239 global_sid_lock->wrlock
240
241 change_master_cmd:
242 channel_map.wrlock, (change_master)
243
244 change_master:
245 mi.channel_wrlock, mi.run_lock, rli.run_lock, (global_init_info),
246 (purge_relay_logs), (init_relay_log_pos), rli.err_lock
247
248 global_init_info:
249 mi.data_lock, rli.data_lock
250
251 purge_relay_logs:
252 rli.data_lock, (relay_log.reset_logs)
253
254 relay_log.reset_logs:
255 .LOCK_log, .LOCK_index, .sid_lock->wrlock
256
257 init_relay_log_pos:
258 rli.data_lock
259
260 queue_event:
261 rli.LOCK_log, relay_log.sid_lock->rdlock, mi.data_lock
262
263 stop_slave:
264 channel_map rdlock,
265 ( mi.channel_wrlock, mi.run_lock, thd.LOCK_thd_data
266 | rli.run_lock, thd.LOCK_thd_data
267 | relay.LOCK_log
268 )
269
270 start_slave:
271 mi.channel_wrlock, mi.run_lock, rli.run_lock, rli.data_lock,
272 global_sid_lock->wrlock
273
274 mysql_bin_log.reset_logs:
275 .LOCK_log, .LOCK_index, global_sid_lock->wrlock
276
277 purge_relay_logs:
278 rli.data_lock, (relay.reset_logs) THD::LOCK_thd_data,
279 relay.LOCK_log, relay.LOCK_index, global_sid_lock->wrlock
280
281 reset_master:
282 (binlog.reset_logs) THD::LOCK_thd_data, binlog.LOCK_log,
283 binlog.LOCK_index, global_sid_lock->wrlock, LOCK_reset_gtid_table
284
285 reset_slave:
286 mi.channel_wrlock, mi.run_lock, rli.run_lock, (purge_relay_logs)
287 rli.data_lock, THD::LOCK_thd_data, relay.LOCK_log, relay.LOCK_index,
288 global_sid_lock->wrlock
289
290 purge_logs:
291 .LOCK_index, LOCK_thd_list, thd.linfo.lock
292
293 [Note: purge_logs contains a known bug: LOCK_index should not be
294 taken before LOCK_thd_list. This implies that, e.g.,
295 purge_source_logs_to_file can deadlock with reset_master. However,
296 although purge_first_log and reset_slave take locks in reverse
297 order, they cannot deadlock because they both first acquire
298 rli.data_lock.]
299
300 purge_source_logs_to_file, purge_source_logs_before_date, purge:
301 (binlog.purge_logs) binlog.LOCK_index, LOCK_thd_list, thd.linfo.lock
302
303 purge_first_log:
304 rli.data_lock, relay.LOCK_index, rli.log_space_lock,
305 (relay.purge_logs) LOCK_thd_list, thd.linfo.lock
306
307 MYSQL_BIN_LOG::new_file_impl:
308 .LOCK_log, .LOCK_index,
309 ( [ if binlog: LOCK_prep_xids ]
310 | global_sid_lock->wrlock
311 )
312
313 rotate_relay_log:
314 (relay.new_file_impl) relay.LOCK_log, relay.LOCK_index
315
316 kill_zombie_dump_threads:
317 LOCK_thd_list, thd.LOCK_thd_data
318
319 rli_init_info:
320 rli.data_lock,
321 ( relay.log_lock
322 | global_sid_lock->wrlock
323 | (relay.open_binlog)
324 | (init_relay_log_pos) rli.data_lock, relay.log_lock
325 )
326
327 So the DAG of lock acquisition order (not counting the buggy
328 purge_logs) is, empirically:
329
330 Gtid_mode::lock, channel_map lock, mi.run_lock, rli.run_lock,
331 ( rli.data_lock,
332 ( LOCK_thd_list,
333 (
334 ( binlog.LOCK_log, binlog.LOCK_index
335 | relay.LOCK_log, relay.LOCK_index
336 ),
337 ( rli.log_space_lock | global_sid_lock->wrlock )
338 | binlog.LOCK_log, binlog.LOCK_index, LOCK_prep_xids
339 | thd.LOCK_data
340 )
341 | mi.err_lock, rli.err_lock
342 )
343 )
344 )
345 | mi.data_lock, rli.data_lock
346*/
347
348extern ulong master_retry_count;
350extern char slave_skip_error_names[];
351extern bool use_slave_mask;
352extern char *replica_load_tmpdir;
353extern const char *master_info_file;
354extern const char *relay_log_info_file;
358extern char *opt_binlog_index_name;
359extern bool opt_skip_replica_start;
360extern bool opt_log_replica_updates;
361extern char *opt_replica_skip_errors;
363
364extern const char *relay_log_index;
365extern const char *relay_log_basename;
366
367/// @brief Helper class used to initialize the replica (includes init_replica())
368/// @details init_replica is called once during the mysqld start-up
370 public:
371 /// @brief Constructor, calls init_replica()
372 /// @param[in] opt_initialize Server option used to indicate whether mysqld
373 /// has been started with --initialize
374 /// @param[in] opt_skip_replica_start When true, skips the start of
375 /// replication threads
376 /// @param[in] filters Replication filters
377 /// @param[in] replica_skip_erors
379 Rpl_channel_filters &filters, char **replica_skip_erors);
380
381 /// @brief Gets initialization code set-up at replica initialization
382 /// @return Error code obtained during the replica initialization
383 int get_initialization_code() const;
384
385 private:
386 /// @brief This function starts replication threads
387 /// @param[in] skip_replica_start When true, skips the start of replication
388 /// threads threads
389 void start_replication_threads(bool skip_replica_start = true);
390
391 /// @brief Initializes replica PSI keys in case PSI interface is available
392 static void init_replica_psi_keys();
393
394 /// @brief Performs replica initialization, creates default replication
395 /// channel and sets channel filters
396 /// @returns Error code
397 int init_replica();
398
399 /// @brief In case debug mode is on, prints channel information
400 void print_channel_info() const;
401
402 /// @brief This function starts replication threads
403 void start_threads();
404
406 false; ///< Indicates whether to initialize replica
408 false; ///< Indicates whether replica threads should be started or not
409 int m_init_code = 0; ///< Replica initialization error code
410 int m_thread_mask = 0; ///< Thread mask indicating type of the thread
411};
412
413/*
414 3 possible values for Master_info::slave_running and
415 Relay_log_info::slave_running.
416 The values 0,1,2 are very important: to keep the diff small, I didn't
417 substitute places where we use 0/1 with the newly defined symbols. So don't
418 change these values. The same way, code is assuming that in Relay_log_info we
419 use only values 0/1. I started with using an enum, but enum_variable=1; is not
420 legal so would have required many line changes.
421*/
422#define MYSQL_SLAVE_NOT_RUN 0
423#define MYSQL_SLAVE_RUN_NOT_CONNECT 1
424#define MYSQL_SLAVE_RUN_CONNECT 2
425
426/*
427 If the following is set, if first gives an error, second will be
428 tried. Otherwise, if first fails, we fail.
429*/
430#define SLAVE_FORCE_ALL 4
431
432/* @todo: see if you can change to int */
433bool start_slave_cmd(THD *thd);
434bool stop_slave_cmd(THD *thd);
435bool change_master_cmd(THD *thd);
436int change_master(THD *thd, Master_info *mi, LEX_MASTER_INFO *lex_mi,
437 bool preserve_logs = false);
438bool reset_slave_cmd(THD *thd);
439bool show_slave_status_cmd(THD *thd);
440bool flush_relay_logs_cmd(THD *thd);
441/**
442 Re-encrypt previous relay logs with current master key for all slave channels.
443
444 @retval false Success.
445 @retval true Error.
446*/
448int flush_relay_logs(Master_info *mi, THD *thd);
449int reset_slave(THD *thd, Master_info *mi, bool reset_all);
450int reset_slave(THD *thd);
452/**
453 Call mi->init_info() and/or mi->rli->init_info(), which will read
454 the replication configuration from repositories.
455
456 This takes care of creating a transaction context in case table
457 repository is needed.
458
459 @param mi The Master_info object to use.
460
461 @param ignore_if_no_info If this is false, and the repository does
462 not exist, it will be created. If this is true, and the repository
463 does not exist, nothing is done.
464
465 @param thread_mask Indicate which repositories will be initialized:
466 if (thread_mask&SLAVE_IO)!=0, then mi->init_info is called; if
467 (thread_mask&SLAVE_SQL)!=0, then mi->rli->init_info is called.
468
469 @param force_load repositories will only read information if they
470 are not yet initialized. When true this flag forces the repositories
471 to load information from table or file.
472
473 @param skip_received_gtid_set_recovery When true, skips the received GTID
474 set recovery.
475
476 @retval 0 Success
477 @retval nonzero Error
478*/
480 Master_info *mi, bool ignore_if_no_info, int thread_mask,
481 bool skip_received_gtid_set_recovery = false, bool force_load = false);
482void end_info(Master_info *mi);
483/**
484 Clear the information regarding the `Master_info` and `Relay_log_info` objects
485 represented by the parameter, meaning, setting to `NULL` all attributes that
486 are not meant to be kept between slave resets.
487
488 @param mi the `Master_info` reference that holds both `Master_info` and
489 `Relay_log_info` data.
490 */
491void clear_info(Master_info *mi);
492int remove_info(Master_info *mi);
493/**
494 Resets the information regarding the `Master_info` and `Relay_log_info`
495 objects represented by the parameter, meaning, setting to `NULL` all
496 attributes that are not meant to be kept between slave resets and persisting
497 all other attribute values in the repository.
498
499 @param mi the `Master_info` reference that holds both `Master_info` and
500 `Relay_log_info` data.
501
502 @returns true if an error occurred and false otherwiser.
503 */
504bool reset_info(Master_info *mi);
505
506/**
507 This method flushes the current configuration for the channel into the
508 connection metadata repository. It will also flush the current contents
509 of the relay log file if instructed to.
510
511 @param mi the `Master_info` reference that holds both `Master_info` and
512 `Relay_log_info` data.
513
514 @param force shall the method ignore the server settings that limit flushes
515 to this repository
516
517 @param need_lock shall the method take the associated data lock and log lock
518 if false ownership is asserted
519
520 @param flush_relay_log should the method also flush the relay log file
521
522 @param skip_repo_persistence if this method shall skip the repository flush
523 This won't skip the relay log flush if
524 flush_relay_log = true
525
526 @returns 0 if no error occurred, !=0 if an error occurred
527*/
528int flush_master_info(Master_info *mi, bool force, bool need_lock = true,
529 bool flush_relay_log = true,
530 bool skip_repo_persistence = false);
531void add_replica_skip_errors(const char *arg);
532void set_replica_skip_errors(char **replica_skip_errors_ptr);
533int add_new_channel(Master_info **mi, const char *channel);
534/**
535 Terminates the slave threads according to the given mask.
536
537 @param mi the master info repository
538 @param thread_mask the mask identifying which thread(s) to terminate
539 @param stop_wait_timeout the timeout after which the method returns and error
540 @param need_lock_term
541 If @c false the lock will not be acquired before waiting on
542 the condition. In this case, it is assumed that the calling
543 function acquires the lock before calling this function.
544
545 @return the operation status
546 @retval 0 OK
547 @retval ER_SLAVE_NOT_RUNNING
548 The slave is already stopped
549 @retval ER_STOP_SLAVE_SQL_THREAD_TIMEOUT
550 There was a timeout when stopping the SQL thread
551 @retval ER_STOP_SLAVE_IO_THREAD_TIMEOUT
552 There was a timeout when stopping the IO thread
553 @retval ER_ERROR_DURING_FLUSH_LOGS
554 There was an error while flushing the log/repositories
555*/
556int terminate_slave_threads(Master_info *mi, int thread_mask,
557 ulong stop_wait_timeout,
558 bool need_lock_term = true);
559bool start_slave_threads(bool need_lock_slave, bool wait_for_start,
560 Master_info *mi, int thread_mask);
561bool start_slave(THD *thd);
562int stop_slave(THD *thd);
563bool start_slave(THD *thd, LEX_SLAVE_CONNECTION *connection_param,
564 LEX_MASTER_INFO *master_param, int thread_mask_input,
565 Master_info *mi, bool set_mts_settings);
566int stop_slave(THD *thd, Master_info *mi, bool net_report, bool for_one_channel,
567 bool *push_temp_table_warning);
568/*
569 cond_lock is usually same as start_lock. It is needed for the case when
570 start_lock is 0 which happens if start_slave_thread() is called already
571 inside the start_lock section, but at the same time we want a
572 mysql_cond_wait() on start_cond, start_lock
573*/
575 mysql_mutex_t *start_lock, mysql_mutex_t *cond_lock,
576 mysql_cond_t *start_cond,
577 std::atomic<uint> *slave_running,
578 std::atomic<ulong> *slave_run_id, Master_info *mi);
579
580bool show_slave_status(THD *thd, Master_info *mi);
581bool show_slave_status(THD *thd);
582bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report,
583 bool (*pred)(const void *), const void *param);
585
586const char *print_slave_db_safe(const char *db);
587
588void end_slave(); /* release slave threads */
589void delete_slave_info_objects(); /* clean up slave threads data */
592int rotate_relay_log(Master_info *mi, bool log_master_fd = true,
593 bool need_lock = true, bool need_log_space_lock = true);
594typedef enum {
600 ulong event_len, bool flush_mi = true);
601
603 std::string binlog_name, uint64_t position,
604 unsigned long &inc_pos, bool &do_flush_mi);
605
606extern "C" void *handle_slave_io(void *arg);
607extern "C" void *handle_slave_sql(void *arg);
608
609/*
610 SYNPOSIS
611 connect_to_master()
612
613 IMPLEMENTATION
614 Try to connect until successful or replica killed or we have retried
615
616 @param[in] thd The thread.
617 @param[in] mysql MySQL connection handle
618 @param[in] mi The Master_info object of the failed connection which
619 needs to be reconnected to the new source.
620 @param[in] reconnect If its need to reconnect to existing source.
621 @param[in] host The Host name or ip address of the source to which
622 connection need to be made.
623 @param[in] port The Port of the source to which connection need to
624 be made.
625 @param[in] is_io_thread To determine if its IO or Monitor IO thread.
626
627 @retval 0 Success connecting to the source.
628 @retval # Error connecting to the source.
629*/
631 bool suppress_warnings,
632 const std::string &host = std::string(),
633 const uint port = 0, bool is_io_thread = true);
634
635bool net_request_file(NET *net, const char *fname);
636
637extern bool replicate_same_server_id;
638
640
641/* the master variables are defaults read from my.cnf or command line */
642extern uint report_port;
643extern const char *master_info_file;
644extern const char *relay_log_info_file;
645extern char *report_user;
647
649/**
650 Processing rli->gaq to find out the low-water-mark (lwm) coordinates
651 which is stored into the central recovery table. rli->data_lock will be
652 required, so the caller should not hold rli->data_lock.
653
654 @param rli pointer to Relay-log-info of Coordinator
655 @param force if true then hang in a loop till some progress
656 @retval false Success
657 @retval true Error
658*/
659bool mta_checkpoint_routine(Relay_log_info *rli, bool force);
660bool sql_slave_killed(THD *thd, Relay_log_info *rli);
661
662/*
663 Check if the error is caused by network.
664 @param[in] errorno Number of the error.
665 RETURNS:
666 true network error
667 false not network error
668*/
669bool is_network_error(uint errorno);
670
671int init_replica_thread(THD *thd, SLAVE_THD_TYPE thd_type);
672
673/**
674 @} (end of group Replication)
675*/
676#endif
Definition: rpl_mi.h:86
Definition: rpl_rli.h:201
Helper class used to initialize the replica (includes init_replica())
Definition: rpl_replica.h:369
int m_init_code
Replica initialization error code.
Definition: rpl_replica.h:409
int m_thread_mask
Thread mask indicating type of the thread.
Definition: rpl_replica.h:410
bool m_opt_skip_replica_start
Indicates whether replica threads should be started or not.
Definition: rpl_replica.h:407
bool m_opt_initialize_replica
Indicates whether to initialize replica.
Definition: rpl_replica.h:405
The class is a container for all the per-channel filters, both a map of Rpl_filter objects and a list...
Definition: rpl_msr.h:472
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
Declarations for the Debug Sync Facility.
int rotate_relay_log(Master_info *mi, bool log_master_fd, bool need_lock, bool need_log_space_lock)
Definition: rpl_replica.cc:8457
bool stop_slave_cmd(THD *thd)
Entry point for the STOP SLAVE command.
Definition: rpl_replica.cc:814
char * replica_load_tmpdir
Definition: rpl_replica.cc:186
QUEUE_EVENT_RESULT
Definition: rpl_replica.h:594
bool opt_log_replica_updates
Definition: mysqld.cc:1224
bool sql_slave_killed(THD *thd, Relay_log_info *rli)
The function analyzes a possible killed status and makes a decision whether to accept it or not.
Definition: rpl_replica.cc:2258
int heartbeat_queue_event(bool is_valid, Master_info *&mi, std::string binlog_name, uint64_t position, unsigned long &inc_pos, bool &do_flush_mi)
Definition: rpl_replica.cc:7383
const char * relay_log_basename
Definition: rpl_replica.cc:191
bool net_request_file(NET *net, const char *fname)
Definition: rpl_replica.cc:2364
bool start_slave_threads(bool need_lock_slave, bool wait_for_start, Master_info *mi, int thread_mask)
Definition: rpl_replica.cc:2045
bool mta_checkpoint_routine(Relay_log_info *rli, bool force)
Processing rli->gaq to find out the low-water-mark (lwm) coordinates which is stored into the central...
Definition: rpl_replica.cc:6336
void clear_info(Master_info *mi)
Clear the information regarding the Master_info and Relay_log_info objects represented by the paramet...
Definition: rpl_replica.cc:1386
bool rpl_master_erroneous_autoinc(THD *thd)
BUG#33029, For all 5.0 up to 5.0.58 exclusive, and 5.1 up to 5.1.12 exclusive, if one statement in a ...
Definition: rpl_replica.cc:8749
void set_replica_skip_errors(char **replica_skip_errors_ptr)
Change arg to the string with the nice, human-readable skip error values.
Definition: rpl_replica.cc:1576
void start_threads()
This function starts replication threads.
Definition: rpl_replica.cc:493
bool change_master_cmd(THD *thd)
Entry point for the CHANGE MASTER command.
Definition: rpl_replica.cc:10966
char * opt_relay_logname
Definition: mysqld.cc:1636
void end_info(Master_info *mi)
Definition: rpl_replica.cc:1374
bool replicate_same_server_id
Definition: rpl_replica.cc:187
int init_replica_thread(THD *thd, SLAVE_THD_TYPE thd_type)
Definition: rpl_replica.cc:4016
int remove_info(Master_info *mi)
Definition: rpl_replica.cc:1406
char * report_password
Definition: rpl_replica.h:646
ReplicaInitializer(bool opt_initialize, bool opt_skip_replica_start, Rpl_channel_filters &filters, char **replica_skip_erors)
Constructor, calls init_replica()
Definition: rpl_replica.cc:424
const char * print_slave_db_safe(const char *db)
Definition: rpl_replica.cc:2377
ulong master_retry_count
Definition: mysqld.cc:1632
int change_master(THD *thd, Master_info *mi, LEX_MASTER_INFO *lex_mi, bool preserve_logs)
Execute a CHANGE MASTER statement.
Definition: rpl_replica.cc:10454
bool reencrypt_relay_logs()
Re-encrypt previous relay logs with current master key for all slave channels.
Definition: rpl_replica.cc:8630
QUEUE_EVENT_RESULT queue_event(Master_info *mi, const char *buf, ulong event_len, bool do_flush_mi)
Store an event received from the master connection into the relay log.
Definition: rpl_replica.cc:7488
bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report, bool(*pred)(const void *), const void *param)
Detects, based on master's version (as found in the relay log), if master has a certain bug.
Definition: rpl_replica.cc:8672
int disconnect_slave_event_count
Definition: rpl_replica.cc:237
bool flush_relay_logs_cmd(THD *thd)
Entry point for FLUSH RELAYLOGS command or to flush relaylogs for the FLUSH LOGS command.
Definition: rpl_replica.cc:8563
char * report_user
Definition: mysqld.cc:1635
static void init_replica_psi_keys()
Initializes replica PSI keys in case PSI interface is available.
Definition: rpl_replica.cc:527
int stop_slave(THD *thd)
Function to stop a slave for all channels.
Definition: rpl_replica.cc:669
int add_new_channel(Master_info **mi, const char *channel)
This function is first called when the Master_info object corresponding to a channel in a multisource...
Definition: rpl_replica.cc:10801
void * handle_slave_io(void *arg)
Slave IO thread entry point.
Definition: rpl_replica.cc:5274
bool reset_slave_cmd(THD *thd)
Entry function for RESET SLAVE command.
Definition: rpl_replica.cc:9284
bool is_network_error(uint errorno)
Definition: rpl_replica.cc:2383
void add_replica_skip_errors(const char *arg)
Definition: rpl_replica.cc:1625
ulonglong relay_log_space_limit
Definition: rpl_replica.cc:188
bool opt_skip_replica_start
If set, slave is not autostarted.
Definition: mysqld.cc:1219
const char * relay_log_info_file
Definition: rpl_replica.h:644
void start_replication_threads(bool skip_replica_start=true)
This function starts replication threads.
Definition: rpl_replica.cc:487
bool show_slave_status(THD *thd)
Method to the show the replication status in all channels.
Definition: rpl_replica.cc:3696
void print_channel_info() const
In case debug mode is on, prints channel information.
Definition: rpl_replica.cc:467
bool reset_info(Master_info *mi)
Resets the information regarding the Master_info and Relay_log_info objects represented by the parame...
Definition: rpl_replica.cc:1427
int load_mi_and_rli_from_repositories(Master_info *mi, bool ignore_if_no_info, int thread_mask, bool skip_received_gtid_set_recovery, bool force_load)
Call mi->init_info() and/or mi->rli->init_info(), which will read the replication configuration from ...
Definition: rpl_replica.cc:1264
const char * relay_log_index
Definition: rpl_replica.cc:190
int init_replica()
Performs replica initialization, creates default replication channel and sets channel filters.
Definition: rpl_replica.cc:540
int flush_relay_logs(Master_info *mi, THD *thd)
flushes the relay logs of a replication channel.
Definition: rpl_replica.cc:8518
void delete_slave_info_objects()
Free all resources used by slave threads at time of executing shutdown.
Definition: rpl_replica.cc:2172
bool mts_recovery_groups(Relay_log_info *rli)
Definition: rpl_replica.cc:6082
bool start_slave_cmd(THD *thd)
Entry point to the START SLAVE command.
Definition: rpl_replica.cc:716
int flush_master_info(Master_info *mi, bool force, bool need_lock, bool do_flush_relay_log, bool skip_repo_persistence)
This method flushes the current configuration for the channel into the connection metadata repository...
Definition: rpl_replica.cc:1465
char * report_host
Definition: mysqld.cc:1635
uint report_port
Definition: mysqld.cc:1631
bool opt_relaylog_index_name_supplied
Definition: mysqld.cc:1641
bool start_slave_thread(PSI_thread_key thread_key, my_start_routine h_func, mysql_mutex_t *start_lock, mysql_mutex_t *cond_lock, mysql_cond_t *start_cond, std::atomic< uint > *slave_running, std::atomic< ulong > *slave_run_id, Master_info *mi)
Definition: rpl_replica.cc:1969
void set_slave_thread_options(THD *thd)
Set slave thread default options.
Definition: rpl_replica.cc:3945
int get_initialization_code() const
Gets initialization code set-up at replica initialization.
Definition: rpl_replica.cc:422
bool server_id_supplied
Definition: mysqld.cc:1181
int abort_slave_event_count
Definition: rpl_replica.h:639
char * opt_relaylog_index_name
Definition: rpl_replica.h:355
int connect_to_master(THD *thd, MYSQL *mysql, Master_info *mi, bool reconnect, bool suppress_warnings, const std::string &host, const uint port, bool is_io_thread)
Definition: rpl_replica.cc:8229
int terminate_slave_threads(Master_info *mi, int thread_mask, ulong stop_wait_timeout, bool need_lock_term)
Terminates the slave threads according to the given mask.
Definition: rpl_replica.cc:1697
int init_recovery(Master_info *mi)
Definition: rpl_replica.cc:1144
char slave_skip_error_names[]
Definition: rpl_replica.cc:184
void end_slave()
Definition: rpl_replica.cc:2141
MY_BITMAP slave_error_mask
Definition: rpl_replica.cc:183
char * opt_binlog_index_name
Definition: mysqld.cc:1671
bool show_slave_status_cmd(THD *thd)
Entry point for SHOW REPLICA STATUS command.
Definition: rpl_replica.cc:3900
void * handle_slave_sql(void *arg)
Slave SQL thread entry point.
Definition: rpl_replica.cc:6850
const char * master_info_file
Definition: rpl_replica.h:643
bool use_slave_mask
Definition: rpl_replica.cc:182
void set_slave_thread_default_charset(THD *thd, Relay_log_info const *rli)
Definition: rpl_replica.cc:3993
bool opt_relay_logname_supplied
Definition: mysqld.cc:1646
bool start_slave(THD *thd)
Function to start a slave for all channels.
Definition: rpl_replica.cc:607
char * opt_replica_skip_errors
Definition: mysqld.cc:1225
@ QUEUE_EVENT_OK
Definition: rpl_replica.h:595
@ QUEUE_EVENT_ERROR_QUEUING
Definition: rpl_replica.h:596
@ QUEUE_EVENT_ERROR_FLUSHING_INFO
Definition: rpl_replica.h:597
unsigned int PSI_thread_key
Instrumented thread key.
Definition: psi_thread_bits.h:49
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
Defines to make different thread packages compatible.
void *(* my_start_routine)(void *)
Definition: my_thread.h:71
static int reconnect(void)
Definition: mysql.cc:3033
static MYSQL mysql
Definition: mysql.cc:153
This file defines the client API to MySQL and also the ABI of the dynamically linked libmysqlclient.
Common definition between mysql server & client.
const char * host
Definition: mysqladmin.cc:58
bool opt_initialize
Definition: mysqld.cc:1218
Definition: buf0block_hint.cc:29
constexpr value_type reset_slave
Definition: classic_protocol_constants.h:311
bool is_valid(const dd::Spatial_reference_system *srs, const Geometry *g, const char *func_name, bool *is_valid) noexcept
Decides if a geometry is valid.
Definition: is_valid.cc:94
Definition: buffer.h:43
Performance schema instrumentation interface.
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:32
SLAVE_THD_TYPE
Definition: rpl_replica.h:53
@ SLAVE_THD_SQL
Definition: rpl_replica.h:55
@ SLAVE_THD_IO
Definition: rpl_replica.h:54
@ SLAVE_THD_WORKER
Definition: rpl_replica.h:56
@ SLAVE_THD_MONITOR
Definition: rpl_replica.h:57
Structure to hold parameters for CHANGE MASTER, START SLAVE, and STOP SLAVE.
Definition: sql_lex.h:350
Definition: mysql.h:298
Definition: my_bitmap.h:42
Definition: mysql_com.h:912
Definition: task.h:426
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
Definition: sql_lex.h:2440
unsigned int uint
Definition: uca-dump.cc:29