MySQL 9.5.0
Source Code Documentation
MVCC Class Reference

The MVCC read view manager. More...

#include <read0read.h>

Public Member Functions

 MVCC (ulint size)
 Constructor. More...
 
 ~MVCC ()
 Destructor. More...
 
void view_open (ReadView *&view, trx_t *trx)
 Allocate and create a view. More...
 
void view_close (ReadView *&view, bool own_mutex)
 Close a view created by the above function. More...
 
void clone_oldest_view (ReadView *view)
 Clones the oldest view into the provided view, unless the function determines that the provided view is already a good enough lower bound. More...
 
ulint size () const
 

Static Public Member Functions

static bool is_view_active (ReadView *view)
 
static void set_view_creator_trx_id (ReadView *view, trx_id_t id)
 Set the view creator transaction id. More...
 

Private Member Functions

bool validate () const
 Validates a read view list. More...
 
ReadViewget_view ()
 Find a free view from the active list, if none found then allocate a new view. More...
 
 MVCC (const MVCC &)
 
MVCCoperator= (const MVCC &)
 
typedef UT_LIST_BASE_NODE_T (ReadView, m_view_list) view_list_t
 

Private Attributes

view_list_t m_free
 Free views ready for reuse. More...
 
view_list_t m_views
 Active and closed views, the closed views will have the creator trx id set to TRX_ID_MAX. More...
 

Detailed Description

The MVCC read view manager.

Constructor & Destructor Documentation

◆ MVCC() [1/2]

MVCC::MVCC ( ulint  size)
explicit

Constructor.

Parameters
sizeNumber of views to pre-allocate

◆ ~MVCC()

MVCC::~MVCC ( )

Destructor.

Free all the views in the m_free list

◆ MVCC() [2/2]

MVCC::MVCC ( const MVCC )
private

Member Function Documentation

◆ clone_oldest_view()

void MVCC::clone_oldest_view ( ReadView view)

Clones the oldest view into the provided view, unless the function determines that the provided view is already a good enough lower bound.

The caller owns the view that is passed in, which is interpreted to be a previous lower bound known to the caller. No need to call view_close(view,..).

Note: This function is called by Purge to determine the purge_sys->view used to distinguish which transactions are considered committed by everybody, and thus their undo logs can be purged. Purge mainly uses purge_sys->view->low_limit_no(), which is a safe lower-bound on what can be purged based on NO, and further limits it to the lowest needed NO reported by GTID Persistor. But other places like ROLLBACK use purge_sys->view->changes_visible(ID,..).

Parameters
[in,out]viewPreallocated view, owned by the caller. Can be either default constructed (m_low_limit_no is 0) or a fully initialized ReadView object.

◆ get_view()

ReadView * MVCC::get_view ( )
inlineprivate

Find a free view from the active list, if none found then allocate a new view.

This function will also attempt to move delete marked views from the active list to the freed list.

Returns
a view to use
a view to use

◆ is_view_active()

static bool MVCC::is_view_active ( ReadView view)
inlinestatic
Returns
true if the view is active and valid

◆ operator=()

MVCC & MVCC::operator= ( const MVCC )
private

◆ set_view_creator_trx_id()

static void MVCC::set_view_creator_trx_id ( ReadView view,
trx_id_t  id 
)
inlinestatic

Set the view creator transaction id.

Note: This should be set only for views created by RW transactions.

Parameters
viewSet the creator trx id for this view
idTransaction id to set

◆ size()

ulint MVCC::size ( ) const
Returns
the number of active views

◆ UT_LIST_BASE_NODE_T()

typedef MVCC::UT_LIST_BASE_NODE_T ( ReadView  ,
m_view_list   
)
private

◆ validate()

bool MVCC::validate ( ) const
private

Validates a read view list.

◆ view_close()

void MVCC::view_close ( ReadView *&  view,
bool  own_mutex 
)

Close a view created by the above function.

Parameters
viewview allocated by trx_open.
own_mutextrue if caller owns trx_sys_t::mutex

◆ view_open()

void MVCC::view_open ( ReadView *&  view,
trx_t trx 
)

Allocate and create a view.

Parameters
viewView owned by this class created for the caller. Must be freed by calling view_close()
trxTransaction instance of caller

If no new RW transaction has been started since the last view was created then reuse the the existing view.

Member Data Documentation

◆ m_free

view_list_t MVCC::m_free
private

Free views ready for reuse.

◆ m_views

view_list_t MVCC::m_views
private

Active and closed views, the closed views will have the creator trx id set to TRX_ID_MAX.


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