MySQL 8.0.39
Source Code Documentation
|
#include <buf0buf.h>
Classes | |
class | io_responsibility_t |
class | Latching_rules_helpers |
The purpose of this class is to hide the knowledge that Buf_io_fix_latching_rules even exists from users of buf_page_t class, while also avoiding having to tediously repeat yourself in each place where buf_page_t's implementation needs to pass typical arguments to Buf_io_fix_latching_rules such as owned_latches or current state, which require access to private fields of buf_page_t. More... | |
Public Member Functions | |
buf_page_t (const buf_page_t &other) | |
Copy constructor. More... | |
void | set_dblwr_batch_id (uint16_t batch_id) |
Set the doublewrite buffer ID. More... | |
uint16_t | get_dblwr_batch_id () const |
space_id_t | space () const noexcept |
Retrieve the tablespace id. More... | |
page_no_t | page_no () const noexcept |
Retrieve the page number. More... | |
bool | is_stale () const |
Checks if this space reference saved during last page ID initialization was deleted or truncated since. More... | |
bool | was_stale () const |
Checks if this space reference saved during last page ID initialization was deleted or truncated since. More... | |
fil_space_t * | get_space () const |
Retrieve the tablespace object if one was available during page ID initialization. More... | |
void | reset_page_id (page_id_t new_page_id) |
Sets stored page ID to the new value. More... | |
void | reset_page_id () |
Sets stored value to invalid/empty value. More... | |
Flush_observer * | get_flush_observer () noexcept |
void | set_flush_observer (Flush_observer *flush_observer) noexcept |
Set the flush observer for the page. More... | |
void | reset_flush_observer () noexcept |
Remove the flush observer. More... | |
lsn_t | get_newest_lsn () const noexcept |
lsn_t | get_oldest_lsn () const noexcept |
bool | is_dirty () const noexcept |
void | set_newest_lsn (lsn_t lsn) noexcept |
Set the latest modification LSN. More... | |
void | set_oldest_lsn (lsn_t lsn) noexcept |
Set the LSN when the page is modified for the first time. More... | |
void | set_clean () noexcept |
Set page to clean state. More... | |
Public Attributes | |
buf_page_t * | hash |
Node used in chaining to buf_pool->page_hash or buf_pool->zip_hash. More... | |
uint32_t | m_version {} |
Version of fil_space_t when the page was updated. More... | |
std::chrono::steady_clock::time_point | access_time |
Time of first access, or 0 if the block was never accessed in the buffer pool. More... | |
bool | old |
true if the block is in the old blocks in buf_pool->LRU_old More... | |
bool | file_page_was_freed |
This is set to true when fsp frees a page in buffer pool; protected by buf_pool->zip_mutex or buf_block_t::mutex. More... | |
bool | in_flush_list |
true if in buf_pool->flush_list; when buf_pool->flush_list_mutex is free, the following should hold: in_flush_list == (state == BUF_BLOCK_FILE_PAGE || state == BUF_BLOCK_ZIP_DIRTY) Writes to this field must be covered by both buf_pool->flush_list_mutex and block->mutex. More... | |
bool | in_free_list |
true if in buf_pool->free; when buf_pool->free_list_mutex is free, the following should hold: in_free_list == (state == BUF_BLOCK_NOT_USED) More... | |
bool | in_LRU_list |
true if the page is in the LRU list; used in debugging More... | |
bool | in_page_hash |
true if in buf_pool->page_hash More... | |
bool | in_zip_hash |
true if in buf_pool->zip_hash More... | |
Private Member Functions | |
void | space_id_changed () |
Updates new space reference and acquires "reference count latch" and the current version of the space object. More... | |
Private Attributes | |
uint16_t | m_dblwr_id {} |
Double write instance ordinal value during writes. More... | |
General fields | |
None of these bit-fields must be modified without holding buf_page_get_mutex() [buf_block_t::mutex or buf_pool->zip_mutex], since they can be stored in the same machine word.
| |
page_id_t | id |
Page id. More... | |
page_size_t | size |
Page size. More... | |
buf_fix_count_atomic_t | buf_fix_count |
Count of how many fold this block is currently bufferfixed. More... | |
buf_page_state | state |
Block state. More... | |
buf_flush_t | flush_type |
If this block is currently being flushed to disk, this tells the flush_type. More... | |
uint8_t | buf_pool_index |
Index number of the buffer pool that this block belongs to. More... | |
copyable_atomic_t< buf_io_fix > | io_fix |
Type of pending I/O operation. More... | |
io_responsibility_t | io_responsibility |
Tracks which thread is responsible for I/O on this page. More... | |
class | Latching_rules_helpers |
bool | someone_has_io_responsibility () const |
Checks if there is any thread responsible for I/O on this page now. More... | |
bool | current_thread_has_io_responsibility () const |
Checks if the current thread is responsible for I/O on this page now. More... | |
void | release_io_responsibility () |
Called by the thread responsible for I/O on this page to release its responsibility. More... | |
void | take_io_responsibility () |
Called by the thread which becomes responsible for I/O on this page to indicate that it takes the responsibility. More... | |
void | init_io_fix () |
This is called only when having full ownership of the page object and no other thread can reach it. More... | |
void | reinit_io_fix () |
This is called only when having full ownership of the page object and no other thread can reach it. More... | |
void | set_io_fix (buf_io_fix io_fix) |
Sets io_fix to specified value. More... | |
buf_io_fix | get_io_fix () const |
Retrieves the current value of io_fix. More... | |
bool | is_io_fix_write () const |
Checks if the current value of io_fix is BUF_IO_WRITE. More... | |
bool | is_io_fix_read () const |
Checks if the current value of io_fix is BUF_IO_READ. More... | |
bool | is_io_fix_read_as_opposed_to_write () const |
Assuming that io_fix is either BUF_IO_READ or BUF_IO_WRITE determines which of the two it is. More... | |
bool | was_io_fix_read () const |
Checks if io_fix is BUF_IO_READ without requiring or acquiring any latches. More... | |
bool | was_io_fixed () const |
Checks if io_fix is BUF_IO_FIX or BUF_IO_READ or BUF_IO_WRITE without requiring or acquiring any latches. More... | |
bool | was_io_fix_none () const |
Checks if io_fix is BUF_IO_NONE without requiring or acquiring any latches. More... | |
bool | has_correct_io_fix_value () const |
Checks if io_fix has any of the known enum values. More... | |
buf_io_fix | get_io_fix_snapshot () const |
Retrieves a value of io_fix without requiring or acquiring any latches. More... | |
static bool | is_correct_io_fix_value (buf_io_fix io_fix) |
Checks if io_fix has any of the known enum values. More... | |
LRU replacement algorithm fields | |
log sequence number of the START of the log entry written of the oldest modification to this block which has not yet been flushed on disk; zero if all modifications are on disk. Writes to this field must be covered by both block->mutex and buf_pool->flush_list_mutex. Hence reads can happen while holding any one of the two mutexes These fields are protected by both buf_pool->LRU_list_mutex and the block mutex. | |
page_zip_des_t | zip |
compressed page; zip.data (but not the data it points to) is protected by buf_pool->zip_mutex; state == BUF_BLOCK_ZIP_PAGE and zip.data == NULL means an active buf_pool->watch More... | |
Flush_observer * | m_flush_observer {} |
Flush observer instance. More... | |
fil_space_t * | m_space {} |
Tablespace instance that this page belongs to. More... | |
uint32_t | freed_page_clock |
The value of buf_pool->freed_page_clock when this block was the last time put to the head of the LRU list; a thread is allowed to read this for heuristic purposes without holding any mutex or latch. More... | |
UT_LIST_NODE_T (buf_page_t) LRU | |
node of the LRU list More... | |
Page flushing fields | |
lsn_t | newest_modification |
The flush LSN, LSN when this page was written to the redo log. More... | |
lsn_t | oldest_modification |
log sequence number of the youngest modification to this block, zero if not modified. More... | |
UT_LIST_NODE_T (buf_page_t) list | |
Based on state, this is a list node, protected by the corresponding list mutex, in one of the following lists in buf_pool: More... | |
|
inline |
Copy constructor.
[in] | other | Instance to copy from. |
|
inline |
Checks if the current thread is responsible for I/O on this page now.
|
inline |
|
inlinenoexcept |
|
inline |
Retrieves the current value of io_fix.
Assumes the caller holds buf_page_get_mutex(this).
|
inlineprivate |
Retrieves a value of io_fix without requiring or acquiring any latches.
Note that this implies that the value might be stale unless caller establishes happens-before relation in some other way. This is a low-level function which shouldn't be used directly, but rather via wrapper methods which check if proper latches are taken or via one of the many was_io_fix_something()
methods with name explicitly warning the developer about the uncertainty involved.
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
Retrieve the tablespace object if one was available during page ID initialization.
The returned object is safe to use as long as this buf_page_t object is not changed. Caller should have a IO fix, buffer fix, mutex or any other mean to assure the page will not be freed. After that is released the space object may be freed.
|
inlineprivate |
Checks if io_fix has any of the known enum values.
|
inline |
This is called only when having full ownership of the page object and no other thread can reach it.
This currently happens during buf_pool_create(), buf_pool_resize() (which latch quite a lot) or from fil_tablespace_iterate() which creates a fake, private block which is not really a part of the buffer pool. Therefore we allow this function to set io_fix without checking for any latches. Please use set_io_fix(BUF_IO_NONE) to change state in a regular situation.
|
inlinestatic |
Checks if io_fix has any of the known enum values.
[in] | io_fix | the value to test |
|
inlinenoexcept |
bool buf_page_t::is_io_fix_read | ( | ) | const |
Checks if the current value of io_fix is BUF_IO_READ.
Assumes the caller holds buf_page_get_mutex(this) or some other latches which prevent state transition from/to BUF_IO_READ.
bool buf_page_t::is_io_fix_read_as_opposed_to_write | ( | ) | const |
Assuming that io_fix is either BUF_IO_READ or BUF_IO_WRITE determines which of the two it is.
Additionally it assumes the caller holds buf_page_get_mutex(this) or some other latches which prevent state transition from BUF_IO_READ or from BUF_IO_WRITE to another state.
bool buf_page_t::is_io_fix_write | ( | ) | const |
Checks if the current value of io_fix is BUF_IO_WRITE.
Assumes the caller holds buf_page_get_mutex(this) or some other latches which prevent state transition from/to BUF_IO_WRITE.
|
inline |
Checks if this space reference saved during last page ID initialization was deleted or truncated since.
|
inlinenoexcept |
Retrieve the page number.
|
inline |
This is called only when having full ownership of the page object and no other thread can reach it.
This currently happens during buf_page_init_low() under buf_page_get_mutex(this), on a previously initialized page for reuse, yet should be treated as initialization of the field, not a state transition. Please use set_io_fix(BUF_IO_NONE) to change state in a regular situation.
|
inline |
Called by the thread responsible for I/O on this page to release its responsibility.
|
inlinenoexcept |
Remove the flush observer.
|
inline |
Sets stored value to invalid/empty value.
Handles space object reference count.
|
inline |
Sets stored page ID to the new value.
Handles space object reference count.
[in] | new_page_id | new page ID to be set. |
|
inlinenoexcept |
Set page to clean state.
|
inline |
Set the doublewrite buffer ID.
[in] | batch_id | Double write batch ID that flushed the page. |
|
inlinenoexcept |
Set the flush observer for the page.
[in] | flush_observer | The flush observer to set. |
void buf_page_t::set_io_fix | ( | buf_io_fix | io_fix | ) |
Sets io_fix to specified value.
Assumes the caller holds buf_page_get_mutex(this). Might require additional latches depending on particular state transition. Calls take_io_responsibility() or release_io_responsibility() as needed.
|
inlinenoexcept |
Set the latest modification LSN.
[in] | lsn | Latest modification lSN. |
|
inlinenoexcept |
Set the LSN when the page is modified for the first time.
[in] | lsn | First modification LSN. |
|
inline |
Checks if there is any thread responsible for I/O on this page now.
|
inlinenoexcept |
Retrieve the tablespace id.
|
inlineprivate |
Updates new space reference and acquires "reference count latch" and the current version of the space object.
|
inline |
Called by the thread which becomes responsible for I/O on this page to indicate that it takes the responsibility.
buf_page_t::UT_LIST_NODE_T | ( | buf_page_t | ) |
Based on state, this is a list node, protected by the corresponding list mutex, in one of the following lists in buf_pool:
The node pointers are protected by the corresponding list mutex.
The contents of the list node is undefined if !in_flush_list && state == BUF_BLOCK_FILE_PAGE, or if state is one of BUF_BLOCK_MEMORY, BUF_BLOCK_REMOVE_HASH or BUF_BLOCK_READY_IN_USE.
buf_page_t::UT_LIST_NODE_T | ( | buf_page_t | ) |
node of the LRU list
|
inline |
Checks if io_fix is BUF_IO_NONE without requiring or acquiring any latches.
Note that this implies calling this function twice in a row could produce different results. Please, prefer this function over !was_io_fixed() to avoid the misleading interpretation as "not(Exists time such that io_fix(time))", while in fact we want and get "Exists time such that !io_fix(time)".
|
inline |
Checks if io_fix is BUF_IO_READ without requiring or acquiring any latches.
Note that this implies calling this function twice in a row could produce different results.
|
inline |
Checks if io_fix is BUF_IO_FIX or BUF_IO_READ or BUF_IO_WRITE without requiring or acquiring any latches.
Note that this implies calling this function twice in a row could produce different results.
|
inline |
Checks if this space reference saved during last page ID initialization was deleted or truncated since.
|
friend |
std::chrono::steady_clock::time_point buf_page_t::access_time |
Time of first access, or 0 if the block was never accessed in the buffer pool.
Protected by block mutex
buf_fix_count_atomic_t buf_page_t::buf_fix_count |
Count of how many fold this block is currently bufferfixed.
uint8_t buf_page_t::buf_pool_index |
Index number of the buffer pool that this block belongs to.
bool buf_page_t::file_page_was_freed |
This is set to true when fsp frees a page in buffer pool; protected by buf_pool->zip_mutex or buf_block_t::mutex.
buf_flush_t buf_page_t::flush_type |
If this block is currently being flushed to disk, this tells the flush_type.
uint32_t buf_page_t::freed_page_clock |
The value of buf_pool->freed_page_clock when this block was the last time put to the head of the LRU list; a thread is allowed to read this for heuristic purposes without holding any mutex or latch.
buf_page_t* buf_page_t::hash |
Node used in chaining to buf_pool->page_hash or buf_pool->zip_hash.
page_id_t buf_page_t::id |
Page id.
bool buf_page_t::in_flush_list |
true if in buf_pool->flush_list; when buf_pool->flush_list_mutex is free, the following should hold: in_flush_list == (state == BUF_BLOCK_FILE_PAGE || state == BUF_BLOCK_ZIP_DIRTY) Writes to this field must be covered by both buf_pool->flush_list_mutex and block->mutex.
Hence reads can happen while holding any one of the two mutexes
bool buf_page_t::in_free_list |
true if in buf_pool->free; when buf_pool->free_list_mutex is free, the following should hold: in_free_list == (state == BUF_BLOCK_NOT_USED)
bool buf_page_t::in_LRU_list |
true if the page is in the LRU list; used in debugging
bool buf_page_t::in_page_hash |
true if in buf_pool->page_hash
bool buf_page_t::in_zip_hash |
true if in buf_pool->zip_hash
|
private |
Type of pending I/O operation.
Modified under protection of buf_page_get_mutex(this). Read under protection of rules described in
|
private |
Tracks which thread is responsible for I/O on this page.
|
private |
Double write instance ordinal value during writes.
This is used by IO completion (writes) to select the double write instance.
Flush_observer* buf_page_t::m_flush_observer {} |
Flush observer instance.
fil_space_t* buf_page_t::m_space {} |
Tablespace instance that this page belongs to.
uint32_t buf_page_t::m_version {} |
Version of fil_space_t when the page was updated.
It can also be viewed as the truncation number.
|
private |
The flush LSN, LSN when this page was written to the redo log.
For non redo logged pages this is set using: buf_flush_borrow_lsn()
bool buf_page_t::old |
true if the block is in the old blocks in buf_pool->LRU_old
|
private |
log sequence number of the youngest modification to this block, zero if not modified.
Protected by block mutex
page_size_t buf_page_t::size |
Page size.
buf_page_state buf_page_t::state |
Block state.
page_zip_des_t buf_page_t::zip |
compressed page; zip.data (but not the data it points to) is protected by buf_pool->zip_mutex; state == BUF_BLOCK_ZIP_PAGE and zip.data == NULL means an active buf_pool->watch