MySQL 8.3.0
Source Code Documentation
Clone_Sys Class Reference

Clone System. More...

#include <clone0clone.h>

Classes

class  Acquire_clone
 
class  Wait_stage
 RAII style wrapper to enter and exit wait stage. More...
 

Public Types

using Wait_Cond_Cbk_Func = std::function< int(bool is_alert, bool &result)>
 Function to check wait condition. More...
 

Public Member Functions

 Clone_Sys ()
 Construct clone system. More...
 
 ~Clone_Sys ()
 Destructor: Call during system shutdown. More...
 
int add_clone (const byte *loc, Clone_Handle_Type hdl_type, Clone_Handle *&clone_hdl)
 Create and add a new clone handle to clone system. More...
 
void drop_clone (Clone_Handle *clone_handle)
 drop a clone handle from clone system More...
 
Clone_Handlefind_clone (const byte *ref_loc, uint loc_len, Clone_Handle_Type hdl_type)
 Find if a clone is already running for the reference locator. More...
 
Clone_Handleget_clone_by_index (const byte *loc, uint loc_len)
 Get the clone handle from locator by index. More...
 
int attach_snapshot (Clone_Handle_Type hdl_type, Ha_clone_type clone_type, uint64_t snapshot_id, bool is_pfs_monitor, Clone_Snapshot *&snapshot)
 Get or create a snapshot for clone and attach. More...
 
void detach_snapshot (Clone_Snapshot *snapshot, Clone_Handle_Type hdl_type)
 Detach clone handle from snapshot. More...
 
bool mark_abort (bool force)
 Mark clone state to abort if no active clone. More...
 
void mark_active ()
 Mark clone state to active if no other abort request. More...
 
void mark_wait ()
 Mark to indicate that new clone operations should wait. More...
 
void mark_free ()
 Free the wait marker. More...
 
void debug_wait_clone_begin ()
 Debug wait while starting clone and waiting for free marker. More...
 
void close_donor_master_file ()
 Close donor master task file if open and unpin. More...
 
int wait_for_free (THD *thd)
 Wait for marker to get freed. More...
 
bool begin_ddl_state (Clone_notify::Type type, space_id_t space, bool no_wait, bool check_intr, uint32_t &blocked_state, int &error)
 Begin restricted state during some critical ddl phase. More...
 
void end_ddl_state (Clone_notify::Type type, space_id_t space, uint32_t blocked_state)
 End restricted state during some critical ddl phase. More...
 
uint64_t get_next_id ()
 Get next unique ID. More...
 
ib_mutex_t * get_mutex ()
 Get clone sys mutex. More...
 
bool check_active_clone (bool print_alert)
 Check if any active clone is running. More...
 
std::tuple< bool, Clone_Handle * > check_active_clone ()
 Check if any active clone is running. More...
 
Clone_persist_gtidget_gtid_persistor ()
 
void set_space_initialized ()
 Remember that all innodb spaces are initialized after last startup. More...
 
bool is_space_initialized () const
 

Static Public Member Functions

static int wait (Clone_Msec sleep_time, Clone_Sec timeout, Clone_Sec alert_interval, Wait_Cond_Cbk_Func &&func, ib_mutex_t *mutex, bool &is_timeout)
 Wait till the condition is satisfied or timeout. More...
 
static int wait_default (Wait_Cond_Cbk_Func &&func, ib_mutex_t *mutex, bool &is_timeout)
 Wait till the condition is satisfied or default timeout. More...
 

Static Public Attributes

static Clone_Sys_State s_clone_sys_state = {CLONE_SYS_INACTIVE}
 Clone System state. More...
 
static uint s_clone_abort_count = 0
 Number of active abort requests. More...
 
static uint s_clone_wait_count = 0
 Number of active wait requests. More...
 

Private Member Functions

int find_free_index (Clone_Handle_Type hdl_type, uint &free_index)
 Find free index to allocate new clone handle. More...
 
bool handle_ddl_state (Clone_notify::Type type, space_id_t space, bool begin)
 Handle restricted state during critical ddl phase. More...
 

Private Attributes

Clone_Handlem_clone_arr [CLONE_ARR_SIZE]
 Array of clone handles. More...
 
uint m_num_clones
 Number of copy clones. More...
 
uint m_num_apply_clones
 Number of apply clones. More...
 
Clone_Snapshotm_snapshot_arr [SNAPSHOT_ARR_SIZE]
 Array of clone snapshots. More...
 
uint m_num_snapshots
 Number of copy snapshots. More...
 
uint m_num_apply_snapshots
 Number of apply snapshots. More...
 
ib_mutex_t m_clone_sys_mutex
 Clone system mutex. More...
 
uint64_t m_clone_id_generator
 Clone unique ID generator. More...
 
