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