![]() |
MySQL 26.7.0
Source Code Documentation
|
The tablespace memory cache. More...
Public Types | |
| using | Fil_shards = std::vector< Fil_shard * > |
Public Member Functions | |
| Fil_system (size_t n_shards, size_t max_open) | |
| Constructor. More... | |
| ~Fil_system () | |
| Destructor. More... | |
| fil_space_t * | space_acquire (space_id_t space_id, bool silent) |
| Acquire a tablespace when it could be dropped concurrently. More... | |
| dberr_t | prepare_open_for_business (bool read_only_mode) |
| Update the DD if any files were moved to a new location. 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... | |
| void | purge () |
| Clean up the shards. More... | |
| size_t | count_undo_deleted (space_id_t undo_num) |
| 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) noexcept |
| Check if a particular undo space_id for a page in the buffer pool has been deleted recently. More... | |
| fil_space_t * | get_space_by_name (const char *name) |
| Fetch the fil_space_t instance that maps to the name. More... | |
| bool | is_greater_than_max_id (space_id_t space_id) const |
| Check a space ID against the maximum known tablespace ID. More... | |
| bool | update_maximum_space_id (space_id_t space_id) |
| Update the maximum known space ID if it's smaller than max_id. More... | |
| bool | assign_new_space_id (space_id_t *space_id) |
| Assigns a new space id for a new single-table tablespace. More... | |
| void | wait_while_ios_in_progress () const |
| Allows other threads to advance work while we wait for I/Os to complete. More... | |
| bool | close_file_in_all_LRU () |
| Tries to close a file in all the LRU lists. More... | |
| void | close_all_files () |
| Close all open files. More... | |
| size_t | get_minimum_limit_for_open_files (size_t n_files_not_belonging_in_lru) const |
| Returns minimum open files limit to be set to allow the specified number of non-LRU files opened. More... | |
| bool | set_open_files_limit (size_t &new_max_open_files) |
| Changes the maximum opened files limit. More... | |
| size_t | get_open_files_limit () const |
| Returns maximum number of allowed opened files. More... | |
| dberr_t | iterate (Fil_iterator::Function &f) |
| Iterate through all persistent tablespace files (FIL_TYPE_TABLESPACE) returning the nodes via callback function cbk. More... | |
| size_t | encryption_rotate () |
| Rotate the tablespace keys by new master key. More... | |
| void | encryption_reencrypt (const std::vector< space_id_t > &sid_vector) |
| Reencrypt tablespace keys by current master key. More... | |
| bool | lookup_for_recovery (space_id_t space_id) |
| Lookup the tablespace ID for recovery and DDL log apply. More... | |
| dberr_t | open_for_recovery (space_id_t space_id) |
| Open a tablespace that has a redo log record to apply. More... | |
| void | moved (dd::Object_id object_id, space_id_t space_id, const char *space_name, const std::string &old_path, const std::string &new_path, bool dd_flag_missing) |
| Note that a file has been relocated. More... | |
| Fil_shard * | shard_by_id (space_id_t space_id) const |
| Fil_shard by space ID. More... | |
| void | mutex_acquire_all () const |
| Acquire all the mutexes. More... | |
| void | mutex_release_all () const |
| Release all the mutexes. More... | |
| bool | validate () const |
| Checks the consistency of the tablespace cache. More... | |
| bool | mutex_owned_all () const |
| Check if all mutexes are owned. More... | |
| dberr_t | rename_tablespace_name_in_cache (space_id_t space_id, const char *old_name, const char *new_name) |
| Rename a tablespace in tablespace cache. More... | |
Static Public Member Functions | |
| static size_t | get_limit_for_non_lru_files (size_t open_files_limit) |
| Returns maximum number of allowed non-LRU files opened for a specified open files limit. More... | |
| static bool | space_belongs_in_LRU (const fil_space_t *space) |
| Determines if a file belongs to the least-recently-used list. More... | |
Private Member Functions | |
| 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_system (Fil_system &&)=delete | |
| Fil_system (const Fil_system &)=delete | |
| Fil_system & | operator= (const Fil_system &)=delete |
Private Attributes | |
| Fil_shards | m_shards |
| Fil_shards managed. More... | |
| fil::detail::Open_files_limit | m_open_files_limit |
| std::atomic< space_id_t > | m_max_assigned_id |
| Maximum space id in the existing tables, or assigned during the time mysqld has been up; at an InnoDB startup we scan the data dictionary and set here the maximum of the space id's of the tables there. More... | |
| dd_fil::Tablespaces | m_moved |
| List of tablespaces that have been relocated. More... | |
| std::mutex | m_moved_mutex |
| Mutex protecting the list of relocated tablespaces. More... | |
| std::atomic_size_t | m_next_shard_to_close_from_LRU {} |
| Next index (modulo number of shards) to try to close a file from the LRU list to distribute closures evenly between the shards. More... | |
| std::atomic_size_t | m_n_files_not_belonging_in_lru {} |
| Current number of files that are not belonging in LRU. More... | |
| ib::Throttler | m_MANY_NON_LRU_FILES_OPENED_throttler {} |
| Throttles messages about high files not belonging in LRU count, the warning ER_IB_WARN_MANY_NON_LRU_FILES_OPENED. More... | |
| ib::Throttler | m_TRYING_TO_OPEN_FILE_FOR_LONG_TIME_throttler {} |
| Throttles messages about long waiting for opened files limit, the warning ER_IB_MSG_TRYING_TO_OPEN_FILE_FOR_LONG_TIME. More... | |
| ib::Throttler | m_ACCESSING_NONEXISTINC_SPACE_throttler {} |
| Throttles messages about accessing space that was already removed, the warning ACCESSING_NONEXISTINC_SPACE. More... | |
Friends | |
| class | Fil_shard |
The tablespace memory cache.
| using Fil_system::Fil_shards = std::vector<Fil_shard *> |
| Fil_system::Fil_system | ( | size_t | n_shards, |
| size_t | max_open | ||
| ) |
Constructor.
| [in] | n_shards | Number of shards to create |
| [in] | max_open | Maximum number of open files |
| Fil_system::~Fil_system | ( | ) |
Destructor.
|
privatedelete |
|
privatedelete |
| bool Fil_system::assign_new_space_id | ( | space_id_t * | space_id | ) |
Assigns a new space id for a new single-table tablespace.
This works simply by incrementing the global counter. If 4 billion ids is not enough, we may need to recycle ids.
| [out] | space_id | Set this to the new tablespace ID |
| void Fil_system::close_all_files | ( | ) |
Close all open files.
| bool Fil_system::close_file_in_all_LRU | ( | ) |
Tries to close a file in all the LRU lists.
The caller must hold the mutex.
|
inline |
Count how many truncated undo space IDs are still tracked in the buffer pool and the file_system cache.
| [in] | undo_num | undo tablespace number. |
| void Fil_system::encryption_reencrypt | ( | const std::vector< space_id_t > & | sid_vector | ) |
Reencrypt tablespace keys by current master key.
| size_t Fil_system::encryption_rotate | ( | ) |
Rotate the tablespace keys by new master key.
| void Fil_system::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)
|
static |
Returns maximum number of allowed non-LRU files opened for a specified open files limit.
| size_t Fil_system::get_minimum_limit_for_open_files | ( | size_t | n_files_not_belonging_in_lru | ) | const |
Returns minimum open files limit to be set to allow the specified number of non-LRU files opened.
This is inverse function for the get_limit_for_non_lru_files.
|
inline |
Returns maximum number of allowed opened files.
|
inline |
Fetch the fil_space_t instance that maps to the name.
| [in] | name | Tablespace name to lookup |
|
private |
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().
| [in] | space_id | tablespace ID |
| [in] | path | path/to/databasename/tablename.ibd |
| [out] | space | the tablespace, or nullptr on error |
|
inlinenoexcept |
Check if a particular undo space_id for a page in the buffer pool has been deleted recently.
Its space_id will be found in Fil_shard::m_deleted_spaces until Fil:shard::checkpoint removes the fil_space_t from Fil_system.
| [in] | space_id | Tablespace ID to check. |
|
inline |
Check a space ID against the maximum known tablespace ID.
| [in] | space_id | Tablespace ID to check |
| dberr_t Fil_system::iterate | ( | Fil_iterator::Function & | f | ) |
Iterate through all persistent tablespace files (FIL_TYPE_TABLESPACE) returning the nodes via callback function cbk.
| [in] | f | Callback |
| bool Fil_system::lookup_for_recovery | ( | space_id_t | space_id | ) |
Lookup the tablespace ID for recovery and DDL log apply.
| [in] | space_id | Tablespace ID to lookup |
|
inline |
Note that a file has been relocated.
| [in] | object_id | Server DD tablespace ID |
| [in] | space_id | InnoDB tablespace ID |
| [in] | space_name | Tablespace name |
| [in] | old_path | Path to the old location |
| [in] | new_path | Path scanned from disk |
| [in] | dd_flag_missing | This tablespace is outside default data directory but missing the DD_TABLE_DATA_DIRECTORY flag. This can happen before versions 8.0.37/8.4.1/9.0.0 |
|
inline |
Acquire all the mutexes.
|
inline |
Check if all mutexes are owned.
|
inline |
Release all the mutexes.
| dberr_t Fil_system::open_for_recovery | ( | space_id_t | space_id | ) |
Open a tablespace that has a redo log record to apply.
| [in] | space_id | Tablespace ID |
|
privatedelete |
| dberr_t Fil_system::prepare_open_for_business | ( | bool | read_only_mode | ) |
Update the DD if any files were moved to a new location.
Free the Tablespace_files instance.
| [in] | read_only_mode | true if InnoDB is started in read only mode. |
|
inline |
Clean up the shards.
| dberr_t Fil_system::rename_tablespace_name_in_cache | ( | space_id_t | space_id, |
| const char * | old_name, | ||
| const char * | new_name | ||
| ) |
Rename a tablespace in tablespace cache.
Use the space_id to find the shard. This operation updates the tablespace name in cache and doesn't produce any persistent log (REDO/DDL_LOG etc.) and doesn't change any thing on disk or in DD.
| [in] | space_id | tablespace ID |
| [in] | old_name | old tablespace name |
| [in] | new_name | new tablespace name |
| bool Fil_system::set_open_files_limit | ( | size_t & | new_max_open_files | ) |
Changes the maximum opened files limit.
| [in,out] | new_max_open_files | New value for the open files limit. If the limit cannot be changed, the value is changed to a minimum value recommended. If there are any concurrent calls to set_open_files_limit in progress, setting the limit will fail and the new_max_open_files will be set to 0. |
|
inline |
Fil_shard by space ID.
| [in] | space_id | Tablespace ID |
| fil_space_t * Fil_system::space_acquire | ( | space_id_t | space_id, |
| bool | silent | ||
| ) |
Acquire a tablespace when it could be dropped concurrently.
Used by background threads that do not necessarily hold proper locks for concurrency control.
| [in] | space_id | Tablespace ID |
| [in] | silent | Whether to silently ignore missing tablespaces |
|
static |
Determines if a file belongs to the least-recently-used list.
| [in] | space | Tablespace to check |
|
inline |
Update the maximum known space ID if it's smaller than max_id.
| [in] | space_id | Value to set if it's greater |
| bool Fil_system::validate | ( | ) | const |
Checks the consistency of the tablespace cache.
|
inline |
Allows other threads to advance work while we wait for I/Os to complete.
|
friend |
|
private |
Throttles messages about accessing space that was already removed, the warning ACCESSING_NONEXISTINC_SPACE.
|
private |
Throttles messages about high files not belonging in LRU count, the warning ER_IB_WARN_MANY_NON_LRU_FILES_OPENED.
|
private |
Maximum space id in the existing tables, or assigned during the time mysqld has been up; at an InnoDB startup we scan the data dictionary and set here the maximum of the space id's of the tables there.
|
private |
List of tablespaces that have been relocated.
We need to update the DD when it is safe to do so.
|
private |
Mutex protecting the list of relocated tablespaces.
|
private |
Current number of files that are not belonging in LRU.
This includes redo and temporary tablespaces, but not files that were temporarily removed from the LRU for I/O.
|
private |
Next index (modulo number of shards) to try to close a file from the LRU list to distribute closures evenly between the shards.
|
private |
|
private |
Fil_shards managed.
|
private |
Throttles messages about long waiting for opened files limit, the warning ER_IB_MSG_TRYING_TO_OPEN_FILE_FOR_LONG_TIME.