std::atomic< bool > m_space_initialized
 If all innodb tablespaces are initialized. More...
 
Clone_persist_gtid m_gtid_persister
 GTID persister. More...
 

Detailed Description

Clone System.

Member Typedef Documentation

◆ Wait_Cond_Cbk_Func

using Clone_Sys::Wait_Cond_Cbk_Func = std::function<int(bool is_alert, bool &result)>

Function to check wait condition.

Parameters
[in]is_alertprint alert message
[out]resulttrue, if condition is satisfied
Returns
error code

Constructor & Destructor Documentation

◆ Clone_Sys()

Clone_Sys::Clone_Sys ( )

Construct clone system.

◆ ~Clone_Sys()

Clone_Sys::~Clone_Sys ( )

Destructor: Call during system shutdown.

Member Function Documentation

◆ add_clone()

int Clone_Sys::add_clone ( const byte loc,
Clone_Handle_Type  hdl_type,
Clone_Handle *&  clone_hdl 
)

Create and add a new clone handle to clone system.

Parameters
[in]loclocator
[in]hdl_typehandle type
[out]clone_hdlclone handle
Returns
error code

◆ attach_snapshot()

int Clone_Sys::attach_snapshot ( Clone_Handle_Type  hdl_type,
Ha_clone_type  clone_type,
uint64_t  snapshot_id,
bool  is_pfs_monitor,
Clone_Snapshot *&  snapshot 
)

Get or create a snapshot for clone and attach.

Parameters
[in]hdl_typehandle type
[in]clone_typeclone type
[in]snapshot_idsnapshot identifier
[in]is_pfs_monitortrue, if needs PFS monitoring
[out]snapshotclone snapshot
Returns
error code

◆ begin_ddl_state()

bool Clone_Sys::begin_ddl_state ( Clone_notify::Type  type,
space_id_t  space,
bool  no_wait,
bool  check_intr,
uint32_t &  blocked_state,
int &  error 
)

Begin restricted state during some critical ddl phase.

Parameters
[in]typeddl notification type
[in]spacetablespace ID for which notification is sent
[in]no_waitreturn with error if needs to wait
[in]check_intrcheck for interrupt during wait
[out]blocked_stateblocked state when state change is blocked
[out]errormysql error code
Returns
true iff clone needs to wait for state change.

◆ check_active_clone() [1/2]

std::tuple< bool, Clone_Handle * > Clone_Sys::check_active_clone ( )

Check if any active clone is running.

Returns
(true, handle) if concurrent clone in progress

◆ check_active_clone() [2/2]

bool Clone_Sys::check_active_clone ( bool  print_alert)

Check if any active clone is running.

Parameters
[in]print_alertprint alert message
Returns
true, if concurrent clone in progress

◆ close_donor_master_file()

void Clone_Sys::close_donor_master_file ( )

Close donor master task file if open and unpin.

◆ debug_wait_clone_begin()

void Clone_Sys::debug_wait_clone_begin ( )

Debug wait while starting clone and waiting for free marker.

◆ detach_snapshot()

void Clone_Sys::detach_snapshot ( Clone_Snapshot snapshot,
Clone_Handle_Type  hdl_type 
)

Detach clone handle from snapshot.

Parameters
[in]snapshotsnapshot
[in]hdl_typehandle type

◆ drop_clone()

void Clone_Sys::drop_clone ( Clone_Handle clone_handle)

drop a clone handle from clone system

Parameters
[in]clone_handleClone handle

◆ end_ddl_state()

void Clone_Sys::end_ddl_state ( Clone_notify::Type  type,
space_id_t  space,
uint32_t  blocked_state 
)

End restricted state during some critical ddl phase.

Parameters
[in]typeddl notification type
[in]spacetablespace ID for which notification is sent
[in]blocked_stateblocked state when state change is blocked

◆ find_clone()

Clone_Handle * Clone_Sys::find_clone ( const byte ref_loc,
uint  loc_len,
Clone_Handle_Type  hdl_type 
)

Find if a clone is already running for the reference locator.

Parameters
[in]ref_locreference locator
[in]loc_lenreference locator length
[in]hdl_typeclone type
Returns
clone handle if found, NULL otherwise

◆ find_free_index()

int Clone_Sys::find_free_index ( Clone_Handle_Type  hdl_type,
uint &  free_index 
)
private

Find free index to allocate new clone handle.

Parameters
[in]hdl_typeclone handle type
[out]free_indexfree index in array
Returns
error code

◆ get_clone_by_index()

Clone_Handle * Clone_Sys::get_clone_by_index ( const byte loc,
uint  loc_len 
)

Get the clone handle from locator by index.

Parameters
[in]loclocator
[in]loc_lenlocator length in bytes
Returns
clone handle

