24#ifndef APPLIER_INCLUDE
25#define APPLIER_INCLUDE
47#define ACTION_PACKET_TYPE 2
48#define VIEW_CHANGE_PACKET_TYPE 3
49#define SINGLE_PRIMARY_PACKET_TYPE 4
50#define SYNC_BEFORE_EXECUTION_PACKET_TYPE 5
51#define TRANSACTION_PREPARED_PACKET_TYPE 6
52#define LEAVING_MEMBERS_PACKET_TYPE 7
55#define APPLIER_GTID_CHECK_TIMEOUT_ERROR -1
56#define APPLIER_RELAY_LOG_NOT_INITED -2
57#define APPLIER_THREAD_ABORTED -3
138 std::shared_ptr<Continuation> checkpoint_condition_arg)
169 if (sid !=
nullptr) {
225 const std::vector<Gcs_member_identifier> &leaving_members)
245 bool *abort_flag,
bool wait_for_execution =
true) = 0;
249 double timeout,
bool check_and_purge_partial_transactions) = 0;
251 std::shared_ptr<Continuation> checkpoint_condition,
bool *abort_flag,
252 bool update_THD_status =
true) = 0;
255 std::string &retrieved_set,
double timeout,
256 bool update_THD_status =
true) = 0;
271 std::list<Gcs_member_identifier> *online_members,
278 std::shared_ptr<Continuation> checkpoint_condition) = 0;
345 ulong stop_timeout,
rpl_sidno group_sidno,
394 std::list<Gcs_member_identifier> *online_members,
397 new Data_packet(data, len,
key, consistency_level, online_members));
583 bool *abort_flag,
bool wait_for_execution =
true)
override;
622 double timeout,
bool check_and_purge_partial_transactions)
override;
647 std::shared_ptr<Continuation> checkpoint_condition,
bool *abort_flag,
648 bool update_THD_status =
true)
override;
677 bool update_THD_status =
true)
override;
721 std::shared_ptr<Continuation> checkpoint_condition)
override;
#define ACTION_PACKET_TYPE
Definition: applier.h:47
char applier_module_channel_name[]
Definition: applier.cc:46
#define LEAVING_MEMBERS_PACKET_TYPE
Definition: applier.h:52
enum_applier_state
Definition: applier.h:234
@ APPLIER_STATE_ON
Definition: applier.h:235
@ APPLIER_STATE_OFF
Definition: applier.h:236
@ APPLIER_ERROR
Definition: applier.h:237
#define TRANSACTION_PREPARED_PACKET_TYPE
Definition: applier.h:51
enum enum_applier_state Member_applier_state
#define SINGLE_PRIMARY_PACKET_TYPE
Definition: applier.h:49
#define VIEW_CHANGE_PACKET_TYPE
Definition: applier.h:48
#define SYNC_BEFORE_EXECUTION_PACKET_TYPE
Definition: applier.h:50
enum_packet_action
Definition: applier.h:62
@ TERMINATION_PACKET
Definition: applier.h:63
@ ACTION_NUMBER
Definition: applier.h:66
@ SUSPENSION_PACKET
Definition: applier.h:64
@ CHECKPOINT_PACKET
Definition: applier.h:65
A packet to control the applier in a event oriented way.
Definition: applier.h:73
Action_packet(enum_packet_action action)
Create a new action packet.
Definition: applier.h:79
enum_packet_action packet_action
Definition: applier.h:84
~Action_packet() override=default
Definition: applier_channel_state_observer.h:30
Definition: applier.h:240
virtual Pipeline_stats_member_collector * get_pipeline_stats_member_collector()=0
virtual bool get_retrieved_gtid_set(std::string &retrieved_set)=0
virtual ~Applier_module_interface()=default
virtual int wait_for_applier_complete_suspension(bool *abort_flag, bool wait_for_execution=true)=0
virtual size_t get_message_queue_size()=0
virtual Certification_handler * get_certification_handler()=0
virtual Flow_control_module * get_flow_control_module()=0
virtual int wait_for_applier_event_execution(double timeout, bool check_and_purge_partial_transactions)=0
virtual int wait_for_applier_event_execution(std::string &retrieved_set, double timeout, bool update_THD_status=true)=0
virtual void add_sync_before_execution_action_packet(Sync_before_execution_action_packet *packet)=0
virtual void add_leaving_members_action_packet(Leaving_members_action_packet *packet)=0
virtual void awake_applier_module()=0
virtual int purge_applier_queue_and_restart_applier_module()=0
virtual Member_applier_state get_applier_status()=0
virtual int handle(const uchar *data, ulong len, enum_group_replication_consistency_level consistency_level, std::list< Gcs_member_identifier > *online_members, PSI_memory_key key)=0
virtual void add_transaction_prepared_action_packet(Transaction_prepared_action_packet *packet)=0
virtual void add_suspension_packet()=0
virtual bool wait_for_current_events_execution(std::shared_ptr< Continuation > checkpoint_condition, bool *abort_flag, bool update_THD_status=true)=0
virtual void run_flow_control_step()=0
virtual void add_view_change_packet(View_change_packet *packet)=0
virtual bool queue_and_wait_on_queue_checkpoint(std::shared_ptr< Continuation > checkpoint_condition)=0
virtual void add_single_primary_action_packet(Single_primary_action_packet *packet)=0
virtual int handle_pipeline_action(Pipeline_action *action)=0
virtual void interrupt_applier_suspension_wait()=0
Definition: applier.h:283
~Applier_module() override
Definition: applier.cc:74
int apply_data_packet(Data_packet *data_packet, Format_description_log_event *fde_evt, Continuation *cont)
Apply a Data packet received by the applier.
Definition: applier.cc:326
Certification_handler * get_certification_handler() override
Returns the handler instance in the applier module responsible for certification.
Definition: applier.cc:953
bool is_applier_thread_aborted()
Is the applier marked for shutdown?
Definition: applier.h:318
void add_termination_packet()
Queues a packet that will make the applier module terminate it's handling process.
Definition: applier.h:489
Plugin_stage_monitor_handler stage_handler
Definition: applier.h:917
int applier_error
Definition: applier.h:886
void clean_applier_thread_context()
Cleans the thread context for the applier thread This includes such tasks as removing the thread from...
Definition: applier.cc:227
bool apply_action_packet(Action_packet *action_packet)
Apply an action packet received by the applier.
Definition: applier.cc:244
int wait_for_applier_complete_suspension(bool *abort_flag, bool wait_for_execution=true) override
Waits for the applier to suspend and apply all the transactions previous to the suspend request.
Definition: applier.cc:812
int applier_thread_handle()
Runs the applier thread process, reading events and processing them.
Definition: applier.cc:423
Member_applier_state get_applier_status() override
Definition: applier.h:698
bool wait_for_current_events_execution(std::shared_ptr< Continuation > checkpoint_condition, bool *abort_flag, bool update_THD_status=true) override
Waits for the execution of all current events by part of the current SQL applier.
Definition: applier.cc:931
int setup_pipeline_handlers()
Configure the applier pipeline handlers.
Definition: applier.cc:161
bool applier_killed_status
Definition: applier.h:888
void set_stop_wait_timeout(ulong timeout)
Sets the applier shutdown timeout.
Definition: applier.h:442
bool m_ignore_applier_errors_during_stop
Definition: applier.h:890
my_thread_handle applier_pthd
Definition: applier.h:870
int apply_single_primary_action_packet(Single_primary_action_packet *packet)
Apply an single primary action packet received by the applier.
Definition: applier.cc:383
void ignore_errors_during_stop(bool ignore_errors)
Check whether to ignore applier errors during stop or not.
Definition: applier.h:466
int purge_applier_queue_and_restart_applier_module() override
Purges the relay logs and restarts the applier thread.
Definition: applier.cc:118
mysql_mutex_t run_lock
Definition: applier.h:879
int apply_transaction_prepared_action_packet(Transaction_prepared_action_packet *packet)
Apply a transaction prepared action packet received by the applier.
Definition: applier.cc:402
bool suspended
Definition: applier.h:898
int setup_applier_module(Handler_pipeline_type pipeline_type, bool reset_logs, ulong stop_timeout, rpl_sidno group_sidno, ulonglong gtid_assignment_block_size)
Configure the applier pipeline according to the given configuration.
Definition: applier.cc:92
void add_suspension_packet() override
Queues a packet that will eventually make the applier module suspend.
Definition: applier.h:478
mysql_cond_t suspension_waiting_condition
Definition: applier.h:901
rpl_sidno group_replication_sidno
Definition: applier.h:875
int intersect_group_executed_sets(std::vector< std::string > >id_sets, Gtid_set *output_set)
This method calculates the intersection of the given sets passed as a list of strings.
Definition: applier.cc:961
bool is_running()
Is the applier running?
Definition: applier.h:329
void add_single_primary_action_packet(Single_primary_action_packet *packet) override
Queues a single primary action packet into the applier.
Definition: applier.h:513
int apply_leaving_members_action_packet(Leaving_members_action_packet *packet)
Apply a leaving members action packet received by the applier.
Definition: applier.cc:416
void suspend_applier_module()
Suspends the applier module, being transactions still queued in the incoming queue.
Definition: applier.h:823
void set_applier_thread_context()
Set the thread context for the applier thread.
Definition: applier.cc:187
int initialize_applier_thread()
Initializes and launches the applier thread.
Definition: applier.cc:653
int terminate_applier_thread()
Terminates the applier thread.
Definition: applier.cc:706
size_t get_message_queue_size() override
Returns the applier module's queue size.
Definition: applier.h:696
bool reset_applier_logs
Definition: applier.h:874
void inform_of_applier_stop(char *channel_name, bool aborted)
This method informs the applier module that an applying thread stopped.
Definition: applier.cc:784
bool is_applier_thread_waiting()
Checks if the applier, and its workers when parallel applier is enabled, has already consumed all rel...
Definition: applier.cc:864
Flow_control_module flow_control_module
Definition: applier.h:916
int wait_for_applier_event_execution(double timeout, bool check_and_purge_partial_transactions) override
Waits for the execution of all events by part of the current SQL applier.
Definition: applier.cc:876
int terminate_applier_pipeline()
Terminates the pipeline, shutting down the handlers and deleting them.
Definition: applier.cc:691
Event_handler * pipeline
Definition: applier.h:907
bool get_retrieved_gtid_set(std::string &retrieved_set) override
Returns the retrieved gtid set for the applier channel.
Definition: applier.cc:902
int handle(const uchar *data, ulong len, enum_group_replication_consistency_level consistency_level, std::list< Gcs_member_identifier > *online_members, PSI_memory_key key) override
Queues the packet coming from the reader for future application.
Definition: applier.h:392
bool applier_aborted
Definition: applier.h:884
Pipeline_stats_member_collector * get_pipeline_stats_member_collector() override
Definition: applier.h:707
mysql_mutex_t suspend_lock
Definition: applier.h:894
int apply_view_change_packet(View_change_packet *view_change_packet, Format_description_log_event *fde_evt, Continuation *cont)
Apply a View Change packet received by the applier.
Definition: applier.cc:266
void awake_applier_module() override
Awakes the applier module.
Definition: applier.h:562
Pipeline_member_stats * get_local_pipeline_stats()
Return the local applier stats.
Definition: applier.cc:1026
bool queue_and_wait_on_queue_checkpoint(std::shared_ptr< Continuation > checkpoint_condition) override
Definition: applier.cc:1020
int inject_event_into_pipeline(Pipeline_event *pevent, Continuation *cont)
Injects an event into the pipeline and waits for its handling.
Definition: applier.cc:233
thread_state applier_thd_state
Definition: applier.h:882
ulonglong gtid_assignment_block_size
Definition: applier.h:876
int apply_sync_before_execution_action_packet(Sync_before_execution_action_packet *packet)
Apply a synchronization before execution action packet received by the applier.
Definition: applier.cc:409
void add_view_change_packet(View_change_packet *packet) override
Queues a view change packet into the applier.
Definition: applier.h:502
void add_sync_before_execution_action_packet(Sync_before_execution_action_packet *packet) override
Queues a synchronization before execution action packet into the applier.
Definition: applier.h:537
THD * applier_thd
Definition: applier.h:871
mysql_cond_t suspend_cond
Definition: applier.h:896
int handle_pipeline_action(Pipeline_action *action) override
Gives the pipeline an action for execution.
Definition: applier.h:410
Pipeline_stats_member_collector pipeline_stats_member_collector
Definition: applier.h:915
void run_flow_control_step() override
Definition: applier.h:716
mysql_cond_t run_cond
Definition: applier.h:880
virtual void queue_certification_enabling_packet()
Queues a single a packet that will enable certification on this member.
Definition: applier.cc:1015
ulong stop_wait_timeout
Definition: applier.h:910
Applier_module()
Definition: applier.cc:55
void interrupt_applier_suspension_wait() override
Interrupts the current applier waiting process either for it's suspension or it's wait for the consum...
Definition: applier.cc:858
Flow_control_module * get_flow_control_module() override
Definition: applier.h:712
Applier_channel_state_observer * applier_channel_observer
Definition: applier.h:913
void add_leaving_members_action_packet(Leaving_members_action_packet *packet) override
Queues a leaving members action packet into the applier.
Definition: applier.h:549
Synchronized_queue< Packet * > * incoming
Definition: applier.h:904
void add_transaction_prepared_action_packet(Transaction_prepared_action_packet *packet) override
Queues a transaction prepared action packet into the applier.
Definition: applier.h:525
Definition: certification_handler.h:32
Class used to wait on the execution of some action.
Definition: pipeline_interfaces.h:462
A wrapper for raw network packets.
Definition: pipeline_interfaces.h:75
Interface for the application of events, them being packets or log events.
Definition: pipeline_interfaces.h:587
virtual int handle_action(Pipeline_action *action)=0
Handling of an action as defined in the handler implementation.
The pipeline stats aggregator of all group members stats and flow control module.
Definition: pipeline_stats.h:593
void flow_control_step(Pipeline_stats_member_collector *)
Evaluate the information received in the last flow control period and adjust the system parameters ac...
Definition: pipeline_stats.cc:742
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:40
Represents a set of GTIDs.
Definition: rpl_gtid.h:1455
Action to configure existing applier handlers.
Definition: pipeline_handlers.h:105
A packet to inform pipeline listeners of leaving members, this packet will be handled on the global m...
Definition: applier.h:217
const std::vector< Gcs_member_identifier > m_leaving_members
Definition: applier.h:231
~Leaving_members_action_packet() override=default
Leaving_members_action_packet(const std::vector< Gcs_member_identifier > &leaving_members)
Create a new leaving members packet.
Definition: applier.h:224
A generic interface for different kinds of packets.
Definition: pipeline_interfaces.h:50
A wrapper for pipeline actions.
Definition: pipeline_interfaces.h:557
A wrapper for log events/packets.
Definition: pipeline_interfaces.h:128
Computed statistics per member.
Definition: pipeline_stats.h:418
The pipeline collector for the local member stats.
Definition: pipeline_stats.h:269
Definition: stage_monitor_handler.h:30
int set_stage(PSI_stage_key key, const char *file, int line, ulonglong estimated_work, ulonglong work_completed)
Set that a new stage is now in progress.
Definition: stage_monitor_handler.cc:79
A packet to wait for queue consumption.
Definition: applier.h:132
std::shared_ptr< Continuation > checkpoint_condition
If we discard a packet.
Definition: applier.h:146
void signal_checkpoint_reached()
Definition: applier.h:142
Queue_checkpoint_packet(std::shared_ptr< Continuation > checkpoint_condition_arg)
Create a new Queue_checkpoint_packet packet.
Definition: applier.h:137
A packet to send new primary election related info to the applier.
Definition: applier.h:111
enum_action
Definition: applier.h:113
@ NEW_PRIMARY
Definition: applier.h:113
@ QUEUE_APPLIED
Definition: applier.h:113
Single_primary_action_packet(enum enum_action action_arg)
Create a new single primary action packet with associated data.
Definition: applier.h:120
~Single_primary_action_packet() override=default
enum enum_action action
Definition: applier.h:125
A packet to request a synchronization point on the global message order on a given member before tran...
Definition: applier.h:191
const Gcs_member_identifier m_gcs_member_id
Definition: applier.h:208
Sync_before_execution_action_packet(my_thread_id thread_id, const Gcs_member_identifier &gcs_member_id)
Create a new synchronization point request.
Definition: applier.h:199
const my_thread_id m_thread_id
Definition: applier.h:207
~Sync_before_execution_action_packet() override=default
Definition: plugin_utils.h:181
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
std::atomic< killed_state > killed
Definition: sql_class.h:2649
A packet to inform that a given member did prepare a given transaction.
Definition: applier.h:153
rpl_sid m_sid
Definition: applier.h:183
const Gcs_member_identifier m_gcs_member_id
Definition: applier.h:178
const rpl_gno m_gno
Definition: applier.h:177
~Transaction_prepared_action_packet() override=default
const rpl_sid * get_sid()
Definition: applier.h:180
const bool m_sid_specified
Definition: applier.h:176
Transaction_prepared_action_packet(const rpl_sid *sid, rpl_gno gno, const Gcs_member_identifier &gcs_member_id)
Create a new transaction prepared action.
Definition: applier.h:163
A packet to send view change related info to the applier.
Definition: applier.h:91
std::string view_id
Definition: applier.h:103
View_change_packet(std::string &view_id_arg)
Create a new data packet with associated data.
Definition: applier.h:98
std::vector< std::string > group_executed_set
Definition: applier.h:104
~View_change_packet() override=default
#define mysql_cond_wait(C, M)
Definition: mysql_cond.h:48
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:50
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:57
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
unsigned char uchar
Definition: my_inttypes.h:52
static my_thread_id thread_id
Definition: my_thr_init.cc:63
uint32 my_thread_id
Definition: my_thread_local.h:34
int(* mysql_cond_broadcast)(mysql_cond_t *that, const char *src_file, unsigned int src_line)
Definition: mysql_cond_service.h:52
static bool ignore_errors
Definition: mysqlcheck.cc:61
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:496
Handler_pipeline_type
Definition: pipeline_factory.h:45
API for Group Replication plugin.
enum_group_replication_consistency_level
Definition: plugin_group_replication.h:35
PSI_stage_info info_GR_STAGE_module_suspending
Definition: plugin_psi.h:228
PSI_stage_info info_GR_STAGE_module_executing
Definition: plugin_psi.h:227
required string key
Definition: replication_asynchronous_connection_failover.proto:60
repeated Action action
Definition: replication_group_member_actions.proto:43
int rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:96
binary_log::gtids::gno_t rpl_gno
GNO, the second (numeric) component of a GTID, is an alias of binary_log::gtids::gno_t.
Definition: rpl_gtid.h:103
PSI_stage_key m_key
The registered stage key.
Definition: psi_stage_bits.h:76
This is a POD.
Definition: uuid.h:61
void copy_from(const unsigned char *data)
Copies the given 16-byte data to this UUID.
Definition: uuid.h:65
Definition: my_thread_bits.h:52
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
Definition: plugin_utils.h:47
bool is_running() const
Definition: plugin_utils.h:84