![]() |
MySQL 26.7.0
Source Code Documentation
|
Concrete class representing job applied by the applier. More...
#include <job_applier.h>
Public Types | |
| using | Resource_monitor_ref = Resource_instance_monitor_ref |
Public Types inherited from mysql::csa::Job_binlog | |
| using | Stat_monitor_ref = scheduler::Statistics_instance_monitor_ref |
| Alias to Statistics_instance_monitor_ref contained in the scheduler library. More... | |
Public Types inherited from mysql::csa::Job | |
| using | Thread_id = unsigned int |
| Type alias for thread identifier. More... | |
Public Member Functions | |
| Job_applier (Channel *channel, unsigned int max_retries, std::shared_ptr< Fetchable_transaction > fetch_object, Stat_monitor_ref stat_monitor, Resource_monitor_ref res_monitor) | |
| Constructor. More... | |
| virtual | ~Job_applier () override |
| Destructor. More... | |
| bool | attach (Thread_id thread_id) override |
| Attaches to relay context. More... | |
| bool | detach (Thread_id thread_id) override |
| Detaches from relay context. More... | |
| bool | is_attached () const override |
| Checks whether this job is attached to relay log context. More... | |
| bool | restart () override |
| Restarts internal state. More... | |
| std::string | to_string () override |
| Presents job identifier. More... | |
| void | set_failure () override |
| Sets job failure. More... | |
| void | prepare_for_apply (Session_service_ptr ss) |
| Prepares this job to be applied. More... | |
| bool | wait_for_rollback_and_restart () |
| Internal function to wait for rollback and restart transaction in case deadlock has been found. More... | |
Public Member Functions inherited from mysql::csa::Job_binlog | |
| Job_binlog (const Job_binlog &)=delete | |
| Deleted copy constructor. More... | |
| Job_binlog & | operator= (const Job_binlog &)=delete |
| Deleted assignment operator. More... | |
| Job_binlog (Channel *channel, unsigned int max_retries, std::shared_ptr< Fetchable_transaction > fetch_object, Stat_monitor_ref stat_monitor) | |
| Constructor for Job_binlog. More... | |
| virtual | ~Job_binlog () override |
| Destructor for Job_binlog. More... | |
| Channel * | get_channel () const |
| Gets the channel this job comes from. More... | |
| const std::string & | get_channel_id () const |
| Gets the transaction identifier as a string. More... | |
| std::string | get_trx_id () const |
| Get transaction GTID. More... | |
| const mysql::gtid::Gtid & | get_trx_gtid () const |
| Gets the transaction GTID. More... | |
| unsigned long long | get_last_committed () const |
| Gets the last committed value to determine when this transaction can run. More... | |
| unsigned long long | get_sequence_number () const |
| Gets the sequence number of this transaction to determine when it can run and commit. More... | |
| unsigned long long | get_trx_length () const |
| Gets the transaction length. More... | |
| void | set_done () override |
| Mark the transaction as done (done with failure or done successfully. More... | |
| unsigned int | get_instance_id () const override |
| Obtains unique instance id to gather statistics separately for different "instances". More... | |
| virtual bool | is_complete () |
| Checks if this transaction has finished fetching. More... | |
| bool | restart () override |
| Restarts the job and prepares for retry. More... | |
| bool | run (Thread_id thread_id) override |
| Binlog job needs to be called twice to apply transaction: More... | |
| bool | is_trx () const override |
| Checks whether handled job is a transaction (supports two phases) More... | |
| void | set_success () override |
| success callback More... | |
| void | skip () override |
| Skip this job, considered complete and done without failure. More... | |
Public Member Functions inherited from mysql::csa::Job | |
| Job (const Job &)=delete | |
| Deleted copy constructor. More... | |
| Job & | operator= (const Job &)=delete |
| Deleted assignment operator. More... | |
| Job (unsigned int max_retries) | |
| Constructor. More... | |
| virtual | ~Job () |
| Destructor. More... | |
| Thread_id | get_attach_id () const |
| Returns an id based on which the job attaches to applier context. More... | |
| virtual std::size_t | get_id () const |
| Gets the job identifier. More... | |
| virtual void | inc_retries () |
| Increments the number of retries for the job. More... | |
| virtual unsigned int | get_retries () const |
| Gets the number of retries for this job. More... | |
| virtual bool | is_error () |
| Checks whether this job is in error state. More... | |
| virtual bool | is_stopped () const |
| Checks whether applier stop has been requested for this job. More... | |
| virtual bool | is_fatal_error () |
| Checks whether job has a fatal, non-recoverable error. More... | |
| virtual void | set_applier_stop (std::atomic< bool > &applier_stop) |
| Injects the applier stop flag for this job. More... | |
| virtual void | set_fatal_error () |
| Sets fatal job error. More... | |
| virtual void | set_error () |
| Sets job error. More... | |
| virtual bool | is_done () |
| Checks whether the job is done. More... | |
Protected Types | |
| using | Log_event_ptr = Managed_event::Log_event_ptr |
| Type alias for log event pointer. More... | |
Protected Member Functions | |
| bool | prepare (Thread_id thread_id) override |
| Transaction prepare phase, control events execute fully in prepare phase. More... | |
| bool | commit (Thread_id thread_id) override |
| Transaction commit phase, noop for control events. More... | |
| bool | commit_register (Thread_id thread_id) override |
| Transaction "register for commit" phase, noop for control events. More... | |
| bool | apply_event (const Log_event_ptr &ev, THD *thd) |
| Applies a single event (internal helper) More... | |
| bool | run_phase (Thread_id thread_id) |
| Apply events from phase until phase ends or transaction ends. More... | |
| bool | check_rpco_conflict (Thread_id thread_id) |
| Checks and handles RPCO conflict if designated. More... | |
| void | ensure_session (uint thread_id) |
| Acquires session if not already obtained. More... | |
| void | finish_before_commit () |
| Called to clean up when a transaction is skipped (skipping commit phase): More... | |
| bool | can_be_retried () override |
| Check if transaction can be retried. More... | |
| void | start_telemetry () |
| Internal function that starts the transaction telemetry tracking. More... | |
| void | finish_telemetry () |
| Internal function that finishes the transaction telemetry tracking. More... | |
| void | sync_rows_query_event_retention () |
| Keeps ROWS_QUERY event memory alive until Relay_log_info cleanup clears the query pointers that reference it. More... | |
Protected Member Functions inherited from mysql::csa::Job_binlog | |
| bool | restart_internal (bool all) |
| Restarts job with fetch metadata. More... | |
Protected Attributes | |
| mysql::csa::Relay_context_ptr | m_relay_context |
| Relay context used to apply transaction. More... | |
| Session_service_ptr | m_session_service |
| The session service to secure a THD and RLI objects when applying the job. More... | |
| bool | m_is_attached {false} |
| Attach flag. Set to true when job is attached to the relay context. More... | |
| Log_event_ptr | m_commit_event |
| Commit event, saved here for the commit phase in case of retry. More... | |
| Log_event_ptr | m_rows_query_event |
| The currently active ROWS_QUERY event for statement-level processlist visibility. More... | |
| Resource_monitor_ref | m_resource_monitor |
| Resource monitoring object for the current channel instance. More... | |
| bool | m_skip {false} |
| Internal flag for skipping transaction used to check if we need to wait for unregistering from COM queue in commit phase. More... | |
| bool | m_skip_rollback {false} |
| Internal flag to skip transaction rollback, used by the restart. More... | |
| bool | m_co_registered {false} |
| Flag indicating that trx registered in the COM queue. More... | |
Protected Attributes inherited from mysql::csa::Job_binlog | |
| mysql::gtid::Gtid | m_trx_gtid |
| The GTID of the transaction. "<unknown>" if not available. More... | |
| Channel * | m_channel |
| The channel this transaction is coming from. More... | |
| mysql::csa::Managed_event | m_first_event |
| The first event fetched to obtain GTID information. More... | |
| uint32_t | m_next_event {0} |
| The cursor for the events to process. More... | |
| Stat_monitor_ref | m_stat_monitor |
| Statistics monitoring object for the current instance. More... | |
| std::shared_ptr< Fetchable_transaction > | m_fetch_metadata |
| Information on how to fetch transaction data. More... | |
| Transaction_phase | m_phase {Transaction_phase::prepare} |
| Transaction phase indicator: More... | |
Protected Attributes inherited from mysql::csa::Job | |
| bool | m_is_error {false} |
| Error flag for job. More... | |
| bool | m_is_fatal_error {false} |
| Specifies if this job has a fatal error - we cannot retry it. More... | |
| bool | m_is_done {false} |
| When set to true, job is done (successfully or not) More... | |
| unsigned int | m_max_retries |
| Maximum number of retries for this job. More... | |
| std::size_t | m_id {0} |
| This job sequence id. More... | |
| Thread_id | m_thread_id {0} |
| Worker pool thread id. More... | |
| std::size_t | m_trx_retries {0} |
| The number of times this job was retried. More... | |
| std::reference_wrapper< std::atomic< bool > > | m_applier_stop |
| Channel stop flag used to interrupt wait loops. More... | |
Additional Inherited Members | |
Static Protected Attributes inherited from mysql::csa::Job | |
| static std::atomic< std::size_t > | next_id = 0 |
| Next job id. Used to generate ids for jobs. More... | |
Concrete class representing job applied by the applier.
Contains logic to execute (prepare, commit, retry) transaction.
|
protected |
Type alias for log event pointer.
| mysql::csa::Job_applier::Job_applier | ( | Channel * | channel, |
| unsigned int | max_retries, | ||
| std::shared_ptr< Fetchable_transaction > | fetch_object, | ||
| Stat_monitor_ref | stat_monitor, | ||
| Resource_monitor_ref | res_monitor | ||
| ) |
Constructor.
| channel | Channel this job comes from. |
| max_retries | Maximum number of retries for this job. |
| fetch_object | Object to fetch job data. |
| stat_monitor | Object for monitoring statistics. |
| res_monitor | Object for monitoring resources. |
|
overridevirtual |
Destructor.
|
protected |
Applies a single event (internal helper)
| ev | Event to apply |
| thd | THD session to apply an event |
|
overridevirtual |
Attaches to relay context.
| thread_id | Thread pool worker identifier |
Implements mysql::csa::Job.
|
overrideprotectedvirtual |
Check if transaction can be retried.
Reimplemented from mysql::csa::Job.
|
protected |
Checks and handles RPCO conflict if designated.
| thread_id | Thread pool worker identifier |
| True | RPCO conflict detected |
| False | No RPCO conflict |
|
overrideprotectedvirtual |
Transaction commit phase, noop for control events.
| thread_id | Thread pool worker identifier |
Implements mysql::csa::Job_binlog.
|
overrideprotectedvirtual |
Transaction "register for commit" phase, noop for control events.
| thread_id | Thread pool worker identifier |
Implements mysql::csa::Job_binlog.
|
overridevirtual |
Detaches from relay context.
| thread_id | Thread pool worker identifier |
Implements mysql::csa::Job.
|
protected |
Acquires session if not already obtained.
Prepares parallel worker context
| thread_id | Thread pool worker identifier |
|
protected |
Called to clean up when a transaction is skipped (skipping commit phase):
|
protected |
Internal function that finishes the transaction telemetry tracking.
|
overridevirtual |
Checks whether this job is attached to relay log context.
Implements mysql::csa::Job.
|
overrideprotectedvirtual |
Transaction prepare phase, control events execute fully in prepare phase.
| thread_id | Thread pool worker identifier |
Implements mysql::csa::Job_binlog.
| void mysql::csa::Job_applier::prepare_for_apply | ( | Session_service_ptr | ss | ) |
Prepares this job to be applied.
| ss | Pointer to session service. |
|
overridevirtual |
Restarts internal state.
Prepares for retry.
Reimplemented from mysql::csa::Job.
|
protected |
Apply events from phase until phase ends or transaction ends.
| thread_id | Thread pool worker identifier |
|
overridevirtual |
Sets job failure.
Reimplemented from mysql::csa::Job.
|
protected |
Internal function that starts the transaction telemetry tracking.
|
protected |
Keeps ROWS_QUERY event memory alive until Relay_log_info cleanup clears the query pointers that reference it.
|
overridevirtual |
| bool mysql::csa::Job_applier::wait_for_rollback_and_restart | ( | ) |
Internal function to wait for rollback and restart transaction in case deadlock has been found.
|
protected |
Flag indicating that trx registered in the COM queue.
|
protected |
Commit event, saved here for the commit phase in case of retry.
|
protected |
Attach flag. Set to true when job is attached to the relay context.
|
protected |
Relay context used to apply transaction.
|
protected |
Resource monitoring object for the current channel instance.
|
protected |
The currently active ROWS_QUERY event for statement-level processlist visibility.
|
protected |
The session service to secure a THD and RLI objects when applying the job.
|
protected |
Internal flag for skipping transaction used to check if we need to wait for unregistering from COM queue in commit phase.
|
protected |
Internal flag to skip transaction rollback, used by the restart.