108#define SLAVE_INIT_DBS_IN_GROUP 4
266template <
typename Element_type>
330 if (
empty())
return nullptr;
343 static constexpr size_t error_result = std::numeric_limits<size_t>::max();
432template <
typename Element_type>
438 const auto ret = (avail++) % capacity;
441 assert(len == avail -
entry);
442 assert(
entry < avail);
453template <
typename Element_type>
458 *item = m_Q[
entry++];
460 assert(len == avail -
entry);
461 assert(
entry <= avail);
465 if (
entry == capacity) {
468 assert(avail < capacity);
469 assert(avail == len);
474template <
typename Element_type>
480 assert(avail >
entry);
481 *item = m_Q[(--avail) % capacity];
483 assert(len == avail -
entry);
511 uint param_id,
const char *param_channel);
769 bool in_active_multi_stmt =
774 (
"Setting gtid_next.type to NOT_YET_DETERMINED_GTID"));
776 }
else if (in_active_multi_stmt) {
777 my_error(ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION,
MYF(0),
863 const char *start_event_relay_log_name,
865 const char *end_event_relay_log_name);
914 va_list v_args)
const override
915 MY_ATTRIBUTE((format(printf, 4, 0)));
919 va_list v_args)
const override
920 MY_ATTRIBUTE((format(printf, 5, 0)));
939 const char *start_event_relay_log_name,
941 const char *end_event_relay_log_name);
Contains the classes representing events occurring in the replication stream.
Class representing an error.
Definition: error.h:48
Stores information to monitor a transaction during the different replication stages.
Definition: rpl_gtid.h:1412
This is the abstract base class for binary log events.
Definition: log_event.h:538
ulong mts_group_idx
Index in rli->gaq array to indicate a group that this event is purging.
Definition: log_event.h:693
Definition: rpl_rli.h:203
Format_description_log_event * get_rli_description_event() const
Return the current Format_description_log_event.
Definition: rpl_rli.h:1749
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:1538
Log_event * current_event
Reference to being applied event.
Definition: rpl_rli.h:2027
Slave_committed_queue * gaq
Definition: rpl_rli.h:1205
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:2619
Format_description_log_event * rli_description_event
Definition: rpl_rli.h:1825
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:351
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:1518
bool de_queue(Slave_job_group *item)
Dequeue from head.
Definition: rpl_rli_pdb.h:410
Slave_committed_queue(size_t max, uint n)
Definition: rpl_rli_pdb.cc:1317
bool inited
Definition: rpl_rli_pdb.h:353
bool count_done(Relay_log_info *rli)
Definition: rpl_rli_pdb.cc:1335
ulong assigned_group_index
Definition: rpl_rli_pdb.h:367
bool de_tail(Slave_job_group *item)
Similar to de_queue() but removing an item from the tail side.
Definition: rpl_rli_pdb.h:420
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:1379
Prealloced_array< ulonglong, 1 > last_done
Definition: rpl_rli_pdb.h:364
Slave_job_group * get_job_group(size_t ind)
Definition: rpl_rli_pdb.h:390
~Slave_committed_queue()
Definition: rpl_rli_pdb.h:371
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:1481
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:399
Slave_job_group lwm
Definition: rpl_rli_pdb.h:361
Definition: rpl_rli_pdb.h:487
Slave_jobs_queue()
Definition: rpl_rli_pdb.h:489
bool overfill
Definition: rpl_rli_pdb.h:494
ulonglong waited_overfill
Definition: rpl_rli_pdb.h:495
Error const & last_error() const
Definition: rpl_reporting.h:143
Definition: rpl_rli_pdb.h:498
ulonglong get_master_log_pos()
Definition: rpl_rli_pdb.h:636
ulong underrun_level
Definition: rpl_rli_pdb.h:573
char checkpoint_relay_log_name[FN_REFLEN]
Definition: rpl_rli_pdb.h:583
Prealloced_array< db_worker_hash_entry *, SLAVE_INIT_DBS_IN_GROUP > curr_group_exec_parts
Definition: rpl_rli_pdb.h:521
ulong excess_cnt
Definition: rpl_rli_pdb.h:578
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:1962
bool curr_group_seen_sequence_number
Definition: rpl_rli_pdb.h:524
void reset_gaq_index()
Definition: rpl_rli_pdb.h:800
ulong overrun_level
Definition: rpl_rli_pdb.h:568
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:643
ulong bitmap_shifted
Definition: rpl_rli_pdb.h:560
longlong sequence_number()
Definition: rpl_rli_pdb.h:882
void reset_commit_order_deadlock()
Set the flag the signals a deadlock to false.
Definition: rpl_rli_pdb.cc:1786
int flush_info(bool force=false)
Definition: rpl_rli_pdb.cc:478
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:696
ulonglong checkpoint_master_log_pos
Definition: rpl_rli_pdb.h:586
Slave_jobs_queue jobs
Definition: rpl_rli_pdb.h:515
volatile bool relay_log_change_notified
Definition: rpl_rli_pdb.h:544
MY_BITMAP group_shifted
Definition: rpl_rli_pdb.h:588
ulong worker_checkpoint_seqno
Definition: rpl_rli_pdb.h:590
bool worker_sleep(ulong seconds)
Sleep for a given amount of seconds or until killed.
Definition: rpl_rli_pdb.cc:1764
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:561
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:1811
ulong gaq_index
Definition: rpl_rli_pdb.h:923
void post_commit(bool on_rollback) override
See the comments for STS version of this method.
Definition: rpl_rli_pdb.h:653
void do_report(loglevel level, int err_code, const char *msg, va_list v_args) const override
Definition: rpl_rli_pdb.cc:1536
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:2642
void report_commit_order_deadlock()
Called when replica-preserve-commit-order is enabled, by the worker processing an earlier transaction...
Definition: rpl_rli_pdb.cc:1794
Slave_worker(const Slave_worker &info)
std::atomic< int > curr_jobs
Definition: rpl_rli_pdb.h:538
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:246
bool write_info(Rpl_info_handler *to) override
Definition: rpl_rli_pdb.cc:583
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:318
static uint get_channel_field_index()
Returns the index of the Channel_name field of the table repository.
Definition: rpl_rli_pdb.cc:2650
bool read_info(Rpl_info_handler *from) override
Definition: rpl_rli_pdb.cc:509
void assign_partition_db(Log_event *ev)
Definition: rpl_rli_pdb.cc:2077
const char * get_master_log_name()
Definition: rpl_rli_pdb.cc:633
static void set_nullable_fields(MY_BITMAP *nullable_fields)
Sets bits for columns that are allowed to be NULL.
Definition: rpl_rli_pdb.cc:627
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:572
ulong server_version
Definition: rpl_rli_pdb.h:592
ulong id
Definition: rpl_rli_pdb.h:526
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:1800
Slave_worker & operator=(const Slave_worker &info)
ulonglong master_log_pos
Definition: rpl_rli_pdb.h:924
int slave_worker_exec_event(Log_event *ev)
MTS worker main routine.
Definition: rpl_rli_pdb.cc:1673
ulong get_master_server_version()
Definition: rpl_rli_pdb.h:906
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:1868
bool end_group_sets_max_dbs
Definition: rpl_rli_pdb.h:542
ulong events_done
Definition: rpl_rli_pdb.h:536
bool exit_incremented
Definition: rpl_rli_pdb.h:622
volatile ulong last_group_done_index
Definition: rpl_rli_pdb.h:532
Relay_log_info * c_rli
Definition: rpl_rli_pdb.h:518
bool found_commit_order_deadlock()
Return true if replica-preserve-commit-order is enabled and an earlier transaction is waiting for a r...
Definition: rpl_rli_pdb.cc:1790
Relay_log_info * get_c_rli() override
Get coordinator's RLI.
Definition: rpl_rli_pdb.h:874
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:614
mysql_mutex_t jobs_lock
Definition: rpl_rli_pdb.h:516
en_running_state
Definition: rpl_rli_pdb.h:593
@ NOT_RUNNING
Definition: rpl_rli_pdb.h:594
@ STOP_ACCEPTED
Definition: rpl_rli_pdb.h:598
@ RUNNING
Definition: rpl_rli_pdb.h:595
@ STOP
Definition: rpl_rli_pdb.h:597
@ ERROR_LEAVING
Definition: rpl_rli_pdb.h:596
void rollback_positions(Slave_job_group *ptr_g)
Definition: rpl_rli_pdb.cc:721
long wq_overrun_cnt
Definition: rpl_rli_pdb.h:562
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:2646
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:1145
ulonglong set_master_log_pos(ulong val)
Definition: rpl_rli_pdb.h:637
bool m_flag_positions_committed
This flag indicates whether positions were already modified during the event processing,...
Definition: rpl_rli_pdb.h:933
std::atomic< bool > m_commit_order_deadlock
Definition: rpl_rli_pdb.h:928
long usage_partition
Definition: rpl_rli_pdb.h:540
void set_gaq_index(ulong val)
Definition: rpl_rli_pdb.h:801
char checkpoint_master_log_name[FN_REFLEN]
Definition: rpl_rli_pdb.h:585
ulonglong last_groups_assigned_index
Definition: rpl_rli_pdb.h:534
void end_info()
Definition: rpl_rli_pdb.cc:464
en_running_state volatile running_status
Definition: rpl_rli_pdb.h:616
ulong wq_empty_waits
Definition: rpl_rli_pdb.h:535
ulonglong checkpoint_relay_log_pos
Definition: rpl_rli_pdb.h:584
bool fd_change_notified
Definition: rpl_rli_pdb.h:559
volatile bool checkpoint_notified
Definition: rpl_rli_pdb.h:545
ulong groups_done
Definition: rpl_rli_pdb.h:537
mysql_cond_t jobs_cond
Definition: rpl_rli_pdb.h:517
static size_t get_number_worker_fields()
Definition: rpl_rli_pdb.cc:623
~Slave_worker() override
Definition: rpl_rli_pdb.cc:288
MY_BITMAP group_executed
Definition: rpl_rli_pdb.h:587
volatile bool master_log_change_notified
Definition: rpl_rli_pdb.h:547
int rli_init_info(bool)
A part of Slave worker initializer that provides a minimum context for MTS recovery.
Definition: rpl_rli_pdb.cc:417
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:1077
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:3229
The class defines a type of queue with a predefined max capacity that is implemented using the circul...
Definition: rpl_rli_pdb.h:267
bool in(size_t i)
Definition: rpl_rli_pdb.h:335
bool empty() const
Definition: rpl_rli_pdb.h:340
static constexpr size_t error_result
Definition: rpl_rli_pdb.h:343
std::atomic< size_t > len
Actual length.
Definition: rpl_rli_pdb.h:289
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:433
size_t capacity
The capacity and maximum length of the queue in terms of element.
Definition: rpl_rli_pdb.h:273
size_t get_length() const
Definition: rpl_rli_pdb.h:339
circular_buffer_queue()
Definition: rpl_rli_pdb.h:302
Element_type * head_queue()
return the value of data member of the head of the queue.
Definition: rpl_rli_pdb.h:329
size_t avail
Its value modulo capacity is index of the element where the next element will be enqueued.
Definition: rpl_rli_pdb.h:279
circular_buffer_queue(size_t max)
Definition: rpl_rli_pdb.h:292
bool de_queue(Element_type *item)
Content of the being dequeued item is copied to the arg-pointer location.
Definition: rpl_rli_pdb.h:454
size_t entry
The head index of the queue.
Definition: rpl_rli_pdb.h:285
bool full() const
Definition: rpl_rli_pdb.h:341
bool inited_queue
Definition: rpl_rli_pdb.h:290
Prealloced_array< Element_type, 1 > m_Q
Definition: rpl_rli_pdb.h:269
bool de_tail(Element_type *item)
Similar to de_queue but extracting happens from the tail side.
Definition: rpl_rli_pdb.h:475
~circular_buffer_queue()=default
const int64_t SEQ_UNINIT
Uninitialized timestamp value (for either last committed or sequence number).
Definition: binlog_event.h:158
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:216
#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:83
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
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:693
Performance schema instrumentation interface.
Instrumentation helpers for mutexes.
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:819
Slave_worker * get_least_occupied_worker(Relay_log_info *rli, Slave_worker_array *workers, Log_event *ev)
Get the least occupied worker.
Definition: rpl_rli_pdb.cc:1129
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
bool init_hash_workers(Relay_log_info *rli)
Definition: rpl_rli_pdb.cc:752
void destroy_hash_workers(Relay_log_info *)
Definition: rpl_rli_pdb.cc:763
Slave_worker * get_thd_worker(const THD *thd)
Definition: rpl_rli_pdb.h:973
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:2446
TABLE * mts_move_temp_table_to_entry(TABLE *, THD *, db_worker_hash_entry *)
Relocating temporary table reference into entry's table list head.
Definition: rpl_rli_pdb.cc:785
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
Slave_worker * map_db_to_worker(const char *dbname, Relay_log_info *rli, db_worker_hash_entry **ptr_entry, bool need_temp_tables, Slave_worker *w)
The function produces a reference to the struct of a Worker that has been or will be engaged to proce...
Definition: rpl_rli_pdb.cc:914
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:2102
This struct represents a specification of a GTID for a statement to be executed: either "AUTOMATIC",...
Definition: rpl_gtid.h:3977
Definition: my_bitmap.h:43
Definition: rpl_rli_pdb.h:110
Slave_job_group()=default
my_off_t master_log_pos
Definition: rpl_rli_pdb.h:189
my_off_t checkpoint_log_pos
Definition: rpl_rli_pdb.h:192
Format_description_log_event * new_fd_event
Definition: rpl_rli_pdb.h:231
Slave_job_group(const Slave_job_group &other)
Definition: rpl_rli_pdb.h:117
bool notified
Definition: rpl_rli_pdb.h:201
time_t ts
Definition: rpl_rli_pdb.h:199
longlong last_committed
Definition: rpl_rli_pdb.h:204
std::atomic< int32 > done
Definition: rpl_rli_pdb.h:197
Slave_job_group & operator=(const Slave_job_group &other)
Definition: rpl_rli_pdb.h:142
Slave_worker * worker
Definition: rpl_rli_pdb.h:186
my_off_t checkpoint_relay_log_pos
Definition: rpl_rli_pdb.h:195
ulong worker_id
Definition: rpl_rli_pdb.h:185
uint checkpoint_seqno
Definition: rpl_rli_pdb.h:191
void reset(my_off_t master_pos, ulonglong seqno)
Definition: rpl_rli_pdb.h:236
my_off_t group_master_log_pos
Definition: rpl_rli_pdb.h:172
char * group_master_log_name
Definition: rpl_rli_pdb.h:168
char * checkpoint_log_name
Definition: rpl_rli_pdb.h:193
ulong shifted
Definition: rpl_rli_pdb.h:198
longlong sequence_number
Definition: rpl_rli_pdb.h:205
char * checkpoint_relay_log_name
Definition: rpl_rli_pdb.h:196
char * group_relay_log_name
Definition: rpl_rli_pdb.h:183
ulonglong total_seqno
Definition: rpl_rli_pdb.h:187
my_off_t group_relay_log_pos
Definition: rpl_rli_pdb.h:184
Definition: completion_hash.h:35
Legends running throughout the module:
Definition: rpl_rli_pdb.h:74
TABLE *volatile temporary_tables
Definition: rpl_rli_pdb.h:90
uint db_len
Definition: rpl_rli_pdb.h:75
long usage
Definition: rpl_rli_pdb.h:82
const char * db
Definition: rpl_rli_pdb.h:76
Slave_worker * worker
Definition: rpl_rli_pdb.h:77
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
double seconds()
Definition: task.cc:310
Include file for Sun RPC to compile out of the box.
int n
Definition: xcom_base.cc:509