MySQL 9.1.0
Source Code Documentation
|
Thread class responsible for the collection of write sets associated to a transaction. More...
#include <rpl_transaction_write_set_ctx.h>
Public Member Functions | |
Rpl_transaction_write_set_ctx () | |
virtual | ~Rpl_transaction_write_set_ctx ()=default |
bool | add_write_set (uint64 hash) |
Function to add the write set of the hash of the PKE in the std::vector in the transaction_ctx object. More... | |
std::vector< uint64 > * | get_write_set () |
void | reset_state () |
Reset the object so it can be used for a new transaction. More... | |
void | set_has_missing_keys () |
bool | get_has_missing_keys () |
void | set_has_related_foreign_keys () |
bool | get_has_related_foreign_keys () |
bool | was_write_set_limit_reached () |
Identifies situations where the limit for number of write set entries already exceeded the configure limit. More... | |
size_t | write_set_memory_size () |
void | add_savepoint (char *name) |
Function to add a new SAVEPOINT identifier in the savepoint map in the transaction_ctx object. More... | |
void | del_savepoint (char *name) |
Function to delete a SAVEPOINT identifier in the savepoint map in the transaction_ctx object. More... | |
void | rollback_to_savepoint (char *name) |
Function to delete all data added to write set and savepoint since SAVEPOINT identifier was added to savepoinbt in the transaction_ctx object. More... | |
void | reset_savepoint_list () |
Function to push savepoint data to a list and clear the savepoint map in order to create another identifier context, needed on functions ant trigger. More... | |
void | restore_savepoint_list () |
Restore previous savepoint map context, called after executed trigger or function. More... | |
void | set_local_ignore_write_set_memory_limit (bool ignore_limit) |
Set if the thread shall ignore any configured memory limit for write set collection. More... | |
void | set_local_allow_drop_write_set (bool allow_drop_write_set) |
Set if the thread shall if needed discard write sets. More... | |
Static Public Member Functions | |
static void | set_global_write_set_memory_size_limit (uint64 limit) |
Adds a memory limit for write sets. More... | |
static void | update_global_write_set_memory_size_limit (uint64 limit) |
Updates the memory limit for write sets. More... | |
static void | set_global_require_full_write_set (bool requires_ws) |
Prevent or allow this class to discard writesets exceeding a size limit If true, a transaction will never discard its write sets. More... | |
Private Member Functions | |
void | clear_write_set () |
Private Attributes | |
std::vector< uint64 > | write_set |
bool | m_has_missing_keys |
bool | m_has_related_foreign_keys |
std::map< std::string, size_t > | savepoint |
Contains information related to SAVEPOINTs. More... | |
std::list< std::map< std::string, size_t > > | savepoint_list |
Create a savepoint context hierarchy to support encapsulation of identifier name when function or trigger are executed. More... | |
bool | m_ignore_write_set_memory_limit |
If the thread should or not ignore the set limit for write set collection. More... | |
bool | m_local_allow_drop_write_set |
Even if a component says all transactions require write sets, this variable says this thread should discard them when they are bigger than m_opt_max_history_size. More... | |
bool | m_local_has_reached_write_set_limit |
True if the write set size is over the configure limit. More... | |
Static Private Attributes | |
static std::atomic< bool > | m_global_component_requires_write_sets |
There is a component requiring write sets on transactions. More... | |
static std::atomic< uint64 > | m_global_write_set_memory_size_limit |
Memory size limit enforced for write set collection. More... | |
Thread class responsible for the collection of write sets associated to a transaction.
It also includes support for save points where information will be discarded on rollbacks to a savepoint.
Write set and flags are reset on Rpl_transaction_write_set_ctx::reset_state().
The write set collection by an executing transaction is capped to a limit. The limit can be "soft" or "hard":
We cannot use a soft limit for transactions that will be certified in GR, since a writeset is required for correct certification. But when GR is disabled, we can use a soft limit, because the writeset is only used to compute transaction dependencies, and we can pessimistically mark the transaction as conflicting with all other transcations when the writeset is discarded. A soft limit can also be used for transactions executed by the GR recovery channel, since they will not be certified, and the GR applier channel, since those transactions have already passed the certification stage.
For the soft limit, we use
For the hard limit, when using Group Replication, we use
We expose the following interfaces so that components such as GR can control the limit. There is an interface to globally disable/enable the soft limit: static void set_global_require_full_write_set(bool requires_ws); set/alter/remove a hard limit: static void set_global_write_set_memory_size_limit(uint64 limit) static void update_global_write_set_memory_size_limit(uint64 limit);
There is another interface to override the global limits for a thread: void set_local_ignore_write_set_memory_limit(bool ignore_limit); void set_local_allow_drop_write_set(bool allow_drop_write_set);
The local methods are used for example for Group Replication applier and recovery threads as group_replication_transaction_size_limit only applies to client sessions and non group replication replica threads.
Rpl_transaction_write_set_ctx::Rpl_transaction_write_set_ctx | ( | ) |
|
virtualdefault |
void Rpl_transaction_write_set_ctx::add_savepoint | ( | char * | name | ) |
Function to add a new SAVEPOINT identifier in the savepoint map in the transaction_ctx object.
[in] | name | - the identifier name of the SAVEPOINT. |
bool Rpl_transaction_write_set_ctx::add_write_set | ( | uint64 | hash | ) |
Function to add the write set of the hash of the PKE in the std::vector in the transaction_ctx object.
[in] | hash | - the uint64 type hash value of the PKE. |
|
private |
void Rpl_transaction_write_set_ctx::del_savepoint | ( | char * | name | ) |
Function to delete a SAVEPOINT identifier in the savepoint map in the transaction_ctx object.
[in] | name | - the identifier name of the SAVEPOINT. |
bool Rpl_transaction_write_set_ctx::get_has_missing_keys | ( | ) |
bool Rpl_transaction_write_set_ctx::get_has_related_foreign_keys | ( | ) |
std::vector< uint64 > * Rpl_transaction_write_set_ctx::get_write_set | ( | ) |
void Rpl_transaction_write_set_ctx::reset_savepoint_list | ( | ) |
Function to push savepoint data to a list and clear the savepoint map in order to create another identifier context, needed on functions ant trigger.
void Rpl_transaction_write_set_ctx::reset_state | ( | ) |
Reset the object so it can be used for a new transaction.
void Rpl_transaction_write_set_ctx::restore_savepoint_list | ( | ) |
Restore previous savepoint map context, called after executed trigger or function.
void Rpl_transaction_write_set_ctx::rollback_to_savepoint | ( | char * | name | ) |
Function to delete all data added to write set and savepoint since SAVEPOINT identifier was added to savepoinbt in the transaction_ctx object.
[in] | name | - the identifier name of the SAVEPOINT. |
|
static |
Prevent or allow this class to discard writesets exceeding a size limit If true, a transaction will never discard its write sets.
requires_ws | if who invoked the method needs or not write sets |
|
static |
Adds a memory limit for write sets.
limit | the limit to be added |
void Rpl_transaction_write_set_ctx::set_has_missing_keys | ( | ) |
void Rpl_transaction_write_set_ctx::set_has_related_foreign_keys | ( | ) |
void Rpl_transaction_write_set_ctx::set_local_allow_drop_write_set | ( | bool | allow_drop_write_set | ) |
Set if the thread shall if needed discard write sets.
allow_drop_write_set | if full write sets are not critical |
void Rpl_transaction_write_set_ctx::set_local_ignore_write_set_memory_limit | ( | bool | ignore_limit | ) |
Set if the thread shall ignore any configured memory limit for write set collection.
ignore_limit | if the limit should be ignored |
|
static |
Updates the memory limit for write sets.
limit | the limit to be added |
bool Rpl_transaction_write_set_ctx::was_write_set_limit_reached | ( | ) |
Identifies situations where the limit for number of write set entries already exceeded the configure limit.
true | if too many write set entries exist, false otherwise |
size_t Rpl_transaction_write_set_ctx::write_set_memory_size | ( | ) |
|
staticprivate |
There is a component requiring write sets on transactions.
|
staticprivate |
Memory size limit enforced for write set collection.
|
private |
|
private |
|
private |
If the thread should or not ignore the set limit for write set collection.
|
private |
Even if a component says all transactions require write sets, this variable says this thread should discard them when they are bigger than m_opt_max_history_size.
|
private |
True if the write set size is over the configure limit.
|
private |
Contains information related to SAVEPOINTs.
The key on map is the identifier and the value is the size of write set when command was executed.
|
private |
Create a savepoint context hierarchy to support encapsulation of identifier name when function or trigger are executed.
|
private |