MySQL 9.0.0
Source Code Documentation
Fil_shard Class Reference

Public Member Functions

 Fil_shard (size_t shard_id)
 Constructor. More...
 
 ~Fil_shard ()
 Destructor. More...
 
size_t id () const
 
void acquire (int line) const
 Acquire the mutex. More...
 
void mutex_release () const
 Release the mutex. More...
 
bool mutex_owned () const
 
bool space_acquire (fil_space_t *space)
 Acquire a tablespace to prevent it from being dropped concurrently. More...
 
void space_release (fil_space_t *space)
 Release a tablespace acquired with Fil_shard::space_acquire(). More...
 
fil_space_tget_space_by_id_from_map (space_id_t space_id) const
 Fetch the fil_space_t instance that maps to space_id. More...
 
fil_space_tget_space_by_id (space_id_t space_id) const
 Fetch the fil_space_t instance that maps to space_id. More...
 
fil_space_tget_space_by_name (const char *name) const
 Fetch the fil_space_t instance that maps to the name. More...
 
bool close_files_in_LRU ()
 Tries to close a file in the shard LRU list. More...
 
void remove_from_LRU (fil_node_t *file)
 Remove the file node from the LRU list. More...
 
void add_to_lru_if_needed (fil_node_t *file)
 Add the file node to the LRU list if required. More...
 
void open_system_tablespaces (size_t max_n_open, size_t *n_open)
 Open all the system files. More...
 
void close_file (fil_node_t *file)
 Close a tablespace file. More...
 
bool close_file (space_id_t space_id)
 Close a tablespace file based on tablespace ID. More...
 
void file_close_to_free (fil_node_t *file, fil_space_t *space)
 Prepare to free a file object from a tablespace memory cache. More...
 
void close_all_files ()
 Close all open files. More...
 
void validate_space_reference_count (Space_References &buffer_pool_references)
 Check that each fil_space_t::m_n_ref_count in this shard matches the number of pages counted in the buffer pool. More...
 
bool needs_encryption_rotate (fil_space_t *space)
 Determine if the tablespace needs encryption rotation. More...
 
size_t encryption_rotate (size_t *rotate_count)
 Rotate the tablespace keys by new master key. More...
 
void space_detach (fil_space_t *space)
 Detach a space object from the tablespace memory cache and closes the tablespace files but does not delete them. More...
 
void space_remove_from_lookup_maps (space_id_t space_id)
 Remove the fil_space_t instance from the maps used to search for it. More...
 
void space_prepare_for_delete (fil_space_t *space) noexcept
 Move the space to the deleted list and remove from the default lookup set. More...
 
void purge ()
 Purge entries from m_deleted_spaces that are no longer referenced by a buffer pool page. More...
 
size_t count_undo_deleted (space_id_t undo_num) noexcept
 Count how many truncated undo space IDs are still tracked in the buffer pool and the file_system cache. More...
 
bool is_deleted (space_id_t space_id)
 Check if a particular space_id for a page in the buffer pool has been deleted recently. More...
 
fil_space_tspace_free (space_id_t space_id)
 Frees a space object from the tablespace memory cache. More...
 
void space_add (fil_space_t *space)
 Map the space ID and name to the tablespace instance. More...
 
void prepare_to_free_file (fil_node_t *file)
 Prepare to free a file. More...
 
void remove_from_unflushed_list (fil_space_t *space)
 If the tablespace is on the unflushed list and there are no pending flushes then remove from the unflushed list. More...
 
void complete_io (fil_node_t *file, const IORequest &type)
 Updates the data structures when an I/O operation finishes. More...
 
bool prepare_file_for_io (fil_node_t *file)
 Prepares a file for I/O. More...
 
void update_space_name_map (fil_space_t *space, const char *new_name)
 Remap the tablespace to the new name. More...
 
void flush_file_spaces ()
 Flush to disk the writes in file spaces possibly cached by the OS (note: spaces of type FIL_TYPE_TEMPORARY are skipped) More...
 
bool space_extend (fil_space_t *space, page_no_t size)
 Try to extend a tablespace if it is smaller than the specified size. More...
 