◆ get_gtid_persistor()

Clone_persist_gtid & Clone_Sys::get_gtid_persistor ( )
inline
Returns
GTID persistor

◆ get_mutex()

ib_mutex_t * Clone_Sys::get_mutex ( )
inline

Get clone sys mutex.

Returns
clone system mutex

◆ get_next_id()

uint64_t Clone_Sys::get_next_id ( )

Get next unique ID.

Returns
unique ID

◆ handle_ddl_state()

bool Clone_Sys::handle_ddl_state ( Clone_notify::Type  type,
space_id_t  space,
bool  begin 
)
private

Handle restricted state during critical ddl phase.

Parameters
[in]typeddl notification type
[in]spacetablespace ID for which notification is sent
[in]begintrue, if beginning state false, if ending
Returns
true iff clone needs to wait for state change.

◆ is_space_initialized()

bool Clone_Sys::is_space_initialized ( ) const
inline
Returns
true if all innodb spaces are initialized.

◆ mark_abort()

bool Clone_Sys::mark_abort ( bool  force)

Mark clone state to abort if no active clone.

If force is set, abort all active clones and set state to abort.

Parameters
[in]forceforce active clones to abort
Returns
true if global state is set to abort successfully

◆ mark_active()

void Clone_Sys::mark_active ( )

Mark clone state to active if no other abort request.

◆ mark_free()

void Clone_Sys::mark_free ( )

Free the wait marker.

◆ mark_wait()

void Clone_Sys::mark_wait ( )

Mark to indicate that new clone operations should wait.

◆ set_space_initialized()

void Clone_Sys::set_space_initialized ( )
inline

Remember that all innodb spaces are initialized after last startup.

◆ wait()

static int Clone_Sys::wait ( Clone_Msec  sleep_time,
Clone_Sec  timeout,
Clone_Sec  alert_interval,
Wait_Cond_Cbk_Func &&  func,
ib_mutex_t *  mutex,
bool &  is_timeout 
)
inlinestatic

Wait till the condition is satisfied or timeout.

Parameters
[in]sleep_timesleep time in milliseconds
[in]timeouttotal time to wait in seconds
[in]alert_intervalalert interval in seconds
[in]funccallback function for condition check
[in]mutexrelease during sleep and re-acquire
[out]is_timeouttrue if timeout
Returns
error code returned by callback function.

◆ wait_default()

static int Clone_Sys::wait_default ( Wait_Cond_Cbk_Func &&  func,
ib_mutex_t *  mutex,
bool &  is_timeout 
)
inlinestatic

Wait till the condition is satisfied or default timeout.

Parameters
[in]funccallback function for condition check
[in]mutexrelease during sleep and re-acquire
[out]is_timeouttrue if timeout
Returns
error code returned by callback function.

◆ wait_for_free()

int Clone_Sys::wait_for_free ( THD thd)

Wait for marker to get freed.

Parameters
[in,out]thduser session
Returns
, error if timeout

Member Data Documentation

◆ m_clone_arr

Clone_Handle* Clone_Sys::m_clone_arr[CLONE_ARR_SIZE]
private

Array of clone handles.

◆ m_clone_id_generator

uint64_t Clone_Sys::m_clone_id_generator
private

Clone unique ID generator.

◆ m_clone_sys_mutex

ib_mutex_t Clone_Sys::m_clone_sys_mutex
private

Clone system mutex.

◆ m_gtid_persister

Clone_persist_gtid Clone_Sys::m_gtid_persister
private

GTID persister.

◆ m_num_apply_clones

uint Clone_Sys::m_num_apply_clones
private

Number of apply clones.

◆ m_num_apply_snapshots

uint Clone_Sys::m_num_apply_snapshots
private

Number of apply snapshots.

◆ m_num_clones

uint Clone_Sys::m_num_clones
private

Number of copy clones.

◆ m_num_snapshots

uint Clone_Sys::m_num_snapshots
private

Number of copy snapshots.

◆ m_snapshot_arr

Clone_Snapshot* Clone_Sys::m_snapshot_arr[SNAPSHOT_ARR_SIZE]
private

Array of clone snapshots.

◆ m_space_initialized

std::atomic<bool> Clone_Sys::m_space_initialized
private

If all innodb tablespaces are initialized.

◆ s_clone_abort_count

uint Clone_Sys::s_clone_abort_count = 0
static

Number of active abort requests.

◆ s_clone_sys_state

Clone_Sys_State Clone_Sys::s_clone_sys_state = {CLONE_SYS_INACTIVE}
static

Clone System state.

◆ s_clone_wait_count

uint Clone_Sys::s_clone_wait_count = 0
static

Number of active wait requests.


The documentation for this class was generated from the following files: