MySQL 26.7.0
Source Code Documentation
rpl_rli_pdb.h
Go to the documentation of this file.
1/* Copyright (c) 2011, 2026, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef RPL_RLI_PDB_H
25#define RPL_RLI_PDB_H
26
27#include <stdarg.h>
28#include <sys/types.h>
29#include <time.h>
30#include <atomic>
31#include <tuple>
32
33#include "my_bitmap.h"
34#include "my_compiler.h"
35#include "my_dbug.h"
36#include "my_inttypes.h"
37#include "my_io.h"
38#include "my_psi_config.h"
44#include "mysql/my_loglevel.h"
46#include "prealloced_array.h" // Prealloced_array
51#include "sql/log_event.h" // Format_description_log_event
52#include "sql/rpl_gtid.h"
53#include "sql/rpl_mta_submode.h" // enum_mts_parallel_type
54#include "sql/rpl_replica.h" // MTS_WORKER_UNDEF
55#include "sql/rpl_rli.h" // Relay_log_info
56#include "sql/sql_class.h"
58
60class Slave_worker;
61struct TABLE;
62
63#ifndef NDEBUG
64extern ulong w_rr;
65#endif
66/**
67 Legends running throughout the module:
68
69 C - Coordinator
70 CP - checkpoint
71 W - Worker
72
73 B-event event that Begins a group (a transaction)
74 T-event event that Terminates a group (a transaction)
75*/
76
78 Slave_worker_array *workers,
79 Log_event *ev);
80
82 Slave_job_group() = default;
83
84 /*
85 We need a custom copy constructor and assign operator because std::atomic<T>
86 is not copy-constructible.
87 */
93 worker_id(other.worker_id),
94 worker(other.worker),
102 done(other.done.load()),
103 shifted(other.shifted),
104 ts(other.ts),
105#ifndef NDEBUG
106 notified(other.notified),
107#endif
111 }
112
118 worker_id = other.worker_id;
119 worker = other.worker;
120 total_seqno = other.total_seqno;
127 done.store(other.done.load());
128 shifted = other.shifted;
129 ts = other.ts;
130#ifndef NDEBUG
131 notified = other.notified;
132#endif
136 return *this;
137 }
138
139 char *group_master_log_name; // (actually redundant)
140 /*
141 T-event lop_pos filled by Worker for CheckPoint (CP)
142 */
144
145 /*
146 When relay-log name changes allocates and fill in a new name of relay-log,
147 otherwise it fills in NULL.
148 Coordinator keeps track of each Worker has been notified on the updating
149 to make sure the routine runs once per change.
150
151 W checks the value at commit and memorizes a not-NULL.
152 Freeing unless NULL is left to Coordinator at CP.
153 */
154 char *group_relay_log_name; // The value is last seen relay-log
159
160 my_off_t master_log_pos; // B-event log_pos
161 /* checkpoint coord are reset by periodical and special (Rotate event) CP:s */
163 my_off_t checkpoint_log_pos; // T-event lop_pos filled by W for CheckPoint
166 checkpoint_relay_log_pos; // T-event lop_pos filled by W for CheckPoint
168 std::atomic<int32> done; // Flag raised by W, read and reset by Coordinator
169 ulong shifted; // shift the last CP bitmap at receiving a new CP
170 time_t ts; // Group's timestamp to update Seconds_behind_source
171#ifndef NDEBUG
172 bool notified{false}; // to debug group_master_log_name change notification
173#endif
174 /* Clock-based scheduler requirement: */
175 longlong last_committed; // commit parent timestamp
176 longlong sequence_number; // transaction's logical timestamp
177 /*
178 After Coordinator has seen a new FD event, it sets this member to
179 point to the new event, once per worker. Coordinator does so
180 when it schedules a first group following the FD event to a worker.
181 It checks Slave_worker::fd_change_notified flag to decide whether
182 to do this or not.
183 When the worker executes the group, it replaces its currently
184 active FD by the new FD once it takes on the group first event. It
185 checks this member and resets it after the FD replacement is done.
186
187 The member is kind of lock-free. It's updated by Coordinator and
188 read by Worker without holding any mutex. That's still safe thanks
189 to Slave_worker::jobs_lock that works as synchronizer, Worker
190 can't read any stale info.
191 The member is updated by Coordinator when it decides which Worker
192 an event following a new FD is to be scheduled.
193 After Coordinator has chosen a Worker, it queues the event to it
194 with necessarily taking Slave_worker::jobs_lock. The Worker grabs
195 the mutex lock later at pulling the event from the queue and
196 releases the lock before to read from this member.
197
198 This sequence of actions shows the write operation always precedes
199 the read one, and ensures no stale FD info is passed to the
200 Worker.
201 */
203 /*
204 Coordinator fills the struct with defaults and options at starting of
205 a group distribution.
206 */
210 group_master_log_name = nullptr; // todo: remove
211 group_relay_log_name = nullptr;
213 total_seqno = seqno;
214 checkpoint_log_name = nullptr;
218 checkpoint_seqno = (uint)-1;
219 done = 0;
220 ts = 0;
221#ifndef NDEBUG
222 notified = false;
223#endif
226 new_fd_event = nullptr;
227 }
228};
229
230/**
231 The class defines a type of queue with a predefined max capacity that is
232 implemented using the circular memory buffer.
233 That is items of the queue are accessed as indexed elements of
234 the array buffer in a way that when the index value reaches
235 a max value it wraps around to point to the first buffer element.
236*/
237template <typename Element_type>
239 public:
241 /**
242 The capacity and maximum length of the queue in terms of element.
243 */
244 size_t capacity;
245 /**
246 Its value modulo `capacity` is index of the element where the next element
247 will be enqueued. It's entry+length. It may be bigger than capacity, but
248 will be smaller than 2*capacity.
249 */
250 size_t avail;
251 /**
252 The head index of the queue. It is an index of next element that will be
253 dequeued. It is less than capacity, so it is an actual index (in contrast
254 to `avail`), don't need to be calculated modulo `capacity`.
255 */
256 size_t entry;
257 /**
258 Actual length. It can be read while not protected by any mutex.
259 */
260 std::atomic<size_t> len;
262
265 capacity(max),
266 avail(0),
267 entry(0),
268 len(0),
269 inited_queue(false) {
270 if (!m_Q.reserve(capacity)) inited_queue = true;
271 m_Q.resize(capacity);
272 }
275
276 /**
277 Content of the being dequeued item is copied to the arg-pointer
278 location.
279
280 @param [out] item A pointer to the being dequeued item.
281 @return true if an element was returned, false if the queue was empty.
282 */
283 bool de_queue(Element_type *item);
284 /**
285 Similar to de_queue but extracting happens from the tail side.
286
287 @param [out] item A pointer to the being dequeued item.
288 @return true if an element was returned, false if the queue was empty.
289 */
290 bool de_tail(Element_type *item);
291
292 /**
293 return the index where the arg item locates
294 or an error encoded as a value `circular_buffer_queue::error_result`.
295 */
296 size_t en_queue(Element_type *item);
297 /**
298 return the value of @c data member of the head of the queue.
299 */
300 Element_type *head_queue() {
301 if (empty()) return nullptr;
302 return &m_Q[entry];
303 }
304
305 /* index is within the valid range */
306 bool in(size_t i) {
307 return (avail >= capacity) ? (entry <= i || i < avail - capacity)
308 : (entry <= i && i < avail);
309 }
310 size_t get_length() const { return len.load(std::memory_order_relaxed); }
311 bool empty() const { return get_length() == 0; }
312 bool full() const { return get_length() == capacity; }
313
315};
316
317/**
318 Group Assigned Queue whose first element identifies first gap
319 in committed sequence. The head of the queue is therefore next to
320 the low-water-mark.
321*/
322class Slave_committed_queue : public circular_buffer_queue<Slave_job_group> {
323 public:
324 bool inited;
325
326 /* master's Rot-ev exec */
327 void update_current_binlog(const char *post_rotate);
328
329 /*
330 The last checkpoint time Low-Water-Mark
331 */
333
334 /* last time processed indexes for each worker */
336
337 /* the being assigned group index in GAQ */
339
340 Slave_committed_queue(size_t max, uint n);
341
343 if (inited) {
345 free_dynamic_items(); // free possibly left allocated strings in GAQ list
346 }
347 }
348
349#ifndef NDEBUG
350 bool count_done(Relay_log_info *rli);
351#endif
352
353 /* Checkpoint routine refreshes the queue */
355 /* Method is for slave shutdown time cleanup */
356 void free_dynamic_items();
357 /*
358 returns a pointer to Slave_job_group struct instance as indexed by arg
359 in the circular buffer dyn-array
360 */
362 assert(ind < capacity);
363 return &m_Q[ind];
364 }
365
366 /**
367 Assigns @c assigned_group_index to an index of enqueued item
368 and returns it.
369 */
370 size_t en_queue(Slave_job_group *item) {
371 return assigned_group_index =
373 }
374
375 /**
376 Dequeue from head.
377
378 @param [out] item A pointer to the being dequeued item.
379 @return true if an element was returned, false if the queue was empty.
380 */
383 }
384
385 /**
386 Similar to de_queue() but removing an item from the tail side.
387
388 @param [out] item A pointer to the being dequeued item.
389 @return true if an element was returned, false if the queue was empty.
390 */
393 }
394
395 size_t find_lwm(Slave_job_group **, size_t);
396};
397
398/**
399 @return the index where the arg item has been located
400 or an error encoded as a value
401 `circular_buffer_queue::error_result`.
402*/
403template <typename Element_type>
405 if (full()) {
406 return error_result;
407 }
408
409 const auto ret = (avail++) % capacity;
410 m_Q[ret] = *item;
411 len++;
412 assert(len == avail - entry);
413 assert(entry < avail);
414
415 return ret;
416}
417
418/**
419 Dequeue from head.
420
421 @param [out] item A pointer to the being dequeued item.
422 @return true if an element was returned, false if the queue was empty.
423*/
424template <typename Element_type>
426 if (empty()) {
427 return false;
428 }
429 *item = m_Q[entry++];
430 len--;
431 assert(len == avail - entry);
432 assert(entry <= avail);
433
434 // The start of the queue just have returned to the first index. Normalize
435 // indexes so they are small again.
436 if (entry == capacity) {
437 entry = 0;
438 avail -= capacity;
439 assert(avail < capacity);
440 assert(avail == len);
441 }
442 return true;
443}
444
445template <typename Element_type>
447 if (empty()) {
448 return false;
449 }
450
451 assert(avail > entry);
452 *item = m_Q[(--avail) % capacity];
453 len--;
454 assert(len == avail - entry);
455 return true;
456}
457
458class Slave_jobs_queue : public circular_buffer_queue<Slave_job_item> {
459 public:
461 /*
462 Coordinator marks with true, Worker signals back at queue back to
463 available
464 */
467};
468
471 public:
474 PSI_mutex_key *param_key_info_run_lock,
475 PSI_mutex_key *param_key_info_data_lock,
476 PSI_mutex_key *param_key_info_sleep_lock,
477 PSI_mutex_key *param_key_info_thd_lock,
478 PSI_mutex_key *param_key_info_data_cond,
479 PSI_mutex_key *param_key_info_start_cond,
480 PSI_mutex_key *param_key_info_stop_cond,
481 PSI_mutex_key *param_key_info_sleep_cond,
482#endif
483 uint param_id, const char *param_channel);
484
485 ~Slave_worker() override;
486
487 Slave_jobs_queue jobs; // assignment queue containing events to execute
488 mysql_mutex_t jobs_lock; // mutex for the jobs queue
489 mysql_cond_t jobs_cond; // condition variable for the jobs queue
490 Relay_log_info *c_rli; // pointer to Coordinator's rli
491
492#ifndef NDEBUG
493 bool curr_group_seen_sequence_number; // is set to true about starts_group()
494#endif
495 ulong id; // numeric identifier of the Worker
496
497 /*
498 Worker runtime statistics
499 */
500 /// Number of transaction handled - incremented at slave_worker_ends_group
502
503 // the index in GAQ of the last processed group by this Worker
504 volatile ulong last_group_done_index;
506 last_groups_assigned_index; // index of previous group assigned to worker
507 std::atomic<int> curr_jobs; // number of active assignments
508
509 volatile bool relay_log_change_notified; // Coord sets and resets, W can read
510 volatile bool checkpoint_notified; // Coord sets and resets, W can read
511 volatile bool
512 master_log_change_notified; // Coord sets and resets, W can read
513 /*
514 The variable serves to Coordinator as a memo to itself
515 to notify a Worker about the fact that a new FD has been read.
516 Normally, the value is true, to mean the Worker is notified.
517 When Coordinator reads a new FD it changes the value to false.
518 When Coordinator schedules to a Worker the first event following the new FD,
519 it propagates the new FD to the Worker through
520 Slave_job_group::new_fd_event. Afterwards Coordinator returns the value back
521 to the regular true, to denote things done. Worker will adapt to the new FD
522 once it takes on a first event of the marked group.
523 */
525 ulong bitmap_shifted; // shift the last bitmap at receiving new CP
526
527 private:
528 /// @brief worker statistics
530 /// @brief Placehold for stats when metric collection is disabled
532
533 /// @brief Is worker metric collection enabled
535
536 public:
537 /// @brief Sets the metric collection as on or off
538 /// This should be done at the worker start
539 /// @param status if metrics are enabled or not
542 }
543
544 /// @brief gets a reference to the worker statistics.
545 /// @return a reference to the worker statistics.
547
548 /// @brief Copies data and sets the metric collection flag
549 /// @param other the instance to be copied
554 }
555
556 /// The number of events applied in an ongoing transaction, used to collect
557 /// statistics when the transaction ends.
559
560 /// True if this transaction occurred after the _metrics breakpoint_ in the
561 /// relay log.
562 ///
563 /// @see Applier_metrics_interface::is_received_initialized.
565
566 /// Update per-event worker metrics.
567 ///
568 /// This includes:
569 ///
570 /// - APPLYING_TRANSACTION_APPLIED_SIZE_BYTES
571 ///
572 /// - The the number of events in the transaction. This is an internal
573 /// counter, not directly user visible, but used to increment
574 /// EVENTS_COMMITTED_COUNT at commit time. This is set to 1 for the GTID
575 /// event, and incremented for all other events. It does not need to be reset
576 /// at rollback, since the value is only used at commits, and the next GTID
577 /// event will reset the value before the next commit.
580 event.common_header->data_written);
582 event.get_type_code()))
584 else
586 }
587
588 // WQ current excess above the overrun level
590 /*
591 number of events starting from which Worker queue is regarded as
592 close to full. The number of the excessive events yields a weight factor
593 to compute Coordinator's nap.
594 */
596 /*
597 reverse to overrun: the number of events below which Worker is
598 considered under-running
599 */
601 /*
602 Total of increments done to rli->mts_wq_excess_cnt on behalf of this worker.
603 When WQ length is dropped below overrun the counter is reset.
604 */
606 /*
607 Coordinates of the last CheckPoint (CP) this Worker has
608 acknowledged; part of is persistent data
609 */
614 MY_BITMAP group_executed; // bitmap describes groups executed after last CP
615 MY_BITMAP group_shifted; // temporary bitmap to compute group_executed
616 ulong
617 worker_checkpoint_seqno; // the most significant ON bit in group_executed
618 /* Initial value of FD-for-execution version until it's gets known. */
623 ERROR_LEAVING = 2, // is set by Worker
624 STOP = 3, // is set by Coordinator upon receiving STOP
626 4 // is set by worker upon completing job when STOP REPLICA is issued
627 };
628
632
633 /// @brief Fulfils Parallel_worker_context interface requirements
634 /// @return Pointer to THD containing transaction context
635 THD *get_transaction_ctx() override;
636
637 /// Accesses mdl context from info THD
638 MDL_context *get_mdl_context() override;
639
640 /// Accesses worker id
641 Worker_id get_worker_id() const override;
642
643 /// Checks if this worker and worker supplied in arg apply transactions
644 /// coming from the same channel
645 /// @return True if this worker and arg worker execute transactions coming
646 /// from the same channel
647 bool is_same_channel(const Parallel_worker_context *arg) const override;
648
649 /// @brief Obtain transaction id (sequence number)
650 /// @return Transaction sequence number
651 Trx_id get_trx_id() override;
652
653 /*
654 This function is used to make a copy of the worker object before we
655 destroy it on STOP REPLICA. This new object is then used to report the
656 worker status until next START REPLICA following which the new worker
657 objects will be used.
658 */
660 THD *worker_thd, const Error &last_error,
661 Gtid_monitoring_info *monitoring_info_arg);
662
663 /*
664 The running status is guarded by jobs_lock mutex that a writer
665 Coordinator or Worker itself needs to hold when write a new value.
666 */
668 /*
669 exit_incremented indicates whether worker has contributed to max updated
670 index. By default it is set to false. When the worker contributes for the
671 first time this variable is set to true.
672 */
674
675 int init_worker(Relay_log_info *, ulong);
676 int rli_init_info(bool);
677 int flush_info(bool force = false);
678 static size_t get_number_worker_fields();
679 /**
680 Sets bits for columns that are allowed to be `NULL`.
681
682 @param nullable_fields the bitmap to hold the nullable fields.
683 */
684 static void set_nullable_fields(MY_BITMAP *nullable_fields);
686 const char *get_master_log_name();
688 ulonglong set_master_log_pos(ulong val) { return master_log_pos = val; }
689 bool commit_positions(Log_event *evt, Slave_job_group *ptr_g, bool force);
690 /**
691 The method is a wrapper to provide uniform interface with STS and is
692 to be called from Relay_log_info and Slave_worker pre_commit() methods.
693 */
694 bool commit_positions() override {
695 assert(current_event);
696
697 return commit_positions(
700 }
701 /**
702 See the comments for STS version of this method.
703 */
704 void post_commit(bool on_rollback) override {
705 if (on_rollback) {
706 if (is_transactional())
709 } else if (!is_transactional())
712 true);
713 }
714 /*
715 When commit fails clear bitmap for executed worker group. Revert back the
716 positions to the old positions that existed before commit using the
717 checkpoint.
718
719 @param Slave_job_group a pointer to Slave_job_group struct instance which
720 holds group master log pos, group relay log pos and checkpoint positions.
721 */
723 bool reset_recovery_info();
724 /**
725 The method runs at Worker initialization, at runtime when
726 Coordinator supplied a new FD event for execution context, and at
727 the Worker pool shutdown.
728 Similarly to the Coordinator's
729 Relay_log_info::set_rli_description_event() the possibly existing
730 old FD is destroyed, carefully; each worker decrements
731 Format_description_log_event::atomic_usage_counter and when it is made
732 zero the destructor runs.
733 Unlike to Coordinator's role, the usage counter of the new FD is *not*
734 incremented, see @c Log_event::get_slave_worker() where and why it's done
735 there.
736
737 Notice, the method is run as well by Coordinator per each Worker at MTS
738 shutdown time.
739
740 Todo: consider to merge logics of the method with that of
741 Relay_log_info class.
742
743 @param fdle pointer to a new Format_description_log_event
744
745 @return 1 if an error was encountered, 0 otherwise.
746 */
749
750 if (fdle) {
751 /*
752 When the master rotates its binary log, set gtid_next to
753 NOT_YET_DETERMINED. This tells the slave thread that:
754
755 - If a Gtid_log_event is read subsequently, gtid_next will be set to the
756 given GTID (this is done in gtid_pre_statement_checks()).
757
758 - If a statement is executed before any Gtid_log_event, then gtid_next
759 is set to anonymous (this is done in Gtid_log_event::do_apply_event().
760
761 It is important to not set GTID_NEXT=NOT_YET_DETERMINED in the middle of
762 a transaction. If that would happen when GTID_MODE=ON, the next
763 statement would fail because it implicitly sets GTID_NEXT=ANONYMOUS,
764 which is disallowed when GTID_MODE=ON. So then there would be no way to
765 end the transaction; any attempt to do so would result in this error.
766
767 There are three possible states when reaching this execution flow point
768 (see further below for a more detailed explanation on each):
769
770 - **No active transaction, and not in a group**: set `gtid_next` to
771 `NOT_YET_DETERMINED`.
772
773 - **No active transaction, and in a group**: do nothing regarding
774 `gtid_next`.
775
776 - **An active transaction exists**: impossible to set `gtid_next` and no
777 reason to process the `Format_description` event so, trigger an error.
778
779 For the sake of correctness, let's defined the meaning of having a
780 transaction "active" or "in a group".
781
782 A transaction is "active" if either BEGIN was executed or autocommit=0
783 and a DML statement was executed (@see
784 THD::in_active_multi_stmt_transaction).
785
786 A transaction is "in a group" if it is applied by the replication
787 applier, and the relay log position is between Gtid_log_event and the
788 committing event (@see Relay_log_info::is_in_group).
789
790 The three different states explained further:
791
792 **No active transaction, and not in a group**: It is normal to have
793 gtid_next=automatic/undefined and have a Format_description_log_event in
794 this condition. We are outside transaction context and should set
795 gtid_next to not_yet_determined.
796
797 **No active transaction, and in a group**: Having
798 gtid_next=automatic/undefined in a group is impossible if master is 5.7
799 or later, because the group always starts with a Gtid_log_event or an
800 Anonymous_gtid_log_event, which will set gtid_next to anonymous or
801 gtid. But it is possible to have gtid_next=undefined when replicating
802 from a 5.6 master with gtid_mode=off, because it does not generate any
803 such event. And then, it is possible to have no active transaction in a
804 group if the master has logged a DDL as a User_var_log_event followed by
805 a Query_log_event. The User_var_log_event will start a group, but not
806 start an active transaction or change gtid_next. In this case, it is
807 possible that a Format_description_log_event occurs, if the group
808 (transaction) is broken on two relay logs, so that User_var_log_event
809 appears at the end of one relay log and Query_log_event at the beginning
810 of the next one. In such cases, we should not set gtid_next.
811
812 **An active transaction exists**: It is possible to have
813 gtid_next=automatic/undefined in an active transaction, only if
814 gtid_next=automatic, which is only possible in a client connection using
815 gtid_next=automatic. In this scenario, there is no reason to execute a
816 Format_description_log_event. So we generate an error.
817 */
818 if (info_thd->variables.gtid_next.is_automatic() ||
819 info_thd->variables.gtid_next.is_undefined()) {
820 bool in_active_multi_stmt =
822
823 if (!is_in_group() && !in_active_multi_stmt) {
824 DBUG_PRINT("info",
825 ("Setting gtid_next.type to NOT_YET_DETERMINED_GTID"));
826 info_thd->variables.gtid_next.set_not_yet_determined();
827 } else if (in_active_multi_stmt) {
828 my_error(ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION, MYF(0),
829 "gtid_next");
830 return 1;
831 }
832 }
835 }
838
840 /* The being deleted by Worker FD can't be the latest one */
842
844 }
845 }
847
848 return 0;
849 }
850
852 inline void set_gaq_index(ulong val) {
853 if (gaq_index == c_rli->gaq->capacity) gaq_index = val;
854 }
855
857
858 /**
859 Make the necessary changes to both the `Slave_worker` and current
860 `Log_event` objects, before retrying to apply the transaction.
861
862 Since the event is going to be re-read from the relay-log file, there
863 may be actions needed to be taken to reset the state both of `this`
864 instance, as well as of the current `Log_event` being processed.
865
866 @param event The `Log_event` object currently being processed.
867 */
869
870 /**
871 Checks if the transaction can be retried, and if not, reports an error.
872
873 @param[in] thd The THD object of current thread.
874
875 @returns std::tuple<bool, bool, uint> where each element has
876 following meaning:
877
878 first element of tuple is function return value and determines:
879 false if the transaction should be retried
880 true if the transaction should not be retried
881
882 second element of tuple determines:
883 the function will set the value to true, in case the retry
884 should be "silent". Silent means that the caller should not
885 report it in performance_schema tables, write to the error log,
886 or sleep. Currently, silent is used by NDB only.
887
888 third element of tuple determines:
889 If the caller should report any other error than that stored in
890 thd->get_stmt_da()->mysql_errno(), then this function will store
891 that error in this third element of the tuple.
892
893 */
894 std::tuple<bool, bool, uint> check_and_report_end_of_retries(THD *thd);
895
896 /// @brief Variation of the check_and_report_end_of_retries; has the same
897 /// side effects but different return value
898 /// @param thd Pointer to current THD representing transaction
899 /// @return true if the transaction should be retried; false otherwise
900 bool can_be_retried(THD *thd) override;
901
902 /**
903 It is called after an error happens. It checks if that is an temporary
904 error and if the transaction should be retried. Then it will retry the
905 transaction if it is allowed. Retry policy and logic is similar to
906 single-threaded slave.
907
908 @param[in] start_relay_pos The offset of the transaction's first event.
909 @param[in] start_event_relay_log_name The name of the relay log which
910 includes the first event of the transaction.
911
912 @param[in] end_relay_pos The offset of the last event it should retry.
913 @param[in] end_event_relay_log_name The name of the relay log which
914 includes the last event it should retry.
915
916 @retval false if transaction succeeds (possibly after a number of retries)
917 @retval true if transaction fails
918 */
919 bool retry_transaction(my_off_t start_relay_pos,
920 const char *start_event_relay_log_name,
921 my_off_t end_relay_pos,
922 const char *end_event_relay_log_name);
923
924 bool set_info_search_keys(Rpl_info_handler *to) override;
925
926 /**
927 Get coordinator's RLI. Especially used get the rli from
928 a slave thread, like this: thd->rli_slave->get_c_rli();
929 thd could be a SQL thread or a worker thread.
930 */
931 Relay_log_info *get_c_rli() override { return c_rli; }
932
933 /**
934 return an extension "for channel channel_name"
935 for error messages per channel
936 */
937 const char *get_for_channel_str(bool upper_case = false) const override;
938
941 return ptr_g->sequence_number;
942 }
943
944 /**
945 Return true if replica-preserve-commit-order is enabled and an
946 earlier transaction is waiting for a row-level lock held by this
947 transaction.
948 */
949 bool found_commit_order_deadlock() const override;
950
951 /**
952 Called when replica-preserve-commit-order is enabled, by the worker
953 processing an earlier transaction that waits on a row-level lock
954 held by this worker's transaction.
955 */
956 void report_commit_order_deadlock(bool) override;
957
958 /**
959 @return either the master server version as extracted from the last
960 installed Format_description_log_event, or when it was not
961 installed then the slave own server version.
962 */
967 }
968
969 protected:
970 void do_report(loglevel level, int err_code, const char *msg,
971 va_list v_args) const override
972 MY_ATTRIBUTE((format(printf, 4, 0)));
973
974 void do_report(loglevel level, int err_code,
975 const Gtid_specification *gtid_next, const char *msg,
976 va_list v_args) const override
977 MY_ATTRIBUTE((format(printf, 5, 0)));
978
979 private:
980 ulong gaq_index; // GAQ index of the current assignment
981 ulonglong master_log_pos; // event's cached log_pos for possible error report
982 void end_info();
983 bool read_info(Rpl_info_handler *from) override;
984 bool write_info(Rpl_info_handler *to) override;
985 std::atomic<bool> m_commit_order_deadlock;
986
987 /// This flag indicates whether positions were already modified during the
988 /// event processing, if yes, positions are not updated in the
989 /// slave_worker_ends_group function
991
994 bool worker_sleep(ulong seconds);
995 bool read_and_apply_events(my_off_t start_relay_pos,
996 const char *start_event_relay_log_name,
997 my_off_t end_relay_pos,
998 const char *end_event_relay_log_name);
999
1000 public:
1001 /**
1002 Set the flag the signals a deadlock to false
1003 */
1004 void reset_commit_order_deadlock() override;
1005
1006 /**
1007 Returns an array with the expected column numbers of the primary key
1008 fields of the table repository.
1009 */
1010 static const uint *get_table_pk_field_indexes();
1011 /**
1012 Returns the index of the Channel_name field of the table repository.
1013 */
1014 static uint get_channel_field_index();
1015};
1016
1019 Slave_job_item *job_item);
1020
1022// Auxiliary function
1024
1026 Relay_log_info *rli);
1027
1028inline Slave_worker *get_thd_worker(const THD *thd) {
1029 return static_cast<Slave_worker *>(thd->rli_slave);
1030}
1031
1033
1034#endif
Contains the classes representing events occurring in the replication stream.
For binlog version 4.
Definition: log_event.h:1558
std::atomic< int32 > atomic_usage_counter
Definition: log_event.h:1576
Stores information to monitor a transaction during the different replication stages.
Definition: rpl_gtid.h:1414
This is the abstract base class for binary log events.
Definition: log_event.h:539
ulong mts_group_idx
Index in rli->gaq array to indicate a group that this event is purging.
Definition: log_event.h:694
Context of the owner of metadata locks.
Definition: mdl.h:1415
Definition: rpl_rli.h:208
Format_description_log_event * get_rli_description_event() const
Return the current Format_description_log_event.
Definition: rpl_rli.h:1727
bool is_in_group() const
A group is defined as the entire range of events that constitute a transaction or auto-committed stat...
Definition: rpl_rli.h:1514
cs::apply::Parallel_worker_context Parallel_worker_context
Definition: rpl_rli.h:213
Log_event * current_event
Reference to being applied event.
Definition: rpl_rli.h:2012
Slave_committed_queue * gaq
Definition: rpl_rli.h:1206
ulong adapt_to_master_version_updown(ulong master_version, ulong current_version)
The method compares two supplied versions and carries out down- or up- grade customization of executi...
Definition: rpl_rli.cc:2688
Format_description_log_event * rli_description_event
Definition: rpl_rli.h:1803
Definition: rpl_info_handler.h:58
bool is_transactional() const
Definition: rpl_info.h:107
THD * info_thd
Definition: rpl_info.h:78
Group Assigned Queue whose first element identifies first gap in committed sequence.
Definition: rpl_rli_pdb.h:322
void free_dynamic_items()
Method should be executed at slave system stop to cleanup dynamically allocated items that remained a...
Definition: rpl_rli_pdb.cc:1108
bool de_queue(Slave_job_group *item)
Dequeue from head.
Definition: rpl_rli_pdb.h:381
Slave_committed_queue(size_t max, uint n)
Definition: rpl_rli_pdb.cc:907
bool inited
Definition: rpl_rli_pdb.h:324
bool count_done(Relay_log_info *rli)
Definition: rpl_rli_pdb.cc:925
ulong assigned_group_index
Definition: rpl_rli_pdb.h:338
bool de_tail(Slave_job_group *item)
Similar to de_queue() but removing an item from the tail side.
Definition: rpl_rli_pdb.h:391
size_t move_queue_head(Slave_worker_array *ws)
The queue is processed from the head item by item to purge items representing committed groups.
Definition: rpl_rli_pdb.cc:969
Prealloced_array< ulonglong, 1 > last_done
Definition: rpl_rli_pdb.h:335
Slave_job_group * get_job_group(size_t ind)
Definition: rpl_rli_pdb.h:361
~Slave_committed_queue()
Definition: rpl_rli_pdb.h:342
void update_current_binlog(const char *post_rotate)
size_t find_lwm(Slave_job_group **, size_t)
Finds low-water mark of committed jobs in GAQ.
Definition: rpl_rli_pdb.cc:1071
size_t en_queue(Slave_job_group *item)
Assigns assigned_group_index to an index of enqueued item and returns it.
Definition: rpl_rli_pdb.h:370
Slave_job_group lwm
Definition: rpl_rli_pdb.h:332
Definition: rpl_rli_pdb.h:458
Slave_jobs_queue()
Definition: rpl_rli_pdb.h:460
bool overfill
Definition: rpl_rli_pdb.h:465
ulonglong waited_overfill
Definition: rpl_rli_pdb.h:466
Error information structure.
Definition: rpl_reporting.h:106
Error const & last_error() const
Definition: rpl_reporting.h:151
Definition: rpl_rli_pdb.h:470
ulonglong get_master_log_pos()
Definition: rpl_rli_pdb.h:687
ulong underrun_level
Definition: rpl_rli_pdb.h:600
char checkpoint_relay_log_name[FN_REFLEN]
Definition: rpl_rli_pdb.h:610
ulong excess_cnt
Definition: rpl_rli_pdb.h:605
bool m_is_worker_metric_collection_enabled
Is worker metric collection enabled.
Definition: rpl_rli_pdb.h:534
bool read_and_apply_events(my_off_t start_relay_pos, const char *start_event_relay_log_name, my_off_t end_relay_pos, const char *end_event_relay_log_name)
Read events from relay logs and apply them.
Definition: rpl_rli_pdb.cc:1534
bool curr_group_seen_sequence_number
Definition: rpl_rli_pdb.h:493
void reset_gaq_index()
Definition: rpl_rli_pdb.h:851
ulong overrun_level
Definition: rpl_rli_pdb.h:595
Trx_id get_trx_id() override
Obtain transaction id (sequence number)
Definition: rpl_rli_pdb.cc:897
bool commit_positions() override
The method is a wrapper to provide uniform interface with STS and is to be called from Relay_log_info...
Definition: rpl_rli_pdb.h:694
bool found_commit_order_deadlock() const override
Return true if replica-preserve-commit-order is enabled and an earlier transaction is waiting for a r...
Definition: rpl_rli_pdb.cc:1358
ulong bitmap_shifted
Definition: rpl_rli_pdb.h:525
longlong sequence_number()
Definition: rpl_rli_pdb.h:939
int flush_info(bool force=false)
Definition: rpl_rli_pdb.cc:466
bool can_be_retried(THD *thd) override
Variation of the check_and_report_end_of_retries; has the same side effects but different return valu...
Definition: rpl_rli_pdb.cc:1379
int set_rli_description_event(Format_description_log_event *fdle) override
The method runs at Worker initialization, at runtime when Coordinator supplied a new FD event for exe...
Definition: rpl_rli_pdb.h:747
ulonglong checkpoint_master_log_pos
Definition: rpl_rli_pdb.h:613
Slave_jobs_queue jobs
Definition: rpl_rli_pdb.h:487
volatile bool relay_log_change_notified
Definition: rpl_rli_pdb.h:509
MY_BITMAP group_shifted
Definition: rpl_rli_pdb.h:615
ulong worker_checkpoint_seqno
Definition: rpl_rli_pdb.h:617
bool worker_sleep(ulong seconds)
Sleep for a given amount of seconds or until killed.
Definition: rpl_rli_pdb.cc:1332
void copy_values_for_PFS(ulong worker_id, en_running_state running_status, THD *worker_thd, const Error &last_error, Gtid_monitoring_info *monitoring_info_arg)
Definition: rpl_rli_pdb.cc:549
bool is_same_channel(const Parallel_worker_context *arg) const override
Checks if this worker and worker supplied in arg apply transactions coming from the same channel.
Definition: rpl_rli_pdb.cc:899
std::tuple< bool, bool, uint > check_and_report_end_of_retries(THD *thd)
Checks if the transaction can be retried, and if not, reports an error.
Definition: rpl_rli_pdb.cc:1383
ulong gaq_index
Definition: rpl_rli_pdb.h:980
void post_commit(bool on_rollback) override
See the comments for STS version of this method.
Definition: rpl_rli_pdb.h:704
void do_report(loglevel level, int err_code, const char *msg, va_list v_args) const override
Definition: rpl_rli_pdb.cc:1133
const char * get_for_channel_str(bool upper_case=false) const override
return an extension "for channel channel_name" for error messages per channel
Definition: rpl_rli_pdb.cc:2262
Slave_worker(const Slave_worker &info)
std::atomic< int > curr_jobs
Definition: rpl_rli_pdb.h:507
Slave_worker(Relay_log_info *rli, 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)
Definition: rpl_rli_pdb.cc:239
void set_worker_metric_collection_status(bool status)
Sets the metric collection as on or off This should be done at the worker start.
Definition: rpl_rli_pdb.h:540
bool write_info(Rpl_info_handler *to) override
Definition: rpl_rli_pdb.cc:571
int init_worker(Relay_log_info *, ulong)
Method is executed by Coordinator at Worker startup time to initialize members parly with values supp...
Definition: rpl_rli_pdb.cc:310
static uint get_channel_field_index()
Returns the index of the Channel_name field of the table repository.
Definition: rpl_rli_pdb.cc:2270
bool read_info(Rpl_info_handler *from) override
Definition: rpl_rli_pdb.cc:497
const char * get_master_log_name()
Definition: rpl_rli_pdb.cc:621
static void set_nullable_fields(MY_BITMAP *nullable_fields)
Sets bits for columns that are allowed to be NULL.
Definition: rpl_rli_pdb.cc:615
cs::apply::instruments::Dummy_worker_metrics m_disabled_worker_metrics
Placehold for stats when metric collection is disabled.
Definition: rpl_rli_pdb.h:531
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_pdb.cc:560
ulong server_version
Definition: rpl_rli_pdb.h:619
ulong id
Definition: rpl_rli_pdb.h:495
int64_t m_events_applied_in_transaction
The number of events applied in an ongoing transaction, used to collect statistics when the transacti...
Definition: rpl_rli_pdb.h:558
MDL_context * get_mdl_context() override
Accesses mdl context from info THD.
Definition: rpl_rli_pdb.cc:891
void prepare_for_retry(Log_event &event)
Make the necessary changes to both the Slave_worker and current Log_event objects,...
Definition: rpl_rli_pdb.cc:1368
void report_commit_order_deadlock(bool) override
Called when replica-preserve-commit-order is enabled, by the worker processing an earlier transaction...
Definition: rpl_rli_pdb.cc:1362
Slave_worker & operator=(const Slave_worker &info)
ulonglong master_log_pos
Definition: rpl_rli_pdb.h:981
int slave_worker_exec_event(Log_event *ev)
MTS worker main routine.
Definition: rpl_rli_pdb.cc:1270
ulong get_master_server_version()
Definition: rpl_rli_pdb.h:963
bool retry_transaction(my_off_t start_relay_pos, const char *start_event_relay_log_name, my_off_t end_relay_pos, const char *end_event_relay_log_name)
It is called after an error happens.
Definition: rpl_rli_pdb.cc:1440
bool exit_incremented
Definition: rpl_rli_pdb.h:673
volatile ulong last_group_done_index
Definition: rpl_rli_pdb.h:504
Relay_log_info * c_rli
Definition: rpl_rli_pdb.h:490
Relay_log_info * get_c_rli() override
Get coordinator's RLI.
Definition: rpl_rli_pdb.h:931
bool reset_recovery_info()
Clean up a part of Worker info table that is regarded in in gaps collecting at recovery.
Definition: rpl_rli_pdb.cc:602
mysql_mutex_t jobs_lock
Definition: rpl_rli_pdb.h:488
THD * get_transaction_ctx() override
Fulfils Parallel_worker_context interface requirements.
Definition: rpl_rli_pdb.cc:889
en_running_state
Definition: rpl_rli_pdb.h:620
@ NOT_RUNNING
Definition: rpl_rli_pdb.h:621
@ STOP_ACCEPTED
Definition: rpl_rli_pdb.h:625
@ RUNNING
Definition: rpl_rli_pdb.h:622
@ STOP
Definition: rpl_rli_pdb.h:624
@ ERROR_LEAVING
Definition: rpl_rli_pdb.h:623
void rollback_positions(Slave_job_group *ptr_g)
Definition: rpl_rli_pdb.cc:709
long wq_overrun_cnt
Definition: rpl_rli_pdb.h:589
static const uint * get_table_pk_field_indexes()
Returns an array with the expected column numbers of the primary key fields of the table repository.
Definition: rpl_rli_pdb.cc:2266
void slave_worker_ends_group(Log_event *, int)
Deallocation routine to cancel out few effects of map_db_to_worker().
Definition: rpl_rli_pdb.cc:774
ulonglong set_master_log_pos(ulong val)
Definition: rpl_rli_pdb.h:688
bool m_flag_positions_committed
This flag indicates whether positions were already modified during the event processing,...
Definition: rpl_rli_pdb.h:990
std::atomic< bool > m_commit_order_deadlock
Definition: rpl_rli_pdb.h:985
void reset_commit_order_deadlock() override
Set the flag the signals a deadlock to false.
Definition: rpl_rli_pdb.cc:1354
cs::apply::instruments::Worker_metrics & get_worker_metrics() override
gets a reference to the worker statistics.
Definition: rpl_rli_pdb.cc:2272
void set_gaq_index(ulong val)
Definition: rpl_rli_pdb.h:852
Worker_id get_worker_id() const override
Accesses worker id.
Definition: rpl_rli_pdb.cc:895
void increment_worker_metrics_for_event(const Log_event &event)
Update per-event worker metrics.
Definition: rpl_rli_pdb.h:578
char checkpoint_master_log_name[FN_REFLEN]
Definition: rpl_rli_pdb.h:612
ulonglong last_groups_assigned_index
Definition: rpl_rli_pdb.h:506
void end_info()
Definition: rpl_rli_pdb.cc:452
en_running_state volatile running_status
Definition: rpl_rli_pdb.h:667
void copy_worker_metrics(Slave_worker *other)
Copies data and sets the metric collection flag.
Definition: rpl_rli_pdb.h:550
ulonglong checkpoint_relay_log_pos
Definition: rpl_rli_pdb.h:611
bool fd_change_notified
Definition: rpl_rli_pdb.h:524
volatile bool checkpoint_notified
Definition: rpl_rli_pdb.h:510
bool m_is_after_metrics_breakpoint
True if this transaction occurred after the metrics breakpoint in the relay log.
Definition: rpl_rli_pdb.h:564
mysql_cond_t jobs_cond
Definition: rpl_rli_pdb.h:489
cs::apply::instruments::Mta_worker_metrics m_worker_metrics
worker statistics
Definition: rpl_rli_pdb.h:529
static size_t get_number_worker_fields()
Definition: rpl_rli_pdb.cc:611
~Slave_worker() override
Definition: rpl_rli_pdb.cc:280
MY_BITMAP group_executed
Definition: rpl_rli_pdb.h:614
volatile bool master_log_change_notified
Definition: rpl_rli_pdb.h:512
int rli_init_info(bool)
A part of Slave worker initializer that provides a minimum context for MTS recovery.
Definition: rpl_rli_pdb.cc:405
ulong transactions_handled
Number of transaction handled - incremented at slave_worker_ends_group.
Definition: rpl_rli_pdb.h:501
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Relay_log_info * rli_slave
Definition: sql_class.h:1096
System_variables variables
Definition: sql_lexer_thd.h:64
bool in_active_multi_stmt_transaction() const
true if the session is in a multi-statement transaction mode (
Definition: sql_class.h:3297
The class defines a type of queue with a predefined max capacity that is implemented using the circul...
Definition: rpl_rli_pdb.h:238
bool in(size_t i)
Definition: rpl_rli_pdb.h:306
bool empty() const
Definition: rpl_rli_pdb.h:311
static constexpr size_t error_result
Definition: rpl_rli_pdb.h:314
std::atomic< size_t > len
Actual length.
Definition: rpl_rli_pdb.h:260
size_t en_queue(Element_type *item)
return the index where the arg item locates or an error encoded as a value circular_buffer_queue::err...
Definition: rpl_rli_pdb.h:404
size_t capacity
The capacity and maximum length of the queue in terms of element.
Definition: rpl_rli_pdb.h:244
size_t get_length() const
Definition: rpl_rli_pdb.h:310
circular_buffer_queue()
Definition: rpl_rli_pdb.h:273
Element_type * head_queue()
return the value of data member of the head of the queue.
Definition: rpl_rli_pdb.h:300
size_t avail
Its value modulo capacity is index of the element where the next element will be enqueued.
Definition: rpl_rli_pdb.h:250
circular_buffer_queue(size_t max)
Definition: rpl_rli_pdb.h:263
bool de_queue(Element_type *item)
Content of the being dequeued item is copied to the arg-pointer location.
Definition: rpl_rli_pdb.h:425
size_t entry
The head index of the queue.
Definition: rpl_rli_pdb.h:256
bool full() const
Definition: rpl_rli_pdb.h:312
bool inited_queue
Definition: rpl_rli_pdb.h:261
Prealloced_array< Element_type, 1 > m_Q
Definition: rpl_rli_pdb.h:240
bool de_tail(Element_type *item)
Similar to de_queue but extracting happens from the tail side.
Definition: rpl_rli_pdb.h:446
~circular_buffer_queue()=default
Class representing the interface for parallel worker context.
Definition: parallel_worker_context.h:47
int64_t Trx_id
Definition: parallel_worker_context.h:51
uint64_t Worker_id
Definition: parallel_worker_context.h:52
Class that intends to be a dummy end point for worker metrics.
Definition: dummy_worker_metrics.h:34
This class contains metrics transaction execution in replica MTA workers.
Definition: mta_worker_metrics.h:34
Abstract class for classes that contain metrics related to transaction execution in applier workers.
Definition: worker_metrics.h:34
virtual void inc_transaction_ongoing_progress_size(int64_t amount)=0
increment the executed size of the ongoing transaction.
unsigned long get_product_version() const
This method is used to find out the version of server that originated the current FD instance.
Definition: control_events.cpp:167
const int64_t SEQ_UNINIT
Uninitialized timestamp value (for either last committed or sequence number).
Definition: binlog_event.h:151
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:217
#define MTS_WORKER_UNDEF
Definition: rpl_replica.h:96
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:52
static constexpr unsigned PSI_INSTRUMENT_ME
Definition: psi_bits.h:43
Binary log event definitions.
Header for compiler-dependent features.
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:181
#define DBUG_TRACE
Definition: my_dbug.h:146
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
long long int longlong
Definition: my_inttypes.h:55
#define MYF(v)
Definition: my_inttypes.h:97
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:87
Definition of the global "loglevel" enumeration.
loglevel
Definition: my_loglevel.h:41
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
#define HAVE_PSI_INTERFACE
Definition: my_psi_config.h:39
Instrumentation helpers for conditions.
ABI for instrumented mutexes.
struct MasterPos master_pos
std::string format(const routing_guidelines::Session_info &session_info, bool extended_session_info)
Definition: dest_metadata_cache.cc:170
bool load(THD *, const dd::String_type &fname, dd::String_type *buf)
Read an sdi file from disk and store in a buffer.
Definition: sdi_file.cc:308
bool empty(const Histogram &histogram)
Return true if 'histogram' was built on an empty table.
Definition: histogram.h:694
std::chrono::seconds seconds
Definition: authorize_manager.cc:70
ValueType max(X &&first)
Definition: gtid.h:103
Performance schema instrumentation interface.
Instrumentation helpers for mutexes.
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:61
required string event
Definition: replication_group_member_actions.proto:32
enum_mts_parallel_type
Definition: rpl_mta_submode.h:47
TABLE * mts_move_temp_tables_to_thd(THD *, TABLE *)
Relocation of the list of temporary tables to thd->temporary_tables.
Definition: rpl_rli_pdb.cc:728
Slave_worker * get_least_occupied_worker(Relay_log_info *rli, Slave_worker_array *workers, Log_event *ev)
Legends running throughout the module:
Definition: rpl_rli_pdb.cc:758
bool set_max_updated_index_on_stop(Slave_worker *worker, Slave_job_item *job_item)
This function is called by both coordinator and workers.
Definition: rpl_rli_pdb.cc:172
Slave_worker * get_thd_worker(const THD *thd)
Definition: rpl_rli_pdb.h:1028
ulong w_rr
Definition: rpl_rli_pdb.cc:81
int slave_worker_exec_job_group(Slave_worker *w, Relay_log_info *rli)
apply one job group.
Definition: rpl_rli_pdb.cc:1994
bool handle_slave_worker_stop(Slave_worker *worker, Slave_job_item *job_item)
This function is called by both coordinator and workers.
Definition: rpl_rli_pdb.cc:108
bool append_item_to_jobs(slave_job_item *job_item, Slave_worker *w, Relay_log_info *rli)
Coordinator enqueues a job item into a Worker private queue.
Definition: rpl_rli_pdb.cc:1649
This struct represents a specification of a GTID for a statement to be executed: either "AUTOMATIC",...
Definition: rpl_gtid.h:4034
Definition: my_bitmap.h:43
Definition: rpl_rli_pdb.h:81
Slave_job_group()=default
my_off_t master_log_pos
Definition: rpl_rli_pdb.h:160
my_off_t checkpoint_log_pos
Definition: rpl_rli_pdb.h:163
Format_description_log_event * new_fd_event
Definition: rpl_rli_pdb.h:202
Slave_job_group(const Slave_job_group &other)
Definition: rpl_rli_pdb.h:88
bool notified
Definition: rpl_rli_pdb.h:172
time_t ts
Definition: rpl_rli_pdb.h:170
longlong last_committed
Definition: rpl_rli_pdb.h:175
std::atomic< int32 > done
Definition: rpl_rli_pdb.h:168
Slave_job_group & operator=(const Slave_job_group &other)
Definition: rpl_rli_pdb.h:113
Slave_worker * worker
Definition: rpl_rli_pdb.h:157
my_off_t checkpoint_relay_log_pos
Definition: rpl_rli_pdb.h:166
ulong worker_id
Definition: rpl_rli_pdb.h:156
uint checkpoint_seqno
Definition: rpl_rli_pdb.h:162
void reset(my_off_t master_pos, ulonglong seqno)
Definition: rpl_rli_pdb.h:207
my_off_t group_master_log_pos
Definition: rpl_rli_pdb.h:143
char * group_master_log_name
Definition: rpl_rli_pdb.h:139
char * checkpoint_log_name
Definition: rpl_rli_pdb.h:164
ulong shifted
Definition: rpl_rli_pdb.h:169
longlong sequence_number
Definition: rpl_rli_pdb.h:176
char * checkpoint_relay_log_name
Definition: rpl_rli_pdb.h:167
char * group_relay_log_name
Definition: rpl_rli_pdb.h:154
ulonglong total_seqno
Definition: rpl_rli_pdb.h:158
my_off_t group_relay_log_pos
Definition: rpl_rli_pdb.h:155
Definition: table.h:1456
Definition: completion_hash.h:35
static bool is_any_gtid_event(const Log_event_type &type)
Helps to identify any GTID event - returns true for GTID_LOG_EVENT, GTID_TAGGED_LOG_EVENT and ANONYMO...
Definition: binlog_event.h:392
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
Definition: rpl_rli.h:86
int n
Definition: xcom_base.cc:509