MySQL 9.0.0
Source Code Documentation
|
Persist GTID along with transaction commit. More...
#include <clone0repl.h>
Public Member Functions | |
Clone_persist_gtid () | |
Constructor: start gtid thread. More... | |
~Clone_persist_gtid () | |
Destructor: stop gtid thread. More... | |
bool | start () |
Start GTID persistence and background thread. More... | |
void | stop () |
void | wait_flush (bool compress_gtid, bool early_timeout, Clone_Alert_Func cbk) |
bool | is_active () const |
bool | is_thread_active () const |
trx_id_t | get_oldest_trx_no () |
Get oldest transaction number for which GTID is not persisted to table. More... | |
void | set_oldest_trx_no_recovery (trx_id_t max_trx_no) |
Set oldest transaction number for which GTID is not persisted to table. More... | |
void | get_gtid_info (trx_t *trx, Gtid_desc >id_desc) |
Get transaction GTID information. More... | |
bool | trx_check_set (trx_t *trx, bool prepare, bool rollback, bool &set_explicit) |
Set transaction flag to persist GTID and check if space need to be allocated for GTID. More... | |
bool | has_gtid (trx_t *trx, THD *&thd, bool &passed_check) |
Check if current transaction has GTID. More... | |
trx_undo_t::Gtid_storage | persists_gtid (const trx_t *trx) |
Check if GTID persistence is set. More... | |
void | set_persist_gtid (trx_t *trx, bool set) |
Set or reset GTID persist flag in THD. More... | |
void | add (const Gtid_desc >id_desc) |
Add GTID to in memory list. More... | |
void | periodic_write () |
Write GTIDs periodically to disk table. More... | |
int | write_other_gtids () |
Write GTIDs of non Innodb transactions to table. More... | |
Clone_persist_gtid (Clone_persist_gtid const &)=delete | |
Disable copy construction. More... | |
Clone_persist_gtid & | operator= (Clone_persist_gtid const &)=delete |
Disable assignment. More... | |
Private Member Functions | |
bool | check_gtid_prepare (THD *thd, trx_t *trx, bool found_gtid, bool &alloc) |
Check if GTID needs to persist at XA prepare. More... | |
bool | check_gtid_commit (THD *thd, bool found_gtid, bool &set_explicit) |
Check if GTID needs to persist at commit. More... | |
bool | check_gtid_rollback (THD *thd, trx_t *trx, bool found_gtid) |
Check if GTID needs to persist at rollback. More... | |
bool | wait_thread (bool start, bool flush, uint64_t flush_number, bool compress, bool early_timeout, Clone_Alert_Func cbk) |
Wait for gtid thread to start, finish or flush. More... | |
Gtid_info_list & | get_active_list () |
Gtid_info_list & | get_list (uint64_t list_number) |
bool | debug_skip_write (bool compression) |
Check if we need to skip write or compression based on debug variables. More... | |
uint64_t | request_immediate_flush (bool compress) |
Request immediate flush of all GTIDs accumulated. More... | |
bool | check_flushed (uint64_t request_number) const |
Check if flush has finished up to a list number. More... | |
bool | flush_immediate () const |
bool | check_compress () |
Check if GTID compression is necessary based on threshold. More... | |
uint64_t | switch_active_list () |
Switch active GTID list. More... | |
int | write_to_table (uint64_t flush_list_number, Gtid_set &table_gtid_set, Tsid_map &tsid_map) |
Persist GTID to gtid_executed table. More... | |
void | update_gtid_trx_no (trx_id_t new_gtid_trx_no) |
Update transaction number up to which GTIDs are flushed to table. More... | |
void | flush_gtids (THD *thd) |
Write all GTIDs to table and update GTID transaction number. More... | |
bool | check_max_gtid_threshold () |
Private Attributes | |
Gtid_info_list | m_gtids [2] |
Two lists of GTID. More... | |
std::atomic< uint64_t > | m_active_number |
Number of the current GTID list. More... | |
std::atomic< uint64_t > | m_flush_number |
Number up to which GTIDs are flushed. More... | |
std::atomic< bool > | m_explicit_request |
If explicit request to flush is made. More... | |
uint64_t | m_flush_request_number {0} |
Number for which last flush request was made. More... | |
os_event_t | m_event |
Event for GTID background thread. More... | |
uint32_t | m_compression_counter {0} |
Counter to keep track of the number of writes till it reaches compression threshold. More... | |
uint32_t | m_compression_gtid_counter {0} |
Counter to keep number of GTIDs flushed before compression. More... | |
std::atomic< uint64_t > | m_gtid_trx_no |
std::atomic< int > | m_num_gtid_mem |
Number of GTID accumulated in memory. More... | |
std::atomic< bool > | m_flush_in_progress |
Flush of GTID is in progress. More... | |
std::atomic< bool > | m_close_thread |
Set to true, when the background thread is asked to exit. More... | |
std::atomic< bool > | m_thread_active |
true, if background thread is active. More... | |
std::atomic< bool > | m_active |
true, if GTID persistence is active. More... | |
Static Private Attributes | |
static constexpr std::chrono::milliseconds | s_time_threshold {100} |
Time threshold to trigger persisting GTID. More... | |
static const uint32_t | s_compression_threshold = 50 |
Threshold for the count for compressing GTID. More... | |
static const int | s_gtid_threshold = 1024 |
Number of transaction/GTID threshold for writing to disk table. More... | |
static const int | s_max_gtid_threshold = 1024 * 1024 |
Maximum Number of transaction/GTID to hold. More... | |
Persist GTID along with transaction commit.
|
inline |
Constructor: start gtid thread.
|
inline |
Destructor: stop gtid thread.
|
delete |
Disable copy construction.
void Clone_persist_gtid::add | ( | const Gtid_desc & | gtid_desc | ) |
Add GTID to in memory list.
[in] | gtid_desc | Descriptor with serialized GTID |
|
private |
Check if GTID compression is necessary based on threshold.
|
inlineprivate |
Check if flush has finished up to a list number.
[in] | request_number | flush request number |
|
private |
Check if GTID needs to persist at commit.
[in] | thd | session THD |
[in] | found_gtid | session is owning GTID |
[out] | set_explicit | if explicitly set to persist GTID |
|
private |
Check if GTID needs to persist at XA prepare.
[in] | thd | session THD |
[in,out] | trx | current innnodb transaction |
[in] | found_gtid | session is owning GTID |
[in,out] | alloc | in:transaction checks are passed out:GTID space need to be allocated |
Check if GTID needs to persist at rollback.
[in] | thd | session THD |
[in,out] | trx | current innnodb transaction |
[in] | found_gtid | session is owning GTID |
|
private |
|
private |
Check if we need to skip write or compression based on debug variables.
[in] | compression | check for compression |
|
private |
Write all GTIDs to table and update GTID transaction number.
[in,out] | thd | current session thread |
|
inlineprivate |
|
inlineprivate |
Get transaction GTID information.
[in,out] | trx | innodb transaction |
[out] | gtid_desc | descriptor with serialized GTID |
|
inlineprivate |
[in] | list_number | list number |
|
inline |
Get oldest transaction number for which GTID is not persisted to table.
Transactions committed after this point should not be purged.
Check if current transaction has GTID.
[in] | trx | innodb transaction |
[in,out] | thd | session THD |
[out] | passed_check | true if transaction is good for GTID |
|
inline |
|
inline |
|
delete |
Disable assignment.
void Clone_persist_gtid::periodic_write | ( | ) |
Write GTIDs periodically to disk table.
trx_undo_t::Gtid_storage Clone_persist_gtid::persists_gtid | ( | const trx_t * | trx | ) |
Check if GTID persistence is set.
[in] | trx | current innnodb transaction |
|
inlineprivate |
Request immediate flush of all GTIDs accumulated.
[in] | compress | request compression of GTID table |
|
inline |
Set oldest transaction number for which GTID is not persisted to table.
This is set during recovery from persisted value.
[in] | max_trx_no | transaction number |
void Clone_persist_gtid::set_persist_gtid | ( | trx_t * | trx, |
bool | set | ||
) |
Set or reset GTID persist flag in THD.
[in,out] | trx | current innnodb transaction |
[in] | set | true, if need to set |
bool Clone_persist_gtid::start | ( | ) |
Start GTID persistence and background thread.
void Clone_persist_gtid::stop | ( | ) |
|
inlineprivate |
Switch active GTID list.
bool Clone_persist_gtid::trx_check_set | ( | trx_t * | trx, |
bool | prepare, | ||
bool | rollback, | ||
bool & | set_explicit | ||
) |
Set transaction flag to persist GTID and check if space need to be allocated for GTID.
[in,out] | trx | current innodb transaction |
[in] | prepare | if operation is Prepare |
[in] | rollback | if operation is Rollback |
[out] | set_explicit | if explicitly set to persist GTID |
|
private |
Update transaction number up to which GTIDs are flushed to table.
[in] | new_gtid_trx_no | GTID transaction number |
void Clone_persist_gtid::wait_flush | ( | bool | compress_gtid, |
bool | early_timeout, | ||
Clone_Alert_Func | cbk | ||
) |
|
private |
Wait for gtid thread to start, finish or flush.
[in] | start | if waiting for start |
[in] | flush | wait for immediate flush |
[in] | flush_number | wait flush to reach this number |
[in] | compress | wait also for compression |
[in] | early_timeout | don't wait long if flush is blocked |
[in] | cbk | alert callback for long wait |
int Clone_persist_gtid::write_other_gtids | ( | ) |
Write GTIDs of non Innodb transactions to table.
|
private |
Persist GTID to gtid_executed table.
[in] | flush_list_number | list number to flush |
[in,out] | table_gtid_set | GTIDs in table during recovery |
[in,out] | tsid_map | TSID map for GTIDs |
|
private |
true, if GTID persistence is active.
|
private |
Number of the current GTID list.
Increased when list is switched
|
private |
Set to true, when the background thread is asked to exit.
|
private |
Counter to keep track of the number of writes till it reaches compression threshold.
|
private |
Counter to keep number of GTIDs flushed before compression.
|
private |
Event for GTID background thread.
|
private |
If explicit request to flush is made.
|
private |
Flush of GTID is in progress.
|
private |
Number up to which GTIDs are flushed.
Increased when list is flushed.
|
private |
Number for which last flush request was made.
|
private |
|
private |
Two lists of GTID.
One of them is active where running transactions add their GTIDs. Other list is used to persist them to table from time to time.
|
private |
Number of GTID accumulated in memory.
|
private |
true, if background thread is active.
|
staticprivate |
Threshold for the count for compressing GTID.
|
staticprivate |
Number of transaction/GTID threshold for writing to disk table.
|
staticprivate |
Maximum Number of transaction/GTID to hold.
Transaction commits must wait beyond this point. Not expected to happen as GTIDs are compressed and written together.
|
staticconstexprprivate |
Time threshold to trigger persisting GTID.
Insert GTID once per 1k transactions or every 100 millisecond.