void space_flush (space_id_t space_id)
 Flushes to disk possible writes cached by the OS. More...
 
bool open_file (fil_node_t *file)
 Open a file of a tablespace. More...
 
bool space_is_flushed (const fil_space_t *space)
 Checks if all the file nodes in a space are flushed. More...
 
bool space_open (space_id_t space_id)
 Open each file of a tablespace if not already open. More...
 
fil_space_tspace_load (space_id_t space_id)
 Opens the files associated with a tablespace and returns a pointer to the fil_space_t that is in the memory cache associated with a space id. More...
 
dberr_t wait_for_pending_operations (space_id_t space_id, fil_space_t *&space, char **path) const
 Wait for pending operations on a tablespace to stop. More...
 
dberr_t space_rename (space_id_t space_id, const char *old_path, const char *new_name, const char *new_path_in)
 Rename a single-table tablespace. More...
 
dberr_t space_delete (space_id_t space_id, buf_remove_t buf_remove)
 Deletes an IBD or IBU tablespace. More...
 
bool space_truncate (space_id_t space_id, page_no_t size_in_pages)
 Truncate the tablespace to needed size. More...
 
fil_space_tspace_create (const char *name, space_id_t space_id, uint32_t flags, fil_type_t purpose)
 Create a space memory object and put it to the fil_system hash table. More...
 
bool adjust_space_name (fil_space_t *space, const char *dd_space_name)
 Adjust temporary auto-generated names created during file discovery with correct tablespace names from the DD. More...
 
bool space_check_exists (space_id_t space_id, const char *name, bool print_err, bool adjust_space)
 Returns true if a matching tablespace exists in the InnoDB tablespace memory cache. More...
 
dberr_t do_io (const IORequest &type, bool sync, const page_id_t &page_id, const page_size_t &page_size, ulint byte_offset, ulint len, void *buf, void *message)
 Read or write data. More...
 
dberr_t iterate (Fil_iterator::Function &f)
 Iterate through all persistent tablespace files (FIL_TYPE_TABLESPACE) returning the nodes via callback function f. More...
 
fil_load_status ibd_open_for_recovery (space_id_t space_id, const std::string &path, fil_space_t *&space)
 Open an ibd tablespace and add it to the InnoDB data structures. More...
 
fil_node_tcreate_node (const char *name, page_no_t size, fil_space_t *space, bool is_raw, bool punch_hole, page_no_t max_pages=PAGE_NO_MAX)
 Attach a file to a tablespace. More...
 
void validate () const
 Validate a shard. More...
 

Static Public Member Functions

static void space_free_low (fil_space_t *&space)
 Free a tablespace object on which fil_space_detach() was invoked. More...
 

Private Types

using File_list = UT_LIST_BASE_NODE_T(fil_node_t, LRU)
 
using Space_list = UT_LIST_BASE_NODE_T(fil_space_t, unflushed_spaces)
 
using Spaces = std::unordered_map< space_id_t, fil_space_t * >
 
using Names = std::unordered_map< const char *, fil_space_t *, Char_Ptr_Hash, Char_Ptr_Compare >
 
using Pair = std::pair< space_id_t, fil_space_t * >
 
using Deleted_spaces = std::vector< Pair, ut::allocator< Pair > >
 

Private Member Functions

fil_space_tget_reserved_space (space_id_t space_id)
 We keep system tablespace files always open; this is important in preventing deadlocks in this module, as a page read completion often performs another read from the insert buffer. More...
 
dberr_t space_prepare_for_truncate (space_id_t space_id, fil_space_t *&space)
 Prepare for truncating a single-table tablespace. More...
 
void write_completed (fil_node_t *file)
 Note that a write IO has completed. More...
 
void add_to_unflushed_list (fil_space_t *space)
 If the tablespace is not on the unflushed list, add it. More...
 
ulint space_check_pending_operations (fil_space_t *space, ulint count) const
 Check for pending operations. More...
 
ulint check_pending_io (const fil_space_t *space, const fil_node_t &file, ulint count) const
 Check for pending IO. More...
 
