MySQL 8.0.39
Source Code Documentation
|
#include <applier.h>
Public Member Functions | |
Applier_module () | |
~Applier_module () override | |
int | initialize_applier_thread () |
Initializes and launches the applier thread. More... | |
Pipeline_member_stats * | get_local_pipeline_stats () |
Return the local applier stats. More... | |
int | terminate_applier_thread () |
Terminates the applier thread. More... | |
bool | is_applier_thread_aborted () |
Is the applier marked for shutdown? More... | |
bool | is_running () |
Is the applier running? More... | |
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. More... | |
int | setup_pipeline_handlers () |
Configure the applier pipeline handlers. More... | |
int | purge_applier_queue_and_restart_applier_module () override |
Purges the relay logs and restarts the applier thread. More... | |
int | applier_thread_handle () |
Runs the applier thread process, reading events and processing them. More... | |
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. More... | |
int | handle_pipeline_action (Pipeline_action *action) override |
Gives the pipeline an action for execution. More... | |
int | inject_event_into_pipeline (Pipeline_event *pevent, Continuation *cont) |
Injects an event into the pipeline and waits for its handling. More... | |
int | terminate_applier_pipeline () |
Terminates the pipeline, shutting down the handlers and deleting them. More... | |
void | set_stop_wait_timeout (ulong timeout) |
Sets the applier shutdown timeout. More... | |
void | inform_of_applier_stop (char *channel_name, bool aborted) |
This method informs the applier module that an applying thread stopped. More... | |
void | ignore_errors_during_stop (bool ignore_errors) |
Check whether to ignore applier errors during stop or not. More... | |
void | add_suspension_packet () override |
Queues a packet that will eventually make the applier module suspend. More... | |
void | add_termination_packet () |
Queues a packet that will make the applier module terminate it's handling process. More... | |
void | add_view_change_packet (View_change_packet *packet) override |
Queues a view change packet into the applier. More... | |
void | add_single_primary_action_packet (Single_primary_action_packet *packet) override |
Queues a single primary action packet into the applier. More... | |
void | add_transaction_prepared_action_packet (Transaction_prepared_action_packet *packet) override |
Queues a transaction prepared action packet into the applier. More... | |
void | add_sync_before_execution_action_packet (Sync_before_execution_action_packet *packet) override |
Queues a synchronization before execution action packet into the applier. More... | |
void | add_leaving_members_action_packet (Leaving_members_action_packet *packet) override |
Queues a leaving members action packet into the applier. More... | |
virtual void | queue_certification_enabling_packet () |
Queues a single a packet that will enable certification on this member. More... | |
void | awake_applier_module () override |
Awakes the applier module. More... | |
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. More... | |
void | interrupt_applier_suspension_wait () override |
Interrupts the current applier waiting process either for it's suspension or it's wait for the consumption of pre suspension events. More... | |
bool | is_applier_thread_waiting () |
Checks if the applier, and its workers when parallel applier is enabled, has already consumed all relay log, that is, applier is waiting for transactions to be queued. More... | |
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. More... | |
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. More... | |
bool | get_retrieved_gtid_set (std::string &retrieved_set) override |
Returns the retrieved gtid set for the applier channel. More... | |
int | wait_for_applier_event_execution (std::string &retrieved_set, double timeout, bool update_THD_status=true) override |
Waits for the execution of all events in the given set by the current SQL applier. More... | |
Certification_handler * | get_certification_handler () override |
Returns the handler instance in the applier module responsible for certification. More... | |
size_t | get_message_queue_size () override |
Returns the applier module's queue size. More... | |
Member_applier_state | get_applier_status () override |
Pipeline_stats_member_collector * | get_pipeline_stats_member_collector () override |
Flow_control_module * | get_flow_control_module () override |
void | run_flow_control_step () override |
bool | queue_and_wait_on_queue_checkpoint (std::shared_ptr< Continuation > checkpoint_condition) override |
Public Member Functions inherited from Applier_module_interface | |
virtual | ~Applier_module_interface ()=default |
Private Member Functions | |
bool | apply_action_packet (Action_packet *action_packet) |
Apply an action packet received by the applier. More... | |
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. More... | |
int | apply_data_packet (Data_packet *data_packet, Format_description_log_event *fde_evt, Continuation *cont) |
Apply a Data packet received by the applier. More... | |
int | apply_single_primary_action_packet (Single_primary_action_packet *packet) |
Apply an single primary action packet received by the applier. More... | |
int | apply_transaction_prepared_action_packet (Transaction_prepared_action_packet *packet) |
Apply a transaction prepared action packet received by the applier. More... | |
int | apply_sync_before_execution_action_packet (Sync_before_execution_action_packet *packet) |
Apply a synchronization before execution action packet received by the applier. More... | |
int | apply_leaving_members_action_packet (Leaving_members_action_packet *packet) |
Apply a leaving members action packet received by the applier. More... | |
void | suspend_applier_module () |
Suspends the applier module, being transactions still queued in the incoming queue. More... | |
void | clean_applier_thread_context () |
Cleans the thread context for the applier thread This includes such tasks as removing the thread from the global thread list. More... | |
void | set_applier_thread_context () |
Set the thread context for the applier thread. More... | |
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. More... | |
Applier_module::Applier_module | ( | ) |
|
override |
|
inlineoverridevirtual |
Queues a leaving members action packet into the applier.
[in] | packet | The packet to be queued |
Implements Applier_module_interface.
|
inlineoverridevirtual |
Queues a single primary action packet into the applier.
[in] | packet | The packet to be queued |
Implements Applier_module_interface.
|
inlineoverridevirtual |
Queues a packet that will eventually make the applier module suspend.
This will happen only after all the previous packets are processed.
Implements Applier_module_interface.
|
inlineoverridevirtual |
Queues a synchronization before execution action packet into the applier.
[in] | packet | The packet to be queued |
Implements Applier_module_interface.
|
inline |
Queues a packet that will make the applier module terminate it's handling process.
Due to the blocking nature of the queue, this method is useful to unblock the handling process on shutdown.
|
inlineoverridevirtual |
Queues a transaction prepared action packet into the applier.
[in] | packet | The packet to be queued |
Implements Applier_module_interface.
|
inlineoverridevirtual |
Queues a view change packet into the applier.
This packets contain the new view id and they mark the exact frontier between transactions from the old and new views.
[in] | packet | The view change packet to be queued |
Implements Applier_module_interface.
int Applier_module::applier_thread_handle | ( | ) |
Runs the applier thread process, reading events and processing them.
0 | OK |
!=0 | Error |
group_replication_wait_for_current_events_execution_fail Member leave has been received. Primary change has started in separate thread. Primary change will go to error and try to suspend the applier by adding suspension packet. But we want to kill the applier via shutdown before suspension packet is processed. So block here till SHUTDOWN forwards the KILL signal.
|
private |
Apply an action packet received by the applier.
It can be a order to suspend or terminate.
action_packet | the received action packet |
|
private |
Apply a Data packet received by the applier.
It executes some certification operations and queues a View Change Event
data_packet | the received data packet packet |
fde_evt | the Format description event associated to the event |
cont | the applier Continuation Object |
0 | OK |
!=0 | Error when injecting event |
|
private |
Apply a leaving members action packet received by the applier.
packet | the received action packet |
0 | OK |
!=0 | Error when applying packet |
|
private |
Apply an single primary action packet received by the applier.
packet | the received action packet |
0 | OK |
!=0 | Error when applying packet |
|
private |
Apply a synchronization before execution action packet received by the applier.
packet | the received action packet |
0 | OK |
!=0 | Error when applying packet |
|
private |
Apply a transaction prepared action packet received by the applier.
packet | the received action packet |
0 | OK |
!=0 | Error when applying packet |
|
private |
Apply a View Change packet received by the applier.
It executes some certification operations and queues a View Change Event
view_change_packet | the received view change packet |
fde_evt | the Format description event associated to the event |
cont | the applier Continuation Object |
0 | OK |
!=0 | Error when injecting event |
|
inlineoverridevirtual |
Awakes the applier module.
Implements Applier_module_interface.
|
private |
Cleans the thread context for the applier thread This includes such tasks as removing the thread from the global thread list.
|
inlineoverridevirtual |
Implements Applier_module_interface.
|
overridevirtual |
Returns the handler instance in the applier module responsible for certification.
!=NULL | The certification handler |
NULL | No certification handler present |
Implements Applier_module_interface.
|
inlineoverridevirtual |
Implements Applier_module_interface.
Pipeline_member_stats * Applier_module::get_local_pipeline_stats | ( | ) |
Return the local applier stats.
|
inlineoverridevirtual |
Returns the applier module's queue size.
Implements Applier_module_interface.
|
inlineoverridevirtual |
Implements Applier_module_interface.
|
overridevirtual |
Returns the retrieved gtid set for the applier channel.
[out] | retrieved_set | the set in string format. |
true | there was an error. |
false | the operation has succeeded. |
Implements Applier_module_interface.
|
inlineoverridevirtual |
Queues the packet coming from the reader for future application.
[in] | data | the packet data |
[in] | len | the packet length |
[in] | consistency_level | the transaction consistency level |
[in] | online_members | the ONLINE members when the transaction message was delivered |
[in] | key | the memory instrument key |
0 | OK |
!=0 | Error on queue |
Implements Applier_module_interface.
|
inlineoverridevirtual |
Gives the pipeline an action for execution.
[in] | action | the action to be executed |
0 | OK |
!=0 | Error executing the action |
Implements Applier_module_interface.
|
inline |
Check whether to ignore applier errors during stop or not.
Errors put the members into ERROR state. If errors are ignored member will stay in ONLINE state. During clone, applier errors are ignored, since data will come from clone.
[in] | ignore_errors | if true ignore applier errors during stop |
void Applier_module::inform_of_applier_stop | ( | char * | channel_name, |
bool | aborted | ||
) |
This method informs the applier module that an applying thread stopped.
int Applier_module::initialize_applier_thread | ( | ) |
Initializes and launches the applier thread.
0 | OK |
!=0 | Error |
int Applier_module::inject_event_into_pipeline | ( | Pipeline_event * | pevent, |
Continuation * | cont | ||
) |
Injects an event into the pipeline and waits for its handling.
[in] | pevent | the event to be injected |
[in] | cont | the object used to wait |
0 | OK |
!=0 | Error on queue |
|
overridevirtual |
Interrupts the current applier waiting process either for it's suspension or it's wait for the consumption of pre suspension events.
Implements Applier_module_interface.
|
private |
This method calculates the intersection of the given sets passed as a list of strings.
[in] | gtid_sets | the vector containing the GTID sets to intersect |
[out] | output_set | the final GTID calculated from the intersection |
0 | all went fine |
!=0 | error |
|
inline |
Is the applier marked for shutdown?
0 | no |
!=0 | yes |
bool Applier_module::is_applier_thread_waiting | ( | ) |
Checks if the applier, and its workers when parallel applier is enabled, has already consumed all relay log, that is, applier is waiting for transactions to be queued.
true | the applier is waiting |
false | otherwise |
|
inline |
Is the applier running?
0 | no |
!=0 | yes |
|
overridevirtual |
Purges the relay logs and restarts the applier thread.
0 | OK |
!=0 | Error |
Implements Applier_module_interface.
|
overridevirtual |
Implements Applier_module_interface.
|
virtual |
Queues a single a packet that will enable certification on this member.
|
inlineoverridevirtual |
Implements Applier_module_interface.
|
private |
Set the thread context for the applier thread.
This allows the thread to behave like an slave thread and perform such tasks as queuing to a relay log.
|
inline |
Sets the applier shutdown timeout.
[in] | timeout | the timeout |
int Applier_module::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.
[in] | pipeline_type | the chosen pipeline |
[in] | reset_logs | if a reset happened in the server |
[in] | stop_timeout | the timeout when waiting on shutdown |
[in] | group_sidno | the group configured sidno |
[in] | gtid_assignment_block_size | the group gtid assignment block size |
0 | OK |
!=0 | Error |
int Applier_module::setup_pipeline_handlers | ( | ) |
Configure the applier pipeline handlers.
0 | OK |
!=0 | Error |
|
inlineprivate |
Suspends the applier module, being transactions still queued in the incoming queue.
int Applier_module::terminate_applier_pipeline | ( | ) |
Terminates the pipeline, shutting down the handlers and deleting them.
0 | OK |
!=0 | Error on pipeline termination |
int Applier_module::terminate_applier_thread | ( | ) |
Terminates the applier thread.
0 | OK |
!=0 | A timeout occurred |
|
overridevirtual |
Waits for the applier to suspend and apply all the transactions previous to the suspend request.
abort_flag | a pointer to a flag that the caller can use to cancel the request. |
wait_for_execution | specify if the suspension waits for transactions execution |
0 | OK |
!=0 | Error when accessing the applier module status |
Wait for the applier execution of pre suspension events (blocking method) while(the wait method times out) wait()
Implements Applier_module_interface.
|
overridevirtual |
Waits for the execution of all events by part of the current SQL applier.
Due to the possible asynchronous nature of module's applier handler, this method inquires the current handler to check if all transactions queued up to this point are already executed.
If no handler exists, then it is assumed that transactions were processed.
timeout | the time (seconds) after which the method returns if the above condition was not satisfied |
check_and_purge_partial_transactions | on successful executions, check and purge partial transactions in the relay log |
0 | All transactions were executed |
-1 | A timeout occurred |
-2 | An error occurred |
Implements Applier_module_interface.
|
overridevirtual |
Waits for the execution of all events in the given set by the current SQL applier.
If no handler exists, then it is assumed that transactions were processed.
retrieved_set | the set in string format of transaction to wait for |
timeout | the time (seconds) after which the method returns if the above condition was not satisfied |
update_THD_status | Shall the method update the THD stage |
0 | All transactions were executed |
-1 | A timeout occurred |
-2 | An error occurred |
Implements Applier_module_interface.
|
overridevirtual |
Waits for the execution of all current events by part of the current SQL applier.
The current gtid retrieved set is extracted and a loop is executed until these transactions are executed.
If the applier SQL thread stops, the method will return an error.
If no handler exists, then it is assumed that transactions were processed.
checkpoint_condition | the class used to wait for the queue to be consumed. Can be used to cancel the wait. |
abort_flag | a pointer to a flag that the caller can use to cancel the request. |
update_THD_status | Shall the method update the THD stage |
false | All transactions were executed |
true | An error occurred |
Implements Applier_module_interface.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |