MySQL 9.1.0
Source Code Documentation
|
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... | |
Tablespace * | get (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... | |
Pool * | m_free |
Vector of tablespaces that are unused. More... | |
Pool * | m_active |
Vector of tablespaces that are being used. More... | |
ib_mutex_t | m_mutex |
Mutex to protect concurrent operations on the pool. More... | |
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.
using ibt::Tablespace_pool::Pool = std::list<Tablespace *, ut::allocator<Tablespace *> > |
ibt::Tablespace_pool::Tablespace_pool | ( | size_t | init_size | ) |
Tablespace_pool constructor.
[in] | init_size | Initial size of the tablespace pool |
ibt::Tablespace_pool::~Tablespace_pool | ( | ) |
Destructor.
|
inlineprivate |
Acquire the mutex.
It is used for all operations on the pool
|
private |
Delete old session temporary tablespaces found on startup.
This can happen if server is killed and started again
[in] | create_new_db | true if we are bootstrapping |
|
private |
Expand the pool to the requested size.
[in] | size | Number of tablespaces to be created |
void ibt::Tablespace_pool::free_ts | ( | Tablespace * | ts | ) |
Truncate and release the tablespace back to the pool.
[in] | ts | tablespace that need to be released back to the pool |
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
[in] | id | session id |
[in] | purpose | purpose of using the tablespace |
|
inline |
Gets current pool size.
dberr_t ibt::Tablespace_pool::initialize | ( | bool | create_new_db | ) |
Initialize the pool on startup.
Also delete old tablespaces if found
[in] | create_new_db | true if the database is being created, false otherwise |
|
inline |
Iterate through the list of tablespaces and perform specified operation on the tablespace on every iteration.
[in] | f | Function pointer for the function to be executed on every iteration |
|
inlineprivate |
Release the mutex.
|
private |
Vector of tablespaces that are being used.
|
private |
Vector of tablespaces that are unused.
|
private |
Initial size of pool.
|
private |
Mutex to protect concurrent operations on the pool.
|
private |
True after the pool has been initialized.