dberr_t get_file_size (fil_node_t *file, bool read_only_mode)
 First we open the file in the normal mode, no async I/O here, for simplicity. More...
 
 Fil_shard (Fil_shard &&)=delete
 
 Fil_shard (const Fil_shard &)=delete
 
Fil_shardoperator= (Fil_shard &&)=delete
 
Fil_shardoperator= (const Fil_shard &)=delete
 

Static Private Member Functions

static AIO_mode get_AIO_mode (const IORequest &req_type, bool sync)
 Get the AIO mode. More...
 
static dberr_t get_file_for_io (fil_space_t *space, page_no_t *page_no, fil_node_t *&file)
 Get the file name for IO and the local offset within that file. More...
 

Private Attributes

const size_t m_id
 Fil_shard ID. More...
 
Spaces m_spaces
 Tablespace instances hashed on the space id. More...
 
Names m_names
 Tablespace instances hashed on the space name. More...
 
Deleted_spaces m_deleted_spaces
 Deleted tablespaces. More...
 
File_list m_LRU
 Base node for the LRU list of the most recently used open files with no pending I/O's; if we start an I/O on the file, we first remove it from this list, and return it to the start of the list when the I/O ends; the system tablespace file is not put to this list: it is opened after the startup, and kept open until shutdown. More...
 
Space_list m_unflushed_spaces
 Base node for the list of those tablespaces whose files contain unflushed writes; those spaces have at least one file where modification_counter > flush_counter. More...
 
int64_t m_modification_counter
 When we write to a file we increment this by one. More...
 
ib_mutex_t m_mutex
 Mutex protecting this shard. More...
 

Friends

class Fil_system
 

Member Typedef Documentation

◆ Deleted_spaces

using Fil_shard::Deleted_spaces = std::vector<Pair, ut::allocator<Pair> >
private

◆ File_list

◆ Names

using Fil_shard::Names = std::unordered_map<const char *, fil_space_t *, Char_Ptr_Hash, Char_Ptr_Compare>
private

◆ Pair

using Fil_shard::Pair = std::pair<space_id_t, fil_space_t *>
private

◆ Space_list

using Fil_shard::Space_list = UT_LIST_BASE_NODE_T(fil_space_t, unflushed_spaces)
private

◆ Spaces

using Fil_shard::Spaces = std::unordered_map<space_id_t, fil_space_t *>
private

Constructor & Destructor Documentation

◆ Fil_shard() [1/3]

Fil_shard::Fil_shard ( size_t  shard_id)
explicit

Constructor.

Parameters
[in]shard_idShard ID

◆ ~Fil_shard()

Fil_shard::~Fil_shard ( )
inline

Destructor.

◆ Fil_shard() [2/3]

Fil_shard::Fil_shard ( Fil_shard &&  )
privatedelete

◆ Fil_shard() [3/3]

Fil_shard::Fil_shard ( const Fil_shard )
privatedelete

Member Function Documentation

◆ acquire()

void Fil_shard::acquire ( int  line) const
inline

Acquire the mutex.

Parameters
[in]lineLine number from where it was called

◆ add_to_lru_if_needed()

void Fil_shard::add_to_lru_if_needed ( fil_node_t file)

Add the file node to the LRU list if required.

Parameters
[in,out]fileFile for the tablespace

◆ add_to_unflushed_list()

void Fil_shard::add_to_unflushed_list ( fil_space_t space)
private

If the tablespace is not on the unflushed list, add it.

Parameters
[in,out]spaceTablespace to add

◆ adjust_space_name()

bool Fil_shard::adjust_space_name ( fil_space_t space,
const char *  dd_space_name 
)

Adjust temporary auto-generated names created during file discovery with correct tablespace names from the DD.

Parameters
[in,out]spaceTablespace
[in]dd_space_nameTablespace name from the DD
Returns
true if the tablespace is a general or undo tablespace.

◆ check_pending_io()

ulint Fil_shard::check_pending_io ( const fil_space_t space,
const fil_node_t file,
ulint  count 
) const
private

Check for pending IO.

