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