![]() |
MySQL 26.7.0
Source Code Documentation
|
Class representing the interface for parallel worker context. More...
#include <csa_worker_context.h>
Public Types | |
| using | Trx_id = Parallel_worker_context::Trx_id |
| using | Worker_id = Parallel_worker_context::Worker_id |
Public Types inherited from cs::apply::Parallel_worker_context | |
| using | Trx_id = int64_t |
| using | Worker_id = uint64_t |
| using | Channel_id = std::string |
Public Member Functions | |
| Csa_worker_context (Trx_id trx_seq_num, Worker_id worker_id, const std::string &channel_id, THD *trx_ctx, int current_retry, int retries_num) | |
| void | report_commit_order_deadlock (bool for_self=false) override |
| Indicates that commit order deadlock has been found. More... | |
| bool | found_commit_order_deadlock () const override |
| Checks if commit order deadlock has been found. More... | |
| void | reset_commit_order_deadlock () override |
| Resets commit order deadlock. More... | |
| bool | is_same_channel (const Parallel_worker_context *arg) const override |
| Checks if arg parallel worker executes transaction coming from the same channel. More... | |
| THD * | get_transaction_ctx () override |
| Returns transaction id (we use sequence number) More... | |
| Worker_id | get_worker_id () const override |
| Returns worker id. More... | |
| instruments::Worker_metrics & | get_worker_metrics () override |
| Obtains worker metrics. More... | |
| MDL_context * | get_mdl_context () override |
| MDL context accessor. More... | |
| const std::string & | get_channel_id () const |
| Channel identifier accessor. More... | |
| Trx_id | get_trx_id () override |
| Obtain transaction id (sequence number) More... | |
| const char * | get_for_channel_id (bool upper_case) const override |
| Get "for channel" id. More... | |
| void | update (Trx_id trx_seq_num, Worker_id worker_id, THD *trx_ctx, int current_retry) |
| Updates internal data for a new transaction. More... | |
| void | update (Worker_id worker_id, int current_retry) |
| Updates internal data for ongoing transaction. More... | |
| void | update (Trx_id trx_seq_num, Worker_id worker_id, const std::string &channel_id, THD *trx_ctx, int current_retry, int retries_num) |
| Updates all internal data for new transaction and channel. More... | |
| bool | can_be_retried (THD *thd) override |
| Returns information on whether THD transaction can be retried. More... | |
| bool | has_temporary_error (THD *thd, int error) |
| Checks whether this transaction error is temporary. More... | |
| void | set_applied () |
| Mark transaction as prepared and externally rollbackable. More... | |
| void | set_committing () |
| Move transaction from prepared into committing state. More... | |
| bool | is_rollback_requested () const |
| Check if external rollback is on-going. More... | |
| void | handle_commit_order_deadlock () |
| Handle commit order deadlock - one of the callers will request transaction rollback due to rpco deadlock. More... | |
| bool | wait_for_rollback () |
| Waits for external rollback to finish. More... | |
| bool | is_csa () const override |
| Checks whether this worker is CSA worker. More... | |
Public Member Functions inherited from cs::apply::Parallel_worker_context | |
| Parallel_worker_context ()=default | |
| virtual | ~Parallel_worker_context ()=default |
Static Public Attributes | |
| static instruments::Dummy_worker_metrics | m_disabled_worker_metrics {} |
| Worker metrics. More... | |
Private Types | |
| enum class | Rpco_state : std::uint8_t { preparing , prepared , commit } |
| RPCO lifecycle visible to deadlock reporting: More... | |
Private Attributes | |
| std::atomic< bool > | m_is_commit_order_deadlock {false} |
| Sticky indicator that this transaction was reported as an RPCO victim. More... | |
| std::atomic< bool > | m_rollback {false} |
| Set once an external rollback request has been enqueued. More... | |
| std::atomic< Rpco_state > | m_rpco_state {Rpco_state::preparing} |
| Current RPCO lifecycle state used to decide how to handle reports. More... | |
| std::promise< bool > | m_rollback_promise |
| Completes when the external rollback worker finishes rescue handling. More... | |
| Trx_id | m_trx_id {0} |
| Transaction identifier reused by commit-order logic. More... | |
| Worker_id | m_worker_id {0} |
| Current worker slot owning this transaction context. More... | |
| std::string | m_channel_id {""} |
| Replication channel this transaction belongs to. More... | |
| THD * | m_trx_ctx {nullptr} |
| THD currently bound to this transaction context. More... | |
| int | m_current_retry {0} |
| Retry number of the current attempt. More... | |
| int | m_retries_num {0} |
| Maximum number of retries allowed for this transaction. More... | |
| std::string | m_for_channel_id {""} |
| Cached "for channel" suffix, built lazily for diagnostics. More... | |
Class representing the interface for parallel worker context.
It accesses basic information like worker id, transaction id, channel id and other functionatlities needed by the commit order manager.
|
strongprivate |
| cs::apply::Csa_worker_context::Csa_worker_context | ( | Trx_id | trx_seq_num, |
| Worker_id | worker_id, | ||
| const std::string & | channel_id, | ||
| THD * | trx_ctx, | ||
| int | current_retry, | ||
| int | retries_num | ||
| ) |
|
overridevirtual |
Returns information on whether THD transaction can be retried.
Implements cs::apply::Parallel_worker_context.
|
overridevirtual |
Checks if commit order deadlock has been found.
Implements cs::apply::Parallel_worker_context.
| const std::string & cs::apply::Csa_worker_context::get_channel_id | ( | ) | const |
Channel identifier accessor.
|
overridevirtual |
Get "for channel" id.
Builds string in flight when needed
| upper_case | Pass true if upper case is needed |
Reimplemented from cs::apply::Parallel_worker_context.
|
overridevirtual |
|
overridevirtual |
Returns transaction id (we use sequence number)
Implements cs::apply::Parallel_worker_context.
|
overridevirtual |
Obtain transaction id (sequence number)
Implements cs::apply::Parallel_worker_context.
|
overridevirtual |
|
overridevirtual |
Obtains worker metrics.
Implements cs::apply::Parallel_worker_context.
| void cs::apply::Csa_worker_context::handle_commit_order_deadlock | ( | ) |
Handle commit order deadlock - one of the callers will request transaction rollback due to rpco deadlock.
| bool cs::apply::Csa_worker_context::has_temporary_error | ( | THD * | thd, |
| int | error | ||
| ) |
Checks whether this transaction error is temporary.
| thd | THD handle |
| error | Additional error information |
|
overridevirtual |
Checks whether this worker is CSA worker.
Reimplemented from cs::apply::Parallel_worker_context.
|
inline |
Check if external rollback is on-going.
|
overridevirtual |
Checks if arg parallel worker executes transaction coming from the same channel.
| arg | Context to compare against |
Implements cs::apply::Parallel_worker_context.
|
overridevirtual |
Indicates that commit order deadlock has been found.
| for_self | When true, a thread reports for its own |
Implements cs::apply::Parallel_worker_context.
|
overridevirtual |
Resets commit order deadlock.
Implements cs::apply::Parallel_worker_context.
| void cs::apply::Csa_worker_context::set_applied | ( | ) |
Mark transaction as prepared and externally rollbackable.
| void cs::apply::Csa_worker_context::set_committing | ( | ) |
Move transaction from prepared into committing state.
| void cs::apply::Csa_worker_context::update | ( | Trx_id | trx_seq_num, |
| Worker_id | worker_id, | ||
| const std::string & | channel_id, | ||
| THD * | trx_ctx, | ||
| int | current_retry, | ||
| int | retries_num | ||
| ) |
Updates all internal data for new transaction and channel.
| trx_seq_num | Transaction sequence number |
| worker_id | Worker identifier |
| channel_id | Channel identifier |
| trx_ctx | Transaction THD |
| current_retry | Current retry number |
| retries_num | Number of possible retries for this transaction |
| void cs::apply::Csa_worker_context::update | ( | Trx_id | trx_seq_num, |
| Worker_id | worker_id, | ||
| THD * | trx_ctx, | ||
| int | current_retry | ||
| ) |
Updates internal data for a new transaction.
| trx_seq_num | Transaction sequence number |
| worker_id | Worker identifier |
| trx_ctx | Transaction THD |
| current_retry | Current retry number |
| void cs::apply::Csa_worker_context::update | ( | Worker_id | worker_id, |
| int | current_retry | ||
| ) |
Updates internal data for ongoing transaction.
| worker_id | Worker identifier |
| current_retry | Current retry number |
| bool cs::apply::Csa_worker_context::wait_for_rollback | ( | ) |
Waits for external rollback to finish.
|
private |
Replication channel this transaction belongs to.
|
private |
Retry number of the current attempt.
|
static |
Worker metrics.
|
mutableprivate |
Cached "for channel" suffix, built lazily for diagnostics.
|
private |
Sticky indicator that this transaction was reported as an RPCO victim.
|
private |
Maximum number of retries allowed for this transaction.
|
private |
Set once an external rollback request has been enqueued.
|
private |
Completes when the external rollback worker finishes rescue handling.
|
private |
Current RPCO lifecycle state used to decide how to handle reports.
THD currently bound to this transaction context.
|
private |
Transaction identifier reused by commit-order logic.
|
private |
Current worker slot owning this transaction context.