MySQL 8.0.39
Source Code Documentation
|
Tablespace or log data space. More...
#include <fil0fil.h>
Public Types | |
using | List_node = UT_LIST_NODE_T(fil_space_t) |
using | Files = std::vector< fil_node_t, ut::allocator< fil_node_t > > |
using | Observer = Flush_observer |
using | Flush_observers = std::vector< Observer *, ut::allocator< Observer * > > |
Public Member Functions | |
void | release_free_extents (ulint n_reserved) |
Release the reserved free extents. More... | |
bool | is_deleted () const |
bool | was_not_deleted () const |
void | set_deleted () |
Marks the space object for deletion. More... | |
uint32_t | get_current_version () const |
Returns current version of the space object. More... | |
uint32_t | get_recent_version () const |
Returns current version of the space object. More... | |
void | bump_version () |
Bumps the space object version and cause all pages in buffer pool that reference the current space object version to be stale and be freed on first encounter. More... | |
bool | has_no_references () const |
size_t | get_reference_count () const |
void | inc_ref () noexcept |
Increment the page reference count. More... | |
void | dec_ref () noexcept |
Decrement the page reference count. More... | |
std::ostream & | print_xdes_pages (std::ostream &out) const |
Print the extent descriptor pages of this tablespace into the given output stream. More... | |
void | print_xdes_pages (const char *filename) const |
Print the extent descriptor pages of this tablespace into the given file. More... | |
void | initialize () noexcept |
Initializes fields. More... | |
bool | is_compressed () const noexcept |
Check if the tablespace is compressed. More... | |
bool | is_encrypted () const noexcept |
Check if the tablespace is encrypted. More... | |
bool | can_encrypt () const noexcept |
Check if the encryption details, like the encryption key, type and other details, that are needed to carry out encryption are available. More... | |
fil_node_t * | get_file_node (page_no_t *page_no) noexcept |
Get the file node corresponding to the given page number of the tablespace. More... | |
Public Attributes | |
ib::Timer | m_last_extended {} |
When the tablespace was extended last. More... | |
page_no_t | m_undo_extend {} |
Extend undo tablespaces by so many pages. More... | |
page_no_t | m_undo_initial {} |
When an undo tablespace has been initialized with required header pages, that size is recorded here. More... | |
char * | name {} |
Tablespace name. More... | |
space_id_t | id |
Tablespace ID. More... | |
bool | prevent_file_open {} |
true if we want to rename the .ibd file of tablespace and want to temporarily prevent other threads from opening the file that is being renamed. More... | |
ib::Throttler | m_prevent_file_open_wait_message_throttler |
Throttles writing to log a message about long waiting for file to perform rename. More... | |
bool | stop_new_ops {} |
We set this true when we start deleting a single-table tablespace. More... | |
ulint | redo_skipped_count {} |
Reference count for operations who want to skip redo log in the file space in order to make fsp_space_modify_check pass. More... | |
fil_type_t | purpose |
Purpose. More... | |
Files | files {} |
Files attached to this tablespace. More... | |
page_no_t | size {} |
Tablespace file size in pages; 0 if not known yet. More... | |
page_no_t | size_in_header {} |
FSP_SIZE in the tablespace header; 0 if not known yet. More... | |
uint64_t | autoextend_size_in_bytes {} |
Autoextend size. More... | |
uint32_t | free_len {} |
Length of the FSP_FREE list. More... | |
page_no_t | free_limit {} |
Contents of FSP_FREE_LIMIT. More... | |
uint32_t | flags {} |
Tablespace flags; see fsp_flags_is_valid() and page_size_t(ulint) (constructor). More... | |
uint32_t | n_reserved_extents {} |
Number of reserved free extents for ongoing operations like B-tree page split. More... | |
uint32_t | n_pending_flushes {} |
This is positive when flushing the tablespace to disk; dropping of the tablespace is forbidden if this is positive. More... | |
uint32_t | n_pending_ops {} |
This is positive when we have pending operations against this tablespace. More... | |
rw_lock_t | latch |
Latch protecting the file space storage allocation. More... | |
List_node | unflushed_spaces |
List of spaces with at least one unflushed file we have written to. More... | |
bool | is_in_unflushed_spaces {} |
true if this space is currently in unflushed_spaces More... | |
Compression::Type | compression_type |
Compression algorithm. More... | |
Encryption_metadata | m_encryption_metadata |
Encryption metadata. More... | |
Encryption::Progress | encryption_op_in_progress {Encryption::Progress::NONE} |
Encryption is in progress. More... | |
lsn_t | m_header_page_flush_lsn |
Flush lsn of header page. More... | |
ulint | magic_n |
FIL_SPACE_MAGIC_N. More... | |
Static Public Attributes | |
static fil_space_t * | s_sys_space |
System tablespace. More... | |
Private Attributes | |
std::atomic< uint32_t > | m_version {} |
All pages in the buffer pool that reference this fil_space_t instance with version before this version can be lazily freed or reused as free pages. More... | |
std::atomic_size_t | m_n_ref_count {} |
Number of buf_page_t entries that point to this instance. More... | |
std::atomic_bool | m_deleted {} |
true if the tablespace is marked for deletion. More... | |
Tablespace or log data space.
using fil_space_t::Files = std::vector<fil_node_t, ut::allocator<fil_node_t> > |
using fil_space_t::Flush_observers = std::vector<Observer *, ut::allocator<Observer *> > |
using fil_space_t::Observer = Flush_observer |
void fil_space_t::bump_version | ( | ) |
Bumps the space object version and cause all pages in buffer pool that reference the current space object version to be stale and be freed on first encounter.
|
inlinenoexcept |
Check if the encryption details, like the encryption key, type and other details, that are needed to carry out encryption are available.
|
inlinenoexcept |
Decrement the page reference count.
uint32_t fil_space_t::get_current_version | ( | ) | const |
Returns current version of the space object.
It is being bumped when the space is truncated or deleted. Guarantees the version returned is up to date as long as fil_shard mutex is not released.
|
noexcept |
Get the file node corresponding to the given page number of the tablespace.
[in,out] | page_no | Caller passes the page number within a tablespace. After return, it contains the page number within the returned file node. For tablespaces containing only one file, the given page_no will not change. |
uint32_t fil_space_t::get_recent_version | ( | ) | const |
Returns current version of the space object.
It is being bumped when the space is truncated or deleted. It does not guarantee the version is current one.
size_t fil_space_t::get_reference_count | ( | ) | const |
bool fil_space_t::has_no_references | ( | ) | const |
|
inlinenoexcept |
Increment the page reference count.
|
inlinenoexcept |
Initializes fields.
This could be replaced by a constructor if SunPro is compiling it correctly.
|
inlinenoexcept |
Check if the tablespace is compressed.
bool fil_space_t::is_deleted | ( | ) | const |
|
inlinenoexcept |
Check if the tablespace is encrypted.
void fil_space_t::print_xdes_pages | ( | const char * | filename | ) | const |
Print the extent descriptor pages of this tablespace into the given file.
[in] | filename | the output file name. |
std::ostream & fil_space_t::print_xdes_pages | ( | std::ostream & | out | ) | const |
Print the extent descriptor pages of this tablespace into the given output stream.
[in] | out | the output stream. |
void fil_space_t::release_free_extents | ( | ulint | n_reserved | ) |
Release the reserved free extents.
[in] | n_reserved | number of reserved extents |
void fil_space_t::set_deleted | ( | ) |
Marks the space object for deletion.
It will bump the space object version and cause all pages in buffer pool that reference to the current space object version to be stale and be freed on first encounter.
bool fil_space_t::was_not_deleted | ( | ) | const |
uint64_t fil_space_t::autoextend_size_in_bytes {} |
Autoextend size.
Compression::Type fil_space_t::compression_type |
Compression algorithm.
Encryption::Progress fil_space_t::encryption_op_in_progress {Encryption::Progress::NONE} |
Encryption is in progress.
Files fil_space_t::files {} |
Files attached to this tablespace.
Note: Only the system tablespace can have multiple files, this is a legacy issue.
uint32_t fil_space_t::flags {} |
Tablespace flags; see fsp_flags_is_valid() and page_size_t(ulint) (constructor).
This is protected by space->latch and tablespace MDL
uint32_t fil_space_t::free_len {} |
Length of the FSP_FREE list.
page_no_t fil_space_t::free_limit {} |
Contents of FSP_FREE_LIMIT.
space_id_t fil_space_t::id |
Tablespace ID.
bool fil_space_t::is_in_unflushed_spaces {} |
true if this space is currently in unflushed_spaces
rw_lock_t fil_space_t::latch |
Latch protecting the file space storage allocation.
|
private |
true if the tablespace is marked for deletion.
Encryption_metadata fil_space_t::m_encryption_metadata |
Encryption metadata.
lsn_t fil_space_t::m_header_page_flush_lsn |
Flush lsn of header page.
It is used only during recovery
ib::Timer fil_space_t::m_last_extended {} |
When the tablespace was extended last.
|
private |
Number of buf_page_t entries that point to this instance.
This field is guarded by the Fil_shard mutex and the "reference count system". The reference count system here is allowing to take a "latch" on the space by incrementing the reference count, and release it by decrementing it.
The increments are possible from two places:
For decrementing the reference count is itself a latch allowing for the safe decrement.
The value is checked for being 0 in Fil_shard::checkpoint under the Fil_shard mutex, and only if the space is deleted. Observing m_n_ref_count==0 might trigger freeing the object. No other thread can be during the process of incrementing m_n_ref_count from 0 to 1 in parallel to this check. This is impossible for following reasons. Recall the only two places where we do increments listed above:
There is also an opposite race possible: while we check for ref count being zero, another thread may be decrementing it in parallel, and we might miss that if we check too soon. This is benign, as it will result in us not reclaiming the memory we could (but not have to) free, and will return to the check on next checkpoint.
ib::Throttler fil_space_t::m_prevent_file_open_wait_message_throttler |
Throttles writing to log a message about long waiting for file to perform rename.
page_no_t fil_space_t::m_undo_extend {} |
Extend undo tablespaces by so many pages.
page_no_t fil_space_t::m_undo_initial {} |
When an undo tablespace has been initialized with required header pages, that size is recorded here.
Auto-truncation happens when the file size becomes bigger than both this and srv_max_undo_log_size.
|
private |
All pages in the buffer pool that reference this fil_space_t instance with version before this version can be lazily freed or reused as free pages.
They should be rejected if there is an attempt to write them to disk.
Writes to m_version are guarded by the exclusive MDL/table lock latches acquired by the caller, as stated in docs. Note that the Fil_shard mutex seems to be latched in 2 of 3 usages only, so is not really an alternative.
Existence of the space object during reads is assured during these operations:
When reading the value for the page being created with buf_page_init_low we have the MDL latches on table that is in tablespace or the tablespace alone, so we won't be able to bump m_version until they are released, so we will read the current value of the version. When reading the value for the page validation with buf_page_t::is_stale(), we will either: a) have the MDL latches required in at least S mode in case we need to be certain if the page is stale, to use it in a query or in purge operation, or b) in case we don't not have the MDL latches, we may read an outdated value. This happens for pages that are seen during for example LRU or flush page scans. These pages are not needed for the query itself. The read is to decide if the page can be safely discarded. Reading incorrect value can lead to no action being executed. Reading incorrect value can't lead to page being incorrectly evicted.
ulint fil_space_t::magic_n |
FIL_SPACE_MAGIC_N.
uint32_t fil_space_t::n_pending_flushes {} |
This is positive when flushing the tablespace to disk; dropping of the tablespace is forbidden if this is positive.
uint32_t fil_space_t::n_pending_ops {} |
This is positive when we have pending operations against this tablespace.
The pending operations can be ibuf merges or lock validation code trying to read a block. Dropping of the tablespace is forbidden if this is positive. Protected by Fil_shard::m_mutex.
uint32_t fil_space_t::n_reserved_extents {} |
Number of reserved free extents for ongoing operations like B-tree page split.
char* fil_space_t::name {} |
Tablespace name.
bool fil_space_t::prevent_file_open {} |
true if we want to rename the .ibd file of tablespace and want to temporarily prevent other threads from opening the file that is being renamed.
fil_type_t fil_space_t::purpose |
Purpose.
ulint fil_space_t::redo_skipped_count {} |
Reference count for operations who want to skip redo log in the file space in order to make fsp_space_modify_check pass.
|
static |
System tablespace.
page_no_t fil_space_t::size {} |
Tablespace file size in pages; 0 if not known yet.
page_no_t fil_space_t::size_in_header {} |
FSP_SIZE in the tablespace header; 0 if not known yet.
bool fil_space_t::stop_new_ops {} |
We set this true when we start deleting a single-table tablespace.
When this is set following new ops are not allowed: read IO request ibuf merge file flush Note that we can still possibly have new write operations because we don't check this flag when doing flush batches.
List_node fil_space_t::unflushed_spaces |
List of spaces with at least one unflushed file we have written to.