MySQL 8.0.40
Source Code Documentation
ibt::Tablespace_pool Class Reference

Pool of session temporary tablespaces. More...

#include <srv0tmp.h>

Public Types

using Pool = std::list< Tablespace *, ut::allocator< Tablespace * > >
 

Public Member Functions

 Tablespace_pool (size_t init_size)
 Tablespace_pool constructor. More...
 
 ~Tablespace_pool ()
 Destructor. More...
 
Tablespaceget (my_thread_id id, enum tbsp_purpose purpose)
 Return a session temporary tablespace. More...
 
void free_ts (Tablespace *ts)
 Truncate and release the tablespace back to the pool. More...
 
dberr_t initialize (bool create_new_db)
 Initialize the pool on startup. More...
 
template<typename F >
void iterate_tbsp (F &&f)
 Iterate through the list of tablespaces and perform specified operation on the tablespace on every iteration. More...
 
size_t get_size ()
 Gets current pool size. More...
 

Private Member Functions

void acquire ()
 Acquire the mutex. More...
 
void release ()
 Release the mutex. More...
 
dberr_t expand (size_t size)
 Expand the pool to the requested size. More...
 
void delete_old_pool (bool create_new_db)
 Delete old session temporary tablespaces found on startup. More...
 

Private Attributes

bool m_pool_initialized
 True after the pool has been initialized. More...
 
size_t m_init_size
 Initial size of pool. More...
 
Poolm_free
 Vector of tablespaces that are unused. More...
 
Poolm_active
 Vector of tablespaces that are being used. More...
 
ib_mutex_t m_mutex
 Mutex to protect concurrent operations on the pool. More...
 

Detailed Description

Pool of session temporary tablespaces.

Each session gets at max two tablespaces. For a session, we allocate one tablespace on the creation of first intrinsic table and another on the creation of first user temporary table (CREATE TEMPORARY TABLE t1). These tablespaces are private to session. No other session can use them when a tablespace is in-use by the session.

Once a session disconnects, the tablespaces are truncated and released to the pool.

Member Typedef Documentation

◆ Pool

Constructor & Destructor Documentation

◆ Tablespace_pool()

ibt::Tablespace_pool::Tablespace_pool ( size_t  init_size)

Tablespace_pool constructor.

Parameters
[in]init_sizeInitial size of the tablespace pool

◆ ~Tablespace_pool()

ibt::Tablespace_pool::~Tablespace_pool ( )

Destructor.

Member Function Documentation

◆ acquire()

void ibt::Tablespace_pool::acquire ( )
inlineprivate

Acquire the mutex.

It is used for all operations on the pool

◆ delete_old_pool()

void ibt::Tablespace_pool::delete_old_pool ( bool  create_new_db)
private

Delete old session temporary tablespaces found on startup.

This can happen if server is killed and started again

Parameters
[in]create_new_dbtrue if we are bootstrapping

◆ expand()

dberr_t ibt::Tablespace_pool::expand ( size_t  size)
private

Expand the pool to the requested size.

Parameters
[in]sizeNumber of tablespaces to be created
Returns
DB_SUCCESS on success, else DB_ERROR on error

◆ free_ts()

void ibt::Tablespace_pool::free_ts ( Tablespace ts)

Truncate and release the tablespace back to the pool.

Parameters
[in]tstablespace that need to be released back to the pool

◆ get()

Tablespace * ibt::Tablespace_pool::get ( my_thread_id  id,
enum tbsp_purpose  purpose 
)

Return a session temporary tablespace.

If pool is exhausted, expand and return one

Parameters
[in]idsession id
[in]purposepurpose of using the tablespace
Returns
Handle to the tablespace

◆ get_size()

size_t ibt::Tablespace_pool::get_size ( )
inline

Gets current pool size.

Returns
Number of tablespaces in the pool, both active and free ones.

◆ initialize()

dberr_t ibt::Tablespace_pool::initialize ( bool  create_new_db)

Initialize the pool on startup.

Also delete old tablespaces if found

Parameters
[in]create_new_dbtrue if the database is being created, false otherwise
Returns
DB_SUCCESS on success, else DB_ERROR on failure

◆ iterate_tbsp()

template<typename F >
void ibt::Tablespace_pool::iterate_tbsp ( F &&  f)
inline

Iterate through the list of tablespaces and perform specified operation on the tablespace on every iteration.

Parameters
[in]fFunction pointer for the function to be executed on every iteration

◆ release()

void ibt::Tablespace_pool::release ( )
inlineprivate

Release the mutex.

Member Data Documentation

◆ m_active

Pool* ibt::Tablespace_pool::m_active
private

Vector of tablespaces that are being used.

◆ m_free

Pool* ibt::Tablespace_pool::m_free
private

Vector of tablespaces that are unused.

◆ m_init_size

size_t ibt::Tablespace_pool::m_init_size
private

Initial size of pool.

◆ m_mutex

ib_mutex_t ibt::Tablespace_pool::m_mutex
private

Mutex to protect concurrent operations on the pool.

◆ m_pool_initialized

bool ibt::Tablespace_pool::m_pool_initialized
private

True after the pool has been initialized.


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