MySQL 26.7.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 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...
 
fil_space_tspace_add (ut::unique_ptr< 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, bool is_write_io)
 Updates the data structures when an I/O operation finishes. More...
 
dberr_t prepare_file_for_io (fil_node_t *file, bool validate_first_page)
 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 new_min_size_in_pages)
 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...
 
dberr_t 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...
 
ut::Expected< fil_space_t * > space_open (space_id_t space_id)
 Looks up the tablespace, acquires the space, opens each node of a tablespace if not already open, validates the first page if it was not validated yet and fills the FSP-related cache if it was not filled yet. 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)
 Deletes an IBD or IBU tablespace. More...
 
bool space_truncate (space_id_t space_id, page_no_t size_in_pages)
 Basically recreates the tablespace`s only node and set it to the needed size in place. 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 type, bool sync, const page_id_t &page_id, const page_size_t &page_size, ulint len, byte *buf, buf_page_t *bpage, std::function< dberr_t(dberr_t)> postprocess_result)
 Read or write data for a single page from a file. 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...
 
dberr_t create_node (const char *name, fil_space_t *space, bool is_raw, page_no_t max_pages)
 Attach a node to a tablespace. More...
 
void validate () const
 Validate a shard. More...
 

Static Public Member Functions

static ut::unique_ptr< fil_space_tspace_create (const char *name, space_id_t space_id, uint32_t flags, fil_type_t purpose)
 Create a space memory object. 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

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...
 
 Fil_shard (Fil_shard &&)=delete
 
 Fil_shard (const Fil_shard &)=delete
 
Fil_shardoperator= (Fil_shard &&)=delete
 
Fil_shardoperator= (const Fil_shard &)=delete
 

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 m_modification_counter > m_flush_counter. 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,
bool  is_write_io 
)

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]is_write_ioMarks the file as modified if it is write IO.

◆ 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()

dberr_t Fil_shard::create_node ( const char *  name,
fil_space_t space,
bool  is_raw,
page_no_t  max_pages 
)

Attach a node to a tablespace.

Parameters
[in]nameFile name of a file. The file can't be open.
[in,out]spaceTablespace to attach to, must not be null.
[in]is_rawwhether this is a raw device or partition
[in]max_pagesmaximum number of pages in file

◆ do_io()

dberr_t Fil_shard::do_io ( const IORequest::Type  type,
bool  sync,
const page_id_t page_id,
const page_size_t page_size,
ulint  len,
byte buf,
buf_page_t bpage,
std::function< dberr_t(dberr_t)>  postprocess_result 
)

Read or write data for a single page from a file.

Parameters
[in]typeIO type
[in]syncIf true then do synchronous IO
[in]page_idPage id to read or write.
[in]page_sizeStructure with information on logical and physical page size in the affected tablespace.
[in]lenSize of the buf supplied. It always has to be a multiply of OS block size (UNIV_SECTOR_SIZE). In case of write of an already compressed data, it is a length of the compressed data buffer. Otherwise it should be page_size.physical(). Actual number of bytes written can be smaller if the tablespace has compression enabled and data was not compressed already.
[in,out]bufA buffer where to store read data or from where to write. Data from this buffer might be copied and the copy transformed before writing it. It must be aligned in memory to OS block size (UNIV_SECTOR_SIZE). Additionally, for reads, it must be aligned to physical page size, too. The memory pointed is managed by the caller and must remain valid until the call returns if sync is true, or until the postprocess_result callback begins execution.
[in]bpagePointer to the page descriptor in the buffer pool. This can be nullptr only if we assure the tablespace can't be deleted in meantime. If this is nullptr, the page with this page_id can't be in the buffer pool, as it risks race condition with a Buffer Pool-induced page flush.
[in]postprocess_resultA callback to be called exactly once when the result of this IO operation is known. It may be a success if the read or write succeeded or a subset of dberr_t errors if the write or read could not be executed or if it failed. It can be called synchronously in this thread before returning from this method, or can be executed asynchronously from another thread, when sync is false, before or after this call returns.
Returns
error code
Return values
DB_SUCCESSon success
DB_TABLESPACE_DELETEDif the tablespace does not exist Note: this is not an exhaustive list of errors returned.

◆ 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_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 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

The tablespace_scanning is not present in MEB, and for MEB it is enough to do the first read for the minimum possible page size, which will be repeated then in Datafile::validate_for_recovery() with a correct page size parsed from the flags.

◆ 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()

dberr_t 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
Return values
DB_SUCCESSif file is already opened or was opened.
DB_TABLESPACE_DELETEDif the tablespace is already deleted.
DB_CANNOT_OPEN_FILEon file opening error.

◆ 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()

dberr_t Fil_shard::prepare_file_for_io ( fil_node_t file,
bool  validate_first_page 
)

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. Caller needs to call the complete_io() to pair with a successful prepare_file_for_io() call. In case of error, the complete_io() don't have to, and actually can't be called.

Parameters
[in]fileTablespace file for IO
[in]validate_first_pageFalse during early recovery, to not use first page for size and other verification.
Returns
DB_SUCCESS if the file is opened, first page validated and is ready for IO and caller needs to call complete_io() eventually. Any other error value means the file might be opened or not, but the complete_io() must not be called to complement this call.

◆ 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()

fil_space_t * Fil_shard::space_add ( ut::unique_ptr< fil_space_t space)

Map the space ID and name to the tablespace instance.

If a space with the same name or ID is mapped already, it does nothing and return nullptr.

Parameters
[in]spaceTablespace instance
Returns
Non-null pointer from the supplied space iff supplied space was added to the space mappings, that is, there were no conflicts in name or ID in the mappings.

◆ 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()

ut::unique_ptr< fil_space_t > Fil_shard::space_create ( const char *  name,
space_id_t  space_id,
uint32_t  flags,
fil_type_t  purpose 
)
static

Create a space memory object.

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

◆ space_delete()

dberr_t Fil_shard::space_delete ( space_id_t  space_id)

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. The pages of this space that are cached in the BufferPool will remain untouched, will be discarded lazily when accessed or encountered in lists like flush list or LRU, as they will be visible as being stale.

Parameters
[in]space_idTablespace ID
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  new_min_size_in_pages 
)

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

Parameters
[in,out]spacetablespace
[in]new_min_size_in_pagesDesired minimum new 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. The caller must own the shard mutex. The mutex might be released and re-acquired before returning.

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_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_open()

ut::Expected< fil_space_t * > Fil_shard::space_open ( space_id_t  space_id)

Looks up the tablespace, acquires the space, opens each node of a tablespace if not already open, validates the first page if it was not validated yet and fills the FSP-related cache if it was not filled yet.

A fil_space_release() needs to be called on the returned space.

Parameters
[in]space_idTablespace ID
Returns
The opened and acquired space object or an error if tablespace is missing, being deleted, its nodes can't be opened or validation resulted in errors.

◆ 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 
)

Basically recreates the tablespace`s only node and set it to the needed size in place.

The content of the prefix up to new size is overwritten with zeros.

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_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 m_modification_counter > m_flush_counter.


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