MySQL  8.0.27
Source Code Documentation
rpl_replica.h
Go to the documentation of this file.
1 /* Copyright (c) 2000, 2021, 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 
43 class Master_info;
44 class Relay_log_info;
45 class THD;
46 struct LEX_MASTER_INFO;
47 struct mysql_cond_t;
48 struct mysql_mutex_t;
49 
51 
52 typedef enum {
58 
59 /**
60  MASTER_DELAY can be at most (1 << 31) - 1.
61 */
62 #define MASTER_DELAY_MAX (0x7FFFFFFF)
63 #if INT_MAX < 0x7FFFFFFF
64 #error "don't support platforms where INT_MAX < 0x7FFFFFFF"
65 #endif
66 
67 /**
68  @defgroup Replication Replication
69  @{
70 
71  @file
72 */
73 
74 /**
75  Some of defines are need in parser even though replication is not
76  compiled in (embedded).
77 */
78 
79 /**
80  The maximum is defined as (ULONG_MAX/1000) with 4 bytes ulong
81 */
82 #define SLAVE_MAX_HEARTBEAT_PERIOD 4294967
83 
84 #define REPLICA_NET_TIMEOUT 60
85 
86 #define MAX_SLAVE_ERROR 14000
87 
88 #define MTS_WORKER_UNDEF ((ulong)-1)
89 #define MTS_MAX_WORKERS 1024
90 #define MAX_SLAVE_RETRY_PAUSE 5
91 
92 /*
93  When using tables to store the slave workers bitmaps,
94  we use a BLOB field. The maximum size of a BLOB is:
95 
96  2^16-1 = 65535 bytes => (2^16-1) * 8 = 524280 bits
97 */
98 #define MTS_MAX_BITS_IN_GROUP ((1L << 19) - 8) /* 524280 */
99 
100 extern bool server_id_supplied;
101 
102 /*****************************************************************************
103 
104  MySQL Replication
105 
106  Replication is implemented via two types of threads:
107 
108  I/O Thread - One of these threads is started for each master server.
109  They maintain a connection to their master server, read log
110  events from the master as they arrive, and queues them into
111  a single, shared relay log file. A Master_info represents
112  each of these threads.
113 
114  SQL Thread - One of these threads is started and reads from the relay log
115  file, executing each event. A Relay_log_info represents this
116  thread.
117 
118  Buffering in the relay log file makes it unnecessary to reread events from
119  a master server across a slave restart. It also decouples the slave from
120  the master where long-running updates and event logging are concerned--ie
121  it can continue to log new events while a slow query executes on the slave.
122 
123 *****************************************************************************/
124 
125 /*
126  # MUTEXES in replication #
127 
128  JAG: TODO: This guide needs to be updated after pushing WL#10406!
129 
130  ## In Multisource_info (channel_map) ##
131 
132  ### m_channel_map_lock ###
133 
134  This rwlock is used to protect the multi source replication data structure
135  (channel_map). Any operation reading contents from the channel_map should
136  hold the rdlock during the operation. Any operation changing the
137  channel_map (either adding/removing channels to/from the channel_map)
138  should hold the wrlock during the operation.
139 
140  [init_replica() does not need it it's called early].
141 
142  ## In Master_info (mi) ##
143 
144  ### m_channel_lock ###
145 
146  It is used to SERIALIZE ALL administrative commands of replication: START
147  SLAVE, STOP SLAVE, CHANGE MASTER, RESET SLAVE, delete_slave_info_objects
148  (when mysqld stops)
149 
150  This thus protects us against a handful of deadlocks, being the know ones
151  around lock_slave_threads and the mixed order they are acquired in some
152  operations:
153 
154  + consider start_slave_thread() which, when starting the I/O thread,
155  releases mi->run_lock, keeps rli->run_lock, and tries to re-acquire
156  mi->run_lock.
157 
158  + Same applies to stop_slave() where a stop of the I/O thread will
159  mi->run_lock, keeps rli->run_lock, and tries to re-acquire mi->run_lock.
160  For the SQL thread, the order is the opposite.
161 
162  ### run_lock ###
163 
164  Protects all information about the running state: slave_running, thd
165  and the existence of the I/O thread itself (to stop/start it, you need
166  this mutex).
167  Check the above m_channel_lock about locking order.
168 
169  ### data_lock ###
170 
171  Protects some moving members of the struct: counters (log name,
172  position).
173 
174  ### sid_lock ###
175 
176  Protects the retrieved GTID set and it's SID map from updates.
177 
178  ## In Relay_log_info (rli) ##
179 
180  ### run_lock ###
181 
182  Same as Master_info's one. However, note that run_lock does not protect
183  Relay_log_info.run_state. That is protected by data_lock.
184  Check the above m_channel_lock about locking order.
185 
186  ### data_lock ###
187 
188  Protects some moving members of the struct: counters (log name,
189  position).
190 
191  ## In MYSQL_BIN_LOG (mysql_bin_log,relay_log) ##
192 
193  ### LOCK_log ###
194 
195  This mutex should be taken when going to write to a log file. Notice that it
196  does not prevent other threads from reading from the file being written (the
197  "hot" file) or any other older file.
198 
199  ### LOCK_index ###
200 
201  This mutex should be taken when going to create/delete a log file (as those
202  operations will update the .index file).
203 
204  ### LOCK_binlog_end_pos ###
205 
206  This mutex protects the access to the binlog_end_pos variable. The variable
207  it set with the position that other threads reading from the currently active
208  log file (the "hot" one) should not cross.
209 
210  ## Gtid_state (gtid_state, global_sid_map) ##
211 
212  ### global_sid_lock ###
213 
214  Protects all Gtid_state GTID sets (lost_gtids, executed_gtids,
215  gtids_only_in_table, previous_gtids_logged, owned_gtids) and the global SID
216  map from updates.
217 
218  The global_sid_lock must not be taken after LOCK_reset_gtid_table.
219 
220  ## Gtid_mode (gtid_mode) ##
221 
222  ### Gtid_mode::lock ###
223 
224  Used to arbitrate changes on server Gtid_mode.
225 
226  # Order of acquisition #
227 
228  Here, we list most major functions that acquire multiple locks.
229 
230  Notation: For each function, we list the locks it takes, in the
231  order it takes them. If a function holds lock A while taking lock
232  B, then we write "A, B". If a function locks A, unlocks A, then
233  locks B, then we write "A | B". If function F1 invokes function F2,
234  then we write F2's name in parentheses in the list of locks for F1.
235 
236  Sys_var_gtid_mode::global_update:
237  Gtid_mode::lock.wrlock, channel_map->wrlock, binlog.LOCK_log,
238  global_sid_lock->wrlock
239 
240  change_master_cmd:
241  channel_map.wrlock, (change_master)
242 
243  change_master:
244  mi.channel_wrlock, mi.run_lock, rli.run_lock, (global_init_info),
245  (purge_relay_logs), (init_relay_log_pos), rli.err_lock
246 
247  global_init_info:
248  mi.data_lock, rli.data_lock
249 
250  purge_relay_logs:
251  rli.data_lock, (relay_log.reset_logs)
252 
253  relay_log.reset_logs:
254  .LOCK_log, .LOCK_index, .sid_lock->wrlock
255 
256  init_relay_log_pos:
257  rli.data_lock
258 
259  queue_event:
260  rli.LOCK_log, relay_log.sid_lock->rdlock, mi.data_lock
261 
262  stop_slave:
263  channel_map rdlock,
264  ( mi.channel_wrlock, mi.run_lock, thd.LOCK_thd_data
265  | rli.run_lock, thd.LOCK_thd_data
266  | relay.LOCK_log
267  )
268 
269  start_slave:
270  mi.channel_wrlock, mi.run_lock, rli.run_lock, rli.data_lock,
271  global_sid_lock->wrlock
272 
273  mysql_bin_log.reset_logs:
274  .LOCK_log, .LOCK_index, global_sid_lock->wrlock
275 
276  purge_relay_logs:
277  rli.data_lock, (relay.reset_logs) THD::LOCK_thd_data,
278  relay.LOCK_log, relay.LOCK_index, global_sid_lock->wrlock
279 
280  reset_master:
281  (binlog.reset_logs) THD::LOCK_thd_data, binlog.LOCK_log,
282  binlog.LOCK_index, global_sid_lock->wrlock, LOCK_reset_gtid_table
283 
284  reset_slave:
285  mi.channel_wrlock, mi.run_lock, rli.run_lock, (purge_relay_logs)
286  rli.data_lock, THD::LOCK_thd_data, relay.LOCK_log, relay.LOCK_index,
287  global_sid_lock->wrlock
288 
289  purge_logs:
290  .LOCK_index, LOCK_thd_list, thd.linfo.lock
291 
292  [Note: purge_logs contains a known bug: LOCK_index should not be
293  taken before LOCK_thd_list. This implies that, e.g.,
294  purge_master_logs can deadlock with reset_master. However,
295  although purge_first_log and reset_slave take locks in reverse
296  order, they cannot deadlock because they both first acquire
297  rli.data_lock.]
298 
299  purge_master_logs, purge_master_logs_before_date, purge:
300  (binlog.purge_logs) binlog.LOCK_index, LOCK_thd_list, thd.linfo.lock
301 
302  purge_first_log:
303  rli.data_lock, relay.LOCK_index, rli.log_space_lock,
304  (relay.purge_logs) LOCK_thd_list, thd.linfo.lock
305 
306  MYSQL_BIN_LOG::new_file_impl:
307  .LOCK_log, .LOCK_index,
308  ( [ if binlog: LOCK_prep_xids ]
309  | global_sid_lock->wrlock
310  )
311 
312  rotate_relay_log:
313  (relay.new_file_impl) relay.LOCK_log, relay.LOCK_index
314 
315  kill_zombie_dump_threads:
316  LOCK_thd_list, thd.LOCK_thd_data
317 
318  rli_init_info:
319  rli.data_lock,
320  ( relay.log_lock
321  | global_sid_lock->wrlock
322  | (relay.open_binlog)
323  | (init_relay_log_pos) rli.data_lock, relay.log_lock
324  )
325 
326  So the DAG of lock acquisition order (not counting the buggy
327  purge_logs) is, empirically:
328 
329  Gtid_mode::lock, channel_map lock, mi.run_lock, rli.run_lock,
330  ( rli.data_lock,
331  ( LOCK_thd_list,
332  (
333  ( binlog.LOCK_log, binlog.LOCK_index
334  | relay.LOCK_log, relay.LOCK_index
335  ),
336  ( rli.log_space_lock | global_sid_lock->wrlock )
337  | binlog.LOCK_log, binlog.LOCK_index, LOCK_prep_xids
338  | thd.LOCK_data
339  )
340  | mi.err_lock, rli.err_lock
341  )
342  )
343  )
344  | mi.data_lock, rli.data_lock
345 */
346 
347 extern ulong master_retry_count;
349 extern char slave_skip_error_names[];
350 extern bool use_slave_mask;
351 extern char *replica_load_tmpdir;
352 extern const char *master_info_file;
353 extern const char *relay_log_info_file;
356 extern bool opt_relay_logname_supplied;
357 extern char *opt_binlog_index_name;
358 extern bool opt_skip_replica_start;
359 extern bool opt_log_replica_updates;
360 extern char *opt_replica_skip_errors;
362 
363 extern const char *relay_log_index;
364 extern const char *relay_log_basename;
365 
366 /*
367  3 possible values for Master_info::slave_running and
368  Relay_log_info::slave_running.
369  The values 0,1,2 are very important: to keep the diff small, I didn't
370  substitute places where we use 0/1 with the newly defined symbols. So don't
371  change these values. The same way, code is assuming that in Relay_log_info we
372  use only values 0/1. I started with using an enum, but enum_variable=1; is not
373  legal so would have required many line changes.
374 */
375 #define MYSQL_SLAVE_NOT_RUN 0
376 #define MYSQL_SLAVE_RUN_NOT_CONNECT 1
377 #define MYSQL_SLAVE_RUN_CONNECT 2
378 
379 /*
380  If the following is set, if first gives an error, second will be
381  tried. Otherwise, if first fails, we fail.
382 */
383 #define SLAVE_FORCE_ALL 4
384 
385 /* @todo: see if you can change to int */
386 bool start_slave_cmd(THD *thd);
387 bool stop_slave_cmd(THD *thd);
388 bool change_master_cmd(THD *thd);
389 int change_master(THD *thd, Master_info *mi, LEX_MASTER_INFO *lex_mi,
390  bool preserve_logs = false);
391 bool reset_slave_cmd(THD *thd);
392 bool show_slave_status_cmd(THD *thd);
393 bool flush_relay_logs_cmd(THD *thd);
394 /**
395  Re-encrypt previous relay logs with current master key for all slave channels.
396 
397  @retval false Success.
398  @retval true Error.
399 */
400 bool reencrypt_relay_logs();
401 int flush_relay_logs(Master_info *mi, THD *thd);
402 int reset_slave(THD *thd, Master_info *mi, bool reset_all);
403 int reset_slave(THD *thd);
404 int init_replica();
405 int init_recovery(Master_info *mi);
406 /**
407  Call mi->init_info() and/or mi->rli->init_info(), which will read
408  the replication configuration from repositories.
409 
410  This takes care of creating a transaction context in case table
411  repository is needed.
412 
413  @param mi The Master_info object to use.
414 
415  @param ignore_if_no_info If this is false, and the repository does
416  not exist, it will be created. If this is true, and the repository
417  does not exist, nothing is done.
418 
419  @param thread_mask Indicate which repositories will be initialized:
420  if (thread_mask&SLAVE_IO)!=0, then mi->init_info is called; if
421  (thread_mask&SLAVE_SQL)!=0, then mi->rli->init_info is called.
422 
423  @param force_load repositories will only read information if they
424  are not yet intialized. When true this flag forces the repositories
425  to load information from table or file.
426 
427  @param skip_received_gtid_set_recovery When true, skips the received GTID
428  set recovery.
429 
430  @retval 0 Success
431  @retval nonzero Error
432 */
434  Master_info *mi, bool ignore_if_no_info, int thread_mask,
435  bool skip_received_gtid_set_recovery = false, bool force_load = false);
436 void end_info(Master_info *mi);
437 /**
438  Clear the information regarding the `Master_info` and `Relay_log_info` objects
439  represented by the parameter, meaning, setting to `NULL` all attributes that
440  are not meant to be kept between slave resets.
441 
442  @param mi the `Master_info` reference that holds both `Master_info` and
443  `Relay_log_info` data.
444  */
445 void clear_info(Master_info *mi);
446 int remove_info(Master_info *mi);
447 /**
448  Resets the information regarding the `Master_info` and `Relay_log_info`
449  objects represented by the parameter, meaning, setting to `NULL` all
450  attributes that are not meant to be kept between slave resets and persisting
451  all other attribute values in the repository.
452 
453  @param mi the `Master_info` reference that holds both `Master_info` and
454  `Relay_log_info` data.
455 
456  @returns true if an error occurred and false otherwiser.
457  */
458 bool reset_info(Master_info *mi);
459 
460 /**
461  This method flushes the current configuration for the channel into the
462  connection metadata repository. It will also flush the current contents
463  of the relay log file if instructed to.
464 
465  @param mi the `Master_info` reference that holds both `Master_info` and
466  `Relay_log_info` data.
467 
468  @param force shall the method ignore the server settings that limit flushes
469  to this repository
470 
471  @param need_lock shall the method take the associated data lock and log lock
472  if false ownership is asserted
473 
474  @param flush_relay_log should the method also flush the relay log file
475 
476  @param skip_repo_persistence if this method shall skip the repository flush
477  This wont skip the relay log flush if
478  flush_relay_log = true
479 
480  @returns 0 if no error ocurred, !=0 if an error ocurred
481 */
482 int flush_master_info(Master_info *mi, bool force, bool need_lock = true,
483  bool flush_relay_log = true,
484  bool skip_repo_persistence = false);
485 void add_replica_skip_errors(const char *arg);
486 void set_replica_skip_errors(char **replica_skip_errors_ptr);
487 int add_new_channel(Master_info **mi, const char *channel);
488 /**
489  Terminates the slave threads according to the given mask.
490 
491  @param mi the master info repository
492  @param thread_mask the mask identifying which thread(s) to terminate
493  @param stop_wait_timeout the timeout after which the method returns and error
494  @param need_lock_term
495  If @c false the lock will not be acquired before waiting on
496  the condition. In this case, it is assumed that the calling
497  function acquires the lock before calling this function.
498 
499  @return the operation status
500  @retval 0 OK
501  @retval ER_SLAVE_NOT_RUNNING
502  The slave is already stopped
503  @retval ER_STOP_SLAVE_SQL_THREAD_TIMEOUT
504  There was a timeout when stopping the SQL thread
505  @retval ER_STOP_SLAVE_IO_THREAD_TIMEOUT
506  There was a timeout when stopping the IO thread
507  @retval ER_ERROR_DURING_FLUSH_LOGS
508  There was an error while flushing the log/repositories
509 */
510 int terminate_slave_threads(Master_info *mi, int thread_mask,
511  ulong stop_wait_timeout,
512  bool need_lock_term = true);
513 bool start_slave_threads(bool need_lock_slave, bool wait_for_start,
514  Master_info *mi, int thread_mask);
515 bool start_slave(THD *thd);
516 int stop_slave(THD *thd);
517 bool start_slave(THD *thd, LEX_SLAVE_CONNECTION *connection_param,
518  LEX_MASTER_INFO *master_param, int thread_mask_input,
519  Master_info *mi, bool set_mts_settings);
520 int stop_slave(THD *thd, Master_info *mi, bool net_report, bool for_one_channel,
521  bool *push_temp_table_warning);
522 /*
523  cond_lock is usually same as start_lock. It is needed for the case when
524  start_lock is 0 which happens if start_slave_thread() is called already
525  inside the start_lock section, but at the same time we want a
526  mysql_cond_wait() on start_cond, start_lock
527 */
528 bool start_slave_thread(PSI_thread_key thread_key, my_start_routine h_func,
529  mysql_mutex_t *start_lock, mysql_mutex_t *cond_lock,
530  mysql_cond_t *start_cond,
531  std::atomic<uint> *slave_running,
532  std::atomic<ulong> *slave_run_id, Master_info *mi);
533 
534 bool show_slave_status(THD *thd, Master_info *mi);
535 bool show_slave_status(THD *thd);
536 bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report,
537  bool (*pred)(const void *), const void *param);
539 
540 const char *print_slave_db_safe(const char *db);
541 
542 void end_slave(); /* release slave threads */
543 void delete_slave_info_objects(); /* clean up slave threads data */
544 void set_slave_thread_options(THD *thd);
546 int rotate_relay_log(Master_info *mi, bool log_master_fd = true,
547  bool need_lock = true, bool need_log_space_lock = true);
548 typedef enum {
554  ulong event_len, bool flush_mi = true);
555 
556 extern "C" void *handle_slave_io(void *arg);
557 extern "C" void *handle_slave_sql(void *arg);
558 
559 /*
560  SYNPOSIS
561  connect_to_master()
562 
563  IMPLEMENTATION
564  Try to connect until successful or replica killed or we have retried
565 
566  @param[in] thd The thread.
567  @param[in] mysql MySQL connection handle
568  @param[in] mi The Master_info object of the failed connection which
569  needs to be reconnected to the new source.
570  @param[in] reconnect If its need to reconnect to existing source.
571  @param[in] host The Host name or ip address of the source to which
572  connection need to be made.
573  @param[in] port The Port fo the source to which connection need to
574  be made.
575  @param[in] is_io_thread To determine if its IO or Monitor IO thread.
576 
577  @retval 0 Success connecting to the source.
578  @retval # Error connecting to the source.
579 */
580 int connect_to_master(THD *thd, MYSQL *mysql, Master_info *mi, bool reconnect,
581  bool suppress_warnings,
582  const std::string &host = std::string(),
583  const uint port = 0, bool is_io_thread = true);
584 
585 bool net_request_file(NET *net, const char *fname);
586 
587 extern bool replicate_same_server_id;
588 
590 
591 /* the master variables are defaults read from my.cnf or command line */
592 extern uint report_port;
593 extern const char *master_info_file;
594 extern const char *relay_log_info_file;
595 extern char *report_user;
597 
599 /**
600  Processing rli->gaq to find out the low-water-mark (lwm) coordinates
601  which is stored into the central recovery table. rli->data_lock will be
602  required, so the caller should not hold rli->data_lock.
603 
604  @param rli pointer to Relay-log-info of Coordinator
605  @param force if true then hang in a loop till some progress
606  @retval false Success
607  @retval true Error
608 */
609 bool mta_checkpoint_routine(Relay_log_info *rli, bool force);
610 bool sql_slave_killed(THD *thd, Relay_log_info *rli);
611 
612 /*
613  Check if the error is caused by network.
614  @param[in] errorno Number of the error.
615  RETURNS:
616  true network error
617  false not network error
618 */
619 bool is_network_error(uint errorno);
620 
621 int init_replica_thread(THD *thd, SLAVE_THD_TYPE thd_type);
622 
623 /**
624  @} (end of group Replication)
625 */
626 #endif
Definition: rpl_mi.h:86
Definition: rpl_rli.h:200
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
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:8338
bool stop_slave_cmd(THD *thd)
Entry point for the STOP SLAVE command.
Definition: rpl_replica.cc:743
char * replica_load_tmpdir
Definition: rpl_replica.cc:183
QUEUE_EVENT_RESULT
Definition: rpl_replica.h:548
bool opt_log_replica_updates
Definition: mysqld.cc:1208
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:2168
const char * relay_log_basename
Definition: rpl_replica.cc:188
bool net_request_file(NET *net, const char *fname)
Definition: rpl_replica.cc:2274
bool start_slave_threads(bool need_lock_slave, bool wait_for_start, Master_info *mi, int thread_mask)
Definition: rpl_replica.cc:1955
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:6250
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:1299
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:8630
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:1489
bool change_master_cmd(THD *thd)
Entry point for the CHANGE MASTER command.
Definition: rpl_replica.cc:10829
char * opt_relay_logname
Definition: mysqld.cc:1610
void end_info(Master_info *mi)
Definition: rpl_replica.cc:1287
bool replicate_same_server_id
Definition: rpl_replica.cc:184
int init_replica_thread(THD *thd, SLAVE_THD_TYPE thd_type)
Definition: rpl_replica.cc:3911
int remove_info(Master_info *mi)
Definition: rpl_replica.cc:1319
char * report_password
Definition: rpl_replica.h:596
const char * print_slave_db_safe(const char *db)
Definition: rpl_replica.cc:2287
int init_replica()
Definition: rpl_replica.cc:429
ulong master_retry_count
Definition: mysqld.cc:1606
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:10317
bool reencrypt_relay_logs()
Re-encrypt previous relay logs with current master key for all slave channels.
Definition: rpl_replica.cc:8511
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:7301
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:8553
int disconnect_slave_event_count
Definition: rpl_replica.cc:234
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:8444
char * report_user
Definition: mysqld.cc:1609
int stop_slave(THD *thd)
Function to stop a slave for all channels.
Definition: rpl_replica.cc:612
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:10664
void * handle_slave_io(void *arg)
Slave IO thread entry point.
Definition: rpl_replica.cc:5196
bool reset_slave_cmd(THD *thd)
Entry function for RESET SLAVE command.
Definition: rpl_replica.cc:9155
bool is_network_error(uint errorno)
Definition: rpl_replica.cc:2293
void add_replica_skip_errors(const char *arg)
Definition: rpl_replica.cc:1538
ulonglong relay_log_space_limit
Definition: rpl_replica.cc:185
bool opt_skip_replica_start
If set, slave is not autostarted.
Definition: mysqld.cc:1203
const char * relay_log_info_file
Definition: rpl_replica.h:594
bool show_slave_status(THD *thd)
Method to the show the replication status in all channels.
Definition: rpl_replica.cc:3591
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:1340
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:1177
const char * relay_log_index
Definition: rpl_replica.cc:187
int flush_relay_logs(Master_info *mi, THD *thd)
flushes the relay logs of a replication channel.
Definition: rpl_replica.cc:8399
void delete_slave_info_objects()
Free all resources used by slave threads at time of executing shutdown.
Definition: rpl_replica.cc:2082
bool mts_recovery_groups(Relay_log_info *rli)
Definition: rpl_replica.cc:5996
bool start_slave_cmd(THD *thd)
Entry point to the START SLAVE command.
Definition: rpl_replica.cc:659
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:1378
char * report_host
Definition: mysqld.cc:1609
uint report_port
Definition: mysqld.cc:1605
bool opt_relaylog_index_name_supplied
Definition: mysqld.cc:1615
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:1879
void set_slave_thread_options(THD *thd)
Set slave thread default options.
Definition: rpl_replica.cc:3840
bool server_id_supplied
Definition: mysqld.cc:1166
int abort_slave_event_count
Definition: rpl_replica.h:589
char * opt_relaylog_index_name
Definition: rpl_replica.h:354
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:8110
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:1610
int init_recovery(Master_info *mi)
Definition: rpl_replica.cc:1057
char slave_skip_error_names[]
Definition: rpl_replica.cc:181
void end_slave()
Definition: rpl_replica.cc:2051
MY_BITMAP slave_error_mask
Definition: rpl_replica.cc:180
char * opt_binlog_index_name
Definition: mysqld.cc:1645
bool show_slave_status_cmd(THD *thd)
Entry point for SHOW REPLICA STATUS command.
Definition: rpl_replica.cc:3795
void * handle_slave_sql(void *arg)
Slave SQL thread entry point.
Definition: rpl_replica.cc:6760
const char * master_info_file
Definition: rpl_replica.h:593
bool use_slave_mask
Definition: rpl_replica.cc:179
void set_slave_thread_default_charset(THD *thd, Relay_log_info const *rli)
Definition: rpl_replica.cc:3888
bool opt_relay_logname_supplied
Definition: mysqld.cc:1620
bool start_slave(THD *thd)
Function to start a slave for all channels.
Definition: rpl_replica.cc:550
char * opt_replica_skip_errors
Definition: mysqld.cc:1209
@ QUEUE_EVENT_OK
Definition: rpl_replica.h:549
@ QUEUE_EVENT_ERROR_QUEUING
Definition: rpl_replica.h:550
@ QUEUE_EVENT_ERROR_FLUSHING_INFO
Definition: rpl_replica.h:551
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:3020
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
Definition: buf0block_hint.cc:29
constexpr value_type reset_slave
Definition: classic_protocol_constants.h:309
Definition: buffer.h:42
Performance schema instrumentation interface.
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:32
SLAVE_THD_TYPE
Definition: rpl_replica.h:52
@ SLAVE_THD_SQL
Definition: rpl_replica.h:54
@ SLAVE_THD_IO
Definition: rpl_replica.h:53
@ SLAVE_THD_WORKER
Definition: rpl_replica.h:55
@ SLAVE_THD_MONITOR
Definition: rpl_replica.h:56
Structure to hold parameters for CHANGE MASTER, START SLAVE, and STOP SLAVE.
Definition: sql_lex.h:348
Definition: mysql.h:297
Definition: my_bitmap.h:41
Definition: mysql_com.h:910
Definition: task.h:425
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
Definition: sql_lex.h:2408
unsigned int uint
Definition: uca-dump.cc:29