MySQL 8.0.29
Source Code Documentation
rpl_rli.h
Go to the documentation of this file.
1/* Copyright (c) 2005, 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_RLI_H
24#define RPL_RLI_H
25
26#include <sys/types.h>
27#include <time.h>
28#include <atomic>
29#include <memory>
30#include <string>
31#include <string_view>
32#include <vector>
33
34#include "lex_string.h"
36#include "m_string.h"
37#include "map_helpers.h"
38#include "my_bitmap.h"
39#include "my_dbug.h"
40#include "my_inttypes.h"
41#include "my_io.h"
42#include "my_loglevel.h"
43#include "my_psi_config.h"
44#include "my_sys.h"
49#include "mysql/thread_type.h"
50#include "prealloced_array.h" // Prealloced_array
51#include "sql/binlog.h" // MYSQL_BIN_LOG
52#include "sql/log_event.h" //Gtid_log_event
53#include "sql/psi_memory_key.h"
54#include "sql/query_options.h"
55#include "sql/rpl_gtid.h" // Gtid_set
56#include "sql/rpl_info.h" // Rpl_info
57#include "sql/rpl_mta_submode.h" // enum_mts_parallel_type
59#include "sql/rpl_tblmap.h" // table_mapping
61#include "sql/rpl_utility.h" // Deferred_log_events
62#include "sql/sql_class.h" // THD
64#include "sql/table.h"
65
67class Master_info;
68class Rpl_filter;
71class Slave_worker;
72class String;
73struct LEX_MASTER_INFO;
75
77
79
80typedef struct slave_job_item {
85
86/**
87 This class is used to store the type and value for
88 Assign_gtids_to_anonymous_transactions parameter of Change master command on
89 slave.
90*/
92 public:
93 /**
94 This accepted value of the type of the
95 Assign_gtids_to_anonymous_transactions info OFF : Anonymous gtid events
96 won't be converted to Gtid event. LOCAL: Anonymous gtid events will be
97 converted to Gtid event & the UUID used while create GTIDs will be the one
98 of replica which is the server where this transformation of anonymous to
99 gtid event happens. UUID: Anonymous gtid events will be converted to Gtid
100 event & the UUID used while create GTIDs will be the one specified via
101 Change master command to the parameter
102 ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
103 */
105 /**
106 The default constructor intializes the parameter to their default value
107 */
110 m_sidno = 0;
111 }
112 rpl_sidno get_sidno() const { return m_sidno; }
113 enum_type get_type() const;
114 std::string get_value() const;
115 /*
116 Here the assign_gtids_to_anonymous_transactions_value contains the textual
117 representation of the UUID used while creating a GTID.
118 */
119 bool set_info(enum_type assign_gtids_to_anonymous_transactions_type,
120 const char *assign_gtids_to_anonymous_transactions_value);
121
122 private:
123 /** This stores the type of Assign_gtids_to_anonymous_transactions info */
125 /** Stores the UUID in case the m_type is not OFF */
126 std::string m_value;
127 // The sidno corresponding to the UUID value.
129};
130/*******************************************************************************
131Replication SQL Thread
132
133Relay_log_info contains:
134 - the current relay log
135 - the current relay log offset
136 - master log name
137 - master log sequence corresponding to the last update
138 - misc information specific to the SQL thread
139
140Relay_log_info is initialized from a repository, i.e. table or file, if there is
141one. Otherwise, data members are intialized with defaults by calling
142init_relay_log_info().
143
144The relay.info table/file shall be updated whenever: (i) the relay log file
145is rotated, (ii) SQL Thread is stopped, (iii) while processing a Xid_log_event,
146(iv) after a Query_log_event (i.e. commit or rollback) and (v) after processing
147any statement written to the binary log without a transaction context.
148
149The Xid_log_event is a commit for transactional engines and must be handled
150differently to provide reliability/data integrity. In this case, positions
151are updated within the context of the current transaction. So
152
153 . If the relay.info is stored in a transactional repository and the server
154 crashes before successfully committing the transaction the changes to the
155 position table will be rolled back along with the data.
156
157 . If the relay.info is stored in a non-transactional repository, for instance,
158 a file or a system table created using MyIsam, and the server crashes before
159 successfully committing the transaction the changes to the position table
160 will not be rolled back but data will.
161
162In particular, when there are mixed transactions, i.e a transaction that updates
163both transaction and non-transactional engines, the Xid_log_event is still used
164but reliability/data integrity cannot be achieved as we shall explain in what
165follows.
166
167Changes to non-transactional engines, such as MyIsam, cannot be rolled back if a
168failure happens. For that reason, there is no point in updating the positions
169within the boundaries of any on-going transaction. This is true for both commit
170and rollback. If a failure happens after processing the pseudo-transaction but
171before updating the positions, the transaction will be re-executed when the
172slave is up most likely causing an error that needs to be manually circumvented.
173This is a well-known issue when non-transactional statements are executed.
174
175Specifically, if rolling back any transaction, positions are updated outside the
176transaction boundaries. However, there may be a problem in this scenario even
177when only transactional engines are updated. This happens because if there is a
178rollback and such transaction is written to the binary log, a non-transactional
179engine was updated or a temporary table was created or dropped within its
180boundaries.
181
182In particular, in both STATEMENT and MIXED logging formats, this happens because
183any temporary table is automatically dropped after a shutdown/startup.
184See BUG#26945 for further details.
185
186Statements written to the binary log outside the boundaries of a transaction are
187DDLs or maintenance commands which are not transactional. These means that they
188cannot be rolled back if a failure happens. In such cases, the positions are
189updated after processing the events. If a failure happens after processing the
190statement but before updating the positions, the statement will be
191re-executed when the slave is up most likely causing an error that needs to be
192manually circumvented. This is a well-known issue when non-transactional
193statements are executed.
194
195The --sync-relay-log-info does not have effect when a system table, either
196transactional or non-transactional is used.
197
198To correctly recovery from failures, one should combine transactional system
199tables along with the --relay-log-recovery.
200*******************************************************************************/
201class Relay_log_info : public Rpl_info {
202 friend class Rpl_info_factory;
203
204 public:
205 /**
206 Set of possible return values for the member methods related to
207 `PRIVILEGE_CHECKS_USER` management.
208 */
209 enum class enum_priv_checks_status : int {
210 /** Function ended successfully */
211 SUCCESS = 0,
212 /** Value for user is anonymous (''@'...') */
214 /** Value for the username part of the user is larger than 32 characters */
216 /** Value for the hostname part of the user is larger than 255 characters */
218 /** Value for the hostname part of the user has illegal characters */
220 /**
221 Value for the username part of the user is NULL but the value for the
222 hostname is not NULL.
223 */
225 /**
226 Provided user doesn't exists.
227 */
229 /**
230 Provided user doesn't have the necesary privileges to execute the needed
231 operations.
232 */
234 /** Values provided for the internal variables are corrupted. */
236 /**
237 Provided user doesn't have `FILE` privileges during the execution of a
238 `LOAD DATA`event.
239 */
241 };
242
243 enum class enum_require_row_status : int {
244 /** Function ended successfully */
245 SUCCESS = 0,
246 /** Value for `privilege_checks_user` is not empty */
248 };
249
250 /*
251 The per-channel filter associated with this RLI
252 */
254 /**
255 Flags for the state of the replication.
256 */
258 /** The replication thread is inside a statement */
260
261 /** Flag counter. Should always be last */
263 };
264
265 /**
266 Identifies what is the slave policy on primary keys in tables.
267 */
269 /**No policy, used on PFS*/
271 /**
272 The slave sets the value of sql_require_primary_key according to
273 the source replicated value.
274 */
276 /** The slave enforces tables to have primary keys for a given channel*/
278 /** The slave does not enforce any policy around primary keys*/
279 PK_CHECK_OFF = 3
280 };
281
282 /**
283 Stores the information related to the ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
284 parameter of CHANGE MASTER
285 */
288
289 /*
290 The SQL thread owns one Relay_log_info, and each client that has
291 executed a BINLOG statement owns one Relay_log_info. This function
292 returns zero for the Relay_log_info object that belongs to the SQL
293 thread and nonzero for Relay_log_info objects that belong to
294 clients.
295 */
296 inline bool belongs_to_client() {
297 assert(info_thd);
298 return !info_thd->slave_thread;
299 }
300/* Instrumentation key for performance schema for mts_temp_table_LOCK */
301#ifdef HAVE_PSI_INTERFACE
303#endif
304 /*
305 Lock to protect race condition while transferring temporary table from
306 worker thread to coordinator thread and vice-versa
307 */
309 /*
310 Lock to acquire by methods that concurrently update lwm of committed
311 transactions and the min waited timestamp and its index.
312 */
315 /*
316 If true, events with the same server id should be replicated. This
317 field is set on creation of a relay log info structure by copying
318 the value of ::replicate_same_server_id and can be overridden if
319 necessary. For example of when this is done, check sql_binlog.cc,
320 where the BINLOG statement can be used to execute "raw" events.
321 */
323
324 /*
325 Protected with internal locks.
326 Must get data_lock when resetting the logs.
327 */
329
330 /*
331 Identifies when the recovery process is going on.
332 See sql/rpl_replica.h:init_recovery for further details.
333 */
335
336 /* The following variables are safe to read any time */
337
338 /*
339 When we restart slave thread we need to have access to the previously
340 created temporary tables. Modified only on init/end and by the SQL
341 thread, read only by SQL thread.
342 */
344
345 /* parent Master_info structure */
347
348 /* number of temporary tables open in this channel */
349 std::atomic<int32> atomic_channel_open_temp_tables{0};
350
351 /** the status of the commit timestamps for the relay log */
352 enum {
353 /*
354 no GTID log event has been processed, so it is not known if this log
355 has commit timestamps
356 */
358 // the immediate master does not support commit timestamps
360 // the immediate master supports commit timestamps
363
364 /**
365 @return the pointer to the Gtid_monitoring_info.
366 */
369 }
370
371 /**
372 Stores the details of the transaction which has just started processing.
373
374 This function is called by the STS applier or MTS worker when applying a
375 Gtid.
376
377 @param gtid_arg the gtid of the trx
378 @param original_ts_arg the original commit timestamp of the transaction
379 @param immediate_ts_arg the immediate commit timestamp of the transaction
380 @param skipped true if the transaction was gtid skipped
381 */
382 void started_processing(Gtid gtid_arg, ulonglong original_ts_arg,
383 ulonglong immediate_ts_arg, bool skipped = false) {
384 gtid_monitoring_info->start(gtid_arg, original_ts_arg, immediate_ts_arg,
385 skipped);
386 }
387
388 /**
389 Stores the details of the transaction which has just started processing.
390
391 This function is called by the MTS coordinator when queuing a Gtid to
392 a worker.
393
394 @param gtid_log_ev_arg the gtid log event of the trx
395 */
396 void started_processing(Gtid_log_event *gtid_log_ev_arg) {
397 Gtid gtid = {0, 0};
398 if (gtid_log_ev_arg->get_type() == ASSIGNED_GTID) {
399 gtid = {gtid_log_ev_arg->get_sidno(true), gtid_log_ev_arg->get_gno()};
400 }
401 started_processing(gtid, gtid_log_ev_arg->original_commit_timestamp,
402 gtid_log_ev_arg->immediate_commit_timestamp);
403 }
404
405 /**
406 When the processing of a transaction is completed, that timestamp is
407 recorded, the information is copied to last_processed_trx and the
408 information in processing_trx is cleared.
409
410 If the transaction was "applied" but GTID-skipped, the copy will not
411 happen and the last_processed_trx will keep its current value.
412 */
414
415 /**
416 @return True if there is a transaction being currently processed
417 */
420 }
421
422 /**
423 Clears the processing_trx structure fields. Normally called when there is an
424 error while processing the transaction.
425 */
427
428 /**
429 Clears the Gtid_monitoring_info fields.
430 */
432
433 /**
434 When a transaction is retried, the error number and message, and total number
435 of retries are stored. The timestamp for this error is also set here.
436
437 @param transient_errno_arg Transient error number.
438 @param transient_err_message_arg Transient error message.
439 @param trans_retries_arg Number of times this transaction has been
440 retried so far.
441 */
442 void retried_processing(uint transient_errno_arg,
443 const char *transient_err_message_arg,
444 ulong trans_retries_arg) {
446 transient_errno_arg, transient_err_message_arg, trans_retries_arg);
447 }
448
449 /*
450 If on init_info() call error_on_rli_init_info is true that means
451 that previous call to init_info() terminated with an error, RESET
452 SLAVE must be executed and the problem fixed manually.
453 */
455
456 /**
457 Retrieves the username part of the `PRIVILEGE_CHECKS_USER` option of `CHANGE
458 MASTER TO` statement.
459
460 @return a string holding the username part of the user or an empty string.
461 */
462 std::string get_privilege_checks_username() const;
463
464 /**
465 Retrieves the host part of the `PRIVILEGE_CHECKS_USER` option of `CHANGE
466 MASTER TO` statement.
467
468 @return a string holding the host part of the user or an empty string.
469 */
470 std::string get_privilege_checks_hostname() const;
471
472 /**
473 Returns whether or not there is no user configured for
474 `PRIVILEGE_CHECKS_USER`.
475
476 @return true if there is no user configured for `PRIVILEGE_CHECKS_USER` and
477 false otherwise.
478 */
480
481 /**
482 Returns whether or not the internal data regarding `PRIVILEGE_CHECKS_USER`
483 is corrupted. This may happen, for instance, if the user tries to change the
484 Relay_log_info repository manually or after a server crash.
485
486 @return true if the data is corrupted, false otherwise.
487 */
489
490 /**
491 Clears the info related to the data initialized from
492 `PRIVILEGE_CHECKS_USER`.
493 */
495
496 /**
497 Sets the flag that tells whether or not the data regarding the
498 `PRIVILEGE_CHECKS_USER` is corrupted.
499
500 @param is_corrupted the flag value.
501 */
502 void set_privilege_checks_user_corrupted(bool is_corrupted);
503
504 /**
505 Initializes data related to `PRIVILEGE_CHECKS_USER`, specifically the user
506 name and the user hostname.
507
508 @param param_privilege_checks_username the username part of the user.
509 @param param_privilege_checks_hostname the hostname part of the user.
510
511 @return a status code describing the state of the data initialization.
512 */
514 char const *param_privilege_checks_username,
515 char const *param_privilege_checks_hostname);
516
517 /**
518 Checks the validity and integrity of the data related to
519 `PRIVILEGE_CHECKS_USER`, specifically the user name and the user
520 hostname. Also checks if the user exists.
521
522 This method takes no parameters as it checks the values stored in the
523 internal member variables.
524
525 @return a status code describing the state of the data initialization.
526 */
528
529 /**
530 Checks the validity and integrity of the data related to
531 `PRIVILEGE_CHECKS_USER`, specifically the user name and the user
532 hostname. Also checks if the user exists.
533
534 @param param_privilege_checks_username the username part of the user.
535 @param param_privilege_checks_hostname the hostname part of the user.
536
537 @return a status code describing the state of the data initialization.
538 */
540 char const *param_privilege_checks_username,
541 char const *param_privilege_checks_hostname);
542 /**
543 Checks the existence of user provided as part of the `PRIVILEGE_CHECKS_USER`
544 option.
545
546 @param param_privilege_checks_username the username part of the user.
547 @param param_privilege_checks_hostname the host part of the user.
548
549 @return a status code describing the state of the data initialization.
550 */
552 char const *param_privilege_checks_username,
553 char const *param_privilege_checks_hostname);
554
555 /**
556 Returns a printable representation of the username and hostname currently
557 being used in the applier security context or empty strings other wise.
558
559 @return an `std::pair` containing the username and the hostname printable
560 representations.
561 */
562 std::pair<const char *, const char *>
564
565 /**
566 Outputs the error message associated with applier thread user privilege
567 checks error `error_code`.
568
569 The output stream to which is outputted is decided based on `to_client`
570 which, if set to `true` will output the message to the client session and if
571 `false` will output to the server log.
572
573 @param level the message urgency level, e.g., `ERROR_LEVEL`,
574 `WARNING_LEVEL`, etc.
575 @param status_code the status code to output the associated error message
576 for.
577 @param to_client a flag indicating if the message should be sent to the
578 client session or to the server log.
579 @param channel_name name of the channel for which the error is being
580 reported.
581 @param user_name username for which the error is being reported.
582 @param host_name hostname for which the error is being reported.
583 */
585 enum_priv_checks_status status_code,
586 bool to_client,
587 char const *channel_name = nullptr,
588 char const *user_name = nullptr,
589 char const *host_name = nullptr) const;
590
591 /**
592 Initializes the security context associated with the `PRIVILEGE_CHECKS_USER`
593 user that is to be used by the provided THD object.
594
595 @return a status code describing the state of the data initialization.
596 */
598 /**
599 Initializes the security context associated with the `PRIVILEGE_CHECKS_USER`
600 user that is to be used by the applier thread.
601
602 @return a status code describing the state of the data initialization.
603 */
605
606 /**
607 Returns whether the slave is running in row mode only.
608
609 @return true if row_format_required is active, false otherwise.
610 */
611 bool is_row_format_required() const;
612
613 /**
614 Sets the flag that tells whether or not the slave is running in row mode
615 only.
616
617 @param require_row the flag value.
618 */
619 void set_require_row_format(bool require_row);
620
621 /**
622 Returns what is the slave policy concerning primary keys on
623 replicated tables.
624
625 @return STREAM if it replicates the source values, ON if it enforces the
626 need on primary keys, OFF if it does no enforce any restrictions.
627 */
629
630 /**
631 Sets the field that tells what is the slave policy concerning primary keys
632 on replicated tables.
633
634 @param require_pk the policy value.
635 */
638
639 /*
640 This will be used to verify transactions boundaries of events being applied
641
642 Its output is used to detect when events were not logged using row based
643 logging.
644 */
646
647 /**
648 Marks the applier position information as being invalid or not.
649
650 @param invalid value to set the position/file info as invalid or not
651 */
653
654 /**
655 Returns if the applier positions are marked as being invalid or not.
656
657 @return true if applier position information is not reliable,
658 false otherwise.
659 */
661
662 /*
663 Let's call a group (of events) :
664 - a transaction
665 or
666 - an autocommiting query + its associated events (INSERT_ID,
667 TIMESTAMP...)
668 We need these rli coordinates :
669 - relay log name and position of the beginning of the group we currently are
670 executing. Needed to know where we have to restart when replication has
671 stopped in the middle of a group (which has been rolled back by the slave).
672 - relay log name and position just after the event we have just
673 executed. This event is part of the current group.
674 Formerly we only had the immediately above coordinates, plus a 'pending'
675 variable, but this dealt wrong with the case of a transaction starting on a
676 relay log and finishing (commiting) on another relay log. Case which can
677 happen when, for example, the relay log gets rotated because of
678 max_binlog_size.
679 */
680 protected:
681 /**
682 Event group means a group of events of a transaction. group_relay_log_name
683 and group_relay_log_pos record the place before where all event groups
684 are applied. When slave starts, it resume to apply events from
685 group_relay_log_pos. They will be initialized to the begin of the first
686 relay log file if it is a new slave(including SLAVE RESET). Then,
687 group_relay_log_pos is advanced after each transaction is applied
688 successfully in single thread slave. For MTS, group_relay_log_pos
689 is updated by mts checkpoint mechanism. group_relay_log_pos and
690 group_relay_log_name are stored into relay_log_info file/table
691 periodically. When server startup, they are loaded from relay log info
692 file/table.
693 */
697 /* The suffix number of relay log name */
701
702 /* current event's start position in relay log */
704 /*
705 Original log name and position of the group we're currently executing
706 (whose coordinates are group_relay_log_name/pos in the relay log)
707 in the master's binlog. These concern the *group*, because in the master's
708 binlog the log_pos that comes with each event is the position of the
709 beginning of the group.
710
711 Note: group_master_log_name, group_master_log_pos must only be
712 written from the thread owning the Relay_log_info (SQL thread if
713 !belongs_to_client(); client thread executing BINLOG statement if
714 belongs_to_client()).
715 */
718
719 private:
721 /*
722 Identifies when this object belongs to the SQL thread and was not
723 created for a client thread or some other purpose including
724 Slave_worker instance initializations. Ends up serving the same
725 purpose as the belongs_to_client method, but its value is set
726 earlier on in the class constructor.
727 */
729 /* Flag that ensures the retrieved GTID set is initialized only once. */
731
732 /**
733 Stores information on the last processed transaction or the transaction
734 that is currently being processed.
735
736 STS:
737 - timestamps of the currently applying/last applied transaction
738
739 MTS:
740 - coordinator thread: timestamps of the currently scheduling/last scheduled
741 transaction in a worker's queue
742 - worker thread: timestamps of the currently applying/last applied
743 transaction
744 */
746
747 /**
748 It will be set to true when receiver truncated relay log for some reason.
749 The truncated data may already be read by applier. So applier need to check
750 it each time the binlog_end_pos is updated.
751 */
753
754 /**
755 The user name part of the user passed on to `PRIVILEGE_CHECKS_USER`.
756 */
758
759 /**
760 The host name part of the user passed on to `PRIVILEGE_CHECKS_USER`.
761 */
763
764 /**
765 Tells whether or not the internal data regarding `PRIVILEGE_CHECKS_USER` is
766 corrupted. This may happen if the user tries to change the Relay_log_info
767 repository by hand.
768 */
770
771 /**
772 Tells if the slave is only accepting events logged with row based logging.
773 It also blocks
774 Operations with temporary table creation/deletion
775 Operations with LOAD DATA
776 Events: INTVAR_EVENT, RAND_EVENT, USER_VAR_EVENT
777 */
779
780 /**
781 Identifies what is the slave policy on primary keys in tables.
782 If set to STREAM it just replicates the value of sql_require_primary_key.
783 If set to ON it fails when the source tries to replicate a table creation
784 or alter operation that does not have a primary key.
785 If set to OFF it does not enforce any policies on the channel for primary
786 keys.
787 */
789
790 /**
791 Are positions invalid. If true it means the applier related position
792 information (group_master_log_name and group_master_log_pos) might
793 be outdated.
794
795 Check also is_group_master_log_pos_invalid
796 */
798
799 public:
801
803
805
808 assert(sidno <= get_sid_map()->get_max_sidno());
809 gtid_set->ensure_sidno(sidno);
810 gtid_set->_add_gtid(sidno, gno);
811 }
812
813 /**
814 Adds a GTID set to received GTID set.
815
816 @param gtid_set the gtid_set to add
817
818 @return RETURN_STATUS_OK or RETURN_STATUS_REPORTED_ERROR.
819 */
821
822 const Gtid_set *get_gtid_set() const { return gtid_set; }
823
824 bool reinit_sql_thread_io_cache(const char *log, bool need_data_lock);
825
826 /**
827 Check if group_relay_log_name is in index file.
828
829 @param [out] errmsg An error message is returned if error happens.
830
831 @retval false It is valid.
832 @retval true It is invalid. In this case, *errmsg is set to point to
833 the error message.
834*/
835 bool is_group_relay_log_name_invalid(const char **errmsg);
836 /**
837 Reset group_relay_log_name and group_relay_log_pos to the start of the
838 first relay log file. The caller must hold data_lock.
839
840 @param[out] errmsg An error message is set into it if error happens.
841
842 @retval false Success
843 @retval true Error
844 */
845 bool reset_group_relay_log_pos(const char **errmsg);
846 /*
847 Update the error number, message and timestamp fields. This function is
848 different from va_report() as va_report() also logs the error message in the
849 log apart from updating the error fields.
850 */
851 void fill_coord_err_buf(loglevel level, int err_code,
852 const char *buff_coord) const;
853
854 /**
855 Flag that the group_master_log_pos is invalid. This may occur
856 (for example) after CHANGE MASTER TO RELAY_LOG_POS. This will
857 be unset after the first event has been executed and the
858 group_master_log_pos is valid again.
859
860 Check also m_is_applier_position_info_invalid
861 */
863
864 /*
865 Handling of the relay_log_space_limit optional constraint.
866 ignore_log_space_limit is used to resolve a deadlock between I/O and SQL
867 threads, the SQL thread sets it to unblock the I/O thread and make it
868 temporarily forget about the constraint.
869 */
871 std::atomic<bool> ignore_log_space_limit;
872
873 /*
874 Used by the SQL thread to instructs the IO thread to rotate
875 the logs when the SQL thread needs to purge to release some
876 disk space.
877 */
878 std::atomic<bool> sql_force_rotate_relay;
879
881
882 /**
883 Reset the delay.
884 This is used by RESET SLAVE to clear the delay.
885 */
887
888 /*
889 Needed for problems when slave stops and we want to restart it
890 skipping one or more events in the master log that have caused
891 errors, and have been manually applied by DBA already.
892 */
894 volatile ulong abort_pos_wait; /* Incremented on change master */
897
898 /*
899 Condition and its parameters from START SLAVE UNTIL clause.
900
901 UNTIL condition is tested with is_until_satisfied() method that is
902 called by exec_relay_log_event(). is_until_satisfied() caches the result
903 of the comparison of log names because log names don't change very often;
904 this cache is invalidated by parts of code which change log names with
905 notify_*_log_name_updated() methods. (They need to be called only if SQL
906 thread is running).
907 */
908 enum {
918
920
921 /*
922 trans_retries varies between 0 to replica_transaction_retries and counts how
923 many times the slave has retried the present transaction; gets reset to 0
924 when the transaction finally succeeds. retried_trans is a cumulative
925 counter: how many times the slave has retried a transaction (any) since
926 slave started.
927 */
929
930 /*
931 If the end of the hot relay log is made of master's events ignored by the
932 slave I/O thread, these two keep track of the coords (in the master's
933 binlog) of the last of these events seen by the slave I/O thread. If not,
934 ign_master_log_name_end[0] == 0.
935 As they are like a Rotate event read/written from/to the relay log, they
936 are both protected by rli->relay_log.LOCK_binlog_end_pos.
937 */
940
941 /*
942 Indentifies where the SQL Thread should create temporary files for the
943 LOAD DATA INFILE. This is used for security reasons.
944 */
947
948 /**
949 Identifies the last time a checkpoint routine has been executed.
950 */
951 struct timespec last_clock;
952
953 /**
954 Invalidates cached until_log_name and event_relay_log_name comparison
955 result. Should be called after switch to next relay log if
956 there chances that sql_thread is running.
957 */
960 down_cast<Until_position *>(until_option)->notify_log_name_change();
961 }
962
963 /**
964 Receiver thread notifies that it truncated some data from relay log.
965 data_lock will be acquired, so the caller should not hold data_lock.
966 */
968 /**
969 Applier clears the flag after it handled the situation. The caller must
970 hold data_lock.
971 */
973
974 /**
975 The same as @c notify_group_relay_log_name_update but for
976 @c group_master_log_name.
977 */
980 down_cast<Until_position *>(until_option)->notify_log_name_change();
981 }
982
985 }
986
987 /**
988 Last executed event group coordinates are updated and optionally
989 forcibly flushed to a repository.
990 @param log_pos a value of the executed position to update to
991 @param need_data_lock whether data_lock should be acquired
992 @param force the value is passed to eventual flush_info()
993 */
994 int inc_group_relay_log_pos(ulonglong log_pos, bool need_data_lock,
995 bool force = false);
996
997 int wait_for_pos(THD *thd, String *log_name, longlong log_pos,
998 double timeout);
999 /**
1000 Wait for a GTID set to be executed.
1001
1002 @param thd The thread for status changes and kill status
1003 @param gtid A char array with a GTID set
1004 @param timeout Number of seconds to wait before timing out
1005 @param update_THD_status Shall the method update the THD stage
1006
1007 @retval 0 The set is already executed
1008 @retval -1 There was a timeout waiting for the set
1009 @retval -2 There was an issue while waiting.
1010 */
1011 int wait_for_gtid_set(THD *thd, const char *gtid, double timeout,
1012 bool update_THD_status = true);
1013 /**
1014 Wait for a GTID set to be executed.
1015
1016 @param thd The thread for status changes and kill status
1017 @param gtid A String with a GTID set
1018 @param timeout Number of seconds to wait before timing out
1019 @param update_THD_status Shall the method update the THD stage
1020
1021 @retval 0 The set is already executed
1022 @retval -1 There was a timeout waiting for the set
1023 @retval -2 There was an issue while waiting.
1024 */
1025 int wait_for_gtid_set(THD *thd, String *gtid, double timeout,
1026 bool update_THD_status = true);
1027 /**
1028 Wait for a GTID set to be executed.
1029
1030 @param thd The thread for status changes and kill status
1031 @param wait_gtid_set A GTID_set object
1032 @param timeout Number of seconds to wait before timing out
1033 @param update_THD_status Shall the method update the THD stage
1034
1035 @retval 0 The set is already executed
1036 @retval -1 There was a timeout waiting for the set
1037 @retval -2 There was an issue while waiting.
1038 */
1039 int wait_for_gtid_set(THD *thd, const Gtid_set *wait_gtid_set, double timeout,
1040 bool update_THD_status = true);
1041
1043
1044 RPL_TABLE_LIST *tables_to_lock; /* RBR: Tables to lock */
1045 uint tables_to_lock_count; /* RBR: Count of tables to lock */
1046 table_mapping m_table_map; /* RBR: Mapping table-id to table */
1047 /* RBR: Record Rows_query log event */
1049
1050 bool get_table_data(TABLE *table_arg, table_def **tabledef_var,
1051 TABLE **conv_table_var) const {
1052 assert(tabledef_var && conv_table_var);
1053 for (TABLE_LIST *ptr = tables_to_lock; ptr != nullptr;
1054 ptr = ptr->next_global)
1055 if (ptr->table == table_arg) {
1056 *tabledef_var = &static_cast<RPL_TABLE_LIST *>(ptr)->m_tabledef;
1057 *conv_table_var = static_cast<RPL_TABLE_LIST *>(ptr)->m_conv_table;
1058 DBUG_PRINT("debug", ("Fetching table data for table %s.%s:"
1059 " tabledef: %p, conv_table: %p",
1060 table_arg->s->db.str, table_arg->s->table_name.str,
1061 *tabledef_var, *conv_table_var));
1062 return true;
1063 }
1064 return false;
1065 }
1066
1067 /**
1068 Last charset (6 bytes) seen by slave SQL thread is cached here; it helps
1069 the thread save 3 @c get_charset() per @c Query_log_event if the charset is
1070 not changing from event to event (common situation). When the 6 bytes are
1071 equal to 0 is used to mean "cache is invalidated".
1072 */
1074 bool cached_charset_compare(char *charset) const;
1075
1076 void cleanup_context(THD *, bool);
1078 void clear_tables_to_lock();
1079 int purge_relay_logs(THD *thd, const char **errmsg, bool delete_only = false);
1080
1081 /*
1082 Used to defer stopping the SQL thread to give it a chance
1083 to finish up the current group of events.
1084 The timestamp is set and reset in @c sql_slave_killed().
1085 */
1087
1088 /* The original master commit timestamp in microseconds since epoch */
1090
1091 /*
1092 A container to hold on Intvar-, Rand-, Uservar- log-events in case
1093 the slave is configured with table filtering rules.
1094 The withhold events are executed when their parent Query destiny is
1095 determined for execution as well.
1096 */
1098
1099 /*
1100 State of the container: true stands for IRU events gathering,
1101 false does for execution, either deferred or direct.
1102 */
1104
1105 /*****************************************************************************
1106 WL#5569 MTS
1107
1108 legends:
1109 C - Coordinator;
1110 W - Worker;
1111 WQ - Worker Queue containing event assignments
1112 */
1113 // number's is determined by global replica_parallel_workers
1115
1116 // To map a database to a worker
1117 malloc_unordered_map<std::string,
1120 bool inited_hash_workers; // flag to check if mapping_db_to_worker is inited
1121
1122 mysql_mutex_t slave_worker_hash_lock; // for mapping_db_to_worker
1123 mysql_cond_t slave_worker_hash_cond; // for mapping_db_to_worker
1124
1125 /*
1126 For the purpose of reporting the worker status in performance schema table,
1127 we need to preserve the workers array after worker thread was killed. So, we
1128 copy this array into the below vector which is used for reporting
1129 until next init_workers(). Note that we only copy those attributes that
1130 would be useful in reporting worker status. We only use a few attributes in
1131 this object as of now but still save the whole object. The idea is
1132 to be future proof. We will extend performance schema tables in future
1133 and then we would use a good number of attributes from this object.
1134 */
1135
1136 std::vector<Slave_worker *> workers_copy_pfs;
1137
1138 /*
1139 This flag is turned ON when the workers array is initialized.
1140 Before destroying the workers array we check this flag to make sure
1141 we are not destroying an unitilized array. For the purpose of reporting the
1142 worker status in performance schema table, we need to preserve the workers
1143 array after worker thread was killed. So, we copy this array into
1144 workers_copy_pfs array which is used for reporting until next
1145 init_workers().
1146 */
1148
1149 volatile ulong pending_jobs;
1152 mysql_mutex_t exit_count_lock; // mutex of worker exit count
1154 ulonglong mts_pending_jobs_size; // actual mem usage by WQ:s
1155 ulonglong mts_pending_jobs_size_max; // max of WQ:s size forcing C to wait
1156 bool mts_wq_oversize; // C raises flag to wait some memory's released
1158 *last_assigned_worker; // is set to a Worker at assigning a group
1159 /*
1160 master-binlog ordered queue of Slave_job_group descriptors of groups
1161 that are under processing. The queue size is @c checkpoint_group.
1162 */
1164 /*
1165 Container for references of involved partitions for the current event group
1166 */
1167 // CGAP dynarray holds id:s of partitions of the Current being executed Group
1169 // deferred array to hold partition-info-free events
1171
1172 bool curr_group_seen_gtid; // current group started with Gtid-event or not
1173 bool curr_group_seen_begin; // current group started with B-event or not
1174 bool curr_group_isolated; // current group requires execution in isolation
1175 bool mts_end_group_sets_max_dbs; // flag indicates if partitioning info is
1176 // discovered
1177 volatile ulong
1178 mts_wq_underrun_w_id; // Id of a Worker whose queue is getting empty
1179 /*
1180 Ongoing excessive overrun counter to correspond to number of events that
1181 are being scheduled while a WQ is close to be filled up.
1182 `Close' is defined as (100 - mts_worker_underrun_level) %.
1183 The counter is incremented each time a WQ get filled over that level
1184 and decremented when the level drops below.
1185 The counter therefore describes level of saturation that Workers
1186 are experiencing and is used as a parameter to compute a nap time for
1187 Coordinator in order to avoid reaching WQ limits.
1188 */
1189 volatile long mts_wq_excess_cnt;
1190 long mts_worker_underrun_level; // % of WQ size at which W is considered
1191 // hungry
1192 ulong mts_coordinator_basic_nap; // C sleeps to avoid WQs overrun
1193 ulong
1194 opt_replica_parallel_workers; // cache for ::opt_replica_parallel_workers
1195 ulong
1196 replica_parallel_workers; // the one slave session time number of workers
1197 ulong
1198 exit_counter; // Number of workers contributed to max updated group index
1200 ulong recovery_parallel_workers; // number of workers while recovering
1201 uint rli_checkpoint_seqno; // counter of groups executed after the most
1202 // recent CP
1203 uint checkpoint_group; // cache for ::opt_mta_checkpoint_group
1204 MY_BITMAP recovery_groups; // bitmap used during recovery
1206 ulong mts_recovery_group_cnt; // number of groups to execute at recovery
1207 ulong mts_recovery_index; // running index of recoverable groups
1209
1210 /*
1211 While distibuting events basing on their properties MTS
1212 Coordinator changes its mts group status.
1213 Transition normally flowws to follow `=>' arrows on the diagram:
1214
1215 +----------------------------+
1216 V |
1217 MTS_NOT_IN_GROUP => |
1218 {MTS_IN_GROUP => MTS_END_GROUP --+} while (!killed) => MTS_KILLED_GROUP
1219
1220 MTS_END_GROUP has `->' loop breaking link to MTS_NOT_IN_GROUP when
1221 Coordinator synchronizes with Workers by demanding them to
1222 complete their assignments.
1223 */
1224 enum {
1225 /*
1226 no new events were scheduled after last synchronization,
1227 includes Single-Threaded-Slave case.
1228 */
1230
1231 MTS_IN_GROUP, /* at least one not-terminal event scheduled to a Worker */
1232 MTS_END_GROUP, /* the last scheduled event is a terminal event */
1233 MTS_KILLED_GROUP /* Coordinator gave up to reach MTS_END_GROUP */
1235
1236 /*
1237 MTS statistics:
1238 */
1239 ulonglong mts_events_assigned; // number of events (statements) scheduled
1240 ulonglong mts_groups_assigned; // number of groups (transactions) scheduled
1241 volatile ulong
1242 mts_wq_overrun_cnt; // counter of all mts_wq_excess_cnt increments
1243 ulong wq_size_waits_cnt; // number of times C slept due to WQ:s oversize
1244 /*
1245 Counter of how many times Coordinator saw Workers are filled up
1246 "enough" with assignements. The enough definition depends on
1247 the scheduler type.
1248 */
1250 std::atomic<longlong>
1251 mts_total_wait_overlap; // Waiting time corresponding to above
1252 /*
1253 Stats to compute Coordinator waiting time for any Worker available,
1254 applies solely to the Commit-clock scheduler.
1255 */
1257 ulong mts_wq_overfill_cnt; // counter of C waited due to a WQ queue was full
1258 /*
1259 Statistics (todo: replace with WL5631) applies to either Coordinator and
1260 Worker. The exec time in the Coordinator case means scheduling. The read
1261 time in the Worker case means getting an event out of Worker queue
1262 */
1265 struct timespec ts_exec[2]; // per event pre- and post- exec timestamp
1266 struct timespec stats_begin; // applier's bootstrap time
1267
1269 /* end of MTS statistics */
1270
1271 /**
1272 Storage for holding newly computed values for the last executed
1273 event group coordinates while the current group of events is
1274 being committed, see @c pre_commit, post_commit.
1275 */
1280
1281 /* Returns the number of elements in workers array/vector. */
1282 inline size_t get_worker_count() {
1284 return workers.size();
1285 else
1286 return workers_copy_pfs.size();
1287 }
1288
1289 /*
1290 Returns a pointer to the worker instance at index n in workers
1291 array/vector.
1292 */
1295 if (n >= workers.size()) return nullptr;
1296
1297 return workers[n];
1298 } else if (workers_copy_pfs.size()) {
1299 if (n >= workers_copy_pfs.size()) return nullptr;
1300
1301 return workers_copy_pfs[n];
1302 } else
1303 return nullptr;
1304 }
1305
1306 /**
1307 The method implements updating a slave info table. It's
1308 specialized differently for STS and MTS.
1309 */
1310 virtual bool commit_positions();
1311
1312 /*Channel defined mts submode*/
1314 /* MTS submode */
1316
1317 /* most of allocation in the coordinator rli is there */
1318 void init_workers(ulong);
1319
1320 /* counterpart of the init */
1321 void deinit_workers();
1322
1323 /**
1324 returns true if there is any gap-group of events to execute
1325 at slave starting phase.
1326 */
1327 inline bool is_mts_recovery() const { return mts_recovery_group_cnt != 0; }
1328
1333 recovery_groups_inited = false;
1334 }
1335 }
1336
1337 /**
1338 returns true if events are to be executed in parallel
1339 */
1340 inline bool is_parallel_exec() const {
1341 bool ret = (replica_parallel_workers > 0) && !is_mts_recovery();
1342
1343 assert(!ret || !workers.empty());
1344
1345 return ret;
1346 }
1347
1348 /**
1349 returns true if Coordinator is scheduling events belonging to
1350 the same group and has not reached yet its terminal event.
1351 */
1352 inline bool is_mts_in_group() {
1354 }
1355
1356 /**
1357 Check if it is time to compute MTS checkpoint.
1358
1359 @retval true It is time to compute MTS checkpoint.
1360 @retval false It is not MTS or it is not time for computing checkpoint.
1361 */
1363 /**
1364 While a group is executed by a Worker the relay log can change.
1365 Coordinator notifies Workers about this event. Worker is supposed
1366 to commit to the recovery table with the new info.
1367 */
1369
1370 /**
1371 While a group is executed by a Worker the relay log can change.
1372 Coordinator notifies Workers about this event. Coordinator and Workers
1373 maintain a bitmap of executed group that is reset with a new checkpoint.
1374 */
1375 void reset_notified_checkpoint(ulong count, time_t new_ts,
1376 bool update_timestamp = false);
1377
1378 /**
1379 Called when gaps execution is ended so it is crash-safe
1380 to reset the last session Workers info.
1381 */
1382 bool mts_finalize_recovery();
1383 /*
1384 * End of MTS section ******************************************************/
1385
1386 /* The general cleanup that slave applier may need at the end of query. */
1387 inline void cleanup_after_query() {
1389 }
1390 /* The general cleanup that slave applier may need at the end of session. */
1392 if (deferred_events) delete deferred_events;
1393 }
1394
1395 /**
1396 Helper function to do after statement completion.
1397
1398 This function is called from an event to complete the group by
1399 either stepping the group position, if the "statement" is not
1400 inside a transaction; or increase the event position, if the
1401 "statement" is inside a transaction.
1402
1403 @param event_log_pos
1404 Master log position of the event. The position is recorded in the
1405 relay log info and used to produce information for <code>SHOW
1406 SLAVE STATUS</code>.
1407 */
1408 int stmt_done(my_off_t event_log_pos);
1409
1410 /**
1411 Set the value of a replication state flag.
1412
1413 @param flag Flag to set
1414 */
1416
1417 /**
1418 Get the value of a replication state flag.
1419
1420 @param flag Flag to get value of
1421
1422 @return @c true if the flag was set, @c false otherwise.
1423 */
1424 bool get_flag(enum_state_flag flag) { return m_flags & (1UL << flag); }
1425
1426 /**
1427 Clear the value of a replication state flag.
1428
1429 @param flag Flag to clear
1430 */
1432
1433 private:
1434 /**
1435 Auxiliary function used by is_in_group.
1436
1437 The execute thread is in the middle of a statement in the
1438 following cases:
1439 - User_var/Intvar/Rand events have been processed, but the
1440 corresponding Query_log_event has not been processed.
1441 - Table_map or Row events have been processed, and the last Row
1442 event did not have the STMT_END_F set.
1443
1444 @retval true Replication thread is inside a statement.
1445 @retval false Replication thread is not inside a statement.
1446 */
1447 bool is_in_stmt() const {
1448 bool ret = (m_flags & (1UL << IN_STMT));
1449 DBUG_PRINT("info", ("is_in_stmt()=%d", ret));
1450 return ret;
1451 }
1452 /**
1453 Auxiliary function used by is_in_group.
1454
1455 @retval true The execute thread is inside a statement or a
1456 transaction, i.e., either a BEGIN has been executed or we are in
1457 the middle of a statement.
1458 @retval false The execute thread thread is not inside a statement
1459 or a transaction.
1460 */
1461 bool is_in_trx_or_stmt() const {
1463 DBUG_PRINT("info", ("is_in_trx_or_stmt()=%d", ret));
1464 return ret;
1465 }
1466
1467 public:
1468 /**
1469 A group is defined as the entire range of events that constitute
1470 a transaction or auto-committed statement. It has one of the
1471 following forms:
1472
1473 (Gtid)? Query(BEGIN) ... (Query(COMMIT) | Query(ROLLBACK) | Xid)
1474 (Gtid)? (Rand | User_var | Int_var)* Query(DDL)
1475
1476 Thus, to check if the execute thread is in a group, there are
1477 two cases:
1478
1479 - If the master generates Gtid events (5.7.5 or later, or 5.6 or
1480 later with GTID_MODE=ON), then is_in_group is the same as
1481 info_thd->owned_gtid.sidno != 0, since owned_gtid.sidno is set
1482 to non-zero by the Gtid_log_event and cleared to zero at commit
1483 or rollback.
1484
1485 - If the master does not generate Gtid events (i.e., master is
1486 pre-5.6, or pre-5.7.5 with GTID_MODE=OFF), then is_in_group is
1487 the same as is_in_trx_or_stmt().
1488
1489 @retval true Replication thread is inside a group.
1490 @retval false Replication thread is not inside a group.
1491 */
1492 bool is_in_group() const {
1493 bool ret = is_in_trx_or_stmt() || info_thd->owned_gtid.sidno != 0;
1494 DBUG_PRINT("info", ("is_in_group()=%d", ret));
1495 return ret;
1496 }
1497
1499
1500 /**
1501 Initialize the relay log info. This function does a set of operations
1502 on the rli object like initializing variables, loading information from
1503 repository, setting up name for relay log files and index, MTS recovery
1504 (if necessary), calculating the received GTID set for the channel and
1505 storing the updated rli object configuration into the repository.
1506
1507 When this function is called in a change master process and the change
1508 master procedure will purge all the relay log files later, there is no
1509 reason to try to calculate the received GTID set of the channel based on
1510 existing relay log files (they will be purged). Allowing reads to existing
1511 relay log files at this point may lead to put the server in a state where
1512 it will be no possible to configure it if it was reset when encryption of
1513 replication log files was ON and the keyring plugin is not available
1514 anymore.
1515
1516 @param skip_received_gtid_set_recovery When true, skips the received GTID
1517 set recovery.
1518
1519 @retval 0 Success.
1520 @retval 1 Error.
1521 */
1522 int rli_init_info(bool skip_received_gtid_set_recovery = false);
1523 void end_info();
1524
1525 /** No flush options given to relay log flush */
1526 static constexpr int RLI_FLUSH_NO_OPTION{0};
1527 /** Ignore server sync options and flush */
1528 static constexpr int RLI_FLUSH_IGNORE_SYNC_OPT{1 << 0};
1529 /** Flush disresgarding the value of GTID_ONLY */
1530 static constexpr int RLI_FLUSH_IGNORE_GTID_ONLY{1 << 1};
1531
1532 int flush_info(const int flush_flags);
1533 /**
1534 Clears from `this` Relay_log_info object all attribute values that are
1535 not to be kept.
1536
1537 @returns true if there were a problem with clearing the data and false
1538 otherwise.
1539 */
1540 bool clear_info();
1541 /**
1542 Checks if the underlying `Rpl_info` handler holds information for the fields
1543 to be kept between slave resets, while the other fields were cleared.
1544
1545 @param previous_result the result return from invoking the `check_info`
1546 method on `this` object.
1547
1548 @returns function success state represented by the `enum_return_check`
1549 enumeration.
1550 */
1552 const enum_return_check &previous_result) const;
1553 int flush_current_log();
1555
1558 }
1561 }
1562
1563 inline const char *get_group_master_log_name() const {
1564 return group_master_log_name;
1565 }
1566 inline const char *get_group_master_log_name_info() const {
1567 if (m_is_applier_source_position_info_invalid) return "INVALID";
1569 }
1571 return group_master_log_pos;
1572 }
1575 return get_group_master_log_pos();
1576 }
1577 inline void set_group_master_log_name(const char *log_file_name) {
1578 strmake(group_master_log_name, log_file_name,
1579 sizeof(group_master_log_name) - 1);
1580 }
1582 group_master_log_pos = log_pos;
1583 // Whenever the position is set, it means it is no longer invalid
1585 }
1586
1587 inline const char *get_group_relay_log_name() { return group_relay_log_name; }
1589 inline void set_group_relay_log_name(const char *log_file_name) {
1590 strmake(group_relay_log_name, log_file_name,
1591 sizeof(group_relay_log_name) - 1);
1592 }
1593 inline void set_group_relay_log_name(const char *log_file_name, size_t len) {
1594 strmake(group_relay_log_name, log_file_name, len);
1595 }
1596 inline void set_group_relay_log_pos(ulonglong log_pos) {
1597 group_relay_log_pos = log_pos;
1598 }
1599
1600 inline const char *get_event_relay_log_name() { return event_relay_log_name; }
1602 inline void set_event_relay_log_name(const char *log_file_name) {
1603 strmake(event_relay_log_name, log_file_name,
1604 sizeof(event_relay_log_name) - 1);
1607 }
1608
1611 event_relay_log_number = number;
1612 }
1613
1614 /**
1615 Given the extension number of the relay log, gets the full
1616 relay log path. Currently used in Slave_worker::retry_transaction()
1617
1618 @param [in] number extension number of relay log
1619 @param[in, out] name The full path of the relay log (per-channel)
1620 to be read by the slave worker.
1621 */
1622 void relay_log_number_to_name(uint number, char name[FN_REFLEN + 1]);
1623 uint relay_log_name_to_number(const char *name);
1624
1627
1628 inline void set_event_relay_log_pos(ulonglong log_pos) {
1629 event_relay_log_pos = log_pos;
1630 }
1631 inline const char *get_rpl_log_name() const {
1633 ? "INVALID"
1635 }
1636
1637 static size_t get_number_info_rli_fields();
1638
1639 /**
1640 Sets bits for columns that are allowed to be `NULL`.
1641
1642 @param nullable_fields the bitmap to hold the nullable fields.
1643 */
1644 static void set_nullable_fields(MY_BITMAP *nullable_fields);
1645
1646 /**
1647 Indicate that a delay starts.
1648
1649 This does not actually sleep; it only sets the state of this
1650 Relay_log_info object to delaying so that the correct state can be
1651 reported by SHOW SLAVE STATUS and SHOW PROCESSLIST.
1652
1653 Requires rli->data_lock.
1654
1655 @param delay_end The time when the delay shall end.
1656 */
1657 void start_sql_delay(time_t delay_end);
1658
1659 /* Note that this is cast to uint32 in show_slave_status(). */
1660 time_t get_sql_delay() { return sql_delay; }
1661 void set_sql_delay(time_t _sql_delay) { sql_delay = _sql_delay; }
1663
1664 Relay_log_info(bool is_slave_recovery,
1665#ifdef HAVE_PSI_INTERFACE
1666 PSI_mutex_key *param_key_info_run_lock,
1667 PSI_mutex_key *param_key_info_data_lock,
1668 PSI_mutex_key *param_key_info_sleep_lock,
1669 PSI_mutex_key *param_key_info_thd_lock,
1670 PSI_mutex_key *param_key_info_data_cond,
1671 PSI_mutex_key *param_key_info_start_cond,
1672 PSI_mutex_key *param_key_info_stop_cond,
1673 PSI_mutex_key *param_key_info_sleep_cond,
1674#endif
1675 uint param_id, const char *param_channel, bool is_rli_fake);
1676 ~Relay_log_info() override;
1677
1678 /*
1679 Determines if a warning message on unsafe execution was
1680 already printed out to avoid clutering the error log
1681 with several warning messages.
1682 */
1684
1685 /*
1686 'sql_thread_kill_accepted is set to true when killed status is recognized.
1687 */
1689
1691
1693 if (row_stmt_start_timestamp == 0) row_stmt_start_timestamp = time(nullptr);
1694
1696 }
1697
1699
1701
1704 }
1705
1707
1708 public:
1709 /**
1710 Delete the existing event and set a new one. This class is
1711 responsible for freeing the event, the caller should not do that.
1712
1713 @return 1 if an error was encountered, 0 otherwise.
1714 */
1716
1717 /**
1718 Return the current Format_description_log_event.
1719 */
1721 return rli_description_event;
1722 }
1723
1724 /**
1725 adaptation for the slave applier to specific master versions.
1726 */
1728 ulong adapt_to_master_version_updown(ulong master_version,
1729 ulong current_version);
1730 uchar slave_version_split[3]; // bytes of the slave server version
1731 /*
1732 relay log info repository should be updated on relay log
1733 rotate. But when the transaction is split across two relay logs,
1734 update the repository will cause unexpected results and should
1735 be postponed till the 'commit' of the transaction is executed.
1736
1737 A flag that set to 'true' when this type of 'forced flush'(at the
1738 time of rotate relay log) is postponed due to transaction split
1739 across the relay logs.
1740 */
1742
1744
1746 commit_order_mngr = mngr;
1747 }
1748
1749 /*
1750 Following set function is required to initialize the 'until_option' during
1751 MTS relay log recovery process.
1752
1753 Ideally initialization of 'until_option' is done through
1754 rli::init_until_option. This init_until_option requires the main server
1755 thread object and it makes use of the thd->lex->mi object to initialize the
1756 'until_option'.
1757
1758 But MTS relay log recovery process happens before the main server comes
1759 up at this time the THD object will not be available. Hence the following
1760 set function does the initialization of 'until_option'.
1761 */
1764 until_option = option;
1766 }
1767
1770 if (until_option) {
1771 delete until_option;
1772 until_option = nullptr;
1773 }
1775 }
1776
1777 bool set_info_search_keys(Rpl_info_handler *to) override;
1778
1779 /**
1780 Get coordinator's RLI. Especially used get the rli from
1781 a slave thread, like this: thd->rli_slave->get_c_rli();
1782 thd could be a SQL thread or a worker thread
1783 */
1784 virtual Relay_log_info *get_c_rli() { return this; }
1785
1786 const char *get_for_channel_str(bool upper_case = false) const override;
1787
1788 /**
1789 Set replication filter for the channel.
1790 */
1791 inline void set_filter(Rpl_filter *channel_filter) {
1792 rpl_filter = channel_filter;
1793 }
1794
1795 protected:
1797
1798 private:
1799 /*
1800 Commit order manager to order commits made by its workers. In context of
1801 Multi Source Replication each worker will be ordered by the coresponding
1802 corrdinator's order manager.
1803 */
1805
1806 /**
1807 Delay slave SQL thread by this amount of seconds.
1808 The delay is applied per transaction and based on the immediate master's
1809 commit time. Exceptionally, if a server in the replication chain does not
1810 support the commit timestamps in Gtid_log_event, the delay is applied per
1811 event and is based on the event timestamp.
1812 This is set with CHANGE MASTER TO MASTER_DELAY=X.
1813
1814 Guarded by data_lock. Initialized by the client thread executing
1815 START SLAVE. Written by client threads executing CHANGE MASTER TO
1816 MASTER_DELAY=X. Read by SQL thread and by client threads
1817 executing SHOW SLAVE STATUS. Note: must not be written while the
1818 slave SQL thread is running, since the SQL thread reads it without
1819 a lock when executing flush_info().
1820 */
1822
1823 /**
1824 During a delay, specifies the point in time when the delay ends.
1825
1826 This is used for the SQL_Remaining_Delay column in SHOW SLAVE STATUS.
1827
1828 Guarded by data_lock. Written by the sql thread. Read by client
1829 threads executing SHOW SLAVE STATUS.
1830 */
1832
1834
1835 /*
1836 Before the MASTER_DELAY parameter was added (WL#344), relay_log.info
1837 had 4 lines. Now it has 5 lines.
1838 */
1840
1841 /*
1842 Before the WL#5599, relay_log.info had 5 lines. Now it has 6 lines.
1843 */
1845
1846 /*
1847 Before the Id was added (BUG#2334346), relay_log.info
1848 had 6 lines. Now it has 7 lines.
1849 */
1851
1852 /*
1853 Add a channel in the slave relay log info
1854 */
1856
1857 /*
1858 Represents line number in relay_log.info to save PRIVILEGE_CHECKS_USERNAME.
1859 It is username part of PRIVILEGES_CHECKS_USER column in
1860 performance_schema.replication_applier_configuration.
1861 */
1863
1864 /*
1865 Maximum length of PRIVILEGE_CHECKS_USERNAME.
1866 */
1867 static const int PRIV_CHECKS_USERNAME_LENGTH = 32;
1868
1869 /*
1870 Represents line number in relay_log.info to save PRIVILEGE_CHECKS_HOSTNAME.
1871 It is hostname part of PRIVILEGES_CHECKS_USER column in
1872 performance_schema.replication_applier_configuration.
1873 */
1875
1876 /*
1877 Maximum length of PRIVILEGE_CHECKS_USERNAME.
1878 */
1879 static const int PRIV_CHECKS_HOSTNAME_LENGTH = 255;
1880
1881 /*
1882 Represents line number in relay_log.info to save REQUIRE_ROW_FORMAT
1883 */
1885
1886 /*
1887 Represents line number in relay_log.info to save
1888 REQUIRE_TABLE_PRIMARY_KEY_CHECK
1889 */
1890 static const int
1892
1893 /*
1894 Represent line number in relay_log.info to save
1895 ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS_TYPE.
1896 */
1897 static const int
1899 13;
1900
1901 /*
1902 Represent line number in relay_log.info to save
1903 ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS_VALUE.
1904 */
1905 static const int
1907 14;
1908 /*
1909 Total lines in relay_log.info.
1910 This has to be updated every time a member is added or removed.
1911 */
1914
1915 bool read_info(Rpl_info_handler *from) override;
1916 bool write_info(Rpl_info_handler *to) override;
1917
1920
1921 /*
1922 Runtime state for printing a note when slave is taking
1923 too long while processing a row event.
1924 */
1927
1928 /**
1929 sets the suffix required for relay log names in multisource
1930 replication. When --relay-log option is not provided, the
1931 names of the relay log files are relaylog.0000x or
1932 relaylog-CHANNEL.00000x in the case of MSR. However, if
1933 that option is provided, then the names of the relay log
1934 files are <relay-log-option>.0000x or
1935 <relay-log-option>-CHANNEL.00000x in the case of MSR.
1936
1937 The function adds a channel suffix (according to the channel to
1938 file name conventions and conversions) to the relay log file.
1939
1940 @todo: truncate the log file if length exceeds.
1941
1942 @param[in, out] buff buffer to store the complete relay log file name
1943 @param[in] buff_size size of buffer buff
1944 @param[in] base_name the base name of the relay log file
1945 */
1946 const char *add_channel_to_relay_log_name(char *buff, uint buff_size,
1947 const char *base_name);
1948
1949 /*
1950 Applier thread InnoDB priority.
1951 When two transactions conflict inside InnoDB, the one with
1952 greater priority wins.
1953 Priority must be set before applier thread start so that all
1954 executed transactions have the same priority.
1955 */
1957
1958 /**
1959 If the SQL thread should or not ignore the set limit for
1960 write set collection
1961 */
1963
1964 /**
1965 Even if a component says all transactions require write sets,
1966 this variable says the SQL thread transactions can drop them
1967 */
1969
1970 /* The object stores and handles START SLAVE UNTIL option */
1972
1973 public:
1974 /*
1975 The boolean is set to true when the binlog (rli_fake) or slave
1976 (rli_slave) applier thread detaches any engine ha_data
1977 it has dealt with at time of XA START processing.
1978 The boolean is reset to false at the end of XA PREPARE,
1979 XA COMMIT ONE PHASE for the binlog applier, and
1980 at internal rollback of the slave applier at the same time with
1981 the engine ha_data re-attachment.
1982 */
1984 /**
1985 Reference to being applied event. The member is set at event reading
1986 and gets reset at the end of the event lifetime.
1987 See more in @c RLI_current_event_raii that provides the main
1988 interface to the member.
1989 */
1991
1992 /**
1993 Raised when slave applies and writes to its binary log statement
1994 which is not atomic DDL and has no XID assigned. Checked at commit
1995 time to decide whether it is safe to update slave info table
1996 within the same transaction as the write to binary log or this
1997 should be deffered. The deffered scenario applies for not XIDed events
1998 in which case such update might be lost on recovery.
1999 */
2001
2003
2005
2006 void set_ignore_write_set_memory_limit(bool ignore_limit) {
2007 m_ignore_write_set_memory_limit = ignore_limit;
2008 }
2009
2012 }
2013
2014 void set_allow_drop_write_set(bool does_not_require_ws) {
2015 m_allow_drop_write_set = does_not_require_ws;
2016 }
2017
2019
2020 const char *get_until_log_name();
2023 return until_option != nullptr &&
2025 }
2027 return until_option != nullptr &&
2029 }
2031 return until_option != nullptr &&
2033 }
2034 /**
2035 Intialize until option object when starting slave.
2036
2037 @param[in] thd The thread object of current session.
2038 @param[in] master_param the parameters of START SLAVE.
2039
2040 @return int
2041 @retval 0 Succeeds to initialize until option object.
2042 @retval <> 0 A defined error number is return if any error happens.
2043 */
2044 int init_until_option(THD *thd, const LEX_MASTER_INFO *master_param);
2045
2046 /**
2047 Detaches the engine ha_data from THD. The fact
2048 is memorized in @c m_is_engine_ha_data_detached flag.
2049
2050 @param thd a reference to THD
2051 */
2052
2053 void detach_engine_ha_data(THD *thd);
2054
2055 /**
2056 Reattaches the engine ha_data to THD. The fact
2057 is memorized in @c m_is_engine_ha_data_detached flag.
2058
2059 @param thd a reference to THD
2060 */
2061
2062 void reattach_engine_ha_data(THD *thd);
2063
2064 /**
2065 Checks whether engine ha data is detached from THD
2066 @retval true if the data is detached
2067 @retval false if the data is not detached
2068 */
2070
2071 /**
2072 Execute actions at replicated atomic DLL post rollback time.
2073 This include marking the current atomic DDL query-log-event
2074 as having processed.
2075 This measure is necessary to avoid slave info table update execution
2076 when @c pre_commit() hook is called as part of DDL's eventual
2077 implicit commit.
2078 */
2080 static_cast<Query_log_event *>(current_event)->has_ddl_committed = true;
2081 }
2082
2083 /**
2084 The method implements a pre-commit hook to add up a new statement
2085 typically to a DDL transaction to update the slave info table.
2086 Note, in the non-transactional repository case the slave info
2087 is updated after successful commit of the main transaction.
2088
2089 @return false as success, otherwise true
2090 */
2091 bool pre_commit() {
2092 bool rc = false;
2093
2094 if (is_transactional()) {
2095 static_cast<Query_log_event *>(current_event)->has_ddl_committed = true;
2096 rc = commit_positions();
2097 }
2098 return rc;
2099 }
2100 /**
2101 Cleanup of any side effect that pre_commit() inflicts, including
2102 restore of the last executed group coordinates in case the current group
2103 has been destined to rollback, and signaling to possible waiters
2104 in the positive case.
2105
2106 @param on_rollback when true the method carries out rollback action
2107 */
2108 virtual void post_commit(bool on_rollback);
2109};
2110
2111/**
2112 Negation operator for `enum_priv_checks_status`, to facilitate validation
2113 against `SUCCESS`. To test for error status, use the `!!` idiom.
2114
2115 @param status the status code to check against `SUCCESS`
2116
2117 @return true if the status is `SUCCESS` and false otherwise.
2118 */
2120
2121/**
2122 Negation operator for `enum_require_row_status`, to facilitate validation
2123 against `SUCCESS`. To test for error status, use the `!!` idiom.
2124
2125 @param status the status code to check against `SUCCESS`
2126
2127 @return true if the status is `SUCCESS` and false otherwise.
2128 */
2130
2132
2133/**
2134 @param thd a reference to THD
2135 @return true if thd belongs to a Worker thread and false otherwise.
2136*/
2137inline bool is_mts_worker(const THD *thd) {
2139}
2140
2141/**
2142 Auxiliary function to check if we have a db partitioned MTS
2143 */
2145
2146/**
2147 Checks whether the supplied event encodes a (2pc-aware) DDL
2148 that has been already committed.
2149
2150 @param ev A reference to Query-log-event
2151 @return true when the event is already committed transactional DDL
2152*/
2153inline bool is_committed_ddl(Log_event *ev) {
2154 return ev->get_type_code() == binary_log::QUERY_EVENT &&
2155 /* has been already committed */
2156 static_cast<Query_log_event *>(ev)->has_ddl_committed;
2157}
2158
2159/**
2160 Checks whether the transaction identified by the argument
2161 is executed by a slave applier thread is an atomic DDL
2162 not yet committed (see @c Query_log_event::has_ddl_committed).
2163 THD::is_operating_substatement_implicitly filters out intermediate
2164 commits done by non-atomic DDLs.
2165 The error-tagged atomic statements are regarded as non-atomic
2166 therefore this predicate returns negative in such case.
2167
2168 Note that call to is_atomic_ddl() returns "approximate" outcome in
2169 this case as it misses information about type of tables used by the DDL.
2170
2171 This can be a problem for binlogging slave, as updates to slave info
2172 which happen in the same transaction as write of binary log event
2173 without XID might be lost on recovery. To avoid this problem
2174 RLI::ddl_not_atomic flag is employed which is set to true when
2175 non-atomic DDL without XID is written to the binary log.
2176
2177 "Approximate" outcome is always fine for non-binlogging slave as in
2178 this case commit happens using one-phase routine for which recovery
2179 is always correct.
2180
2181 @param thd a pointer to THD describing the transaction context
2182 @return true when a slave applier thread is set to commmit being processed
2183 DDL query-log-event, otherwise returns false.
2184*/
2186 assert(thd);
2187
2188 Relay_log_info *rli = thd->rli_slave;
2189
2190 /* Early return is about an error in the SQL thread initialization */
2191 if (!rli) return false;
2192
2193 return ((thd->system_thread == SYSTEM_THREAD_SLAVE_SQL ||
2195 rli->current_event)
2196 ? (rli->is_transactional() &&
2197 /* has not yet committed */
2198 (rli->current_event->get_type_code() ==
2200 !static_cast<Query_log_event *>(rli->current_event)
2201 ->has_ddl_committed) &&
2202 /* unless slave binlogger identified non-atomic */
2203 !rli->ddl_not_atomic &&
2204 /* slave info is not updated when a part of multi-DROP-TABLE
2205 commits */
2207 (is_atomic_ddl(thd, true) &&
2209 /* error-tagged atomic DDL do not update yet slave info */
2210 static_cast<Query_log_event *>(rli->current_event)
2211 ->error_code == 0)
2212 : false;
2213}
2214
2215/**
2216 RAII class to control the slave applier execution context binding
2217 with a being handled event. The main object of control is Query-log-event
2218 containing DDL statement.
2219 The member RLI::current_event is set to refer to an event once it is
2220 read, e.g by next_event() and is reset to NULL at exiting a
2221 read-exec loop. Once the event is destroyed RLI::current_event must be reset
2222 or guaranteed not be accessed anymore.
2223 In the MTS execution the worker is reliably associated with an event
2224 only with the latter is not deferred. This includes Query-log-event.
2225*/
2228
2229 public:
2231 : m_rli(rli_arg) {
2232 m_rli->current_event = ev;
2233 }
2236};
2237
2238/**
2239 @class MDL_lock_guard
2240
2241 Utility class to allow RAII pattern with `MDL_request` and `MDL_context`
2242 classes.
2243 */
2245 public:
2246 /**
2247 Constructor that initializes the object and the target `THD` object but
2248 doesn't try to acquire any lock.
2249
2250 @param target THD object, source for the `MDL_context` to use.
2251 */
2252 MDL_lock_guard(THD *target);
2253 /**
2254 Constructor that initializes the object and the target `THD` object and tries
2255 to acquire the lock identified by `namespace_arg` with MDL type identified by
2256 `mdl_type_arg`.
2257
2258 If the `blocking` parameter is true, it will instantly try to acquire the
2259 lock and block. If the `blocking` parameter is false, it will first test if
2260 the lock is already acquired and only try to lock if no conflicting lock is
2261 already acquired.
2262
2263 @param target THD object, source for the `MDL_context` to use.
2264 @param namespace_arg MDL key namespace to acquire the lock from.
2265 @param mdl_type_arg MDL acquisition type
2266 @param blocking whether or not the execution should block if the lock is
2267 already acquired.
2268 */
2269 MDL_lock_guard(THD *target, MDL_key::enum_mdl_namespace namespace_arg,
2270 enum_mdl_type mdl_type_arg, bool blocking = false);
2271 /**
2272 Destructor that unlocks all acquired locks.
2273 */
2274 virtual ~MDL_lock_guard();
2275
2276 /**
2277 Uses the target `THD` object MDL context to acquire the lock identified by
2278 `namespace_arg` with MDL type identified by `mdl_type_arg`.
2279
2280 If the `blocking` parameter is true, it will instantly try to acquire the
2281 lock and block. If the `blocking` parameter is false, it will first test if
2282 the lock is already acquired and only try to lock if no conflicting lock is
2283 already acquired.
2284
2285 The lock is determined to have been acquired if the `THD` object MDL context
2286 hasn't already a lock and the lock is acquired. In other words, if the MDL
2287 context already has acquired the lock, the method will return failure.
2288
2289 @param namespace_arg MDL key namespace to acquire the lock from.
2290 @param mdl_type_arg MDL acquisition type
2291 @param blocking whether or not the execution should block if the lock is
2292 already acquired.
2293
2294 @return false if the lock has been acquired by this method invocation and
2295 true if not.
2296 */
2297 bool lock(MDL_key::enum_mdl_namespace namespace_arg,
2298 enum_mdl_type mdl_type_arg, bool blocking = false);
2299 /**
2300 Returns whether or not the lock as been acquired within this object
2301 life-cycle.
2302
2303 @return true if the lock has been acquired within this object life-cycle.
2304 */
2305 bool is_locked();
2306
2307 private:
2308 /** The `THD` object holding the MDL context used for acquiring/releasing. */
2310 /** The MDL request holding the MDL ticket issued upon acquisition */
2312};
2313
2314/**
2315 @class Applier_security_context_guard
2316
2317 Utility class to allow RAII pattern with `Security_context` class.
2318
2319 At initiliazation, if the `THD` main security context isn't already the
2320 appropriate one, it copies the `Relay_log_info::info_thd::security_context`
2321 and replaces it with the one initialized with the `PRIVILEGE_CHECK_USER` user.
2322 At deinitialization, it copies the backed up security context.
2323
2324 It also deals with the case where no privilege checks are required, meaning,
2325 `PRIVILEGE_CHECKS_USER` is `NULL`.
2326
2327 Usage examples:
2328
2329 (1)
2330 @code
2331 Applier_security_context_guard security_context{rli, thd};
2332 if (!security_context.has_access({SUPER_ACL})) {
2333 return ER_NO_ACCESS;
2334 }
2335 @endcode
2336
2337 (4)
2338 @code
2339 Applier_security_context_guard security_context{rli, thd};
2340 if (!security_context.has_access(
2341 {{CREATE_ACL | INSERT_ACL | UPDATE_ACL, table},
2342 {SELECT_ACL, table}})) {
2343 return ER_NO_ACCESS;
2344 }
2345 @endcode
2346 */
2347
2349 public:
2350 /**
2351 If needed, backs up the current `thd` security context and replaces it with
2352 a security context for `PRIVILEGE_CHECKS_USER` user.
2353
2354 @param rli the `Relay_log_info` object that holds the
2355 `PRIVILEGE_CHECKS_USER` info.
2356 @param thd the `THD` for which initialize the security context.
2357 */
2358 Applier_security_context_guard(Relay_log_info const *rli, THD const *thd);
2359 /**
2360 Destructor that restores the backed up security context, if needed.
2361 */
2363
2364 // --> Deleted constructors and methods to remove default move/copy semantics
2366 delete;
2369 const Applier_security_context_guard &) = delete;
2371 delete;
2372 // <--
2373
2374 /**
2375 Returns whether or not privilege checks may be skipped within the current
2376 context.
2377
2378 @return true if privilege checks may be skipped and false otherwise.
2379 */
2380 bool skip_priv_checks() const;
2381 /**
2382 Checks if the `PRIVILEGE_CHECKS_USER` user has access to the privilieges
2383 passed on by `extra_privileges` parameter as well as to the privileges
2384 passed on at initilization time.
2385
2386 This particular method checks those privileges agains a given table and
2387 against that table's columns - the ones that are used or changed in the
2388 event.
2389
2390 @param extra_privileges set of privileges to check, additionally to those
2391 passed on at initialization. It's a list of
2392 (privilege, TABLE*, Rows_log_event*) tuples.
2393
2394 @return true if the privileges are included in the security context and
2395 false, otherwise.
2396 */
2397 bool has_access(
2398 std::vector<std::tuple<ulong, TABLE const *, Rows_log_event *>>
2399 &extra_privileges) const;
2400 /**
2401 Checks if the `PRIVILEGE_CHECKS_USER` user has access to the privilieges
2402 passed on by `extra_privileges` parameter as well as to the privileges
2403 passed on at initilization time.
2404
2405 @param extra_privileges set of privileges to check, additionally to those
2406 passed on at initialization. It's a list of
2407 privileges to be checked against any database.
2408
2409 @return true if the privileges are included in the security context and
2410 false, otherwise.
2411 */
2412 bool has_access(
2413 std::initializer_list<std::string_view> extra_privileges) const;
2414
2415 /**
2416 Checks if the `PRIVILEGE_CHECKS_USER` user has access to the privilieges
2417 passed on by `extra_privileges` parameter as well as to the privileges
2418 passed on at initilization time.
2419
2420 @param extra_privileges set of privileges to check, additionally to those
2421 passed on at initialization. It's a list of
2422 privileges to be checked against any database.
2423
2424 @return true if the privileges are included in the security context and
2425 false, otherwise.
2426 */
2427 bool has_access(std::initializer_list<ulong> extra_privileges) const;
2428
2429 /**
2430 Returns the username for the user for which the security context was
2431 initialized.
2432
2433 If `PRIVILEGE_CHECKS_USER` was configured for the target `Relay_log_info`
2434 object, that one is returned.
2435
2436 Otherwise, the username associated with the `Security_context` initialized
2437 for `Relay_log_info::info_thd` will be returned.
2438
2439 @return an `std::string` holding the username for the active security
2440 context.
2441 */
2442 std::string get_username() const;
2443 /**
2444 Returns the hostname for the user for which the security context was
2445 initialized.
2446
2447 If `PRIVILEGE_CHECKS_USER` was configured for the target `Relay_log_info`
2448 object, that one is returned.
2449
2450 Otherwise, the hostname associated with the `Security_context` initialized
2451 for `Relay_log_info::info_thd` will be returned.
2452
2453 @return an `std::string` holding the hostname for the active security
2454 context.
2455 */
2456 std::string get_hostname() const;
2457
2458 private:
2459 /**
2460 The `Relay_log_info` object holding the info required to initialize the
2461 context.
2462 */
2464 /**
2465 The `THD` object for which the security context will be initialized.
2466 */
2467 THD const *m_thd;
2468 /** Applier security context based on `PRIVILEGE_CHECK_USER` user */
2470 /** Currently in use security context */
2472 /** Backed up security context */
2474 /** Flag that states if privilege check should be skipped */
2476 /** Flag that states if there is a logged user */
2478
2480 std::vector<std::string> &columns) const;
2481};
2482
2483#endif /* RPL_RLI_H */
Contains the classes representing events occurring in the replication stream.
Utility class to allow RAII pattern with Security_context class.
Definition: rpl_rli.h:2348
Applier_security_context_guard(Applier_security_context_guard &&)=delete
void extract_columns_to_check(TABLE const *table, Rows_log_event *event, std::vector< std::string > &columns) const
Definition: rpl_rli.cc:3489
virtual ~Applier_security_context_guard()
Destructor that restores the backed up security context, if needed.
Definition: rpl_rli.cc:3407
Applier_security_context_guard(Relay_log_info const *rli, THD const *thd)
If needed, backs up the current thd security context and replaces it with a security context for PRIV...
Definition: rpl_rli.cc:3356
bool skip_priv_checks() const
Returns whether or not privilege checks may be skipped within the current context.
Definition: rpl_rli.cc:3415
Security_context m_applier_security_ctx
Applier security context based on PRIVILEGE_CHECK_USER user.
Definition: rpl_rli.h:2469
bool m_privilege_checks_none
Flag that states if privilege check should be skipped.
Definition: rpl_rli.h:2475
Applier_security_context_guard & operator=(const Applier_security_context_guard &)=delete
std::string get_username() const
Returns the username for the user for which the security context was initialized.
Definition: rpl_rli.cc:3477
THD const * m_thd
The THD object for which the security context will be initialized.
Definition: rpl_rli.h:2467
Security_context * m_previous
Backed up security context.
Definition: rpl_rli.h:2473
Security_context * m_current
Currently in use security context.
Definition: rpl_rli.h:2471
bool m_logged_in_acl_user
Flag that states if there is a logged user.
Definition: rpl_rli.h:2477
std::string get_hostname() const
Returns the hostname for the user for which the security context was initialized.
Definition: rpl_rli.cc:3483
Applier_security_context_guard & operator=(Applier_security_context_guard &&)=delete
bool has_access(std::vector< std::tuple< ulong, TABLE const *, Rows_log_event * > > &extra_privileges) const
Checks if the PRIVILEGE_CHECKS_USER user has access to the privilieges passed on by extra_privileges ...
Definition: rpl_rli.cc:3443
Relay_log_info const * m_target
The Relay_log_info object holding the info required to initialize the context.
Definition: rpl_rli.h:2463
Applier_security_context_guard(const Applier_security_context_guard &)=delete
This class is used to store the type and value for Assign_gtids_to_anonymous_transactions parameter o...
Definition: rpl_rli.h:91
bool set_info(enum_type assign_gtids_to_anonymous_transactions_type, const char *assign_gtids_to_anonymous_transactions_value)
Definition: rpl_rli.cc:3287
rpl_sidno m_sidno
Definition: rpl_rli.h:128
enum_type get_type() const
Definition: rpl_rli.cc:3283
enum_type m_type
This stores the type of Assign_gtids_to_anonymous_transactions info.
Definition: rpl_rli.h:124
Assign_gtids_to_anonymous_transactions_info()
The default constructor intializes the parameter to their default value.
Definition: rpl_rli.h:108
std::string m_value
Stores the UUID in case the m_type is not OFF.
Definition: rpl_rli.h:126
enum_type
This accepted value of the type of the Assign_gtids_to_anonymous_transactions info OFF : Anonymous gt...
Definition: rpl_rli.h:104
rpl_sidno get_sidno() const
Definition: rpl_rli.h:112
std::string get_value() const
Definition: rpl_rli.cc:3278
This has the functionality of mysql_rwlock_t, with two differences:
Definition: rpl_gtid.h:308
void assert_some_lock() const
Assert that some thread holds either the read or the write lock.
Definition: rpl_gtid.h:545
On a replica and only on a replica, this class is responsible for commiting the applyed transactions ...
Definition: rpl_replica_commit_order_manager.h:196
Definition: rpl_utility.h:476
void rewind()
Definition: rpl_utility.cc:1184
For binlog version 4.
Definition: log_event.h:1613
This is a subclass if Gtid_event and Log_event.
Definition: log_event.h:3829
rpl_sidno get_sidno(bool need_lock)
Return the SIDNO relative to the global sid_map for this GTID.
Definition: log_event.cc:13253
enum_gtid_type get_type() const
Return the gtid type for this Gtid_log_event: this can be either ANONYMOUS_GTID, AUTOMATIC_GTID,...
Definition: log_event.h:3933
rpl_gno get_gno() const
Return the GNO for this GTID.
Definition: log_event.h:3969
Stores information to monitor a transaction during the different replication stages.
Definition: rpl_gtid.h:1310
void clear()
Clear all monitoring information.
Definition: rpl_gtid_misc.cc:419
void finish()
Sets the final information, copy processing info to last_processed and clears processing info.
Definition: rpl_gtid_misc.cc:486
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:446
bool is_processing_trx_set()
Returns true if the processing_trx is set, false otherwise.
Definition: rpl_gtid_misc.cc:516
void store_transient_error(uint transient_errno_arg, const char *transient_err_message_arg, ulong trans_retries_arg)
Stores the information about the last transient error in the current transaction, namely: the error n...
Definition: rpl_gtid_misc.cc:534
void clear_processing_trx()
Clear only the processing_trx monitoring info.
Definition: rpl_gtid_misc.cc:426
Represents a set of GTIDs.
Definition: rpl_gtid.h:1454
enum_return_status ensure_sidno(rpl_sidno sidno)
Allocates space for all sidnos up to the given sidno in the array of intervals.
Definition: rpl_gtid_set.cc:131
void _add_gtid(rpl_sidno sidno, rpl_gno gno)
Adds the given GTID to this Gtid_set.
Definition: rpl_gtid.h:1516
Sid_map * get_sid_map() const
Return the Sid_map associated with this Gtid_set.
Definition: rpl_gtid.h:1886
This is the abstract base class for binary log events.
Definition: log_event.h:659
Log_event_type get_type_code() const
Definition: log_event.h:916
Utility class to allow RAII pattern with MDL_request and MDL_context classes.
Definition: rpl_rli.h:2244
bool lock(MDL_key::enum_mdl_namespace namespace_arg, enum_mdl_type mdl_type_arg, bool blocking=false)
Uses the target THD object MDL context to acquire the lock identified by namespace_arg with MDL type ...
Definition: rpl_rli.cc:3328
bool is_locked()
Returns whether or not the lock as been acquired within this object life-cycle.
Definition: rpl_rli.cc:3354
THD * m_target
The THD object holding the MDL context used for acquiring/releasing.
Definition: rpl_rli.h:2309
MDL_lock_guard(THD *target)
Constructor that initializes the object and the target THD object but doesn't try to acquire any lock...
Definition: rpl_rli.cc:3318
MDL_request m_request
The MDL request holding the MDL ticket issued upon acquisition.
Definition: rpl_rli.h:2311
virtual ~MDL_lock_guard()
Destructor that unlocks all acquired locks.
Definition: rpl_rli.cc:3347
A pending metadata lock request.
Definition: mdl.h:798
Definition: binlog.h:139
Definition: rpl_mi.h:86
Definition: rpl_mta_submode.h:54
bool empty() const
Definition: prealloced_array.h:225
size_t size() const
Definition: prealloced_array.h:226
A Query event is written to the binary log whenever the database is modified on the master,...
Definition: log_event.h:1385
RAII class to control the slave applier execution context binding with a being handled event.
Definition: rpl_rli.h:2226
Relay_log_info * m_rli
Definition: rpl_rli.h:2227
void set_current_event(Log_event *ev)
Definition: rpl_rli.h:2234
~RLI_current_event_raii()
Definition: rpl_rli.h:2235
RLI_current_event_raii(Relay_log_info *rli_arg, Log_event *ev)
Definition: rpl_rli.h:2230
Definition: rpl_rli.h:201
bool curr_group_seen_begin
Definition: rpl_rli.h:1173
uint checkpoint_group
Definition: rpl_rli.h:1203
static constexpr int RLI_FLUSH_IGNORE_SYNC_OPT
Ignore server sync options and flush.
Definition: rpl_rli.h:1528
static const int LINES_IN_RELAY_LOG_INFO_WITH_WORKERS
Definition: rpl_rli.h:1844
enum_return_check check_if_info_was_cleared(const enum_return_check &previous_result) const
Checks if the underlying Rpl_info handler holds information for the fields to be kept between slave r...
Definition: rpl_rli.cc:1957
enum_require_table_primary_key m_require_table_primary_key_check
Identifies what is the slave policy on primary keys in tables.
Definition: rpl_rli.h:788
Prealloced_array< Slave_job_item, 8 > curr_group_da
Definition: rpl_rli.h:1170
enum_priv_checks_status check_applier_acl_user(char const *param_privilege_checks_username, char const *param_privilege_checks_hostname)
Checks the existence of user provided as part of the PRIVILEGE_CHECKS_USER option.
Definition: rpl_rli.cc:3042
Format_description_log_event * get_rli_description_event() const
Return the current Format_description_log_event.
Definition: rpl_rli.h:1720
ulonglong mts_events_assigned
Definition: rpl_rli.h:1239
char cached_charset[6]
Definition: rpl_rli.h:919
volatile uint32 slave_skip_counter
Definition: rpl_rli.h:893
std::atomic< int32 > atomic_channel_open_temp_tables
Definition: rpl_rli.h:349
TABLE * save_temporary_tables
Definition: rpl_rli.h:343
int stmt_done(my_off_t event_log_pos)
Helper function to do after statement completion.
Definition: rpl_rli.cc:1228
ulong wq_size_waits_cnt
Definition: rpl_rli.h:1243
mysql_cond_t log_space_cond
Definition: rpl_rli.h:896
ulonglong get_group_master_log_pos_info() const
Definition: rpl_rli.h:1573
bool reset_group_relay_log_pos(const char **errmsg)
Reset group_relay_log_name and group_relay_log_pos to the start of the first relay log file.
Definition: rpl_rli.cc:508
void set_event_start_pos(my_off_t pos)
Definition: rpl_rli.h:1625
bool is_in_group() const
A group is defined as the entire range of events that constitute a transaction or auto-committed stat...
Definition: rpl_rli.h:1492
bool cached_charset_compare(char *charset) const
Definition: rpl_rli.cc:1218
int count_relay_log_space()
Definition: rpl_rli.cc:487
int flush_current_log()
Definition: rpl_rli.cc:1858
ulonglong max_updated_index
Definition: rpl_rli.h:1199
Rows_query_log_event * rows_query_ev
Definition: rpl_rli.h:1048
bool is_long_find_row_note_printed()
Definition: rpl_rli.h:1706
void notify_relay_log_change()
Invalidates cached until_log_name and event_relay_log_name comparison result.
Definition: rpl_rli.h:958
int init_until_option(THD *thd, const LEX_MASTER_INFO *master_param)
Intialize until option object when starting slave.
Definition: rpl_rli.cc:2695
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_rli.cc:2285
bool is_in_trx_or_stmt() const
Auxiliary function used by is_in_group.
Definition: rpl_rli.h:1461
void set_filter(Rpl_filter *channel_filter)
Set replication filter for the channel.
Definition: rpl_rli.h:1791
volatile ulong pending_jobs
Definition: rpl_rli.h:1149
volatile long mts_wq_excess_cnt
Definition: rpl_rli.h:1189
bool curr_group_seen_gtid
Definition: rpl_rli.h:1172
Gtid_set * gtid_set
Definition: rpl_rli.h:720
ulong mts_wq_no_underrun_cnt
Definition: rpl_rli.h:1249
const char * get_group_master_log_name() const
Definition: rpl_rli.h:1563
MY_BITMAP recovery_groups
Definition: rpl_rli.h:1204
table_mapping m_table_map
Definition: rpl_rli.h:1046
ulong mts_slave_worker_queue_len_max
Definition: rpl_rli.h:1153
static const int LINES_IN_RELAY_LOG_INFO_WITH_CHANNEL
Definition: rpl_rli.h:1855
mysql_cond_t logical_clock_cond
Definition: rpl_rli.h:314
bool is_in_stmt() const
Auxiliary function used by is_in_group.
Definition: rpl_rli.h:1447
ulonglong mts_groups_assigned
Definition: rpl_rli.h:1240
bool reinit_sql_thread_io_cache(const char *log, bool need_data_lock)
@ COMMIT_TS_FOUND
Definition: rpl_rli.h:361
@ COMMIT_TS_NOT_FOUND
Definition: rpl_rli.h:359
@ COMMIT_TS_UNKNOWN
Definition: rpl_rli.h:357
void close_temporary_tables()
Definition: rpl_rli.cc:1000
ulong retried_trans
Definition: rpl_rli.h:928
struct timespec last_clock
Identifies the last time a checkpoint routine has been executed.
Definition: rpl_rli.h:951
Checkable_rwlock * get_sid_lock()
Definition: rpl_rli.h:804
void detach_engine_ha_data(THD *thd)
Detaches the engine ha_data from THD.
Definition: rpl_rli.cc:2775
mysql_mutex_t pending_jobs_lock
Definition: rpl_rli.h:1150
bool inited_hash_workers
Definition: rpl_rli.h:1120
void set_event_relay_log_pos(ulonglong log_pos)
Definition: rpl_rli.h:1628
ulonglong group_relay_log_pos
Definition: rpl_rli.h:695
uchar slave_version_split[3]
Definition: rpl_rli.h:1730
ulong mts_coordinator_basic_nap
Definition: rpl_rli.h:1192
size_t slave_patternload_file_size
Definition: rpl_rli.h:946
char ign_master_log_name_end[FN_REFLEN]
Definition: rpl_rli.h:938
bool recovery_groups_inited
Definition: rpl_rli.h:1205
ulonglong event_relay_log_pos
Definition: rpl_rli.h:699
void end_info()
Definition: rpl_rli.cc:1838
bool rli_fake
Definition: rpl_rli.h:728
ulong opt_replica_parallel_workers
Definition: rpl_rli.h:1194
void set_allow_drop_write_set(bool does_not_require_ws)
Definition: rpl_rli.h:2014
std::atomic< longlong > mts_total_wait_overlap
Definition: rpl_rli.h:1251
time_t get_sql_delay()
Definition: rpl_rli.h:1660
void clear_gtid_monitoring_info()
Clears the Gtid_monitoring_info fields.
Definition: rpl_rli.h:431
char group_master_log_name[FN_REFLEN]
Definition: rpl_rli.h:716
void clear_mts_recovery_groups()
Definition: rpl_rli.h:1329
Prealloced_array< db_worker_hash_entry *, 4 > curr_group_assigned_parts
Definition: rpl_rli.h:1168
const char * get_for_channel_str(bool upper_case=false) const override
Definition: rpl_rli.cc:2660
ulonglong ign_master_log_pos_end
Definition: rpl_rli.h:939
void cleanup_after_query()
Definition: rpl_rli.h:1387
Commit_order_manager * get_commit_order_manager()
Definition: rpl_rli.h:1743
ulong trans_retries
Definition: rpl_rli.h:928
void init_workers(ulong)
The method to invoke at slave threads start.
Definition: rpl_rli.cc:262
~Relay_log_info() override
Definition: rpl_rli.cc:283
uint32 m_flags
Definition: rpl_rli.h:1833
void clear_tables_to_lock()
Definition: rpl_rli.cc:1363
const char * get_until_log_name()
Definition: rpl_rli.cc:2677
void post_rollback()
Execute actions at replicated atomic DLL post rollback time.
Definition: rpl_rli.h:2079
my_off_t event_start_pos
Definition: rpl_rli.h:703
static const int LINES_IN_RELAY_LOG_INFO_WITH_PRIV_CHECKS_HOSTNAME
Definition: rpl_rli.h:1874
bool m_is_engine_ha_data_detached
Definition: rpl_rli.h:1983
static size_t get_number_info_rli_fields()
Definition: rpl_rli.cc:2031
bool reported_unsafe_warning
Definition: rpl_rli.h:1683
static const int LINES_IN_RELAY_LOG_INFO_WITH_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS_VALUE
Definition: rpl_rli.h:1906
void set_require_table_primary_key_check(enum_require_table_primary_key require_pk)
Sets the field that tells what is the slave policy concerning primary keys on replicated tables.
Definition: rpl_rli.cc:3264
uint64 original_commit_timestamp
Definition: rpl_rli.h:1089
mysql_cond_t pending_jobs_cond
Definition: rpl_rli.h:1151
void set_commit_order_manager(Commit_order_manager *mngr)
Definition: rpl_rli.h:1745
std::vector< Slave_worker * > workers_copy_pfs
Definition: rpl_rli.h:1136
static const int LINES_IN_RELAY_LOG_INFO_WITH_REQUIRE_TABLE_PRIMARY_KEY_CHECK
Definition: rpl_rli.h:1891
void set_thd_tx_priority(int priority)
Definition: rpl_rli.h:2002
void fill_coord_err_buf(loglevel level, int err_code, const char *buff_coord) const
Update the error number, message and timestamp fields.
Definition: rpl_rli.cc:552
volatile ulong mts_wq_overrun_cnt
Definition: rpl_rli.h:1242
enum_return_status add_gtid_set(const Gtid_set *gtid_set)
Adds a GTID set to received GTID set.
Definition: rpl_rli.cc:2667
bool replicate_same_server_id
Definition: rpl_rli.h:322
void add_logged_gtid(rpl_sidno sidno, rpl_gno gno)
Definition: rpl_rli.h:806
bool is_time_for_mta_checkpoint()
Check if it is time to compute MTS checkpoint.
Definition: rpl_rli.cc:2911
void set_flag(enum_state_flag flag)
Set the value of a replication state flag.
Definition: rpl_rli.h:1415
std::string m_privilege_checks_hostname
The host name part of the user passed on to PRIVILEGE_CHECKS_USER.
Definition: rpl_rli.h:762
mysql_mutex_t slave_worker_hash_lock
Definition: rpl_rli.h:1122
ulong exit_counter
Definition: rpl_rli.h:1198
int rli_init_info(bool skip_received_gtid_set_recovery=false)
Initialize the relay log info.
Definition: rpl_rli.cc:1492
void reset_notified_relay_log_change()
While a group is executed by a Worker the relay log can change.
Definition: rpl_rli.cc:343
static void set_nullable_fields(MY_BITMAP *nullable_fields)
Sets bits for columns that are allowed to be NULL.
Definition: rpl_rli.cc:2035
bool m_is_applier_source_position_info_invalid
Are positions invalid.
Definition: rpl_rli.h:797
void set_master_info(Master_info *info)
Definition: rpl_rli.cc:1867
bool gtid_retrieved_initialized
Definition: rpl_rli.h:730
ulonglong stats_exec_time
Definition: rpl_rli.h:1263
bool force_flush_postponed_due_to_split_trans
Definition: rpl_rli.h:1741
volatile ulong mts_wq_underrun_w_id
Definition: rpl_rli.h:1178
void clear_processing_trx()
Clears the processing_trx structure fields.
Definition: rpl_rli.h:426
void deinit_workers()
The method to invoke at slave threads stop.
Definition: rpl_rli.cc:281
void clear_privilege_checks_user()
Clears the info related to the data initialized from PRIVILEGE_CHECKS_USER.
Definition: rpl_rli.cc:2948
my_off_t get_event_start_pos()
Definition: rpl_rli.h:1626
bool get_ignore_write_set_memory_limit()
Definition: rpl_rli.h:2010
@ UNTIL_SQL_VIEW_ID
Definition: rpl_rli.h:915
@ UNTIL_MASTER_POS
Definition: rpl_rli.h:910
@ UNTIL_NONE
Definition: rpl_rli.h:909
@ UNTIL_SQL_BEFORE_GTIDS
Definition: rpl_rli.h:912
@ UNTIL_SQL_AFTER_GTIDS
Definition: rpl_rli.h:913
@ UNTIL_SQL_AFTER_MTS_GAPS
Definition: rpl_rli.h:914
@ UNTIL_DONE
Definition: rpl_rli.h:916
@ UNTIL_RELAY_POS
Definition: rpl_rli.h:911
virtual void post_commit(bool on_rollback)
Cleanup of any side effect that pre_commit() inflicts, including restore of the last executed group c...
Definition: rpl_rli.cc:2847
void start_sql_delay(time_t delay_end)
Indicate that a delay starts.
Definition: rpl_rli.cc:2043
void cached_charset_invalidate()
Last charset (6 bytes) seen by slave SQL thread is cached here; it helps the thread save 3 get_charse...
Definition: rpl_rli.cc:1211
static const int LINES_IN_RELAY_LOG_INFO_WITH_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS_TYPE
Definition: rpl_rli.h:1898
uint tables_to_lock_count
Definition: rpl_rli.h:1045
std::atomic< bool > ignore_log_space_limit
Definition: rpl_rli.h:871
int get_thd_tx_priority()
Definition: rpl_rli.h:2004
bool mts_recovery_group_seen_begin
Definition: rpl_rli.h:1208
bool long_find_row_note_printed
Definition: rpl_rli.h:1926
Deferred_log_events * deferred_events
Definition: rpl_rli.h:1097
Rpl_filter * rpl_filter
Definition: rpl_rli.h:253
ulong replica_parallel_workers
Definition: rpl_rli.h:1196
ulonglong log_space_limit
Definition: rpl_rli.h:870
Until_option * until_option
Definition: rpl_rli.h:1971
@ MTS_KILLED_GROUP
Definition: rpl_rli.h:1233
@ MTS_NOT_IN_GROUP
Definition: rpl_rli.h:1229
@ MTS_IN_GROUP
Definition: rpl_rli.h:1231
@ MTS_END_GROUP
Definition: rpl_rli.h:1232
ulonglong mts_total_wait_worker_avail
Definition: rpl_rli.h:1256
int flush_info(const int flush_flags)
Stores the file and position where the execute-slave thread are in the relay log:
Definition: rpl_rli.cc:1923
bool is_relay_log_recovery
Definition: rpl_rli.h:334
Relay_log_info(bool is_slave_recovery, 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_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, uint param_id, const char *param_channel, bool is_rli_fake)
Definition: rpl_rli.cc:107
bool workers_array_initialized
Definition: rpl_rli.h:1147
bool write_info(Rpl_info_handler *to) override
Definition: rpl_rli.cc:2293
time_t sql_delay_end
During a delay, specifies the point in time when the delay ends.
Definition: rpl_rli.h:1831
void set_ignore_write_set_memory_limit(bool ignore_limit)
Definition: rpl_rli.h:2006
bool mts_wq_oversize
Definition: rpl_rli.h:1156
bool m_privilege_checks_user_corrupted
Tells whether or not the internal data regarding PRIVILEGE_CHECKS_USER is corrupted.
Definition: rpl_rli.h:769
enum_state_flag
Flags for the state of the replication.
Definition: rpl_rli.h:257
@ IN_STMT
The replication thread is inside a statement.
Definition: rpl_rli.h:259
@ STATE_FLAGS_COUNT
Flag counter.
Definition: rpl_rli.h:262
uint event_relay_log_number
Definition: rpl_rli.h:698
ulong mts_recovery_group_cnt
Definition: rpl_rli.h:1206
time_t row_stmt_start_timestamp
Definition: rpl_rli.h:1925
static constexpr int RLI_FLUSH_IGNORE_GTID_ONLY
Flush disresgarding the value of GTID_ONLY.
Definition: rpl_rli.h:1530
void set_group_master_log_name(const char *log_file_name)
Definition: rpl_rli.h:1577
void clear_flag(enum_state_flag flag)
Clear the value of a replication state flag.
Definition: rpl_rli.h:1431
ulong mts_wq_overfill_cnt
Definition: rpl_rli.h:1257
bool belongs_to_client()
Definition: rpl_rli.h:296
void set_future_event_relay_log_pos(ulonglong log_pos)
Definition: rpl_rli.h:1559
bool curr_group_isolated
Definition: rpl_rli.h:1174
void set_long_find_row_note_printed()
Definition: rpl_rli.h:1700
void set_privilege_checks_user_corrupted(bool is_corrupted)
Sets the flag that tells whether or not the data regarding the PRIVILEGE_CHECKS_USER is corrupted.
Definition: rpl_rli.cc:2955
char group_relay_log_name[FN_REFLEN]
Event group means a group of events of a transaction.
Definition: rpl_rli.h:694
time_t get_row_stmt_start_timestamp()
Definition: rpl_rli.h:1690
ulonglong get_future_event_relay_log_pos()
Definition: rpl_rli.h:1556
time_t get_sql_delay_end()
Definition: rpl_rli.h:1662
void cleanup_context(THD *, bool)
Definition: rpl_rli.cc:1275
char new_group_master_log_name[FN_REFLEN]
Storage for holding newly computed values for the last executed event group coordinates while the cur...
Definition: rpl_rli.h:1276
Slave_worker * get_worker(size_t n)
Definition: rpl_rli.h:1293
mysql_mutex_t log_space_lock
Definition: rpl_rli.h:895
ulong adapt_to_master_version(Format_description_log_event *fdle)
adaptation for the slave applier to specific master versions.
Definition: rpl_rli.cc:2496
bool is_engine_ha_data_detached()
Checks whether engine ha data is detached from THD.
Definition: rpl_rli.h:2069
bool is_mts_recovery() const
returns true if there is any gap-group of events to execute at slave starting phase.
Definition: rpl_rli.h:1327
void notify_group_master_log_name_update()
The same as notify_group_relay_log_name_update but for group_master_log_name.
Definition: rpl_rli.h:978
enum_require_row_status
Definition: rpl_rli.h:243
@ PRIV_CHECKS_USER_NOT_NULL
Value for privilege_checks_user is not empty.
@ SUCCESS
Function ended successfully.
Assign_gtids_to_anonymous_transactions_info m_assign_gtids_to_anonymous_transactions_info
Stores the information related to the ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS parameter of CHANGE MAST...
Definition: rpl_rli.h:287
virtual Relay_log_info * get_c_rli()
Get coordinator's RLI.
Definition: rpl_rli.h:1784
void clear_sql_delay()
Reset the delay.
Definition: rpl_rli.h:886
Log_event * current_event
Reference to being applied event.
Definition: rpl_rli.h:1990
time_t mts_last_online_stat
Definition: rpl_rli.h:1268
my_off_t get_until_log_pos()
Definition: rpl_rli.cc:2686
Mts_submode * current_mts_submode
Definition: rpl_rli.h:1315
time_t set_row_stmt_start_timestamp()
Definition: rpl_rli.h:1692
Slave_committed_queue * gaq
Definition: rpl_rli.h:1163
bool is_relay_log_truncated()
Definition: rpl_rli.h:800
bool m_ignore_write_set_memory_limit
If the SQL thread should or not ignore the set limit for write set collection.
Definition: rpl_rli.h:1962
my_off_t new_group_master_log_pos
Definition: rpl_rli.h:1277
enum Relay_log_info::@145 until_condition
bool clear_info()
Clears from this Relay_log_info object all attribute values that are not to be kept.
Definition: rpl_rli.cc:1985
void clear_until_option()
Definition: rpl_rli.h:1768
ulonglong stats_read_time
Definition: rpl_rli.h:1264
bool is_privilege_checks_user_null() const
Returns whether or not there is no user configured for PRIVILEGE_CHECKS_USER.
Definition: rpl_rli.cc:2937
void set_sql_delay(time_t _sql_delay)
Definition: rpl_rli.h:1661
static const int PRIV_CHECKS_HOSTNAME_LENGTH
Definition: rpl_rli.h:1879
bool is_applier_source_position_info_invalid() const
Returns if the applier positions are marked as being invalid or not.
Definition: rpl_rli.cc:3274
bool is_group_master_log_pos_invalid
Flag that the group_master_log_pos is invalid.
Definition: rpl_rli.h:862
void reset_row_stmt_start_timestamp()
Definition: rpl_rli.h:1698
MYSQL_BIN_LOG relay_log
Definition: rpl_rli.h:328
static const int LINES_IN_RELAY_LOG_INFO_WITH_ID
Definition: rpl_rli.h:1850
bool m_require_row_format
Tells if the slave is only accepting events logged with row based logging.
Definition: rpl_rli.h:778
void reset_notified_checkpoint(ulong count, time_t new_ts, bool update_timestamp=false)
While a group is executed by a Worker the relay log can change.
Definition: rpl_rli.cc:370
bool m_allow_drop_write_set
Even if a component says all transactions require write sets, this variable says the SQL thread trans...
Definition: rpl_rli.h:1968
uint rli_checkpoint_seqno
Definition: rpl_rli.h:1201
uint get_event_relay_log_number()
Definition: rpl_rli.h:1609
bool is_until_satisfied_at_start_slave()
Definition: rpl_rli.h:2022
std::pair< const char *, const char * > print_applier_security_context_user_host() const
Returns a printable representation of the username and hostname currently being used in the applier s...
Definition: rpl_rli.cc:3068
static const int MAXIMUM_LINES_IN_RELAY_LOG_INFO_FILE
Definition: rpl_rli.h:1912
void set_group_master_log_pos(ulonglong log_pos)
Definition: rpl_rli.h:1581
volatile my_off_t group_master_log_pos
Definition: rpl_rli.h:717
long mts_worker_underrun_level
Definition: rpl_rli.h:1190
bool is_until_satisfied_before_dispatching_event(const Log_event *ev)
Definition: rpl_rli.h:2026
ulonglong get_group_relay_log_pos()
Definition: rpl_rli.h:1588
void set_group_relay_log_name(const char *log_file_name, size_t len)
Definition: rpl_rli.h:1593
int inc_group_relay_log_pos(ulonglong log_pos, bool need_data_lock, bool force=false)
Last executed event group coordinates are updated and optionally forcibly flushed to a repository.
Definition: rpl_rli.cc:928
ulonglong log_space_total
Definition: rpl_rli.h:870
bool is_group_relay_log_name_invalid(const char **errmsg)
Check if group_relay_log_name is in index file.
Definition: rpl_rli.cc:522
Relay_log_info & operator=(const Relay_log_info &info)
const char * get_rpl_log_name() const
Definition: rpl_rli.h:1631
void set_until_option(Until_option *option)
Definition: rpl_rli.h:1762
void finished_processing()
When the processing of a transaction is completed, that timestamp is recorded, the information is cop...
Definition: rpl_rli.h:413
enum_priv_checks_status set_privilege_checks_user(char const *param_privilege_checks_username, char const *param_privilege_checks_hostname)
Initializes data related to PRIVILEGE_CHECKS_USER, specifically the user name and the user hostname.
Definition: rpl_rli.cc:2961
int purge_relay_logs(THD *thd, const char **errmsg, bool delete_only=false)
Purges relay logs.
Definition: rpl_rli.cc:1032
bool is_privilege_checks_user_corrupted() const
Returns whether or not the internal data regarding PRIVILEGE_CHECKS_USER is corrupted.
Definition: rpl_rli.cc:2944
bool is_until_satisfied_after_dispatching_event()
Definition: rpl_rli.h:2030
enum_priv_checks_status initialize_security_context(THD *thd)
Initializes the security context associated with the PRIVILEGE_CHECKS_USER user that is to be used by...
Definition: rpl_rli.cc:3209
void set_group_relay_log_pos(ulonglong log_pos)
Definition: rpl_rli.h:1596
const char * get_group_relay_log_name()
Definition: rpl_rli.h:1587
enum_priv_checks_status check_privilege_checks_user()
Checks the validity and integrity of the data related to PRIVILEGE_CHECKS_USER, specifically the user...
Definition: rpl_rli.cc:2991
const char * get_event_relay_log_name()
Definition: rpl_rli.h:1600
enum Relay_log_info::@144 commit_timestamps_status
the status of the commit timestamps for the relay log
virtual int set_rli_description_event(Format_description_log_event *fdle)
Delete the existing event and set a new one.
Definition: rpl_rli.cc:2376
Gtid_monitoring_info * gtid_monitoring_info
Stores information on the last processed transaction or the transaction that is currently being proce...
Definition: rpl_rli.h:745
const char * add_channel_to_relay_log_name(char *buff, uint buff_size, const char *base_name)
sets the suffix required for relay log names in multisource replication.
Definition: rpl_rli.cc:1179
size_t get_worker_count()
Definition: rpl_rli.h:1282
ulonglong get_group_master_log_pos() const
Definition: rpl_rli.h:1570
const char * get_group_master_log_name_info() const
Definition: rpl_rli.h:1566
void report_privilege_check_error(enum loglevel level, enum_priv_checks_status status_code, bool to_client, char const *channel_name=nullptr, char const *user_name=nullptr, char const *host_name=nullptr) const
Outputs the error message associated with applier thread user privilege checks error error_code.
Definition: rpl_rli.cc:3086
enum_require_table_primary_key
Identifies what is the slave policy on primary keys in tables.
Definition: rpl_rli.h:268
@ PK_CHECK_ON
The slave enforces tables to have primary keys for a given channel.
Definition: rpl_rli.h:277
@ PK_CHECK_STREAM
The slave sets the value of sql_require_primary_key according to the source replicated value.
Definition: rpl_rli.h:275
@ PK_CHECK_OFF
The slave does not enforce any policy around primary keys.
Definition: rpl_rli.h:279
@ PK_CHECK_NONE
No policy, used on PFS.
Definition: rpl_rli.h:270
void started_processing(Gtid gtid_arg, ulonglong original_ts_arg, ulonglong immediate_ts_arg, bool skipped=false)
Stores the details of the transaction which has just started processing.
Definition: rpl_rli.h:382
bool pre_commit()
The method implements a pre-commit hook to add up a new statement typically to a DDL transaction to u...
Definition: rpl_rli.h:2091
void retried_processing(uint transient_errno_arg, const char *transient_err_message_arg, ulong trans_retries_arg)
When a transaction is retried, the error number and message, and total number of retries are stored.
Definition: rpl_rli.h:442
static constexpr int RLI_FLUSH_NO_OPTION
No flush options given to relay log flush.
Definition: rpl_rli.h:1526
bool sql_thread_kill_accepted
Definition: rpl_rli.h:1688
static const int PRIV_CHECKS_USERNAME_LENGTH
Definition: rpl_rli.h:1867
void slave_close_thread_tables(THD *)
Definition: rpl_rli.cc:1404
enum_priv_checks_status
Set of possible return values for the member methods related to PRIVILEGE_CHECKS_USER management.
Definition: rpl_rli.h:209
@ USERNAME_NULL_HOSTNAME_NOT_NULL
Value for the username part of the user is NULL but the value for the hostname is not NULL.
@ USER_DOES_NOT_HAVE_PRIVILEGES
Provided user doesn't have the necesary privileges to execute the needed operations.
@ USER_ANONYMOUS
Value for user is anonymous (''@'...')
@ USERNAME_TOO_LONG
Value for the username part of the user is larger than 32 characters.
@ HOSTNAME_TOO_LONG
Value for the hostname part of the user is larger than 255 characters.
@ LOAD_DATA_EVENT_NOT_ALLOWED
Provided user doesn't have FILE privileges during the execution of a LOAD DATAevent.
@ USER_DATA_CORRUPTED
Values provided for the internal variables are corrupted.
@ USER_DOES_NOT_EXIST
Provided user doesn't exists.
@ SUCCESS
Function ended successfully.
@ HOSTNAME_SYNTAX_ERROR
Value for the hostname part of the user has illegal characters.
bool ddl_not_atomic
Raised when slave applies and writes to its binary log statement which is not atomic DDL and has no X...
Definition: rpl_rli.h:2000
bool get_flag(enum_state_flag flag)
Get the value of a replication state flag.
Definition: rpl_rli.h:1424
static const int LINES_IN_RELAY_LOG_INFO_WITH_REQUIRE_ROW_FORMAT
Definition: rpl_rli.h:1884
void inc_event_relay_log_pos()
Definition: rpl_rli.h:983
volatile ulong abort_pos_wait
Definition: rpl_rli.h:894
bool read_info(Rpl_info_handler *from) override
Definition: rpl_rli.cc:2049
void started_processing(Gtid_log_event *gtid_log_ev_arg)
Stores the details of the transaction which has just started processing.
Definition: rpl_rli.h:396
struct timespec stats_begin
Definition: rpl_rli.h:1266
mysql_mutex_t exit_count_lock
Definition: rpl_rli.h:1152
void notify_relay_log_truncated()
Receiver thread notifies that it truncated some data from relay log.
Definition: rpl_rli.cc:2900
uint relay_log_name_to_number(const char *name)
Definition: rpl_rli.cc:2652
Sid_map * get_sid_map()
Definition: rpl_rli.h:802
time_t last_event_start_time
Definition: rpl_rli.h:1086
ulonglong get_event_relay_log_pos()
Definition: rpl_rli.h:1601
void relay_log_number_to_name(uint number, char name[FN_REFLEN+1])
Given the extension number of the relay log, gets the full relay log path.
Definition: rpl_rli.cc:2639
ulong adapt_to_master_version_updown(ulong master_version, ulong current_version)
The method compares two supplied versions and carries out down- or up- grade customization of executi...
Definition: rpl_rli.cc:2576
enum_priv_checks_status initialize_applier_security_context()
Initializes the security context associated with the PRIVILEGE_CHECKS_USER user that is to be used by...
Definition: rpl_rli.cc:3245
static const int LINES_IN_RELAY_LOG_INFO_WITH_PRIV_CHECKS_USERNAME
Definition: rpl_rli.h:1862
ulonglong mts_pending_jobs_size
Definition: rpl_rli.h:1154
Format_description_log_event * rli_description_event
Definition: rpl_rli.h:1796
bool mts_finalize_recovery()
Called when gaps execution is ended so it is crash-safe to reset the last session Workers info.
Definition: rpl_rli.cc:427
void set_group_relay_log_name(const char *log_file_name)
Definition: rpl_rli.h:1589
int thd_tx_priority
Definition: rpl_rli.h:1956
my_off_t new_group_relay_log_pos
Definition: rpl_rli.h:1279
void clear_relay_log_truncated()
Applier clears the flag after it handled the situation.
Definition: rpl_rli.cc:2906
Replication_transaction_boundary_parser transaction_parser
Definition: rpl_rli.h:645
char slave_patternload_file[FN_REFLEN]
Definition: rpl_rli.h:945
ulong mts_recovery_index
Definition: rpl_rli.h:1207
void unset_long_find_row_note_printed()
Definition: rpl_rli.h:1702
mysql_mutex_t mts_temp_table_LOCK
Definition: rpl_rli.h:308
bool deferred_events_collecting
Definition: rpl_rli.h:1103
bool m_relay_log_truncated
It will be set to true when receiver truncated relay log for some reason.
Definition: rpl_rli.h:752
bool is_mts_in_group()
returns true if Coordinator is scheduling events belonging to the same group and has not reached yet ...
Definition: rpl_rli.h:1352
time_t last_master_timestamp
Definition: rpl_rli.h:880
bool is_parallel_exec() const
returns true if events are to be executed in parallel
Definition: rpl_rli.h:1340
int wait_for_gtid_set(THD *thd, const char *gtid, double timeout, bool update_THD_status=true)
Wait for a GTID set to be executed.
Definition: rpl_rli.cc:768
malloc_unordered_map< std::string, unique_ptr_with_deleter< db_worker_hash_entry > > mapping_db_to_worker
Definition: rpl_rli.h:1119
RPL_TABLE_LIST * tables_to_lock
Definition: rpl_rli.h:1044
bool error_on_rli_init_info
Definition: rpl_rli.h:454
std::string get_privilege_checks_username() const
Retrieves the username part of the PRIVILEGE_CHECKS_USER option of CHANGE MASTER TO statement.
Definition: rpl_rli.cc:2929
static const int LINES_IN_RELAY_LOG_INFO_WITH_DELAY
Definition: rpl_rli.h:1839
Master_info * mi
Definition: rpl_rli.h:346
std::atomic< bool > sql_force_rotate_relay
Definition: rpl_rli.h:878
std::string m_privilege_checks_username
The user name part of the user passed on to PRIVILEGE_CHECKS_USER.
Definition: rpl_rli.h:757
bool is_processing_trx()
Definition: rpl_rli.h:418
bool is_row_format_required() const
Returns whether the slave is running in row mode only.
Definition: rpl_rli.cc:3250
const Gtid_set * get_gtid_set() const
Definition: rpl_rli.h:822
void cleanup_after_session()
Definition: rpl_rli.h:1391
PSI_mutex_key m_key_mta_temp_table_LOCK
Definition: rpl_rli.h:302
virtual bool commit_positions()
The method implements updating a slave info table.
Definition: rpl_rli.cc:2796
char event_relay_log_name[FN_REFLEN]
Definition: rpl_rli.h:696
enum_require_table_primary_key get_require_table_primary_key_check() const
Returns what is the slave policy concerning primary keys on replicated tables.
Definition: rpl_rli.cc:3260
Slave_worker_array workers
Definition: rpl_rli.h:1114
bool get_allow_drop_write_set()
Definition: rpl_rli.h:2018
ulonglong future_event_relay_log_pos
Definition: rpl_rli.h:700
Commit_order_manager * commit_order_mngr
Definition: rpl_rli.h:1804
struct timespec ts_exec[2]
Definition: rpl_rli.h:1265
std::string get_privilege_checks_hostname() const
Retrieves the host part of the PRIVILEGE_CHECKS_USER option of CHANGE MASTER TO statement.
Definition: rpl_rli.cc:2933
Gtid_monitoring_info * get_gtid_monitoring_info()
Definition: rpl_rli.h:367
char new_group_relay_log_name[FN_REFLEN]
Definition: rpl_rli.h:1278
void set_event_relay_log_name(const char *log_file_name)
Definition: rpl_rli.h:1602
void set_applier_source_position_info_invalid(bool invalid)
Marks the applier position information as being invalid or not.
Definition: rpl_rli.cc:3270
int wait_for_pos(THD *thd, String *log_name, longlong log_pos, double timeout)
Waits until the SQL thread reaches (has executed up to) the log/position or timed out.
Definition: rpl_rli.cc:588
void set_require_row_format(bool require_row)
Sets the flag that tells whether or not the slave is running in row mode only.
Definition: rpl_rli.cc:3254
void reattach_engine_ha_data(THD *thd)
Reattaches the engine ha_data to THD.
Definition: rpl_rli.cc:2785
bool mts_end_group_sets_max_dbs
Definition: rpl_rli.h:1175
time_t sql_delay
Delay slave SQL thread by this amount of seconds.
Definition: rpl_rli.h:1821
mysql_cond_t slave_worker_hash_cond
Definition: rpl_rli.h:1123
Relay_log_info(const Relay_log_info &info)
Slave_worker * last_assigned_worker
Definition: rpl_rli.h:1158
ulong recovery_parallel_workers
Definition: rpl_rli.h:1200
ulonglong mts_pending_jobs_size_max
Definition: rpl_rli.h:1155
bool get_table_data(TABLE *table_arg, table_def **tabledef_var, TABLE **conv_table_var) const
Definition: rpl_rli.h:1050
enum_mts_parallel_type channel_mts_submode
Definition: rpl_rli.h:1313
enum Relay_log_info::@146 mts_group_status
void set_event_relay_log_number(uint number)
Definition: rpl_rli.h:1610
mysql_mutex_t mts_gaq_LOCK
Definition: rpl_rli.h:313
This is the class for verifying transaction boundaries in a replication event stream.
Definition: rpl_trx_boundary_parser.h:50
Common base class for all row-containing log events.
Definition: log_event.h:2698
It is used to record the original query for the rows events in RBR.
Definition: log_event.h:3656
Rpl_filter.
Definition: rpl_filter.h:213
Definition: rpl_info_factory.h:43
Definition: rpl_info_handler.h:57
Definition: rpl_info.h:42
mysql_mutex_t data_lock
Definition: rpl_info.h:57
bool is_transactional() const
Definition: rpl_info.h:110
THD * info_thd
Definition: rpl_info.h:77
A set of THD members describing the current authenticated user.
Definition: sql_security_ctx.h:53
Represents a bidirectional map between SID and SIDNO.
Definition: rpl_gtid.h:723
Checkable_rwlock * get_sid_lock() const
Return the sid_lock.
Definition: rpl_gtid.h:826
Group Assigned Queue whose first element identifies first gap in committed sequence.
Definition: rpl_rli_pdb.h:350
Definition: rpl_rli_pdb.h:497
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:945
Gtid owned_gtid
The GTID of the currently owned transaction.
Definition: sql_class.h:3648
bool slave_thread
Definition: sql_class.h:2616
Relay_log_info * rli_slave
Definition: sql_class.h:1073
enum enum_thread_type system_thread
Definition: sql_class.h:2409
struct System_variables variables
Definition: sql_class.h:1130
bool is_commit_in_middle_of_statement
Definition: sql_class.h:3806
bool is_operating_substatement_implicitly
Definition: sql_class.h:2232
This is the abstract base class for slave start until options.
Definition: rpl_replica_until_options.h:55
bool is_satisfied_after_dispatching_event()
check if the until option is satisfied after applied or dispatched a event.
Definition: rpl_replica_until_options.h:96
bool is_satisfied_before_dispatching_event(const Log_event *ev)
check if the until option is satisfied before applying or dispatching a event.
Definition: rpl_replica_until_options.h:82
bool is_satisfied_at_start_slave()
Check if the until option is already satisfied at coordinator starting.
Definition: rpl_replica_until_options.h:66
unsigned long long int original_commit_timestamp
Timestamp when the transaction was committed on the originating master.
Definition: control_events.h:981
unsigned long long int immediate_commit_timestamp
Timestamp when the transaction was committed on the nearest master.
Definition: control_events.h:983
uint16_t error_code
Definition: statement_events.h:559
std::unordered_map, but with my_malloc, so that you can track the memory used using PSI memory keys.
Definition: map_helpers.h:147
A table definition from the master.
Definition: rpl_utility.h:247
Maps table id's (integers) to table pointers.
Definition: rpl_tblmap.h:50
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:49
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:56
char * pos
Definition: do_ctype.cc:76
#define base_name(A)
Definition: my_sys.h:705
uint sql_replica_skip_counter
a copy of active_mi->rli->slave_skip_counter, for showing in SHOW GLOBAL VARIABLES,...
Definition: rpl_replica.cc:8686
bool is_atomic_ddl(THD *thd, bool using_trans_arg)
The function lists all DDL instances that are supported for crash-recovery (WL9175).
Definition: log_event.cc:3769
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:51
static int flag
Definition: hp_test1.cc:39
Binary log event definitions.
char * strmake(char *dst, const char *src, size_t length)
Definition: strmake.cc:42
std::unique_ptr< T, void(*)(T *)> unique_ptr_with_deleter
std::unique_ptr, but with a custom delete function.
Definition: map_helpers.h:88
enum_mdl_type
Type of metadata lock request.
Definition: mdl.h:195
void bitmap_free(MY_BITMAP *map)
Definition: my_bitmap.cc:157
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:180
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
ulonglong my_off_t
Definition: my_inttypes.h:71
unsigned char uchar
Definition: my_inttypes.h:51
long long int longlong
Definition: my_inttypes.h:54
uint64_t uint64
Definition: my_inttypes.h:68
uint32_t uint32
Definition: my_inttypes.h:66
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:82
Definition of the global "loglevel" enumeration.
loglevel
Definition: my_loglevel.h:40
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
#define HAVE_PSI_INTERFACE
Definition: my_psi_config.h:38
Common header for many mysys elements.
static int count
Definition: myisam_ftdump.cc:42
Instrumentation helpers for conditions.
ABI for instrumented mutexes.
Log info(cout, "NOTE")
@ QUERY_EVENT
Definition: binlog_event.h:280
const std::string charset("charset")
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:493
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2853
Instrumentation helpers for mutexes.
PSI_memory_key key_memory_db_worker_hash_entry
Definition: psi_memory_key.cc:103
Instrumentation helpers for mutexes.
#define OPTION_BEGIN
Definition: query_options.h:74
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:60
required uint32 priority
Definition: replication_group_member_actions.proto:34
required string event
Definition: replication_group_member_actions.proto:31
enum_return_status
Generic return type for many functions that can succeed or fail.
Definition: rpl_gtid.h:121
int rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:95
binary_log::gtids::gno_t rpl_gno
GNO, the second (numeric) component of a GTID, is an alias of binary_log::gtids::gno_t.
Definition: rpl_gtid.h:102
@ ASSIGNED_GTID
Specifies that the transaction has been assigned a GTID (UUID:NUMBER).
Definition: rpl_gtid.h:3698
enum_return_check
Definition: rpl_info_handler.h:50
enum_mts_parallel_type
Definition: rpl_mta_submode.h:46
bool operator!(Relay_log_info::enum_priv_checks_status status)
Negation operator for enum_priv_checks_status, to facilitate validation against SUCCESS.
Definition: rpl_rli.cc:2921
Prealloced_array< Slave_worker *, 4 > Slave_worker_array
Definition: rpl_rli.h:78
struct slave_job_item Slave_job_item
bool is_mts_worker(const THD *thd)
Definition: rpl_rli.h:2137
bool is_committed_ddl(Log_event *ev)
Checks whether the supplied event encodes a (2pc-aware) DDL that has been already committed.
Definition: rpl_rli.h:2153
bool is_atomic_ddl_commit_on_slave(THD *thd)
Checks whether the transaction identified by the argument is executed by a slave applier thread is an...
Definition: rpl_rli.h:2185
bool mysql_show_relaylog_events(THD *thd)
Execute a SHOW RELAYLOG EVENTS statement.
Definition: rpl_rli.cc:1447
bool is_mts_db_partitioned(Relay_log_info *rli)
Auxiliary function to check if we have a db partitioned MTS.
Definition: rpl_rli.cc:2656
Replication transaction boundary parser.
case opt name
Definition: sslopt-case.h:32
TODO: Move this structure to libbinlogevents/include/control_events.h when we start using C++11.
Definition: rpl_gtid.h:1065
rpl_sidno sidno
SIDNO of this Gtid.
Definition: rpl_gtid.h:1067
Structure to hold parameters for CHANGE MASTER, START SLAVE, and STOP SLAVE.
Definition: sql_lex.h:348
enum_mdl_namespace
Object namespaces.
Definition: mdl.h:399
const char * str
Definition: mysql_lex_string.h:40
Definition: my_bitmap.h:42
Extend the normal table list with a few new fields needed by the slave thread, but nowhere else.
Definition: rpl_utility.h:464
ulonglong option_bits
OPTION_xxx constants, e.g. OPTION_PROFILING.
Definition: system_variables.h:207
Definition: table.h:2684
TABLE_LIST * next_global
Definition: table.h:3377
LEX_CSTRING table_name
Definition: table.h:771
LEX_CSTRING db
Definition: table.h:770
Definition: table.h:1394
TABLE_SHARE * s
Definition: table.h:1395
Legends running throughout the module:
Definition: rpl_rli_pdb.h:73
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
Definition: rpl_rli.h:80
Log_event * data
Definition: rpl_rli.h:81
my_off_t relay_pos
Definition: rpl_rli.h:83
uint relay_number
Definition: rpl_rli.h:82
static bool update_timestamp(THD *thd, set_var *var)
Definition: sys_vars.cc:5543
@ SYSTEM_THREAD_SLAVE_WORKER
Definition: thread_type.h:41
@ SYSTEM_THREAD_SLAVE_SQL
Definition: thread_type.h:36
Include file for Sun RPC to compile out of the box.
unsigned int uint
Definition: uca-dump.cc:29
int n
Definition: xcom_base.cc:505