Parameters
[in]spaceTablespace to check
[in]fileFile in space list
[in]countnumber of attempts so far
Returns
0 if no pending else count + 1.

◆ close_all_files()

void Fil_shard::close_all_files ( )

Close all open files.

◆ close_file() [1/2]

void Fil_shard::close_file ( fil_node_t file)

Close a tablespace file.

Parameters
[in,out]fileTablespace file to close

◆ close_file() [2/2]

bool Fil_shard::close_file ( space_id_t  space_id)

Close a tablespace file based on tablespace ID.

Parameters
[in]space_idTablespace ID
Returns
false if space_id was not found.

◆ close_files_in_LRU()

bool Fil_shard::close_files_in_LRU ( )

Tries to close a file in the shard LRU list.

The caller must hold the Fil_shard::m_mutex.

Returns
true if success, false if should retry later

◆ complete_io()

void Fil_shard::complete_io ( fil_node_t file,
const IORequest type 
)

Updates the data structures when an I/O operation finishes.

Updates the pending I/O's field in the file appropriately.

Parameters
[in]fileTablespace file
[in]typeMarks the file as modified type == WRITE

◆ count_undo_deleted()

size_t Fil_shard::count_undo_deleted ( space_id_t  undo_num)
inlinenoexcept

Count how many truncated undo space IDs are still tracked in the buffer pool and the file_system cache.

Parameters
[in]undo_numundo tablespace number.
Returns
number of undo tablespaces that are still in memory.

◆ create_node()

fil_node_t * Fil_shard::create_node ( const char *  name,
page_no_t  size,
fil_space_t space,
bool  is_raw,
bool  punch_hole,
page_no_t  max_pages = PAGE_NO_MAX 
)

Attach a file to a tablespace.

Parameters
[in]namefile name of a file that is not open
[in]sizefile size in entire database blocks
[in,out]spacetablespace from fil_space_create()
[in]is_rawwhether this is a raw device or partition
[in]punch_holetrue if supported for this file
[in]max_pagesmaximum number of pages in file
Returns
pointer to the file name
Return values
nullptrif error

◆ do_io()

dberr_t Fil_shard::do_io ( const IORequest type,
bool  sync,
const page_id_t page_id,
const page_size_t page_size,
ulint  byte_offset,
ulint  len,
void *  buf,
void *  message 
)

Read or write data.

This operation could be asynchronous (aio).

Parameters
[in]typeIO context
[in]syncwhether synchronous aio is desired
[in]page_idpage id
[in]page_sizepage size
[in]byte_offsetremainder of offset in bytes; in AIO this must be divisible by the OS block size
[in]lenhow many bytes to read or write; this must not cross a file boundary; in AIO this must be a block size multiple
[in,out]bufbuffer where to store read data or from where to write; in AIO this must be appropriately aligned
[in]messagemessage for AIO handler if !sync, else ignored
Returns
error code
Return values
DB_SUCCESSon success
DB_TABLESPACE_DELETEDif the tablespace does not exist

◆ encryption_rotate()

size_t Fil_shard::encryption_rotate ( size_t *  rotate_count)

Rotate the tablespace keys by new master key.

Parameters
[in,out]rotate_countA cumulative count of all tablespaces rotated in the Fil_system.
Returns
the number of tablespaces that failed to rotate.

◆ file_close_to_free()

void Fil_shard::file_close_to_free ( fil_node_t file,
fil_space_t space 
)

Prepare to free a file object from a tablespace memory cache.

Parameters
[in,out]fileTablespace file
[in]spacetablespace

◆ flush_file_spaces()

void Fil_shard::flush_file_spaces ( )

Flush to disk the writes in file spaces possibly cached by the OS (note: spaces of type FIL_TYPE_TEMPORARY are skipped)

◆ get_AIO_mode()

AIO_mode Fil_shard::get_AIO_mode ( const IORequest req_type,
bool  sync 
)
staticprivate

Get the AIO mode.

Parameters
[in]req_typeIO request type
[in]synctrue if Synchronous IO return the AIO mode

◆ get_file_for_io()

