![]() |
MySQL 26.7.0
Source Code Documentation
|
The tablespace memory cache. More...
#include <errno.h>#include <fcntl.h>#include <sys/types.h>#include <mysql/service_thd_wait.h>#include "scope_guard.h"#include "my_config.h"#include "detail/fil/open_files_limit.h"#include "arch0page.h"#include "btr0btr.h"#include "buf0buf.h"#include "buf0flu.h"#include "clone0api.h"#include "dict0boot.h"#include "dict0dd.h"#include "dict0dict.h"#include "fil0fil.h"#include "fil0innodb_pages_persistence.h"#include "fil0innodb_tablespaces_nodes.h"#include "fil0tablespace_node_handle_interface.h"#include "fil0tablespace_scan.h"#include "fil0tablespaces_nodes_interface.h"#include "fsp0file.h"#include "fsp0fsp.h"#include "fsp0space.h"#include "fsp0sysspace.h"#include "ha_prototypes.h"#include "hash0hash.h"#include "log0buf.h"#include "log0chkp.h"#include "log0handler_interface.h"#include "log0helpers.h"#include "log0recv.h"#include "mach0data.h"#include "mem0mem.h"#include "mtr0log.h"#include "my_dbug.h"#include "os0file.h"#include "page0zip.h"#include "sql/mysqld.h"#include "srv0srv.h"#include "srv0start.h"#include "trx0purge.h"#include "univ.i"#include "ut0dbg.h"#include "ut0new.h"#include "buf0lru.h"#include "ibuf0ibuf.h"#include "mysql/components/library_mysys/my_system.h"#include "os0event.h"#include "row0mysql.h"#include "sql_backup_lock.h"#include "sql_class.h"#include "sync0sync.h"#include "os0thread-create.h"#include "current_thd.h"#include <array>#include <fstream>#include <functional>#include <list>#include <mutex>#include <thread>#include <tuple>#include <unordered_map>Classes | |
| struct | dd_fil::Moved |
| struct | Char_Ptr_Hash |
| Hash a NUL terminated 'string'. More... | |
| struct | Char_Ptr_Compare |
| Compare two 'strings'. More... | |
| class | Fil_shard |
| class | Fil_system |
| The tablespace memory cache. More... | |
| struct | Fil_page_iterator |
Namespaces | |
| namespace | dd_fil |
| Used for collecting the data in boot_tablespaces() | |
| namespace | ib |
| namespace | ib::fil |
Macros | |
| #define | mutex_acquire() acquire(__LINE__) |
| We want to store the line number from where it was called. More... | |
| #define | fil_report_invalid_page_access(b, s, n, l, t) fil_report_invalid_page_access_low((b), (s), (n), (l), (t), __LINE__) |
| #define | PAGE_TYPE(x) |
Typedefs | |
| using | dd_fil::Tablespaces = std::vector< Moved > |
Enumerations | |
| enum | fil_load_status { FIL_LOAD_OK , FIL_LOAD_ID_CHANGED , FIL_LOAD_NOT_FOUND , FIL_LOAD_INVALID , FIL_LOAD_MISMATCH , FIL_LOAD_DBWLR_CORRUPTION } |
| enum | fil_operation_t { FIL_OPERATION_DELETE , FIL_OPERATION_CLOSE } |
| File operations for tablespace. More... | |
Functions | |
| dberr_t | dict_stats_rename_table (const char *old_name, const char *new_name, char *errstr, size_t errstr_sz) |
| Renames a table in InnoDB persistent stats storage. More... | |
| size_t | fil_get_scan_threads (size_t num_files) |
| Calculate the number of threads that can be spawned to scan the given number of files taking into the consideration, number of cores available on the machine. More... | |
| static bool | fil_needs_flushes_for_durability (const fil_space_t *space) |
| Determine if flush is needed for durability. More... | |
| void | ib::fil::set_tablespaces_nodes (ut::unique_ptr< Tablespaces_nodes_interface > new_tablepsaces_nodes) |
| void | ib::fil::set_pages_persistence (ut::unique_ptr< Pages_persistence_interface > new_persistence) |
| Sets the implementation of the Pages_persistence_interface. More... | |
| static bool | is_fast_shutdown () |
| static bool | fil_op_replay_rename (fil_space_t *space, const std::string &old_name, const std::string &new_name) |
| Replay a file rename operation on space present in the fil subsystem cache, if it is possible to perform. More... | |
| static bool | fil_validate_skip () |
| Checks the consistency of the tablespace cache some of the time. More... | |
| bool | fil_validate () |
| Checks the consistency of the tablespace cache. More... | |
| static dberr_t | fil_read (const page_id_t &page_id, const page_size_t &page_size, byte *buf) |
| Reads data from a space to a buffer. More... | |
| static dberr_t | fil_write (const page_id_t &page_id, const page_size_t &page_size, ulint len, byte *buf) |
| Writes data to a space from a buffer. More... | |
| fil_space_t * | fil_space_get (space_id_t space_id) |
| Look up a tablespace. More... | |
| rw_lock_t * | fil_space_get_latch (space_id_t space_id) |
| Returns the latch of a file space. More... | |
| fil_type_t | fil_space_get_type (space_id_t space_id) |
| Gets the type of a file space. More... | |
| void | fil_space_set_imported (space_id_t space_id) |
| Note that a tablespace has been imported. More... | |
| void | fil_node_create (const char *name, fil_space_t *space, bool is_raw, page_no_t max_pages) |
| Attach a node to a tablespace. More... | |
| static bool | fil_space_free (space_id_t space_id, bool x_latched) |
| Frees a space object from the tablespace memory cache. More... | |
| fil_space_t * | fil_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. More... | |
| bool | fil_assign_new_space_id (space_id_t *space_id) |
| Assigns a new space id for a new single-table tablespace. More... | |
| char * | fil_space_get_first_path (space_id_t space_id) |
| Returns the path from the first fil_node_t found with this space ID. More... | |
| page_no_t | fil_space_get_size (space_id_t space_id) |
| Returns the size of the space in pages. More... | |
| page_no_t | fil_space_get_undo_initial_size (space_id_t space_id) |
| Returns the size of an undo space just after it was initialized. More... | |
| void | fil_space_set_undo_size (space_id_t space_id, bool use_current) |
| This is called for an undo tablespace after it has been initialized or opened. More... | |
| uint32_t | fil_space_get_flags (space_id_t space_id) |
| Returns the flags of the space. More... | |
| ut::Expected< fil_space_t * > | fil_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... | |
| void | fil_space_close (space_id_t space_id) |
| Close each file of a tablespace if open. More... | |
| const page_size_t | fil_space_get_page_size (space_id_t space_id, bool *found) |
| Returns the page size of the space and whether it is compressed or not. More... | |
| void | fil_init (ulint max_n_open) |
| Initializes the tablespace memory cache. More... | |
| bool | fil_open_files_limit_update (size_t &new_max_open_files) |
| Changes the maximum opened files limit. More... | |
| static void | fil_validate_space_reference_count (fil_space_t *space, Space_References &buffer_pool_references) |
| void | fil_close_all_files () |
| Closes all open files. More... | |
| void | fil_set_max_space_id_if_bigger (space_id_t max_id) |
| Sets the max tablespace id counter if the given number is bigger than the previous value. More... | |
| dberr_t | fil_write_flushed_lsn (lsn_t lsn) |
| Write the flushed LSN to the page header of the first page in the system tablespace. More... | |
| fil_space_t * | fil_space_acquire (space_id_t space_id) |
| Acquire a tablespace when it could be dropped concurrently. More... | |
| fil_space_t * | fil_space_acquire_silent (space_id_t space_id) |
| Acquire a tablespace that may not exist. More... | |
| void | fil_space_release (fil_space_t *space) |
| Release a tablespace acquired with fil_space_acquire(). More... | |
| dberr_t | fil_close_tablespace (space_id_t space_id) |
| Closes a single-table tablespace. More... | |
| void | fil_op_write_log (mlog_id_t type, space_id_t space_id, const char *path, const char *new_path, uint32_t flags, mtr_t *mtr) |
| Write a log record about an operation on a tablespace file. More... | |
| dberr_t | fil_delete_tablespace (space_id_t space_id) |
| Deletes an IBD or IBU tablespace. More... | |
| bool | fil_truncate_tablespace (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... | |
| void | fil_space_inc_redo_skipped_count (space_id_t space_id) |
| Increase redo skipped count for a tablespace. More... | |
| void | fil_space_dec_redo_skipped_count (space_id_t space_id) |
| Decrease redo skipped count for a tablespace. More... | |
| bool | fil_space_is_redo_skipped (space_id_t space_id) |
| Check whether a single-table tablespace is redo skipped. More... | |
| dberr_t | fil_discard_tablespace (space_id_t space_id) |
| Discards a single-table tablespace. More... | |
| static void | fil_name_write_rename (space_id_t space_id, const char *old_name, const char *new_name, mtr_t *mtr) |
| Write redo log for renaming a file. More... | |
| dberr_t | fil_rename_tablespace_check (space_id_t space_id, const char *old_path, const char *new_path, bool is_discarded) |
| Test if a tablespace file can be renamed to a new filepath by checking if that the old filepath exists and the new filepath does not exist. More... | |
| dberr_t | fil_rename_tablespace (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 | fil_rename_tablespace_by_id (space_id_t space_id, const char *old_name, const char *new_name) |
| Rename a tablespace. More... | |
| dberr_t | fil_write_initial_pages (pfs_os_file_t file, const char *path, const byte *encrypt_info, space_id_t space_id, const uint32_t space_flags) |
| Write initial pages for a new tablespace file created. More... | |
| static dberr_t | fil_create_tablespace (const space_id_t space_id, const char *name, const uint32_t flags, const page_no_t size_in_pages, const fil_type_t type, const ib::fil::Tablespaces_nodes_interface::Create_node_hints &create_node_hints) |
| Create a tablespace (an IBD or IBT or UNDO) file. More... | |
| dberr_t | fil_ibd_create (space_id_t space_id, const char *name, const char *path, uint32_t flags, page_no_t size) |
| Create an IBD tablespace file. More... | |
| dberr_t | fil_ibt_create (space_id_t space_id, const char *name, const char *path, uint32_t flags, page_no_t size) |
| Create a session temporary tablespace (IBT) file. More... | |
| dberr_t | fil_undo_create (space_id_t space_id, const char *name, const char *path, uint32_t flags, page_no_t size, bool is_explicit) |
| Create an UNDO tablespace file. More... | |
| dberr_t | fil_ibd_open (bool validate, fil_type_t purpose, space_id_t space_id, uint32_t flags, const char *space_name, const char *path_in, bool strict, bool old_space) |
| Open a single-table tablespace and optionally do some validation such as checking that the space id is correct. More... | |
| bool | fil_space_read_name_and_filepath (space_id_t space_id, std::string &name, std::string &filepath) |
| Looks for a pre-existing fil_space_t with the given tablespace ID and, if found, returns the name and filepath in newly allocated buffers that the caller must free. More... | |
| std::string | fil_path_to_space_name (const std::string &file_path, space_id_t space_id, uint32_t flags) |
| Convert a file path to a tablespace name, based on space ID and its flags. More... | |
| std::string | fil_path_to_space_name (std::string file_path) |
| Convert a file name to a tablespace name. More... | |
| static void | fil_report_missing_tablespace (const char *name, space_id_t space_id) |
| Report that a tablespace for a table was not found. More... | |
| bool | fil_space_exists_in_mem (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... | |
| space_id_t | fil_space_get_id_by_name (const char *name) |
| Returns the space ID based on the tablespace name. More... | |
| bool | fil_space_extend (fil_space_t *space, page_no_t size) |
| Try to extend a tablespace if it is smaller than the specified size. More... | |
| bool | fil_space_reserve_free_extents (space_id_t space_id, ulint n_free_now, ulint n_to_reserve) |
| Tries to reserve free extents in a file space. More... | |
| void | fil_space_release_free_extents (space_id_t space_id, ulint n_reserved) |
| Releases free extents in a file space. More... | |
| ulint | fil_space_get_n_reserved_extents (space_id_t space_id) |
| Gets the number of reserved extents. More... | |
| static void | fil_report_invalid_page_access_low (page_no_t block_offset, space_id_t space_id, const char *space_name, ulint len, bool is_read, int line) |
| Report information about an invalid page access. More... | |
| void | fil_io_set_encryption (IORequest &req_type, const page_id_t &page_id, fil_space_t *space) |
| Set encryption information for IORequest. More... | |
| void | fil_aio_wait (ulint segment) |
| Waits for an AIO operation to complete. More... | |
| dberr_t | fil_io (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, bool evict_after_write, std::function< void(dberr_t err)> pre_io_complete_callback) |
| Read or write data for a single page from a file. More... | |
| void | fil_flush (space_id_t space_id) |
| Flushes to disk possible writes cached by the OS. More... | |
| void | fil_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 | fil_addr_is_null (const fil_addr_t &addr) |
| Returns true if file address is undefined. More... | |
| page_no_t | fil_page_get_prev (const byte *page) |
| Get the predecessor of a file page. More... | |
| page_no_t | fil_page_get_next (const byte *page) |
| Get the successor of a file page. More... | |
| void | fil_page_set_type (byte *page, ulint type) |
| Sets the file page type. More... | |
| void | fil_page_reset_type (const page_id_t &page_id, byte *page, ulint type, mtr_t *mtr) |
| Reset the page type. More... | |
| void | fil_close () |
| Closes the tablespace memory cache. More... | |
| static void | fil_buf_block_init (buf_block_t *block, byte *frame) |
| Initializes the buffer control block used by fil_tablespace_iterate. More... | |
| static dberr_t | fil_iterate (const Fil_page_iterator &iter, buf_block_t *block, PageCallback &callback) |
| TODO: This can be made parallel trivially by chunking up the file and creating a callback per thread. More... | |
| void | fil_adjust_name_import (dict_table_t *table, const char *path, ib_file_suffix extn) |
| Adjust file name for import for partition files in different letter case. More... | |
| dberr_t | fil_tablespace_iterate (const Encryption_metadata &encryption_metadata, dict_table_t *table, ulint n_io_buffers, Compression::Type compression_type, PageCallback &callback) |
| Iterate over all the pages in the tablespace. More... | |
| dberr_t | fil_rename_precheck (const dict_table_t *old_table, const dict_table_t *new_table, const char *tmp_name) |
| Check if swapping two .ibd files can be done without failure. More... | |
| dberr_t | fil_set_compression (space_id_t space_id, const char *algorithm) |
| Set the compression type for the tablespace. More... | |
| Compression::Type | fil_get_compression (space_id_t space_id) |
| Get the compression algorithm for a tablespace. More... | |
| dberr_t | fil_set_autoextend_size (space_id_t space_id, uint64_t autoextend_size) |
| Set the autoextend_size attribute for the tablespace. More... | |
| dberr_t | fil_set_encryption (space_id_t space_id, Encryption::Type algorithm, byte *key, byte *iv) |
| Set the encryption type for the tablespace. More... | |
| dberr_t | fil_reset_encryption (space_id_t space_id) |
| Reset the encryption type for the tablespace. More... | |
| size_t | fil_encryption_rotate () |
| Rotate the tablespace keys by new master key. More... | |
| void | fil_encryption_reencrypt (const std::vector< space_id_t > &sid_vector) |
| Re-encrypt the tablespace keys by current master key. More... | |
| void | fil_space_set_flags (fil_space_t *space, uint32_t flags) |
| Sets the flags of the tablespace. More... | |
| static void | fil_tablespace_encryption_init (const fil_space_t *space) |
| Initialize the table space encryption. More... | |
| static void | fil_adjust_partition_stat (const std::string &old_path, const std::string &new_path) |
| Modify table name in Innodb persistent stat tables, if needed. More... | |
| dberr_t | fil_open_for_business (bool read_only_mode) |
| Free the Tablespace_files instance. More... | |
| bool | fil_op_replay_rename_for_ddl (const space_id_t space_id, const char *old_name, const char *new_name) |
| Replay a file rename operation for ddl replay. More... | |
| static std::string | fil_real_dir_for_lookup (const std::string &dir) |
| Real path of the input directory. More... | |
| bool | fil_tablespace_lookup_for_recovery (space_id_t space_id) |
| Lookup the tablespace ID. More... | |
| dberr_t | fil_tablespace_open_for_recovery (space_id_t space_id) |
| Open the tablespace and also get the tablespace filenames, space_id must already be known. More... | |
| Fil_state | fil_tablespace_dir_equals (const space_id_t space_id, const char *space_name, const ulint fsp_flags, const Dirs_in_datadir &schema_dirs, const std::string old_path, std::string &new_path) |
| Lookups the tablespace ID in the scanned tablespaces and return its path to the file. More... | |
| void | fil_add_moved_space (dd::Object_id dd_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) |
| Add tablespace to the set of tablespaces to be updated in DD. More... | |
| const byte * | fil_tablespace_redo_create_wrapper (const byte *ptr, const byte *end, space_id_t space_id) |
| TODO: This is a wrapper for fil_tablespace_redo_create to be called during recovery, it uses tablespace_scanning to resolve tablespace file path. More... | |
| static const byte * | parse_path_from_redo (const byte *ptr, const byte *end, bool check_suffix, std::string &path, std::string &error_str) |
| Parse a path from a buffer. More... | |
| const byte * | fil_tablespace_redo_create (const byte *ptr, const byte *end, space_id_t space_id, bool parse_only) |
| Redo a tablespace create. More... | |
| const byte * | fil_tablespace_redo_rename (const byte *ptr, const byte *end, space_id_t space_id, bool parse_only) |
| Redo a tablespace rename. More... | |
| const byte * | fil_tablespace_redo_extend_wrapper (const byte *ptr, const byte *end, space_id_t space_id) |
| TODO: This is a wrapper for fil_tablespace_redo_extend to be called during recovery, it makes sure tablespace is loaded in fil cache. More... | |
| const byte * | fil_tablespace_redo_extend (const byte *ptr, const byte *end, space_id_t space_id, bool parse_only) |
| Redo a tablespace extend. More... | |
| const byte * | fil_tablespace_redo_delete_wrapper (const byte *ptr, const byte *end, space_id_t space_id) |
| TODO: This is a wrapper for fil_tablespace_redo_delete to be called during recovery, it uses tablespace_scanning to resolve tablespace file path. More... | |
| const byte * | fil_tablespace_redo_delete (const byte *ptr, const byte *end, space_id_t space_id, bool parse_only) |
| Redo a tablespace delete. More... | |
| std::optional< bool > | fil_tablespace_redo_encryption (const byte *ptr, const byte *end, space_id_t space_id, lsn_t lsn) |
| Parse and process an encryption redo record. More... | |
| void | fil_space_update_name (fil_space_t *space, const char *name) |
| Update the tablespace name. More... | |
| void | fil_purge () |
| Allows fil system to do periodical cleanup. More... | |
| size_t | fil_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... | |
| const char * | fil_get_page_type_str (page_type_t type) noexcept |
| Get the page type as a string. More... | |
| bool | fil_is_page_type_valid (page_type_t type) noexcept |
| Check if the given page type is valid. More... | |
| dberr_t | fil_prepare_file_for_io (space_id_t space_id, page_no_t &page_no, fil_node_t **node_out) |
| void | fil_complete_write (space_id_t space_id, fil_node_t *node) |
Variables | |
| Fil_path | MySQL_datadir_path |
| Reference to the server data directory. More... | |
| Fil_path | MySQL_undo_path |
| Reference to the server undo directory. More... | |
| bool | MySQL_undo_path_is_unique |
| The undo path is different from any other known directory. More... | |
| const char * | dot_ext [] |
| Common InnoDB file extensions. More... | |
| std::atomic< std::uint64_t > | fil_n_pending_tablespace_flushes = 0 |
| Number of pending tablespace flushes. More... | |
| std::atomic_size_t | fil_n_files_open {0} |
| Number of files currently open. More... | |
| fil_addr_t | fil_addr_null = {FIL_NULL, 0} |
| The null file address. More... | |
| static const size_t | MAX_SHARDS = 68 |
| Maximum number of shards supported. More... | |
| static const size_t | UNDO_SHARDS = 4 |
| Number of undo shards to reserve. More... | |
| static const size_t | UNDO_SHARDS_START = MAX_SHARDS - UNDO_SHARDS |
| The UNDO logs have their own shards (4). More... | |
| static Fil_system * | fil_system = nullptr |
| The tablespace memory cache. More... | |
| ut::unique_ptr< ib::fil::Tablespaces_nodes_interface > | tablespaces_nodes |
| The low-level tablespaces' nodes' storage implementation. More... | |
| ut::unique_ptr< ib::fil::Pages_persistence_interface > | pages_persistence |
| The implementation of persistence for the pages stored in tablespaces' nodes' storage. More... | |
| ut::unique_ptr< ib::fil::Tablespace_scanning > | tablespace_scanning |
| static const size_t | FIL_VALIDATE_SKIP = 17 |
| Try fil_validate() every this many times. More... | |
The tablespace memory cache.
| #define fil_report_invalid_page_access | ( | b, | |
| s, | |||
| n, | |||
| l, | |||
| t | |||
| ) | fil_report_invalid_page_access_low((b), (s), (n), (l), (t), __LINE__) |
| #define mutex_acquire | ( | ) | acquire(__LINE__) |
We want to store the line number from where it was called.
| #define PAGE_TYPE | ( | x | ) |
| enum fil_load_status |
| enum fil_operation_t |
| dberr_t dict_stats_rename_table | ( | const char * | old_name, |
| const char * | new_name, | ||
| char * | errstr, | ||
| size_t | errstr_sz | ||
| ) |
Renames a table in InnoDB persistent stats storage.
This function creates its own transaction and commits it.
| old_name | in: old name, e.g. 'db/table' |
| new_name | in: new name, e.g. 'db/table' |
| errstr | out: error string if != DB_SUCCESS is returned |
| errstr_sz | in: errstr size |
| void fil_add_moved_space | ( | dd::Object_id | dd_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 | ||
| ) |
Add tablespace to the set of tablespaces to be updated in DD.
| [in] | dd_object_id | Server DD tablespace ID |
| [in] | space_id | Innodb tablespace ID |
| [in] | space_name | New tablespace name |
| [in] | old_path | Old Path in the data dictionary |
| [in] | new_path | New path to be update in dictionary |
| [in] | dd_flag_missing | This tablespace is outside default data directory, yet it is missing DD_TABLE_DATA_DIRECTORY flag. This could happen in versions earlier than 8.0.38/8.4.1/9.0.0 |
| bool fil_addr_is_null | ( | const fil_addr_t & | addr | ) |
Returns true if file address is undefined.
| [in] | addr | File address to check |
| void fil_adjust_name_import | ( | dict_table_t * | table, |
| const char * | path, | ||
| ib_file_suffix | extn | ||
| ) |
Adjust file name for import for partition files in different letter case.
| [in] | table | Innodb dict table |
| [in] | path | file path to open |
| [in] | extn | file extension |
|
static |
Modify table name in Innodb persistent stat tables, if needed.
Required when partitioned table file names from old versions are modified to change the letter case.
| [in] | old_path | path to old file |
| [in] | new_path | path to new file |
| void fil_aio_wait | ( | ulint | segment | ) |
Waits for an AIO operation to complete.
This function is used to write the handler for completed requests. The aio array of pending requests is divided into segments (see os0file.cc for more info). The thread specifies which segment it wants to wait for.
| [in] | segment | The number of the segment in the AIO array to wait for |
| bool fil_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 id's is not enough, we may need to recycle id's.
| [out] | space_id | Set this to the new tablespace ID |
|
static |
Initializes the buffer control block used by fil_tablespace_iterate.
| [in] | block | Pointer to the control block |
| [in] | frame | Pointer to buffer frame |
| void fil_close | ( | ) |
Closes the tablespace memory cache.
Initializes the tablespace memory cache.
| void fil_close_all_files | ( | ) |
Closes all open files.
There must not be any pending i/o's or not flushed modifications in the files.
| dberr_t fil_close_tablespace | ( | space_id_t | space_id | ) |
Closes a single-table tablespace.
The tablespace must be cached in the memory cache. Free all pages used by the tablespace.
| [in] | space_id | Tablespace ID |
| void fil_complete_write | ( | space_id_t | space_id, |
| fil_node_t * | node | ||
| ) |
| size_t fil_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.
| [in] | undo_num | undo tablespace number. |
|
static |
Create a tablespace (an IBD or IBT or UNDO) file.
| [in] | space_id | Tablespace ID |
| [in] | name | Tablespace name in dbname/tablename format. For general tablespaces, the 'dbname/' part may be missing. |
| [in] | flags | Tablespace flags |
| [in] | size_in_pages | Initial size of the tablespace file in pages, must be >= FIL_IBD_FILE_INITIAL_SIZE |
| [in] | type | FIL_TYPE_TABLESPACE or FIL_TYPE_TEMPORARY |
| [in] | create_node_hints | Additional information that is required to create the tablespace. |
| dberr_t fil_delete_tablespace | ( | 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.
| [in] | space_id | Tablespace ID |
| dberr_t fil_discard_tablespace | ( | space_id_t | space_id | ) |
Discards a single-table tablespace.
The tablespace must be cached in the memory cache. Discarding is like deleting a tablespace, but
| [in] | space_id | Tablespace ID |
| void fil_encryption_reencrypt | ( | const std::vector< space_id_t > & | sid_vector | ) |
Re-encrypt the tablespace keys by current master key.
| size_t fil_encryption_rotate | ( | ) |
Rotate the tablespace keys by new master key.
| void fil_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.
| [in] | space_id | Tablespace ID |
| void fil_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)
| Compression::Type fil_get_compression | ( | space_id_t | space_id | ) |
Get the compression algorithm for a tablespace.
| [in] | space_id | Space ID to check |
|
noexcept |
Get the page type as a string.
| [in] | type | page type to be converted to string. |
| size_t fil_get_scan_threads | ( | size_t | num_files | ) |
Calculate the number of threads that can be spawned to scan the given number of files taking into the consideration, number of cores available on the machine.
| [in] | num_files | Number of files to be scanned |
| dberr_t fil_ibd_create | ( | space_id_t | space_id, |
| const char * | name, | ||
| const char * | path, | ||
| uint32_t | flags, | ||
| page_no_t | size | ||
| ) |
Create an IBD tablespace file.
| [in] | space_id | Tablespace ID |
| [in] | name | Tablespace name in dbname/tablename format. For general tablespaces, the 'dbname/' part may be missing. |
| [in] | path | Path and filename of the datafile to create. |
| [in] | flags | Tablespace flags |
| [in] | size | Initial size of the tablespace file in pages, must be >= FIL_IBD_FILE_INITIAL_SIZE |
| dberr_t fil_ibd_open | ( | bool | validate, |
| fil_type_t | purpose, | ||
| space_id_t | space_id, | ||
| uint32_t | flags, | ||
| const char * | space_name, | ||
| const char * | path_in, | ||
| bool | strict, | ||
| bool | old_space | ||
| ) |
Open a single-table tablespace and optionally do some validation such as checking that the space id is correct.
If the file is already open, the validation will be done before reporting success. If not successful, print an error message to the error log. This function is used to open a tablespace when we start up mysqld, and also in IMPORT TABLESPACE. NOTE that we assume this operation is used either at the database startup or under the protection of the dictionary mutex, so that two users cannot race here.
The fil_node_t::handle will not be left open.
| [in] | validate | whether we should validate the tablespace (read the first page of the file and check that the space id in it matches id) |
| [in] | purpose | FIL_TYPE_TABLESPACE or FIL_TYPE_TEMPORARY |
| [in] | space_id | Tablespace ID |
| [in] | flags | tablespace flags |
| [in] | space_name | tablespace name of the datafile If file-per-table, it is the table name in the databasename/tablename format |
| [in] | path_in | expected filepath, usually read from dictionary |
| [in] | strict | whether to report error when open ibd failed |
| [in] | old_space | whether it is a 5.7 tablespace opening by upgrade |
| dberr_t fil_ibt_create | ( | space_id_t | space_id, |
| const char * | name, | ||
| const char * | path, | ||
| uint32_t | flags, | ||
| page_no_t | size | ||
| ) |
Create a session temporary tablespace (IBT) file.
| [in] | space_id | Tablespace ID |
| [in] | name | Tablespace name |
| [in] | path | Path and filename of the datafile to create. |
| [in] | flags | Tablespace flags |
| [in] | size | Initial size of the tablespace file in pages, must be >= FIL_IBT_FILE_INITIAL_SIZE |
| void fil_init | ( | ulint | max_n_open | ) |
Initializes the tablespace memory cache.
| [in] | max_n_open | Maximum number of open files |
| dberr_t fil_io | ( | 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, | ||
| bool | evict_after_write, | ||
| std::function< void(dberr_t err)> | pre_io_complete_callback = [](dberr_t) {} |
||
| ) |
Read or write data for a single page from a file.
| [in] | type | IO type |
| [in] | sync | If true then do synchronous IO |
| [in] | page_id | Page id to read or write. |
| [in] | page_size | Structure with information on logical and physical page size in the affected tablespace. |
| [in] | len | Size 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] | buf | A 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] | bpage | Pointer 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] | evict_after_write | Evicts the page after successful write. It is ignored if bpage is nullptr or if it is not a write request. |
| [in] | pre_io_complete_callback | A 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. The buf_page_io_complete() is called after this callback returns DB_SUCCESS and bpage is not null. |
| DB_SUCCESS | on success |
| DB_TABLESPACE_DELETED | if the tablespace does not exist Note: this is not an exhaustive list of errors returned. |
| void fil_io_set_encryption | ( | IORequest & | req_type, |
| const page_id_t & | page_id, | ||
| fil_space_t * | space | ||
| ) |
Set encryption information for IORequest.
| [in,out] | req_type | IO request |
| [in] | page_id | page id |
| [in] | space | table space |
|
noexcept |
Check if the given page type is valid.
| [in] | type | the page type to be checked for validity. |
|
static |
TODO: This can be made parallel trivially by chunking up the file and creating a callback per thread.
Main benefit will be to use multiple CPUs for checksums and compressed tables. We have to do compressed tables block by block right now. Secondly we need to decompress/compress and copy too much of data. These are CPU intensive.
Iterate over all the pages in the tablespace.
| [in] | iter | Tablespace iterator |
| [in,out] | block | Block to use for IO |
| [in] | callback | Callback to inspect and update page contents |
| DB_SUCCESS | or error code |
|
static |
Write redo log for renaming a file.
| [in] | space_id | Tablespace id |
| [in] | old_name | Tablespace file name |
| [in] | new_name | Tablespace file name after renaming |
| [in,out] | mtr | Mini-transaction |
|
inlinestatic |
Determine if flush is needed for durability.
It could be disabled for example when user has explicitly disabled fsync().
| void fil_node_create | ( | const char * | name, |
| fil_space_t * | space, | ||
| bool | is_raw, | ||
| page_no_t | max_pages | ||
| ) |
Attach a node to a tablespace.
| [in] | name | file name (file must be closed) |
| [in,out] | space | space where to attach to. Must not be null. |
| [in] | is_raw | true if a raw device or a raw disk partition |
| [in] | max_pages | maximum number of pages in file |
|
static |
Replay a file rename operation on space present in the fil subsystem cache, if it is possible to perform.
| [in] | space | Pointer to the space object. |
| [in] | old_name | old file name |
| [in] | new_name | new file name |
| bool fil_op_replay_rename_for_ddl | ( | space_id_t | space_id, |
| const char * | old_name, | ||
| const char * | new_name | ||
| ) |
Replay a file rename operation for ddl replay.
| [in] | space_id | Space ID |
| [in] | old_name | old file name |
| [in] | new_name | new file name |
| void fil_op_write_log | ( | mlog_id_t | type, |
| space_id_t | space_id, | ||
| const char * | path, | ||
| const char * | new_path, | ||
| uint32_t | flags, | ||
| mtr_t * | mtr | ||
| ) |
Write a log record about an operation on a tablespace file.
| [in] | type | MLOG_FILE_OPEN or MLOG_FILE_DELETE or MLOG_FILE_CREATE or MLOG_FILE_RENAME |
| [in] | space_id | Tablespace identifier |
| [in] | path | File path |
| [in] | new_path | If type is MLOG_FILE_RENAME, the new name |
| [in] | flags | If type is MLOG_FILE_CREATE, the space flags |
| [in,out] | mtr | Mini-transaction |
| bool fil_open_files_limit_update | ( | 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. |
| dberr_t fil_open_for_business | ( | bool | read_only_mode | ) |
Free the Tablespace_files instance.
| [in] | read_only_mode | true if InnoDB is started in read only mode. |
Get the successor of a file page.
| [in] | page | File page |
Get the predecessor of a file page.
| [in] | page | File page |
Reset the page type.
Data files created before MySQL 5.1 may contain garbage in FIL_PAGE_TYPE. In MySQL 3.23.53, only undo log pages and index pages were tagged. Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
| [in] | page_id | Page number |
| [in,out] | page | Page with invalid FIL_PAGE_TYPE |
| [in] | type | Expected page type |
| [in,out] | mtr | Mini-transaction |
Sets the file page type.
| [in,out] | page | File page |
| [in] | type | File page type to set |
| std::string fil_path_to_space_name | ( | const std::string & | file_path, |
| space_id_t | space_id, | ||
| uint32_t | flags | ||
| ) |
Convert a file path to a tablespace name, based on space ID and its flags.
| [in] | file_path | Full path to the tablespace file. |
| [in] | space_id | space_id emitted by the redo log |
| [in] | flags | FSP flags of the tablespace. |
| std::string fil_path_to_space_name | ( | std::string | filename | ) |
Convert a file name to a tablespace name.
Strip the file name prefix and suffix, leaving only databasename/tablename.
| [in] | filename | directory/databasename/tablename.ibd |
| dberr_t fil_prepare_file_for_io | ( | space_id_t | space_id, |
| page_no_t & | page_no, | ||
| fil_node_t ** | node_out | ||
| ) |
| void fil_purge | ( | ) |
Allows fil system to do periodical cleanup.
|
static |
Reads data from a space to a buffer.
Remember that the possible incomplete blocks at the end of file are ignored: they are not taken into account when calculating the byte offset within a space. If the data on disk is compressed or encrypted, the data is decompressed and decrypted using tablespace's keys before returning in the buf.
| [in] | page_id | page id |
| [in] | page_size | Structure with information on logical and physical page size in the affected tablespace. |
| [in,out] | buf | A buffer where to store read data. It must be aligned to physical page size. It must be able to contain physical page size bytes of data. The memory pointed is managed by the caller and must remain valid until the call returns. |
|
static |
Real path of the input directory.
| [in] | dir | Directory path |
| dberr_t fil_rename_precheck | ( | const dict_table_t * | old_table, |
| const dict_table_t * | new_table, | ||
| const char * | tmp_name | ||
| ) |
Check if swapping two .ibd files can be done without failure.
| [in] | old_table | old table |
| [in] | new_table | new table |
| [in] | tmp_name | temporary table name |
| dberr_t fil_rename_tablespace | ( | 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.
| [in] | space_id | Tablespace ID |
| [in] | old_path | Old file name |
| [in] | new_name | New tablespace name in the schema/name format |
| [in] | new_path_in | New file name, or nullptr if it is located in the normal data directory |
| dberr_t fil_rename_tablespace_by_id | ( | space_id_t | space_id, |
| const char * | old_name, | ||
| const char * | new_name | ||
| ) |
Rename a tablespace.
Use the space_id to find the shard.
| [in] | space_id | tablespace ID |
| [in] | old_name | old tablespace name |
| [in] | new_name | new tablespace name |
| dberr_t fil_rename_tablespace_check | ( | space_id_t | space_id, |
| const char * | old_path, | ||
| const char * | new_path, | ||
| bool | is_discarded | ||
| ) |
Test if a tablespace file can be renamed to a new filepath by checking if that the old filepath exists and the new filepath does not exist.
Any unexpected errors are reported as DB_ERROR.
| [in] | space_id | Tablespace ID |
| [in] | old_path | Old filepath |
| [in] | new_path | New filepath |
| [in] | is_discarded | Whether the tablespace is discarded |
|
static |
Report information about an invalid page access.
| [in] | block_offset | Block offset |
| [in] | space_id | Tablespace ID |
| [in] | space_name | Tablespace name |
| [in] | len | I/O length |
| [in] | is_read | I/O type |
| [in] | line | Line called from |
|
static |
Report that a tablespace for a table was not found.
| [in] | name | Table name |
| [in] | space_id | Table's space ID |
| dberr_t fil_reset_encryption | ( | space_id_t | space_id | ) |
Reset the encryption type for the tablespace.
| [in] | space_id | Space ID of tablespace for which to set |
| dberr_t fil_set_autoextend_size | ( | space_id_t | space_id, |
| uint64_t | autoextend_size | ||
| ) |
Set the autoextend_size attribute for the tablespace.
| [in] | space_id | Space ID of tablespace for which to set |
| [in] | autoextend_size | Value of autoextend_size attribute |
| dberr_t fil_set_compression | ( | space_id_t | space_id, |
| const char * | algorithm | ||
| ) |
Set the compression type for the tablespace.
| [in] | space_id | Space ID of the tablespace |
| [in] | algorithm | Text representation of the algorithm |
| dberr_t fil_set_encryption | ( | space_id_t | space_id, |
| Encryption::Type | algorithm, | ||
| byte * | key, | ||
| byte * | iv | ||
| ) |
Set the encryption type for the tablespace.
| [in] | space_id | Space ID of tablespace for which to set |
| [in] | algorithm | Encryption algorithm |
| [in] | key | Encryption key |
| [in] | iv | Encryption iv |
| void fil_set_max_space_id_if_bigger | ( | space_id_t | max_id | ) |
Sets the max tablespace id counter if the given number is bigger than the previous value.
| [in] | max_id | Maximum known tablespace ID |
| fil_space_t * fil_space_acquire | ( | space_id_t | space_id | ) |
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 |
| fil_space_t * fil_space_acquire_silent | ( | space_id_t | space_id | ) |
Acquire a tablespace that may not exist.
Used by background threads that do not necessarily hold proper locks for concurrency control.
| [in] | space_id | Tablespace ID |
| void fil_space_close | ( | space_id_t | space_id | ) |
Close each file of a tablespace if open.
| [in] | space_id | Tablespace ID |
| fil_space_t * fil_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.
| [in] | name | Tablespace name |
| [in] | space_id | Tablespace ID |
| [in] | flags | Tablespace flags |
| [in] | purpose | Tablespace purpose |
| nullptr | on failure (such as when the same tablespace exists) |
| void fil_space_dec_redo_skipped_count | ( | space_id_t | space_id | ) |
Decrease redo skipped count for a tablespace.
| [in] | space_id | Tablespace ID |
| bool fil_space_exists_in_mem | ( | 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.
| [in] | space_id | Tablespace ID |
| [in] | name | Tablespace name used in space_create(). |
| [in] | print_err | Print detailed error information to the error log if a matching tablespace is not found from memory. |
| [in] | adjust_space | Whether to adjust space id on mismatch |
| bool fil_space_extend | ( | fil_space_t * | space, |
| page_no_t | size | ||
| ) |
Try to extend a tablespace if it is smaller than the specified size.
| [in,out] | space | Tablespace ID |
| [in] | size | desired size in pages |
|
static |
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.
| [in] | space_id | Tablespace ID |
| [in] | x_latched | Whether the caller holds X-mode space->latch |
| fil_space_t * fil_space_get | ( | space_id_t | space_id | ) |
Look up a tablespace.
The caller should hold an InnoDB table lock or a MDL that prevents the tablespace from being dropped during the operation, or the caller should be in single-threaded crash recovery mode (no user connections that could drop tablespaces). If this is not the case, fil_space_acquire() and fil_space_release() should be used instead.
| [in] | space_id | Tablespace ID |
| char * fil_space_get_first_path | ( | space_id_t | space_id | ) |
Returns the path from the first fil_node_t found with this space ID.
The caller is responsible for freeing the memory allocated here for the value returned.
| [in] | space_id | Tablespace ID |
| uint32_t fil_space_get_flags | ( | space_id_t | space_id | ) |
Returns the flags of the space.
The tablespace must be cached in the memory cache.
| [in] | space_id | Tablespace ID for which to get the flags |
| space_id_t fil_space_get_id_by_name | ( | const char * | name | ) |
Returns the space ID based on the tablespace name.
The tablespace must be found in the tablespace memory cache. This call is made from external to this module, so the mutex is not owned.
| [in] | name | Tablespace name |
| rw_lock_t * fil_space_get_latch | ( | space_id_t | space_id | ) |
Returns the latch of a file space.
| [in] | space_id | Tablespace ID |
| ulint fil_space_get_n_reserved_extents | ( | space_id_t | space_id | ) |
Gets the number of reserved extents.
If the database is silent, this number should be zero.
| [in] | space_id | Tablespace ID |
| const page_size_t fil_space_get_page_size | ( | space_id_t | space_id, |
| bool * | found | ||
| ) |
Returns the page size of the space and whether it is compressed or not.
The tablespace must be cached in the memory cache.
| [in] | space_id | Tablespace ID |
| [out] | found | true if tablespace was found |
| page_no_t fil_space_get_size | ( | space_id_t | space_id | ) |
Returns the size of the space in pages.
If the tablespace is not present in the fil subsystem mappings, a value of 0 is returned.
| [in] | space_id | Tablespace ID |
| fil_type_t fil_space_get_type | ( | space_id_t | space_id | ) |
Gets the type of a file space.
| [in] | space_id | Tablespace ID |
| page_no_t fil_space_get_undo_initial_size | ( | space_id_t | space_id | ) |
Returns the size of an undo space just after it was initialized.
| [in] | space_id | Tablespace ID |
| void fil_space_inc_redo_skipped_count | ( | space_id_t | space_id | ) |
Increase redo skipped count for a tablespace.
| [in] | space_id | Tablespace ID |
| bool fil_space_is_redo_skipped | ( | space_id_t | space_id | ) |
Check whether a single-table tablespace is redo skipped.
| [in] | space_id | Tablespace ID |
| ut::Expected< fil_space_t * > fil_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.
| [in] | space_id | Tablespace ID |
| bool fil_space_read_name_and_filepath | ( | space_id_t | space_id, |
| std::string & | name, | ||
| std::string & | filepath | ||
| ) |
Looks for a pre-existing fil_space_t with the given tablespace ID and, if found, returns the name and filepath in newly allocated buffers that the caller must free.
| [in] | space_id | The tablespace ID to search for. |
| [out] | name | Name of the tablespace found. |
| [out] | filepath | The filepath of the first datafile for the tablespace. |
| void fil_space_release | ( | fil_space_t * | space | ) |
Release a tablespace acquired with fil_space_acquire().
| [in,out] | space | Tablespace to release |
| void fil_space_release_free_extents | ( | space_id_t | space_id, |
| ulint | n_reserved | ||
| ) |
Releases free extents in a file space.
| [in] | space_id | Tablespace ID |
| [in] | n_reserved | How many were reserved |
| bool fil_space_reserve_free_extents | ( | space_id_t | space_id, |
| ulint | n_free_now, | ||
| ulint | n_to_reserve | ||
| ) |
Tries to reserve free extents in a file space.
| [in] | space_id | Tablespace ID |
| [in] | n_free_now | Number of free extents now |
| [in] | n_to_reserve | How many one wants to reserve |
| void fil_space_set_flags | ( | fil_space_t * | space, |
| uint32_t | flags | ||
| ) |
Sets the flags of the tablespace.
The tablespace must be locked in MDL_EXCLUSIVE MODE.
| [in] | space | tablespace in-memory struct |
| [in] | flags | tablespace flags |
| void fil_space_set_imported | ( | space_id_t | space_id | ) |
Note that a tablespace has been imported.
It is initially marked as FIL_TYPE_IMPORT so that no logging is done during the import process when the space ID is stamped to each page. Now we change it to FIL_TYPE_TABLESPACE to start redo and undo logging. NOTE: temporary tablespaces are never imported.
| [in] | space_id | Tablespace ID |
| void fil_space_set_undo_size | ( | space_id_t | space_id, |
| bool | use_current | ||
| ) |
This is called for an undo tablespace after it has been initialized or opened.
It sets the minimum size in pages at which it should be truncated and the number of pages that it should be extended. An undo tablespace is extended by larger amounts than normal tablespaces. It starts at 16Mb and is increased during aggressive growth and decreased when the growth is slower.
| [in] | space_id | Tablespace ID |
| [in] | use_current | If true, use the current size in pages as the initial size. If false, use UNDO_INITIAL_SIZE_IN_PAGES. |
| void fil_space_update_name | ( | fil_space_t * | space, |
| const char * | name | ||
| ) |
Update the tablespace name.
In case, the new name and old name are same, no update done.
| [in,out] | space | tablespace object on which name will be updated |
| [in] | name | new name for tablespace |
| Fil_state fil_tablespace_dir_equals | ( | const space_id_t | space_id, |
| const char * | space_name, | ||
| const ulint | fsp_flags, | ||
| const Dirs_in_datadir & | dirs_in_datadir, | ||
| const std::string | old_path, | ||
| std::string & | new_path | ||
| ) |
Lookups the tablespace ID in the scanned tablespaces and return its path to the file.
Compares the absolute base dir (absolute path without filename) of found scanned path and one supplied as the path from DD for equality. For example it will return path is matching for ./test/a.ibd and ./test/b.ibd.
| [in] | space_id | tablespace ID to lookup |
| [in] | space_name | tablespace name |
| [in] | fsp_flags | tablespace flags |
| [in] | dirs_in_datadir | full paths for dirs directly under datadir |
| [in] | old_path | the path found in dd:Tablespace_files |
| [out] | new_path | the scanned path for this space_id |
|
static |
Initialize the table space encryption.
| [in,out] | space | Tablespace instance |
| dberr_t fil_tablespace_iterate | ( | const Encryption_metadata & | encryption_metadata, |
| dict_table_t * | table, | ||
| ulint | n_io_buffers, | ||
| Compression::Type | compression_type, | ||
| PageCallback & | callback | ||
| ) |
Iterate over all the pages in the tablespace.
| [in] | encryption_metadata | the encryption metadata to use for reading |
| [in] | table | the table definition in the server |
| [in] | n_io_buffers | number of blocks to read and write together |
| [in] | compression_type | compression type if compression is enabled, else Compression::Type::NONE |
| [in,out] | callback | functor that will do the page updates |
Add an extra page for compressed page scratch area.
| bool fil_tablespace_lookup_for_recovery | ( | space_id_t | space_id | ) |
Lookup the tablespace ID.
| [in] | space_id | Tablespace ID to lookup |
| dberr_t fil_tablespace_open_for_recovery | ( | space_id_t | space_id | ) |
Open the tablespace and also get the tablespace filenames, space_id must already be known.
| [in] | space_id | Tablespace ID to lookup |
| const byte * fil_tablespace_redo_create | ( | const byte * | ptr, |
| const byte * | end, | ||
| space_id_t | space_id, | ||
| bool | parse_only | ||
| ) |
Redo a tablespace create.
| [in] | ptr | redo log record |
| [in] | end | end of the redo log buffer |
| [in] | space_id | Tablespace Id |
| [in] | parse_only | Don't apply, parse only |
| nullptr | if this log record was truncated |
| const byte * fil_tablespace_redo_create_wrapper | ( | const byte * | ptr, |
| const byte * | end, | ||
| space_id_t | space_id | ||
| ) |
TODO: This is a wrapper for fil_tablespace_redo_create to be called during recovery, it uses tablespace_scanning to resolve tablespace file path.
The reason it exists is because we want to call fil_tablespace_redo_create from read replica code, and tablespace_scanning is not available in this case. OTOH, we have a special tablespace interface implementation for read replica, and it needs to be investigated further, how to hide these details behind the tablespace interface.
| [in] | ptr | redo log record |
| [in] | end | end of the redo log buffer |
| [in] | space_id | Tablespace Id |
| nullptr | if this log record was truncated |
| const byte * fil_tablespace_redo_delete | ( | const byte * | ptr, |
| const byte * | end, | ||
| space_id_t | space_id, | ||
| bool | parse_only | ||
| ) |
Redo a tablespace delete.
| [in] | ptr | redo log record |
| [in] | end | end of the redo log buffer |
| [in] | space_id | Tablespace Id |
| [in] | parse_only | Don't apply, parse only |
| nullptr | if this log record was truncated |
| const byte * fil_tablespace_redo_delete_wrapper | ( | const byte * | ptr, |
| const byte * | end, | ||
| space_id_t | space_id | ||
| ) |
TODO: This is a wrapper for fil_tablespace_redo_delete to be called during recovery, it uses tablespace_scanning to resolve tablespace file path.
The reason it exists is because we want to call fil_tablespace_redo_delete from read replica code, and tablespace_scanning is not available in this case. OTOH, we have a special tablespace interface implementation for read replica, and it needs to be investigated further, how to hide these details behind the tablespace interface.
| [in] | ptr | redo log record |
| [in] | end | end of the redo log buffer |
| [in] | space_id | Tablespace Id |
| nullptr | if this log record was truncated |
| std::optional< bool > fil_tablespace_redo_encryption | ( | const byte * | ptr, |
| const byte * | end, | ||
| space_id_t | space_id, | ||
| lsn_t | lsn | ||
| ) |
Parse and process an encryption redo record.
| [in] | ptr | redo log record |
| [in] | end | end of the redo log buffer |
| [in] | space_id | the tablespace ID |
| [in] | lsn | lsn for REDO record |
| const byte * fil_tablespace_redo_extend | ( | const byte * | ptr, |
| const byte * | end, | ||
| space_id_t | space_id, | ||
| bool | parse_only | ||
| ) |
Redo a tablespace extend.
if parse_only is false, function expects tablespace to be present in fil cache.
| [in] | ptr | redo log record |
| [in] | end | end of the redo log buffer |
| [in] | space_id | Tablespace Id |
| [in] | parse_only | Don't apply the log if true |
| nullptr | if this log record was truncated |
| const byte * fil_tablespace_redo_extend_wrapper | ( | const byte * | ptr, |
| const byte * | end, | ||
| space_id_t | space_id | ||
| ) |
TODO: This is a wrapper for fil_tablespace_redo_extend to be called during recovery, it makes sure tablespace is loaded in fil cache.
The reason it exists is because we want to call fil_tablespace_redo_extend from read replica code, and loading tablespace for recovery does not make any sense in this case. OTOH, we have a special tablespace interface implementation for read replica, and it needs to be investigated further, how to hide these details behind the tablespace interface.
| [in] | ptr | redo log record |
| [in] | end | end of the redo log buffer |
| [in] | space_id | Tablespace Id |
| nullptr | if this log record was truncated |
| const byte * fil_tablespace_redo_rename | ( | const byte * | ptr, |
| const byte * | end, | ||
| space_id_t | space_id, | ||
| bool | parse_only | ||
| ) |
Redo a tablespace rename.
This function doesn't do anything, simply parses the redo log record.
| [in] | ptr | redo log record |
| [in] | end | end of the redo log buffer |
| [in] | space_id | Tablespace Id |
| [in] | parse_only | Don't apply, parse only |
| nullptr | if this log record was truncated |
| bool fil_truncate_tablespace | ( | 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.
| [in] | space_id | Tablespace ID to truncate |
| [in] | size_in_pages | Truncate size. |
| dberr_t fil_undo_create | ( | space_id_t | space_id, |
| const char * | name, | ||
| const char * | path, | ||
| uint32_t | flags, | ||
| page_no_t | size, | ||
| bool | is_explicit | ||
| ) |
Create an UNDO tablespace file.
| [in] | space_id | Tablespace ID |
| [in] | name | Tablespace name in dbname/tablename format. |
| [in] | path | Path and filename of the datafile to create. |
| [in] | flags | Tablespace flags |
| [in] | size | Initial size of the tablespace file in pages, must be >= FIL_IBD_FILE_INITIAL_SIZE |
| [in] | is_explicit | Enabled if it is an explicit UNDO tablespace |
| bool fil_validate | ( | ) |
Checks the consistency of the tablespace cache.
|
static |
Checks the consistency of the tablespace cache some of the time.
The fil_validate() call skip counter. Use a signed type because of the race condition below.
|
static |
|
static |
Writes data to a space from a buffer.
Remember that the possible incomplete blocks at the end of file are ignored: they are not taken into account when calculating the byte offset within a space.
| [in] | page_id | page id |
| [in] | page_size | Structure with information on logical and physical page size in the affected tablespace. |
| [in] | len | Size of the buf supplied. It always has to be a multiple 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. The data supplied will be compressed and encrypted according to the tablespace settings. |
| [in,out] | buf | A buffer from where to write. Data from this buffer might be copied and the copy transformed before writing it. It must be aligned to OS block size (UNIV_SECTOR_SIZE). The memory pointed is managed by the caller and must remain valid until the call returns. |
Write the flushed LSN to the page header of the first page in the system tablespace.
Assumes the Buffer Pool is empty, or at least does not contain the first page of the System Tablespace.
| [in] | lsn | Flushed LSN |
| dberr_t fil_write_initial_pages | ( | pfs_os_file_t | file, |
| const char * | path, | ||
| const byte * | encrypt_info, | ||
| space_id_t | space_id, | ||
| uint32_t | space_flags | ||
| ) |
Write initial pages for a new tablespace file created.
Caller of this function should call fsync() to make the effect of this function durable.
| [in] | file | open file handle |
| [in] | path | path and filename of the datafile |
| [in] | encrypt_info | encryption key information |
| [in] | space_id | tablespace ID |
| [in,out] | space_flags | tablespace flags |
|
static |
|
static |
Parse a path from a buffer.
| [in] | ptr | redo log record |
| [in] | end | end of the redo log buffer |
| [in] | check_suffix | indicate that .ibd suffix is required |
| [out] | path | the path parsed from the buffer |
| [out] | error_str | optional description of a detected corruption recv_sys->found_corrupt_log is set to true when error_str is set to a non empty string |
| nullptr | if this log record was truncated or corrupted |
| const char* dot_ext[] |
Common InnoDB file extensions.
| fil_addr_t fil_addr_null = {FIL_NULL, 0} |
The null file address.
| std::atomic_size_t fil_n_files_open {0} |
Number of files currently open.
| std::atomic<std::uint64_t> fil_n_pending_tablespace_flushes = 0 |
Number of pending tablespace flushes.
|
static |
The tablespace memory cache.
This variable is nullptr before the module is initialized.
|
static |
Try fil_validate() every this many times.
|
static |
Maximum number of shards supported.
| Fil_path MySQL_datadir_path |
Reference to the server data directory.
The MySQL server –datadir value.
| Fil_path MySQL_undo_path |
Reference to the server undo directory.
The MySQL server –innodb-undo-directory value.
| bool MySQL_undo_path_is_unique |
The undo path is different from any other known directory.
| ut::unique_ptr<ib::fil::Pages_persistence_interface> pages_persistence |
The implementation of persistence for the pages stored in tablespaces' nodes' storage.
| ut::unique_ptr<ib::fil::Tablespace_scanning> tablespace_scanning |
| ut::unique_ptr<ib::fil::Tablespaces_nodes_interface> tablespaces_nodes |
The low-level tablespaces' nodes' storage implementation.
|
static |
Number of undo shards to reserve.
|
static |
The UNDO logs have their own shards (4).