236template <
typename Element_type>
300 if (
empty())
return nullptr;
402template <
typename Element_type>
408 const auto ret = (avail++) % capacity;
411 assert(len == avail -
entry);
412 assert(
entry < avail);
423template <
typename Element_type>
428 *item = m_Q[
entry++];
430 assert(len == avail -
entry);
431 assert(
entry <= avail);
435 if (
entry == capacity) {
438 assert(avail < capacity);
439 assert(avail == len);
444template <
typename Element_type>
450 assert(avail >
entry);
451 *item = m_Q[(--avail) % capacity];
453 assert(len == avail -
entry);
481 uint param_id,
const char *param_channel);
578 event.common_header->data_written);
580 event.get_type_code()))
794 bool in_active_multi_stmt =
799 (
"Setting gtid_next.type to NOT_YET_DETERMINED_GTID"));
801 }
else if (in_active_multi_stmt) {
802 my_error(ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION,
MYF(0),
888 const char *start_event_relay_log_name,
890 const char *end_event_relay_log_name);
939 va_list v_args)
const override
940 MY_ATTRIBUTE((
format(printf, 4, 0)));
944 va_list v_args)
const override
945 MY_ATTRIBUTE((
format(printf, 5, 0)));
964 const char *start_event_relay_log_name,
966 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:1413
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:205
Format_description_log_event * get_rli_description_event() const
Return the current Format_description_log_event.
Definition: rpl_rli.h:1717
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:1506
Log_event * current_event
Reference to being applied event.
Definition: rpl_rli.h:1995
Slave_committed_queue * gaq
Definition: rpl_rli.h:1198
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:2609
Format_description_log_event * rli_description_event
Definition: rpl_rli.h:1793
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:321
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:1090
bool de_queue(Slave_job_group *item)
Dequeue from head.
Definition: rpl_rli_pdb.h:380
Slave_committed_queue(size_t max, uint n)
Definition: rpl_rli_pdb.cc:889
bool inited
Definition: rpl_rli_pdb.h:323
bool count_done(Relay_log_info *rli)
Definition: rpl_rli_pdb.cc:907
ulong assigned_group_index
Definition: rpl_rli_pdb.h:337
bool de_tail(Slave_job_group *item)
Similar to de_queue() but removing an item from the tail side.
Definition: rpl_rli_pdb.h:390
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:951
Prealloced_array< ulonglong, 1 > last_done
Definition: rpl_rli_pdb.h:334
Slave_job_group * get_job_group(size_t ind)
Definition: rpl_rli_pdb.h:360
~Slave_committed_queue()
Definition: rpl_rli_pdb.h:341
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:1053
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:369
Slave_job_group lwm
Definition: rpl_rli_pdb.h:331
Definition: rpl_rli_pdb.h:457
Slave_jobs_queue()
Definition: rpl_rli_pdb.h:459
bool overfill
Definition: rpl_rli_pdb.h:464
ulonglong waited_overfill
Definition: rpl_rli_pdb.h:465
Error const & last_error() const
Definition: rpl_reporting.h:143
Definition: rpl_rli_pdb.h:468
ulonglong get_master_log_pos()
Definition: rpl_rli_pdb.h:661
ulong underrun_level
Definition: rpl_rli_pdb.h:598
char checkpoint_relay_log_name[FN_REFLEN]
Definition: rpl_rli_pdb.h:608
ulong excess_cnt
Definition: rpl_rli_pdb.h:603
bool m_is_worker_metric_collection_enabled
Is worker metric collection enabled.
Definition: rpl_rli_pdb.h:532
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:1505
bool curr_group_seen_sequence_number
Definition: rpl_rli_pdb.h:491
void reset_gaq_index()
Definition: rpl_rli_pdb.h:825
ulong overrun_level
Definition: rpl_rli_pdb.h:593
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:668
ulong bitmap_shifted
Definition: rpl_rli_pdb.h:523
longlong sequence_number()
Definition: rpl_rli_pdb.h:907
void reset_commit_order_deadlock()
Set the flag the signals a deadlock to false.
Definition: rpl_rli_pdb.cc:1329
int flush_info(bool force=false)
Definition: rpl_rli_pdb.cc:466
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:721
ulonglong checkpoint_master_log_pos
Definition: rpl_rli_pdb.h:611
Slave_jobs_queue jobs
Definition: rpl_rli_pdb.h:485
volatile bool relay_log_change_notified
Definition: rpl_rli_pdb.h:507
MY_BITMAP group_shifted
Definition: rpl_rli_pdb.h:613
ulong worker_checkpoint_seqno
Definition: rpl_rli_pdb.h:615
bool worker_sleep(ulong seconds)
Sleep for a given amount of seconds or until killed.
Definition: rpl_rli_pdb.cc:1307
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
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:1354
ulong gaq_index
Definition: rpl_rli_pdb.h:948
void post_commit(bool on_rollback) override
See the comments for STS version of this method.
Definition: rpl_rli_pdb.h:678
void do_report(loglevel level, int err_code, const char *msg, va_list v_args) const override
Definition: rpl_rli_pdb.cc:1108
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:2229
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:1337
Slave_worker(const Slave_worker &info)
std::atomic< int > curr_jobs
Definition: rpl_rli_pdb.h:505
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:538
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:2237
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:529
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:617
ulong id
Definition: rpl_rli_pdb.h:493
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:556
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:1343
Slave_worker & operator=(const Slave_worker &info)
ulonglong master_log_pos
Definition: rpl_rli_pdb.h:949
int slave_worker_exec_event(Log_event *ev)
MTS worker main routine.
Definition: rpl_rli_pdb.cc:1245
ulong get_master_server_version()
Definition: rpl_rli_pdb.h:931
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:1411
bool exit_incremented
Definition: rpl_rli_pdb.h:647
volatile ulong last_group_done_index
Definition: rpl_rli_pdb.h:502
Relay_log_info * c_rli
Definition: rpl_rli_pdb.h:488
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:1333
Relay_log_info * get_c_rli() override
Get coordinator's RLI.
Definition: rpl_rli_pdb.h:899
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:486
en_running_state
Definition: rpl_rli_pdb.h:618
@ NOT_RUNNING
Definition: rpl_rli_pdb.h:619
@ STOP_ACCEPTED
Definition: rpl_rli_pdb.h:623
@ RUNNING
Definition: rpl_rli_pdb.h:620
@ STOP
Definition: rpl_rli_pdb.h:622
@ ERROR_LEAVING
Definition: rpl_rli_pdb.h:621
void rollback_positions(Slave_job_group *ptr_g)
Definition: rpl_rli_pdb.cc:709
long wq_overrun_cnt
Definition: rpl_rli_pdb.h:587
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:2233
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:662
bool m_flag_positions_committed
This flag indicates whether positions were already modified during the event processing,...
Definition: rpl_rli_pdb.h:958
std::atomic< bool > m_commit_order_deadlock
Definition: rpl_rli_pdb.h:953
void set_gaq_index(ulong val)
Definition: rpl_rli_pdb.h:826
void increment_worker_metrics_for_event(const Log_event &event)
Update per-event worker metrics.
Definition: rpl_rli_pdb.h:576
char checkpoint_master_log_name[FN_REFLEN]
Definition: rpl_rli_pdb.h:610
ulonglong last_groups_assigned_index
Definition: rpl_rli_pdb.h:504
void end_info()
Definition: rpl_rli_pdb.cc:452
cs::apply::instruments::Worker_metrics & get_worker_metrics()
gets a reference to the worker statistics.
Definition: rpl_rli_pdb.cc:2239
en_running_state volatile running_status
Definition: rpl_rli_pdb.h:641
void copy_worker_metrics(Slave_worker *other)
Copies data and sets the metric collection flag.
Definition: rpl_rli_pdb.h:548
ulonglong checkpoint_relay_log_pos
Definition: rpl_rli_pdb.h:609
bool fd_change_notified
Definition: rpl_rli_pdb.h:522
volatile bool checkpoint_notified
Definition: rpl_rli_pdb.h:508
bool m_is_after_metrics_breakpoint
True if this transaction occurred after the metrics breakpoint in the relay log.
Definition: rpl_rli_pdb.h:562
mysql_cond_t jobs_cond
Definition: rpl_rli_pdb.h:487
cs::apply::instruments::Mta_worker_metrics m_worker_metrics
worker statistics
Definition: rpl_rli_pdb.h:527
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:612
volatile bool master_log_change_notified
Definition: rpl_rli_pdb.h:510
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:499
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:1092
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:3282
The class defines a type of queue with a predefined max capacity that is implemented using the circul...
Definition: rpl_rli_pdb.h:237
bool in(size_t i)
Definition: rpl_rli_pdb.h:305
bool empty() const
Definition: rpl_rli_pdb.h:310
static constexpr size_t error_result
Definition: rpl_rli_pdb.h:313
std::atomic< size_t > len
Actual length.
Definition: rpl_rli_pdb.h:259
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:403
size_t capacity
The capacity and maximum length of the queue in terms of element.
Definition: rpl_rli_pdb.h:243
size_t get_length() const
Definition: rpl_rli_pdb.h:309
circular_buffer_queue()
Definition: rpl_rli_pdb.h:272
Element_type * head_queue()
return the value of data member of the head of the queue.
Definition: rpl_rli_pdb.h:299
size_t avail
Its value modulo capacity is index of the element where the next element will be enqueued.
Definition: rpl_rli_pdb.h:249
circular_buffer_queue(size_t max)
Definition: rpl_rli_pdb.h:262
bool de_queue(Element_type *item)
Content of the being dequeued item is copied to the arg-pointer location.
Definition: rpl_rli_pdb.h:424
size_t entry
The head index of the queue.
Definition: rpl_rli_pdb.h:255
bool full() const
Definition: rpl_rli_pdb.h:311
bool inited_queue
Definition: rpl_rli_pdb.h:260
Prealloced_array< Element_type, 1 > m_Q
Definition: rpl_rli_pdb.h:239
bool de_tail(Element_type *item)
Similar to de_queue but extracting happens from the tail side.
Definition: rpl_rli_pdb.h:445
~circular_buffer_queue()=default
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.
const int64_t SEQ_UNINIT
Uninitialized timestamp value (for either last committed or sequence number).
Definition: binlog_event.h:150
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:91
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
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
std::chrono::seconds seconds
Definition: authorize_manager.cc:68
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:996
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:1961
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:1616
This struct represents a specification of a GTID for a statement to be executed: either "AUTOMATIC",...
Definition: rpl_gtid.h:3999
Definition: my_bitmap.h:43
Definition: rpl_rli_pdb.h:80
Slave_job_group()=default
my_off_t master_log_pos
Definition: rpl_rli_pdb.h:159
my_off_t checkpoint_log_pos
Definition: rpl_rli_pdb.h:162
Format_description_log_event * new_fd_event
Definition: rpl_rli_pdb.h:201
Slave_job_group(const Slave_job_group &other)
Definition: rpl_rli_pdb.h:87
bool notified
Definition: rpl_rli_pdb.h:171
time_t ts
Definition: rpl_rli_pdb.h:169
longlong last_committed
Definition: rpl_rli_pdb.h:174
std::atomic< int32 > done
Definition: rpl_rli_pdb.h:167
Slave_job_group & operator=(const Slave_job_group &other)
Definition: rpl_rli_pdb.h:112
Slave_worker * worker
Definition: rpl_rli_pdb.h:156
my_off_t checkpoint_relay_log_pos
Definition: rpl_rli_pdb.h:165
ulong worker_id
Definition: rpl_rli_pdb.h:155
uint checkpoint_seqno
Definition: rpl_rli_pdb.h:161
void reset(my_off_t master_pos, ulonglong seqno)
Definition: rpl_rli_pdb.h:206
my_off_t group_master_log_pos
Definition: rpl_rli_pdb.h:142
char * group_master_log_name
Definition: rpl_rli_pdb.h:138
char * checkpoint_log_name
Definition: rpl_rli_pdb.h:163
ulong shifted
Definition: rpl_rli_pdb.h:168
longlong sequence_number
Definition: rpl_rli_pdb.h:175
char * checkpoint_relay_log_name
Definition: rpl_rli_pdb.h:166
char * group_relay_log_name
Definition: rpl_rli_pdb.h:153
ulonglong total_seqno
Definition: rpl_rli_pdb.h:157
my_off_t group_relay_log_pos
Definition: rpl_rli_pdb.h:154
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:391
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
Include file for Sun RPC to compile out of the box.
int n
Definition: xcom_base.cc:509