dberr_t Fil_shard::get_file_for_io ( fil_space_t space,
page_no_t page_no,
fil_node_t *&  file 
)
staticprivate

Get the file name for IO and the local offset within that file.

Parameters
[in,out]spaceTablespace for IO
[in,out]page_noThe relative page number in the file
[out]fileFile node if DB_SUCCESS, NULL if not
Return values
DB_SUCCESSif the file is found with the page_no
DB_ERRORif the file is not found or does not contain the page. in this case file == nullptr

◆ get_file_size()

dberr_t Fil_shard::get_file_size ( fil_node_t file,
bool  read_only_mode 
)
private

First we open the file in the normal mode, no async I/O here, for simplicity.

Then do some checks, and close the file again. NOTE that we could not use the simple file read function os_file_read() in Windows to read from a file opened for async I/O!

Parameters
[in,out]fileGet the size of this file
[in]read_only_modetrue if read only mode set
Returns
DB_SUCCESS or error

Add some tolerance when the tablespace is upgraded. If an empty general tablespace is created in 5.7, and then upgraded to 8.0, then its size changes from FIL_IBD_FILE_INITIAL_SIZE_5_7 pages to FIL_IBD_FILE_INITIAL_SIZE-1.

◆ get_reserved_space()

fil_space_t * Fil_shard::get_reserved_space ( space_id_t  space_id)
private

We keep system tablespace files always open; this is important in preventing deadlocks in this module, as a page read completion often performs another read from the insert buffer.

The insert buffer is in tablespace TRX_SYS_SPACE, and we cannot end up waiting in this function.

Parameters
[in]space_idTablespace ID to look up
Returns
tablespace instance

◆ get_space_by_id()

fil_space_t * Fil_shard::get_space_by_id ( space_id_t  space_id) const

Fetch the fil_space_t instance that maps to space_id.

Parameters
[in]space_idTablespace ID to lookup
Returns
tablespace instance or nullptr if not found.

◆ get_space_by_id_from_map()

fil_space_t * Fil_shard::get_space_by_id_from_map ( space_id_t  space_id) const
inline

Fetch the fil_space_t instance that maps to space_id.

Does not look through system reserved spaces.

Parameters
[in]space_idTablespace ID to lookup
Returns
tablespace instance or nullptr if not found.

◆ get_space_by_name()

fil_space_t * Fil_shard::get_space_by_name ( const char *  name) const
inline

Fetch the fil_space_t instance that maps to the name.

Parameters
[in]nameTablespace name to lookup
Returns
tablespace instance or nullptr if not found.

◆ ibd_open_for_recovery()

fil_load_status Fil_shard::ibd_open_for_recovery ( space_id_t  space_id,
const std::string &  path,
fil_space_t *&  space 
)

Open an ibd tablespace and add it to the InnoDB data structures.

This is similar to fil_ibd_open() except that it is used while processing the redo and DDL log, so the data dictionary is not available and very little validation is done. The tablespace name is extracted from the dbname/tablename.ibd portion of the filename, which assumes that the file is a file-per-table tablespace. Any name will do for now. General tablespace names will be read from the dictionary after it has been recovered. The tablespace flags are read at this time from the first page of the file in validate_for_recovery().

Parameters
[in]space_idtablespace ID
[in]pathpath/to/databasename/tablename.ibd
[out]spacethe tablespace, or nullptr on error
Returns
status of the operation

◆ id()

size_t Fil_shard::id ( ) const
inline
Returns
the shard ID

◆ is_deleted()

bool Fil_shard::is_deleted ( space_id_t  space_id)
inline

Check if a particular space_id for a page in the buffer pool has been deleted recently.

Its space_id will be found in m_deleted_spaces until Fil:shard::checkpoint removes the fil_space_t from Fil_system.

Parameters
[in]space_idTablespace ID to check.
Returns
true if this space_id is in the list of recently deleted spaces.

◆ iterate()

dberr_t Fil_shard::iterate ( Fil_iterator::Function f)

Iterate through all persistent tablespace files (FIL_TYPE_TABLESPACE) returning the nodes via callback function f.

