33#ifndef CLONE_REPL_INCLUDE
34#define CLONE_REPL_INCLUDE
53using Gtid_info = std::array<unsigned char, GTID_INFO_SIZE>;
144 <<
"GTID recovery trx_no: " << max_trx_no;
147 if (max_trx_no == 0) {
246 int list_index = (list_number &
static_cast<uint64_t
>(1));
264 ut_a(request_number > 0);
273 return (request_number);
303 ut_ad(active_list.size() == 0);
305 return (flush_number);
Persist GTID along with transaction commit.
Definition: clone0repl.h:71
std::atomic< bool > m_flush_in_progress
Flush of GTID is in progress.
Definition: clone0repl.h:377
trx_id_t get_oldest_trx_no()
Get oldest transaction number for which GTID is not persisted to table.
Definition: clone0repl.h:119
static const int s_max_gtid_threshold
Maximum Number of transaction/GTID to hold.
Definition: clone0repl.h:341
Clone_persist_gtid & operator=(Clone_persist_gtid const &)=delete
Disable assignment.
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.
Definition: clone0repl.cc:651
bool start()
Start GTID persistence and background thread.
Definition: clone0repl.cc:719
void stop()
Definition: clone0repl.cc:738
bool has_gtid(trx_t *trx, THD *&thd, bool &passed_check)
Check if current transaction has GTID.
Definition: clone0repl.cc:280
trx_undo_t::Gtid_storage persists_gtid(const trx_t *trx)
Check if GTID persistence is set.
Definition: clone0repl.cc:87
static const int s_gtid_threshold
Number of transaction/GTID threshold for writing to disk table.
Definition: clone0repl.h:336
void set_persist_gtid(trx_t *trx, bool set)
Set or reset GTID persist flag in THD.
Definition: clone0repl.cc:108
std::atomic< bool > m_explicit_request
If explicit request to flush is made.
Definition: clone0repl.h:355
bool is_active() const
Definition: clone0repl.h:111
void update_gtid_trx_no(trx_id_t new_gtid_trx_no)
Update transaction number up to which GTIDs are flushed to table.
Definition: clone0repl.cc:484
static constexpr std::chrono::milliseconds s_time_threshold
Time threshold to trigger persisting GTID.
Definition: clone0repl.h:330
std::atomic< int > m_num_gtid_mem
Number of GTID accumulated in memory.
Definition: clone0repl.h:374
Gtid_info_list & get_active_list()
Definition: clone0repl.h:237
Gtid_info_list m_gtids[2]
Two lists of GTID.
Definition: clone0repl.h:346
bool check_gtid_rollback(THD *thd, trx_t *trx, bool found_gtid)
Check if GTID needs to persist at rollback.
Definition: clone0repl.cc:242
bool check_flushed(uint64_t request_number) const
Check if flush has finished up to a list number.
Definition: clone0repl.h:279
bool debug_skip_write(bool compression)
Check if we need to skip write or compression based on debug variables.
Definition: clone0repl.cc:408
void periodic_write()
Write GTIDs periodically to disk table.
Definition: clone0repl.cc:587
Clone_persist_gtid()
Constructor: start gtid thread.
Definition: clone0repl.h:74
std::atomic< uint64_t > m_active_number
Number of the current GTID list.
Definition: clone0repl.h:349
os_event_t m_event
Event for GTID background thread.
Definition: clone0repl.h:361
uint64_t m_flush_request_number
Number for which last flush request was made.
Definition: clone0repl.h:358
bool check_compress()
Check if GTID compression is necessary based on threshold.
Definition: clone0repl.cc:384
void set_oldest_trx_no_recovery(trx_id_t max_trx_no)
Set oldest transaction number for which GTID is not persisted to table.
Definition: clone0repl.h:142
uint32_t m_compression_counter
Counter to keep track of the number of writes till it reaches compression threshold.
Definition: clone0repl.h:365
static const uint32_t s_compression_threshold
Threshold for the count for compressing GTID.
Definition: clone0repl.h:333
void flush_gtids(THD *thd)
Write all GTIDs to table and update GTID transaction number.
Definition: clone0repl.cc:501
bool check_max_gtid_threshold()
Definition: clone0repl.cc:579
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.
Definition: clone0repl.cc:162
bool check_gtid_prepare(THD *thd, trx_t *trx, bool found_gtid, bool &alloc)
Check if GTID needs to persist at XA prepare.
Definition: clone0repl.cc:191
std::atomic< bool > m_thread_active
true, if background thread is active.
Definition: clone0repl.h:383
std::atomic< uint64_t > m_gtid_trx_no
Definition: clone0repl.h:371
~Clone_persist_gtid()
Destructor: stop gtid thread.
Definition: clone0repl.h:91
Clone_persist_gtid(Clone_persist_gtid const &)=delete
Disable copy construction.
void add(const Gtid_desc >id_desc)
Add GTID to in memory list.
Definition: clone0repl.cc:45
std::atomic< bool > m_close_thread
Set to true, when the background thread is asked to exit.
Definition: clone0repl.h:380
uint64_t request_immediate_flush(bool compress)
Request immediate flush of all GTIDs accumulated.
Definition: clone0repl.h:258
uint64_t switch_active_list()
Switch active GTID list.
Definition: clone0repl.h:293
void get_gtid_info(trx_t *trx, Gtid_desc >id_desc)
Get transaction GTID information.
Definition: clone0repl.cc:336
int write_other_gtids()
Write GTIDs of non Innodb transactions to table.
Definition: clone0repl.cc:376
bool flush_immediate() const
Definition: clone0repl.h:284
std::atomic< bool > m_active
true, if GTID persistence is active.
Definition: clone0repl.h:386
Gtid_info_list & get_list(uint64_t list_number)
Definition: clone0repl.h:245
int write_to_table(uint64_t flush_list_number, Gtid_set &table_gtid_set, Tsid_map &tsid_map)
Persist GTID to gtid_executed table.
Definition: clone0repl.cc:419
std::atomic< uint64_t > m_flush_number
Number up to which GTIDs are flushed.
Definition: clone0repl.h:352
void wait_flush(bool compress_gtid, bool early_timeout, Clone_Alert_Func cbk)
Definition: clone0repl.cc:747
bool check_gtid_commit(THD *thd, bool found_gtid, bool &set_explicit)
Check if GTID needs to persist at commit.
Definition: clone0repl.cc:229
uint32_t m_compression_gtid_counter
Counter to keep number of GTIDs flushed before compression.
Definition: clone0repl.h:368
bool is_thread_active() const
Definition: clone0repl.h:114
Represents a set of GTIDs.
Definition: rpl_gtid.h:1556
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Represents a bidirectional map between TSID and SIDNO.
Definition: rpl_gtid.h:749
The class info is used to emit informational log messages.
Definition: ut0log.h:189
Performance Schema stage instrumentation to monitor clone progress.
std::function< int()> Clone_Alert_Func
Function to alert caller for long wait.
Definition: clone0monitor.h:43
constexpr uint32_t GTID_VERSION
GTID format version.
Definition: clone0repl.h:50
std::vector< Gtid_desc > Gtid_info_list
List of GTIDs.
Definition: clone0repl.h:58
constexpr size_t GTID_INFO_SIZE
Serialized GTID information size.
Definition: clone0repl.h:47
std::array< unsigned char, GTID_INFO_SIZE > Gtid_info
Serialized GTID.
Definition: clone0repl.h:53
static int compress(PACK_MRG_INFO *file, char *join_name)
Definition: myisampack.cc:467
static mysql_service_status_t flush(reference_caching_cache cache) noexcept
Definition: component.cc:114
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2882
os_event_t os_event_create()
Creates an event semaphore, i.e., a semaphore which may just have two states: signaled and nonsignale...
Definition: os0event.cc:528
void os_event_destroy(os_event_t &event)
Frees an event object.
Definition: os0event.cc:595
The interface to the threading wrapper.
static bool rollback(THD *thd)
Abort the current statement and transaction.
Definition: sql_cmd_srs.cc:140
@ SRV_FORCE_NO_UNDO_LOG_SCAN
do not look at undo logs when starting the database: InnoDB will treat even incomplete transactions a...
Definition: srv0srv.h:935
ulong srv_force_recovery
Normally 0.
Definition: srv0srv.cc:537
Starts the Innobase database server.
GTID descriptor with version information.
Definition: clone0repl.h:61
uint32_t m_version
Definition: clone0repl.h:67
bool m_is_set
If GTID descriptor is set.
Definition: clone0repl.h:63
Gtid_info m_info
Serialized GTID information.
Definition: clone0repl.h:65
InnoDB condition variable.
Definition: os0event.cc:63
Definition: trx0trx.h:684
Gtid_storage
Undo log may could be allocated to store transaction GTIDs.
Definition: trx0undo.h:341
static void trx_sys_serialisation_mutex_exit()
Release the trx_sys->serialisation_mutex.
Definition: trx0sys.h:621
static void trx_sys_serialisation_mutex_enter()
Acquire the trx_sys->serialisation_mutex.
Definition: trx0sys.h:616
static bool trx_sys_serialisation_mutex_own()
Test if trx_sys->serialisation_mutex is owned.
Definition: trx0sys.h:610
constexpr trx_id_t TRX_ID_MAX
Maximum transaction identifier.
Definition: trx0types.h:145
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:138
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:105
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:93
static void prepare(pax_msg *p, pax_op op)
Definition: xcom_base.cc:1588