MySQL 26.7.0
Source Code Documentation
rpl_mi.h
Go to the documentation of this file.
1/* Copyright (c) 2006, 2026, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef RPL_MI_H
25#define RPL_MI_H
26
27#include <sys/types.h>
28#include <time.h>
29#include <atomic>
30
31#include "compression.h" // COMPRESSION_ALGORITHM_NAME_BUFFER_SIZE
32#include "my_inttypes.h"
33#include "my_io.h"
34#include "my_psi_config.h"
35#include "mysql/binlog/event/binlog_event.h" // enum_binlog_checksum_alg
38#include "mysql_com.h"
39#include "sql/binlog.h"
40#include "sql/log_event.h" // Format_description_log_event
41#include "sql/rpl_gtid.h" // Gtid
42#include "sql/rpl_info.h" // Rpl_info
43#include "sql/rpl_rli.h" // rli->get_log_lock()
44#include "sql/rpl_trx_boundary_parser.h" // Transaction_boundary_parser
45#include "sql/sql_const.h"
46#include "strmake.h"
47
49class Server_ids;
50class THD;
51struct MYSQL;
52
53#define DEFAULT_CONNECT_RETRY 60
54
55/*****************************************************************************
56 Replication IO Thread
57
58 Master_info contains:
59 - information about how to connect to a master
60 - current master log name
61 - current master log offset
62 - misc control variables
63
64 Master_info is initialized once from the master.info repository if such
65 exists. Otherwise, data members corresponding to master.info fields
66 are initialized with defaults specified by master-* options. The
67 initialization is done through mi_init_info() call.
68
69 Logically, the format of master.info repository is presented as follows:
70
71 log_name
72 log_pos
73 source_host
74 source_user
75 source_pass
76 source_port
77 source_connect_retry
78
79 To write out the contents of master.info to disk a call to flush_info()
80 is required. Currently, it is needed every time we read and queue data
81 from the master.
82
83 To clean up, call end_info()
84
85*****************************************************************************/
86
87class Master_info : public Rpl_info {
88 friend class Rpl_info_factory;
89
90 public:
91 /// In case we start replication from the first binary log file and
92 /// source log name is empty, we use first_source_log_name instead of
93 /// 'master_log_name' in the error log
94 static constexpr auto first_source_log_name = "<First log>";
95
96 /**
97 Host name or ip address stored in the master.info.
98 */
100
101 /*
102 Check if the channel is configured.
103
104 @param mi Pointer to Master_info.
105
106 @retval true The channel is configured.
107 @retval false The channel is not configured.
108 */
109 static bool is_configured(Master_info *mi) { return mi && mi->host[0]; }
110
111 private:
112 /**
113 If true, USER/PASSWORD was specified when running START REPLICA.
114 */
116 /**
117 User's name stored in the master.info.
118 */
120 /**
121 User's password stored in the master.info.
122 */
124 /**
125 User specified when running START REPLICA.
126 */
128 /**
129 Password specified when running START REPLICA.
130 */
132 /**
133 Stores the authentication plugin specified when running START REPLICA.
134 */
136 /**
137 Stores the authentication plugin directory specified when running
138 START REPLICA.
139 */
141
142 /// Information on the current and last queued transactions
144
145#ifdef HAVE_PSI_INTERFACE
146 /**
147 PSI key for the `rotate_lock`
148 */
150 /**
151 PSI key for the `rotate_cond`
152 */
154#endif
155 /**
156 Lock to protect from rotating the relay log when in the middle of a
157 transaction.
158 */
160 /**
161 Waiting condition that will block the process/thread requesting a relay log
162 rotation in the middle of a transaction. The process/thread will wait until
163 the transaction is written to the relay log and the rotation is,
164 successfully accomplished.
165 */
167 /**
168 If a rotate was requested while the relay log was in a transaction.
169 */
170 std::atomic<bool> rotate_requested{false};
171
172 public:
173 /**
174 Returns if USER/PASSWORD was specified when running
175 START REPLICA.
176
177 @return true or false.
178 */
180 /**
181 Returns if DEFAULT_AUTH was specified when running START REPLICA.
182
183 @return true or false.
184 */
186 return (start_plugin_auth[0] != 0);
187 }
188 /**
189 Returns if PLUGIN_DIR was specified when running START REPLICA.
190
191 @return true or false.
192 */
194 return (start_plugin_dir[0] != 0);
195 }
196 /**
197 Defines that USER/PASSWORD was specified or not when running
198 START REPLICA.
199
200 @param config is true or false.
201 */
202 void set_start_user_configured(bool config) {
203 start_user_configured = config;
204 }
205 /**
206 Sets either user's name in the master.info repository when CHANGE
207 MASTER is executed or user's name used in START REPLICA if USER is
208 specified.
209
210 @param user_arg is user's name.
211 */
212 void set_user(const char *user_arg) {
213 if (user_arg && start_user_configured) {
214 strmake(start_user, user_arg, sizeof(start_user) - 1);
215 } else if (user_arg) {
216 strmake(user, user_arg, sizeof(user) - 1);
217 }
218 }
219 /**
220 Returns user's size name. See @c get_user().
221
222 @return user's size name.
223 */
224 size_t get_user_size() const {
225 return (start_user_configured ? sizeof(start_user) : sizeof(user));
226 }
227 /**
228 If an user was specified when running START REPLICA, this function returns
229 such user. Otherwise, it returns the user stored in master.info.
230
231 @return user's name.
232 */
233 const char *get_user() const {
235 }
236 /**
237 Stores either user's password in the master.info repository when CHANGE
238 MASTER is executed or user's password used in START REPLICA if PASSWORD
239 is specified.
240
241 @param password_arg is user's password.
242
243 */
244 void set_password(const char *password_arg);
245 /**
246 Returns either user's password in the master.info repository or
247 user's password used in START REPLICA.
248
249 @param[out] password_arg is user's password.
250 @param[out] password_arg_size is user's password size.
251
252 @return false if there is no error, otherwise true is returned.
253 */
254 bool get_password(char *password_arg, size_t *password_arg_size);
255 /**
256 Cleans in-memory password defined by START REPLICA.
257 */
258 void reset_start_info();
259 /**
260 Returns the DEFAULT_AUTH defined by START REPLICA.
261
262 @return DEFAULT_AUTH.
263 */
264 const char *get_start_plugin_auth() { return start_plugin_auth; }
265 /**
266 Returns the PLUGIN_DIR defined by START REPLICA.
267
268 @return PLUGIN_DIR.
269 */
270 const char *get_start_plugin_dir() { return start_plugin_dir; }
271 /**
272 Stores the DEFAULT_AUTH defined by START REPLICA.
273 */
274 void set_plugin_auth(const char *src) {
275 if (src) strmake(start_plugin_auth, src, sizeof(start_plugin_auth) - 1);
276 }
277 /**
278 Stores the DEFAULT_AUTH defined by START REPLICA.
279 */
280 void set_plugin_dir(const char *src) {
281 if (src) strmake(start_plugin_dir, src, sizeof(start_plugin_dir) - 1);
282 }
283
284 bool ssl; // enables use of SSL connection if true
291 /*
292 Ciphersuites used for TLS 1.3 communication with the master server.
293 tls_ciphersuites = NULL means that TLS 1.3 default ciphersuites
294 are enabled. To allow a value that can either be NULL or a string,
295 it is represented by the pair:
296 first: true if tls_ciphersuites is set to NULL
297 second: the string value when first is false
298 */
299 std::pair<bool, std::string> tls_ciphersuites = {true, ""};
304
306 uint32 file_id; /* for 3.23 load data infile */
308 uint port;
310 /*
311 The difference in seconds between the clock of the master and the clock of
312 the slave (second - first). It must be signed as it may be <0 or >0.
313 clock_diff_with_master is computed when the I/O thread starts; for this the
314 I/O thread does a SELECT UNIX_TIMESTAMP() on the master.
315 "how late the slave is compared to the master" is computed like this:
316 clock_of_slave - last_timestamp_executed_by_SQL_thread -
317 clock_diff_with_master
318
319 */
321 float heartbeat_period; // interface with CHANGE REPLICATION SOURCE or
322 // master.info
323 ulonglong received_heartbeats; // counter of received heartbeat events
324
326
327 /// The decompressed size of the transaction that is currently in progress of
328 /// being queued, if any. This is private to the reciever.
330 /// The size of the gtid event for the transaction that is currently in
331 /// progress of being queued. This is private to the receiver.
333
335
337 /*
338 to hold checksum alg in use until IO thread has received FD.
339 Initialized to novalue, then set to the queried from master
340 @@global.binlog_checksum and deactivated once FD has been received.
341 */
346
347 /*
348 Name of a network namespace where a socket for connection to a master
349 should be created.
350 */
352
353 bool is_set_network_namespace() const { return network_namespace[0] != 0; }
354
355 const char *network_namespace_str() const {
357 }
358 /*
359 describes what compression algorithm and level is used between
360 master/slave communication protocol
361 */
364 NET_SERVER server_extn; // maintain compress context info.
365
366 int mi_init_info();
367 void end_info();
368 int flush_info(bool force = false);
370
371 bool shall_ignore_server_id(ulong s_id);
372
373 /*
374 A buffer to hold " for channel <channel_name>
375 used in error messages per channel
376 */
379
380 /**
381 @return The pointer to the Gtid_monitoring_info
382 */
385 }
386
387 /**
388 Stores the details of the transaction the receiver thread has just started
389 queueing.
390
391 @param gtid_arg the gtid of the trx
392 @param original_ts_arg the original commit timestamp of the transaction
393 @param immediate_ts_arg the immediate commit timestamp of the transaction
394 */
395 void started_queueing(Gtid gtid_arg, ulonglong original_ts_arg,
396 ulonglong immediate_ts_arg) {
397 gtid_monitoring_info->start(gtid_arg, original_ts_arg, immediate_ts_arg);
398 }
399
400 /**
401 Track statistics after the receiver has finished queueing a transaction.
402
403 In gtid_monitoring_info, the transaction timestamp is recorded and the
404 information is copied to last_queued_trx and cleared from queueing_trx.
405
406 In applier_metrics, the size/count of received transactions are incremented.
407 */
410
412 // Transactions before the metrics breakpoint count their sizes at commit
413 // time. Transactions after the metrics breakpoint count their sizes here,
414 // at the time they are fully received. See
415 // Applier_metrics_interface::is_after_metrics_breakpoint for details.
417 applier_metrics.inc_transactions_received_size_sum(
419 applier_metrics.inc_transactions_received_count(1);
420 }
421 }
422
423 /**
424 @return True if there is a transaction currently being queued
425 */
428 }
429
430 /**
431 @return The pointer to the GTID of the processing_trx of
432 Gtid_monitoring_info.
433 */
436 }
437
438 /**
439 Clears the processing_trx monitoring info.
440
441 Normally called when there is an error while queueing the transaction.
442 */
443 void clear_queueing_trx(bool need_lock = false) {
444 if (need_lock) mysql_mutex_lock(&data_lock);
446 if (need_lock) mysql_mutex_unlock(&data_lock);
447 }
448
449 /**
450 Clears all GTID monitoring info.
451 */
452 void clear_gtid_monitoring_info(bool need_lock = false) {
453 if (need_lock) mysql_mutex_lock(&data_lock);
455 if (need_lock) mysql_mutex_unlock(&data_lock);
456 }
457
458 ~Master_info() override;
459
460 /**
461 Sets the flag that indicates that a relay log rotation has been requested.
462
463 @param[in] thd the client thread carrying the command.
464 */
465 void request_rotate(THD *thd);
466 /**
467 Clears the flag that indicates that a relay log rotation has been requested
468 and notifies requester that the rotation has finished.
469 */
471 /**
472 Checks whether or not there is a request for rotating the underlying relay
473 log.
474
475 @returns true if there is, false otherwise
476 */
477 bool is_rotate_requested();
478
479 protected:
482
483 public:
484 inline const char *get_master_log_name() const { return master_log_name; }
485 inline const char *get_master_log_name_info() const {
486 if (m_is_receiver_position_info_invalid) return "INVALID";
487 return get_master_log_name();
488 }
489 inline ulonglong get_master_log_pos() const { return master_log_pos; }
492 return get_master_log_pos();
493 }
494 inline void set_master_log_name(const char *log_file_name) {
496 }
497 inline void set_master_log_pos(ulonglong log_pos) {
499 master_log_pos = log_pos;
500 }
501 inline const char *get_io_rpl_log_name() {
502 return (master_log_name[0] ? master_log_name : "FIRST");
503 }
504 static size_t get_number_info_mi_fields();
505
506 /**
507 returns the column number of a channel in the TABLE repository.
508 Mainly used during server startup to load the information required
509 from the slave repository tables. See rpl_info_factory.cc
510 */
511 static uint get_channel_field_num();
512
513 /**
514 Returns an array with the expected column names of the primary key
515 fields of the table repository.
516 */
517 static const char **get_table_pk_field_names();
518
519 /**
520 Returns an array with the expected column numbers of the primary key
521 fields of the table repository.
522 */
523 static const uint *get_table_pk_field_indexes();
524
525 /**
526 Sets bits for columns that are allowed to be `NULL`.
527
528 @param nullable_fields the bitmap to hold the nullable fields.
529 */
530 static void set_nullable_fields(MY_BITMAP *nullable_fields);
531
533
534 void set_auto_position(bool auto_position_param) {
535 auto_position = auto_position_param;
536 }
537
538 /**
539 Checks if Asynchronous Replication Connection Failover feature is enabled.
540
541 @returns true if Asynchronous Replication Connection Failover feature is
542 enabled.
543 false otherwise.
544 */
547 }
548
549 /**
550 Enable Asynchronous Replication Connection Failover feature.
551 */
554 }
555
556 /**
557 Disable Asynchronous Replication Connection Failover feature.
558 */
561 }
562
563 /**
564 Return current position in the Failover source list for the
565 Asynchronous Replication Connection Failover feature.
566 Based on this position next failover source is selected.
567
568 @returns current position in the Failover source list.
569 */
571
572 /**
573 Reset current position to 0, when new failover source list is fetched.
574 */
576
577 /**
578 Increment current position, so next failover source can be selected on
579 failure.
580 */
582
583 /**
584 Checks if network error has occurred.
585
586 @returns true if slave IO thread failure was due to network error,
587 false otherwise.
588 */
590
591 /**
592 Sets m_network_error to true. Its used by async replication connection
593 failover in case of slave IO thread failure to check if it was due to
594 network failure.
595 */
597
598 /**
599 Resets m_network_error to false.
600 */
602
603 /**
604 Checks if compatibility error has occurred.
605
606 @returns true a version-compatibility error was detected during
607 source replica negotiation.
608 false otherwise.
609 */
610 [[nodiscard]] bool is_compatibility_error() { return m_compatibility_error; }
611
612 /**
613 Mark that a version-compatibility error has occurred.
614
615 This is used by the asynchronous replication failover logic to determine
616 whether an I/O thread failure was caused by a version mismatch between
617 the source and replica.
618 */
620
621 /**
622 Clear the compatibility error flag.
623 */
625
626 /**
627 This member function shall return true if there are server
628 ids configured to be ignored.
629
630 @return true if there are server ids to be ignored,
631 false otherwise.
632 */
634
635 private:
636 /**
637 Format_description_log_event for events received from the master
638 by the IO thread and written to the tail of the relay log.
639
640 Use patterns:
641 - Created when the IO thread starts and destroyed when the IO
642 thread stops.
643 - Updated when the IO thread receives a
644 Format_description_log_event.
645 - Accessed by the IO thread when it de-serializes events (e.g.,
646 rotate events, Gtid events).
647 - Written by the IO thread to the new relay log on every rotation.
648 - Written by a client that executes FLUSH LOGS to the new relay
649 log on every rotation.
650
651 Locks:
652 All access is protected by Relay_log::LOCK_log.
653 */
655
656 public:
660 }
665 }
666
667 bool set_info_search_keys(Rpl_info_handler *to) override;
668
669 const char *get_for_channel_str(bool upper_case = false) const override {
670 return reinterpret_cast<const char *>(upper_case ? for_channel_uppercase_str
672 }
673
674 void init_master_log_pos();
675
676 private:
677 bool read_info(Rpl_info_handler *from) override;
678 bool write_info(Rpl_info_handler *to) override;
679
680 bool auto_position{false};
683 bool m_network_error{false};
685
688 PSI_mutex_key *param_key_info_run_lock,
689 PSI_mutex_key *param_key_info_data_lock,
690 PSI_mutex_key *param_key_info_sleep_lock,
691 PSI_mutex_key *param_key_info_thd_lock,
692 PSI_mutex_key *param_key_info_rotate_lock,
693 PSI_mutex_key *param_key_info_data_cond,
694 PSI_mutex_key *param_key_info_start_cond,
695 PSI_mutex_key *param_key_info_stop_cond,
696 PSI_mutex_key *param_key_info_sleep_cond,
697 PSI_mutex_key *param_key_info_rotate_cond,
698#endif
699 uint param_id, const char *param_channel);
700
703
704 public:
705 /*
706 This will be used to verify transactions boundaries of events sent by the
707 master server.
708 It will also be used to verify transactions boundaries on the relay log
709 while collecting the Retrieved_Gtid_Set to make sure of only adding GTIDs
710 of fully retrieved transactions.
711 Its output is also used to detect when events were not logged using row
712 based logging.
713 */
715
716 private:
717 /*
718 This is the channel lock. It is a rwlock used to serialize all replication
719 administrative commands that cannot be performed concurrently for a given
720 replication channel:
721 - START REPLICA;
722 - STOP REPLICA;
723 - CHANGE REPLICATION SOURCE;
724 - RESET REPLICA;
725 - end_slave() (when mysqld stops)).
726 Any of these commands must hold the wrlock from the start till the end.
727 */
729
730 /* References of the channel, the channel can only be deleted when it is 0. */
731 std::atomic<int32> atomic_references{0};
732
733 public:
734 /**
735 Acquire the channel read lock.
736 */
737 void channel_rdlock();
738
739 /**
740 Acquire the channel write lock.
741 */
742 void channel_wrlock();
743
744 /**
745 Try to acquire the write lock, and fail if it cannot be
746 immediately granted.
747 */
748 int channel_trywrlock();
749
750 /**
751 Release the channel lock (whether it is a write or read lock).
752 */
754
755 /**
756 Assert that some thread holds either the read or the write lock.
757 */
758 inline void channel_assert_some_lock() const {
760 }
761
762 /**
763 Assert that some thread holds the write lock.
764 */
765 inline void channel_assert_some_wrlock() const {
767 }
768
769 /**
770 Increase the reference count to prohibit deleting a channel. This function
771 must be protected by channel_map.rdlock(). dec_reference has to be
772 called in conjunction with inc_reference().
773 */
775
776 /**
777 Decrease the reference count. Doesn't need the protection of
778 channel_map.rdlock.
779 */
781
782 /**
783 It mush be called before deleting a channel and protected by
784 channel_map_lock.wrlock().
785
786 @param thd the THD object of current thread
787 */
788 void wait_until_no_reference(THD *thd);
789
790 /* Set true when the Master_info object was cleared by a RESET REPLICA */
791 bool reset;
792
793 /**
794 Sync flushed_relay_log_info with current relay log coordinates.
795
796 It will sync the receiver thread relay log coordinates (file name and
797 position) with the last master coordinates that were flushed into the
798 Master_info repository.
799
800 This function shall be called by Master_info::flush_info() at the end of a
801 successful flush of the Master_info content into the repository while still
802 holding the data_lock.
803
804 It is also called my load_mi_and_rli_from_repositories(), right after the
805 successful call to rli_init_info() that opens the relay log.
806 */
807
809
810 /**
811 Collect relay log coordinates (file name and position) that related to the
812 last Master_info master coordinates flushed into the repository.
813
814 @param [out] linfo Where the relay log coordinates shall be stored.
815 */
816
818
819 /**
820 Marks the receiver position information (master_log_name, master_log_pos)
821 as being invalid or not.
822
823 @param invalid The value to set the status to invalid or valid
824 */
825 void set_receiver_position_info_invalid(bool invalid);
826
827 /**
828 Returns if receiver position information is valid or invalid
829
830 @return true if receiver position information is not reliable,
831 false otherwise.
832 */
834
835 /**
836 Enable or disable the gtid_only mode
837
838 @param gtid_only_mode value to set gtid_only (enable/disable it)
839 */
840 void set_gtid_only_mode(bool gtid_only_mode);
841
842 /**
843 Returns if gtid_only is enabled or not
844
845 @return true if gtid_only mode is active for a channel,
846 false otherwise.
847 */
848 bool is_gtid_only_mode() const;
849
850 private:
851 /*
852 Holds the relay log coordinates (file name and position) of the last master
853 coordinates flushed into Master_info repository.
854 */
856
857 /**
858 Is the replica working in GTID only mode, meaning it does not
859 persist position related information when executing or queueing
860 transactions.
861 */
863
864 /**
865 Are positions invalid. When true this means the values for
866 receiver position related information might be outdated.
867 */
869
870 public:
871 /*
872 Hostname of the server where master_uuid was last read.
873 */
874 std::string m_uuid_from_host{};
875
876 /*
877 Port of the server where master_uuid was last read.
878 */
880
881 private:
882 /// Is the collection of metrics enabled?
884
885 public:
886 /// @brief Enable or disable metric collection
887 /// @param value true to enable, false to disable
890 }
891
892 /// @brief Returns if metric collection is enabled on this channel
893 /// @return True if yes, false if no
895};
896
897#endif /* RPL_MI_H */
Contains the classes representing events occurring in the replication stream.
This has the functionality of mysql_rwlock_t, with two differences:
Definition: rpl_gtid.h:326
void assert_some_lock() const
Assert that some thread holds either the read or the write lock.
Definition: rpl_gtid.h:573
void unlock()
Release the lock (whether it is a write or read lock).
Definition: rpl_gtid.h:507
void assert_some_wrlock() const
Assert that some thread holds the write lock.
Definition: rpl_gtid.h:577
For binlog version 4.
Definition: log_event.h:1558
Stores information to monitor a transaction during the different replication stages.
Definition: rpl_gtid.h:1414
const Gtid * get_processing_trx_gtid()
Returns the GTID of the processing_trx.
Definition: rpl_gtid_misc.cc:602
void clear()
Clear all monitoring information.
Definition: rpl_gtid_misc.cc:496
void finish()
Sets the final information, copy processing info to last_processed and clears processing info.
Definition: rpl_gtid_misc.cc:563
void start(Gtid gtid_arg, ulonglong original_ts_arg, ulonglong immediate_ts_arg, bool skipped_arg=false)
Sets the initial monitoring information.
Definition: rpl_gtid_misc.cc:523
bool is_processing_trx_set()
Returns true if the processing_trx is set, false otherwise.
Definition: rpl_gtid_misc.cc:593
void clear_processing_trx()
Clear only the processing_trx monitoring info.
Definition: rpl_gtid_misc.cc:503
mysql_mutex_t * get_log_lock()
Definition: binlog.h:889
Definition: rpl_mi.h:87
static const uint * get_table_pk_field_indexes()
Returns an array with the expected column numbers of the primary key fields of the table repository.
Definition: rpl_mi.cc:450
Gtid_monitoring_info * gtid_monitoring_info
Information on the current and last queued transactions.
Definition: rpl_mi.h:143
size_t get_user_size() const
Returns user's size name.
Definition: rpl_mi.h:224
void set_password(const char *password_arg)
Stores either user's password in the master.info repository when CHANGE MASTER is executed or user's ...
Definition: rpl_mi.cc:724
bool start_user_configured
If true, USER/PASSWORD was specified when running START REPLICA.
Definition: rpl_mi.h:115
char network_namespace[NAME_LEN]
Definition: rpl_mi.h:351
bool m_gtid_only_mode
Is the replica working in GTID only mode, meaning it does not persist position related information wh...
Definition: rpl_mi.h:862
bool is_rotate_requested()
Checks whether or not there is a request for rotating the underlying relay log.
Definition: rpl_mi.cc:309
Relay_log_info * rli
Definition: rpl_mi.h:307
void end_info()
Definition: rpl_mi.cc:340
bool is_gtid_only_mode() const
Returns if gtid_only is enabled or not.
Definition: rpl_mi.cc:819
void set_master_log_pos(ulonglong log_pos)
Definition: rpl_mi.h:497
char public_key_path[FN_REFLEN]
Definition: rpl_mi.h:301
char start_plugin_auth[FN_REFLEN+1]
Stores the authentication plugin specified when running START REPLICA.
Definition: rpl_mi.h:135
int mi_init_info()
Creates or reads information from the repository, initializing the Master_info.
Definition: rpl_mi.cc:410
void inc_reference()
Increase the reference count to prohibit deleting a channel.
Definition: rpl_mi.h:774
void get_flushed_relay_log_info(Log_info *linfo)
Collect relay log coordinates (file name and position) that related to the last Master_info master co...
Definition: rpl_mi.cc:801
void increment_failover_list_position()
Increment current position, so next failover source can be selected on failure.
Definition: rpl_mi.h:581
long clock_diff_with_master
Definition: rpl_mi.h:320
char master_uuid[UUID_LENGTH+1]
Definition: rpl_mi.h:344
mysql::binlog::event::enum_binlog_checksum_alg checksum_alg_before_fd
Definition: rpl_mi.h:342
char start_password[MAX_PASSWORD_LENGTH+1]
Password specified when running START REPLICA.
Definition: rpl_mi.h:131
void set_plugin_auth(const char *src)
Stores the DEFAULT_AUTH defined by START REPLICA.
Definition: rpl_mi.h:274
void set_receiver_position_info_invalid(bool invalid)
Marks the receiver position information (master_log_name, master_log_pos) as being invalid or not.
Definition: rpl_mi.cc:807
Gtid_monitoring_info * get_gtid_monitoring_info()
Definition: rpl_mi.h:383
void set_master_log_name(const char *log_file_name)
Definition: rpl_mi.h:494
static uint get_channel_field_num()
returns the column number of a channel in the TABLE repository.
Definition: rpl_mi.cc:445
void reset_network_error()
Resets m_network_error to false.
Definition: rpl_mi.h:601
bool is_compatibility_error()
Checks if compatibility error has occurred.
Definition: rpl_mi.h:610
const char * get_for_channel_str(bool upper_case=false) const override
Definition: rpl_mi.h:669
const char * get_user() const
If an user was specified when running START REPLICA, this function returns such user.
Definition: rpl_mi.h:233
static const char ** get_table_pk_field_names()
Returns an array with the expected column names of the primary key fields of the table repository.
NET_SERVER server_extn
Definition: rpl_mi.h:364
bool set_info_search_keys(Rpl_info_handler *to) override
To search in the slave repositories, each slave info object (mi, rli or worker) should use a primary ...
Definition: rpl_mi.cc:681
void set_source_connection_auto_failover()
Enable Asynchronous Replication Connection Failover feature.
Definition: rpl_mi.h:552
my_off_t master_log_pos
Definition: rpl_mi.h:481
Checkable_rwlock * m_channel_lock
Definition: rpl_mi.h:728
void set_user(const char *user_arg)
Sets either user's name in the master.info repository when CHANGE MASTER is executed or user's name u...
Definition: rpl_mi.h:212
void request_rotate(THD *thd)
Sets the flag that indicates that a relay log rotation has been requested.
Definition: rpl_mi.cc:268
char compression_algorithm[COMPRESSION_ALGORITHM_NAME_BUFFER_SIZE]
Definition: rpl_mi.h:362
bool is_source_connection_auto_failover()
Checks if Asynchronous Replication Connection Failover feature is enabled.
Definition: rpl_mi.h:545
const char * get_start_plugin_dir()
Returns the PLUGIN_DIR defined by START REPLICA.
Definition: rpl_mi.h:270
bool is_set_network_namespace() const
Definition: rpl_mi.h:353
void reset_failover_list_position()
Reset current position to 0, when new failover source list is fetched.
Definition: rpl_mi.h:575
void clear_gtid_monitoring_info(bool need_lock=false)
Clears all GTID monitoring info.
Definition: rpl_mi.h:452
uint connect_retry
Definition: rpl_mi.h:309
bool is_network_error()
Checks if network error has occurred.
Definition: rpl_mi.h:589
char for_channel_uppercase_str[CHANNEL_NAME_LENGTH+31]
Definition: rpl_mi.h:378
bool auto_position
Definition: rpl_mi.h:680
void clear_rotate_requests()
Clears the flag that indicates that a relay log rotation has been requested and notifies requester th...
Definition: rpl_mi.cc:288
bool ssl
Definition: rpl_mi.h:284
void set_gtid_only_mode(bool gtid_only_mode)
Enable or disable the gtid_only mode.
Definition: rpl_mi.cc:815
uint m_failover_list_position
Definition: rpl_mi.h:682
Log_info flushed_relay_log_info
Definition: rpl_mi.h:855
void channel_rdlock()
Acquire the channel read lock.
Definition: rpl_mi.cc:760
char ssl_capath[FN_REFLEN]
Definition: rpl_mi.h:285
void reset_start_info()
Cleans in-memory password defined by START REPLICA.
Definition: rpl_mi.cc:751
std::pair< bool, std::string > tls_ciphersuites
Definition: rpl_mi.h:299
Replication_transaction_boundary_parser transaction_parser
Definition: rpl_mi.h:714
void set_applier_metric_collection_status(bool value)
Enable or disable metric collection.
Definition: rpl_mi.h:888
void set_auto_position(bool auto_position_param)
Definition: rpl_mi.h:534
void reset_compatibility_error()
Clear the compatibility error flag.
Definition: rpl_mi.h:624
static bool is_configured(Master_info *mi)
Definition: rpl_mi.h:109
bool get_password(char *password_arg, size_t *password_arg_size)
Returns either user's password in the master.info repository or user's password used in START REPLICA...
Definition: rpl_mi.cc:735
void set_mi_description_event(Format_description_log_event *fdle)
Definition: rpl_mi.h:661
static constexpr auto first_source_log_name
In case we start replication from the first binary log file and source log name is empty,...
Definition: rpl_mi.h:94
Format_description_log_event * get_mi_description_event()
Definition: rpl_mi.h:657
void dec_reference()
Decrease the reference count.
Definition: rpl_mi.h:780
char master_log_name[FN_REFLEN]
Definition: rpl_mi.h:480
bool is_ignore_server_ids_configured()
This member function shall return true if there are server ids configured to be ignored.
Definition: rpl_mi.cc:786
void channel_wrlock()
Acquire the channel write lock.
Definition: rpl_mi.cc:765
void update_flushed_relay_log_info()
Sync flushed_relay_log_info with current relay log coordinates.
Definition: rpl_mi.cc:790
ulonglong last_heartbeat
Definition: rpl_mi.h:325
bool read_info(Rpl_info_handler *from) override
Definition: rpl_mi.cc:462
char tls_kex[FN_REFLEN]
Definition: rpl_mi.h:290
bool ssl_verify_server_cert
Definition: rpl_mi.h:302
bool use_pqc_sign
Definition: rpl_mi.h:289
uint32 file_id
Definition: rpl_mi.h:306
bool m_compatibility_error
Definition: rpl_mi.h:684
int flush_info(bool force=false)
Store the master file and position where the slave's I/O thread are in the relay log.
Definition: rpl_mi.cc:369
bool m_network_error
Definition: rpl_mi.h:683
void wait_until_no_reference(THD *thd)
It mush be called before deleting a channel and protected by channel_map_lock.wrlock().
Definition: rpl_mi.cc:775
std::atomic< int32 > atomic_references
Definition: rpl_mi.h:731
static void set_nullable_fields(MY_BITMAP *nullable_fields)
Sets bits for columns that are allowed to be NULL.
Definition: rpl_mi.cc:454
bool reset
Definition: rpl_mi.h:791
void channel_unlock()
Release the channel lock (whether it is a write or read lock).
Definition: rpl_mi.h:753
PSI_mutex_key * key_info_rotate_cond
PSI key for the rotate_cond
Definition: rpl_mi.h:153
ulong master_id
Definition: rpl_mi.h:336
int64_t m_queueing_transaction_size
The decompressed size of the transaction that is currently in progress of being queued,...
Definition: rpl_mi.h:329
void set_relay_log_info(Relay_log_info *info)
Definition: rpl_mi.cc:404
std::string m_uuid_from_host
Definition: rpl_mi.h:874
char ssl_key[FN_REFLEN]
Definition: rpl_mi.h:286
bool m_is_receiver_position_info_invalid
Are positions invalid.
Definition: rpl_mi.h:868
const char * get_io_rpl_log_name()
Definition: rpl_mi.h:501
const Gtid * get_queueing_trx_gtid()
Definition: rpl_mi.h:434
PSI_mutex_key * key_info_rotate_lock
PSI key for the rotate_lock
Definition: rpl_mi.h:149
MYSQL * mysql
Definition: rpl_mi.h:305
ulonglong received_heartbeats
Definition: rpl_mi.h:323
char host[HOSTNAME_LENGTH+1]
Host name or ip address stored in the master.info.
Definition: rpl_mi.h:99
char user[USERNAME_LENGTH+1]
User's name stored in the master.info.
Definition: rpl_mi.h:119
const char * get_master_log_name_info() const
Definition: rpl_mi.h:485
char ssl_crl[FN_REFLEN]
Definition: rpl_mi.h:300
char ssl_cipher[FN_REFLEN]
Definition: rpl_mi.h:286
char ssl_ca[FN_REFLEN]
Definition: rpl_mi.h:285
bool is_start_plugin_auth_configured() const
Returns if DEFAULT_AUTH was specified when running START REPLICA.
Definition: rpl_mi.h:185
uint get_failover_list_position()
Return current position in the Failover source list for the Asynchronous Replication Connection Failo...
Definition: rpl_mi.h:570
Master_info(PSI_mutex_key *param_key_info_run_lock, PSI_mutex_key *param_key_info_data_lock, PSI_mutex_key *param_key_info_sleep_lock, PSI_mutex_key *param_key_info_thd_lock, PSI_mutex_key *param_key_info_rotate_lock, PSI_mutex_key *param_key_info_data_cond, PSI_mutex_key *param_key_info_start_cond, PSI_mutex_key *param_key_info_stop_cond, PSI_mutex_key *param_key_info_sleep_cond, PSI_mutex_key *param_key_info_rotate_cond, uint param_id, const char *param_channel)
Definition: rpl_mi.cc:160
void channel_assert_some_wrlock() const
Assert that some thread holds the write lock.
Definition: rpl_mi.h:765
char tls_version[FN_REFLEN]
Definition: rpl_mi.h:287
char bind_addr[HOSTNAME_LENGTH+1]
Definition: rpl_mi.h:345
void set_compatibility_error()
Mark that a version-compatibility error has occurred.
Definition: rpl_mi.h:619
mysql_cond_t rotate_cond
Waiting condition that will block the process/thread requesting a relay log rotation in the middle of...
Definition: rpl_mi.h:166
void set_start_user_configured(bool config)
Defines that USER/PASSWORD was specified or not when running START REPLICA.
Definition: rpl_mi.h:202
ulonglong get_master_log_pos() const
Definition: rpl_mi.h:489
Server_ids * ignore_server_ids
Definition: rpl_mi.h:334
bool is_auto_position()
Definition: rpl_mi.h:532
bool is_start_user_configured() const
Returns if USER/PASSWORD was specified when running START REPLICA.
Definition: rpl_mi.h:179
char for_channel_str[CHANNEL_NAME_LENGTH+31]
Definition: rpl_mi.h:377
uint m_uuid_from_port
Definition: rpl_mi.h:879
~Master_info() override
Definition: rpl_mi.cc:251
char ssl_crlpath[FN_REFLEN]
Definition: rpl_mi.h:300
char start_user[USERNAME_LENGTH+1]
User specified when running START REPLICA.
Definition: rpl_mi.h:127
int64_t m_queueing_transaction_gtid_event_size
The size of the gtid event for the transaction that is currently in progress of being queued.
Definition: rpl_mi.h:332
bool is_receiver_position_info_invalid() const
Returns if receiver position information is valid or invalid.
Definition: rpl_mi.cc:811
bool shall_ignore_server_id(ulong s_id)
Reports if the s_id server has been configured to ignore events it generates with.
Definition: rpl_mi.cc:326
const char * network_namespace_str() const
Definition: rpl_mi.h:355
void channel_assert_some_lock() const
Assert that some thread holds either the read or the write lock.
Definition: rpl_mi.h:758
ulong retry_count
Definition: rpl_mi.h:343
bool write_info(Rpl_info_handler *to) override
Definition: rpl_mi.cc:689
void clear_queueing_trx(bool need_lock=false)
Clears the processing_trx monitoring info.
Definition: rpl_mi.h:443
void set_network_error()
Sets m_network_error to true.
Definition: rpl_mi.h:596
void finished_queueing()
Track statistics after the receiver has finished queueing a transaction.
Definition: rpl_mi.h:408
char start_plugin_dir[FN_REFLEN+1]
Stores the authentication plugin directory specified when running START REPLICA.
Definition: rpl_mi.h:140
int zstd_compression_level
Definition: rpl_mi.h:363
Master_info(const Master_info &info)
char ssl_cert[FN_REFLEN]
Definition: rpl_mi.h:285
std::atomic< bool > rotate_requested
If a rotate was requested while the relay log was in a transaction.
Definition: rpl_mi.h:170
mysql_mutex_t rotate_lock
Lock to protect from rotating the relay log when in the middle of a transaction.
Definition: rpl_mi.h:159
bool m_source_connection_auto_failover
Definition: rpl_mi.h:681
bool get_public_key
Definition: rpl_mi.h:303
ulonglong get_master_log_pos_info() const
Definition: rpl_mi.h:490
void started_queueing(Gtid gtid_arg, ulonglong original_ts_arg, ulonglong immediate_ts_arg)
Stores the details of the transaction the receiver thread has just started queueing.
Definition: rpl_mi.h:395
float heartbeat_period
Definition: rpl_mi.h:321
static size_t get_number_info_mi_fields()
Definition: rpl_mi.cc:441
Master_info & operator=(const Master_info &info)
uint port
Definition: rpl_mi.h:308
bool is_metric_collection_enabled()
Returns if metric collection is enabled on this channel.
Definition: rpl_mi.h:894
bool is_queueing_trx()
Definition: rpl_mi.h:426
int channel_trywrlock()
Try to acquire the write lock, and fail if it cannot be immediately granted.
Definition: rpl_mi.cc:770
bool force_pqc
Definition: rpl_mi.h:288
const char * get_master_log_name() const
Definition: rpl_mi.h:484
bool m_is_metric_collection_enabled
Is the collection of metrics enabled?
Definition: rpl_mi.h:883
Format_description_log_event * mi_description_event
Format_description_log_event for events received from the master by the IO thread and written to the ...
Definition: rpl_mi.h:654
bool is_start_plugin_dir_configured() const
Returns if PLUGIN_DIR was specified when running START REPLICA.
Definition: rpl_mi.h:193
void init_master_log_pos()
Definition: rpl_mi.cc:331
void set_plugin_dir(const char *src)
Stores the DEFAULT_AUTH defined by START REPLICA.
Definition: rpl_mi.h:280
char password[MAX_PASSWORD_LENGTH+1]
User's password stored in the master.info.
Definition: rpl_mi.h:123
void unset_source_connection_auto_failover()
Disable Asynchronous Replication Connection Failover feature.
Definition: rpl_mi.h:559
const char * get_start_plugin_auth()
Returns the DEFAULT_AUTH defined by START REPLICA.
Definition: rpl_mi.h:264
Definition: rpl_rli.h:208
cs::apply::instruments::Applier_metrics_interface & get_applier_metrics()
Returns the replication applier metrics aggregator.
Definition: rpl_rli.cc:3401
MYSQL_BIN_LOG relay_log
Definition: rpl_rli.h:342
This is the class for verifying transaction boundaries in a replication event stream.
Definition: rpl_trx_boundary_parser.h:51
Definition: rpl_info_factory.h:41
Definition: rpl_info_handler.h:58
Definition: rpl_info.h:43
mysql_mutex_t data_lock
Definition: rpl_info.h:58
Definition: dynamic_ids.h:33
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
virtual bool is_after_metrics_breakpoint() const =0
Query whether the size/count of received transactions has been completely computed.
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:50
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:57
#define COMPRESSION_ALGORITHM_NAME_BUFFER_SIZE
Definition: compression.h:42
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:52
#define mysql_mutex_assert_owner(M)
Wrapper, to use safe_mutex_assert_owner with instrumented mutexes.
Definition: mysql_mutex.h:112
std::string log_file_name(const Log_files_context &ctx, Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0files_io.cc:695
Binary log event definitions.
static constexpr int HOSTNAME_LENGTH
Definition: my_hostname.h:43
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
ulonglong my_off_t
Definition: my_inttypes.h:72
uint32_t uint32
Definition: my_inttypes.h:67
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:87
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
#define HAVE_PSI_INTERFACE
Definition: my_psi_config.h:39
Common definition between mysql server & client.
#define NAME_LEN
Definition: mysql_com.h:67
#define USERNAME_LENGTH
Definition: mysql_com.h:69
Definition: applier_metrics_pfs_table.cc:33
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
enum_binlog_checksum_alg
Enumeration spcifying checksum algorithm used to encode a binary log event.
Definition: binlog_event.h:455
Instrumentation helpers for mutexes.
Instrumentation helpers for mutexes.
#define CHANNEL_NAME_LENGTH
Definition: rpl_info.h:41
Replication transaction boundary parser.
File containing constants that can be used throughout the server.
constexpr const size_t UUID_LENGTH
Definition: sql_const.h:266
char * strmake(char *dst, const char *src, size_t length)
Definition: strmake.cc:42
TODO: Move this structure to mysql/binlog/event/control_events.h when we start using C++11.
Definition: rpl_gtid.h:1102
Definition: binlog_index.h:86
Definition: mysql.h:303
Definition: my_bitmap.h:43
Definition: mysql_com_server.h:59
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
#define MAX_PASSWORD_LENGTH
Definition: validate_password.cc:66