Iterate through all persistent tablespace files (FIL_TYPE_TABLESPACE) returning the nodes via callback function cbk.

Parameters
[in]fCallback
Returns
any error returned by the callback function.

◆ mutex_owned()

bool Fil_shard::mutex_owned ( ) const
inline
Returns
true if the mutex is owned.

◆ mutex_release()

void Fil_shard::mutex_release ( ) const
inline

Release the mutex.

◆ needs_encryption_rotate()

bool Fil_shard::needs_encryption_rotate ( fil_space_t space)

Determine if the tablespace needs encryption rotation.

Parameters
[in]spacetablespace to rotate
Returns
true if the tablespace needs to be rotated, false if not.

◆ open_file()

bool Fil_shard::open_file ( fil_node_t file)

Open a file of a tablespace.

The caller must own the shard mutex.

Parameters
[in,out]fileTablespace file
Returns
false if the file can't be opened, otherwise true

◆ open_system_tablespaces()

void Fil_shard::open_system_tablespaces ( size_t  max_n_open,
size_t *  n_open 
)

Open all the system files.

Parameters
[in]max_n_openMaximum number of open files allowed
[in,out]n_openCurrent number of open files

◆ operator=() [1/2]

Fil_shard & Fil_shard::operator= ( const Fil_shard )
privatedelete

◆ operator=() [2/2]

Fil_shard & Fil_shard::operator= ( Fil_shard &&  )
privatedelete

◆ prepare_file_for_io()

bool Fil_shard::prepare_file_for_io ( fil_node_t file)

Prepares a file for I/O.

Opens the file if it is closed. Updates the pending I/O's field in the file and the system appropriately. Takes the file off the LRU list if it is in the LRU list.

Parameters
[in]fileTablespace file for IO
Returns
false if the file can't be opened, otherwise true

◆ prepare_to_free_file()

void Fil_shard::prepare_to_free_file ( fil_node_t file)

Prepare to free a file.

Remove from the unflushed list if there are no pending flushes.

Parameters
[in,out]fileFile instance to free

◆ purge()

void Fil_shard::purge ( )
inline

Purge entries from m_deleted_spaces that are no longer referenced by a buffer pool page.

This is no longer required to be done during checkpoint - this is done here for historical reasons - it has to be done periodically somewhere.

◆ remove_from_LRU()

void Fil_shard::remove_from_LRU ( fil_node_t file)

Remove the file node from the LRU list.

Parameters
[in,out]fileFile for the tablespace

◆ remove_from_unflushed_list()

void Fil_shard::remove_from_unflushed_list ( fil_space_t space)

If the tablespace is on the unflushed list and there are no pending flushes then remove from the unflushed list.

Parameters
[in,out]spaceTablespace to remove

◆ space_acquire()

bool Fil_shard::space_acquire ( fil_space_t space)
inline

Acquire a tablespace to prevent it from being dropped concurrently.

The thread must call Fil_shard::fil_space_release() when the operation is done.

Parameters
[in]spacetablespace to acquire
Returns
true if not space->stop_new_ops

◆ space_add()

void Fil_shard::space_add ( fil_space_t space)

Map the space ID and name to the tablespace instance.

Parameters
[in]spaceTablespace instance

◆ space_check_exists()

bool Fil_shard::space_check_exists ( space_id_t  space_id,
const char *  name,
bool  print_err,
bool  adjust_space 
)

Returns true if a matching tablespace exists in the InnoDB tablespace memory cache.

Parameters
[in]space_idTablespace ID
[in]nameTablespace name used in fil_space_create().
[in]print_errPrint detailed error information to the error log if a matching tablespace is not found from memory.
[in]adjust_spaceWhether to adjust space id on mismatch
Returns
true if a matching tablespace exists in the memory cache

◆ space_check_pending_operations()

ulint Fil_shard::space_check_pending_operations ( fil_space_t space,
ulint  count 
) const
private

Check for pending operations.

Parameters
[in]spacetablespace
[in]countnumber of attempts so far
Returns
0 if no pending operations else count + 1.

◆ space_create()

