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