fil_space_t * Fil_shard::space_create ( const char *  name,
space_id_t  space_id,
uint32_t  flags,
fil_type_t  purpose 
)

Create a space memory object and put it to the fil_system hash table.

The tablespace name is independent from the tablespace file-name. Error messages are issued to the server log.

Parameters
[in]nameTablespace name
[in]space_idTablespace identifier
[in]flagsTablespace flags
[in]purposeTablespace purpose
Returns
pointer to created tablespace, to be filled in with fil_node_create()
Return values
nullptron failure (such as when the same tablespace exists)

◆ space_delete()

dberr_t Fil_shard::space_delete ( space_id_t  space_id,
buf_remove_t  buf_remove 
)

Deletes an IBD or IBU tablespace.

The tablespace must be cached in the memory cache. This will delete the datafile, fil_space_t & fil_node_t entries from the file_system_t cache.

Parameters
[in]space_idTablespace ID
[in]buf_removeSpecify the action to take on the pages for this table in the buffer pool.
Returns
DB_SUCCESS, DB_TABLESPCE_NOT_FOUND or DB_IO_ERROR

◆ space_detach()

void Fil_shard::space_detach ( fil_space_t space)

Detach a space object from the tablespace memory cache and closes the tablespace files but does not delete them.

There must not be any pending I/O's or flushes on the files.

Parameters
[in,out]spacetablespace

◆ space_extend()

bool Fil_shard::space_extend ( fil_space_t space,
page_no_t  size 
)

Try to extend a tablespace if it is smaller than the specified size.

Parameters
[in,out]spacetablespace
[in]sizedesired size in pages
Returns
whether the tablespace is at least as big as requested

◆ space_flush()

void Fil_shard::space_flush ( space_id_t  space_id)

Flushes to disk possible writes cached by the OS.

If the space does not exist or is being dropped, does not do anything.

Parameters
[in]space_idfile space ID (id of tablespace of the database)

◆ space_free()

fil_space_t * Fil_shard::space_free ( space_id_t  space_id)

Frees a space object from the tablespace memory cache.

Closes a tablespaces' files but does not delete them. There must not be any pending I/O's or flushes on the files.

Parameters
[in]space_idTablespace ID
Returns
fil_space_t instance on success or nullptr

◆ space_free_low()

void Fil_shard::space_free_low ( fil_space_t *&  space)
static

Free a tablespace object on which fil_space_detach() was invoked.

There must not be any pending I/O's or flushes on the files.

Parameters
[in,out]spacetablespace

◆ space_is_flushed()

bool Fil_shard::space_is_flushed ( const fil_space_t space)

Checks if all the file nodes in a space are flushed.

The caller must hold the fil_system mutex.

Parameters
[in]spaceTablespace to check
Returns
true if all are flushed

◆ space_load()

fil_space_t * Fil_shard::space_load ( space_id_t  space_id)

Opens the files associated with a tablespace and returns a pointer to the fil_space_t that is in the memory cache associated with a space id.

Open the files associated with a tablespace, make sure the size of the tablespace is read from the header page, and return a pointer to the fil_space_t that is in the memory cache associated with the given space id.

Parameters
[in]space_idGet the tablespace instance or this ID
Returns
file_space_t pointer, nullptr if space not found

◆ space_open()

bool Fil_shard::space_open ( space_id_t  space_id)

Open each file of a tablespace if not already open.

Parameters
[in]space_idtablespace identifier
Return values
trueif all file nodes were opened
falseon failure

◆ space_prepare_for_delete()

void Fil_shard::space_prepare_for_delete ( fil_space_t space)
inlinenoexcept

Move the space to the deleted list and remove from the default lookup set.

Parameters
[in,out]spaceSpace instance to delete.

◆ space_prepare_for_truncate()

dberr_t Fil_shard::space_prepare_for_truncate ( space_id_t  space_id,
fil_space_t *&  space 
)
private

Prepare for truncating a single-table tablespace.

1) Wait for pending operations on the tablespace to stop; 2) Remove all insert buffer entries for the tablespace;

Parameters
[in]space_idTablespace ID
[out]spaceInstance that maps to the space ID.
Returns
DB_SUCCESS or error

◆ space_release()

void Fil_shard::space_release ( fil_space_t space)

Release a tablespace acquired with Fil_shard::space_acquire().

Parameters
[in,out]spacetablespace to release

◆ space_remove_from_lookup_maps()

void Fil_shard::space_remove_from_lookup_maps ( space_id_t  space_id)
inline

Remove the fil_space_t instance from the maps used to search for it.

Parameters
[in]space_idTablespace ID to remove from maps.

◆ space_rename()

dberr_t Fil_shard::space_rename ( space_id_t  space_id,
const char *  old_path,
const char *  new_name,
const char *  new_path_in 
)

Rename a single-table tablespace.

The tablespace must exist in the memory cache.

Parameters
[in]space_idTablespace ID
[in]old_pathOld file name
[in]new_nameNew tablespace name in the schema/space
[in]new_path_inNew file name, or nullptr if it is located in the normal data directory
Returns
InnoDB error code

◆ space_truncate()

bool Fil_shard::space_truncate ( space_id_t  space_id,
page_no_t  size_in_pages 
)

Truncate the tablespace to needed size.

Parameters
[in]space_idTablespace ID to truncate
[in]size_in_pagesTruncate size.
Returns
true if truncate was successful.

◆ update_space_name_map()

void Fil_shard::update_space_name_map ( fil_space_t space,
const char *  new_name 
)

Remap the tablespace to the new name.

Parameters
[in]spaceTablespace instance, with old name.
[in]new_nameNew tablespace name

◆ validate()

void Fil_shard::validate ( ) const

Validate a shard.

◆ validate_space_reference_count()

void Fil_shard::validate_space_reference_count ( Space_References buffer_pool_references)

Check that each fil_space_t::m_n_ref_count in this shard matches the number of pages counted in the buffer pool.

Parameters
[in]buffer_pool_referencesMap of spaces instances to the count of their pages in the buffer pool.

◆ wait_for_pending_operations()

dberr_t Fil_shard::wait_for_pending_operations ( space_id_t  space_id,
fil_space_t *&  space,
char **  path 
) const

Wait for pending operations on a tablespace to stop.

Parameters
[in]space_idTablespace ID
[out]spacetablespace instance in memory
[out]pathtablespace path
Returns
DB_SUCCESS or DB_TABLESPACE_NOT_FOUND.

◆ write_completed()

void Fil_shard::write_completed ( fil_node_t file)
private

Note that a write IO has completed.

Parameters
[in,out]fileFile on which a write was completed

Friends And Related Function Documentation

◆ Fil_system

friend class Fil_system
friend

Member Data Documentation

◆ m_deleted_spaces

Deleted_spaces Fil_shard::m_deleted_spaces
private

Deleted tablespaces.

All pages for these tablespaces in the buffer pool will be passively deleted. They need not be written. Once the reference count is zero, this fil_space_t can be deleted from m_deleted_spaces and removed from memory. All reads and writes must be done under the shard mutex.

◆ m_id

const size_t Fil_shard::m_id
private

Fil_shard ID.

◆ m_LRU

File_list Fil_shard::m_LRU
private

Base node for the LRU list of the most recently used open files with no pending I/O's; if we start an I/O on the file, we first remove it from this list, and return it to the start of the list when the I/O ends; the system tablespace file is not put to this list: it is opened after the startup, and kept open until shutdown.

◆ m_modification_counter

int64_t Fil_shard::m_modification_counter
private

When we write to a file we increment this by one.

◆ m_mutex

ib_mutex_t Fil_shard::m_mutex
mutableprivate

Mutex protecting this shard.

◆ m_names

Names Fil_shard::m_names
private

Tablespace instances hashed on the space name.

◆ m_spaces

Spaces Fil_shard::m_spaces
private

Tablespace instances hashed on the space id.

◆ m_unflushed_spaces

Space_list Fil_shard::m_unflushed_spaces
private

Base node for the list of those tablespaces whose files contain unflushed writes; those spaces have at least one file where modification_counter > flush_counter.


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