MySQL  8.0.22
Source Code Documentation
buf_block_t Struct Reference

The buffer control block structure. More...

#include <buf0buf.h>

Public Member Functions

const page_id_tget_page_id () const
 Get the page number and space id of the current buffer block. More...
 
page_no_t get_page_no () const
 Get the page number of the current buffer block. More...
 
page_no_t get_next_page_no () const
 Get the next page number of the current buffer block. More...
 
page_no_t get_prev_page_no () const
 Get the prev page number of the current buffer block. More...
 
page_type_t get_page_type () const
 Get the page type of the current buffer block. More...
 
const char * get_page_type_str () const
 Get the page type of the current buffer block as string. More...
 

Public Attributes

bool made_dirty_with_no_latch
 true if block has been made dirty without acquiring X/SX latch as the block belongs to temporary tablespace and block is always accessed by a single thread. More...
 
BPageMutex mutex
 mutex protecting this block: state (also protected by the buffer pool mutex), io_fix, buf_fix_count, and accessed; we introduce this new mutex in InnoDB-5.1 to relieve contention on the buffer pool mutex More...
 
Optimistic search field
uint64_t modify_clock
 This clock is incremented every time a pointer to a record on the page may become obsolete; this is used in the optimistic cursor positioning: if the modify clock has not changed, we know that the pointer is still valid; this field may be changed if the thread (1) owns the LRU list mutex and the page is not bufferfixed, or (2) the thread has an x-latch on the block, or (3) the block must belong to an intrinsic table. More...
 
Hash search fields (unprotected)

NOTE that these fields are NOT protected by any semaphore!

ulint n_hash_helps
 counter which controls building of a new hash index for the page More...
 
volatile ulint n_bytes
 recommended prefix length for hash search: number of bytes in an incomplete last field More...
 
volatile ulint n_fields
 recommended prefix length for hash search: number of full fields More...
 
volatile bool left_side
 true or false, depending on whether the leftmost record of several records with the same prefix should be indexed in the hash index More...
 
Hash search fields

These 5 fields may only be modified when: we are holding the appropriate x-latch in btr_search_latches[], and one of the following holds: (1) the block state is BUF_BLOCK_FILE_PAGE, and we are holding an s-latch or x-latch on buf_block_t::lock, or (2) buf_block_t::buf_fix_count == 0, or (3) the block state is BUF_BLOCK_REMOVE_HASH.

An exception to this is when we init or create a page in the buffer pool in buf0buf.cc.

Another exception for buf_pool_clear_hash_index() is that assigning block->index = NULL (and block->n_pointers = 0) is allowed whenever btr_search_own_all(RW_LOCK_X).

Another exception is that ha_insert_for_fold_func() may decrement n_pointers without holding the appropriate latch in btr_search_latches[]. Thus, n_pointers must be protected by atomic memory access.

This implies that the fields may be read without race condition whenever any of the following hold:

  • the btr_search_latches[] s-latch or x-latch is being held, or
  • the block state is not BUF_BLOCK_FILE_PAGE or BUF_BLOCK_REMOVE_HASH, and holding some latch prevents the state from changing to that.

Some use of assert_block_ahi_empty() or assert_block_ahi_valid() is prone to race conditions while buf_pool_clear_hash_index() is executing (the adaptive hash index is being disabled). Such use is explicitly commented.

ulint n_pointers
 used in debugging: the number of pointers in the adaptive hash index pointing to this frame; protected by atomic memory access or btr_search_own_all(). More...
 
unsigned curr_n_fields: 10
 prefix length for hash indexing: number of full fields More...
 
unsigned curr_n_bytes: 15
 number of bytes in hash indexing More...
 
unsigned curr_left_side: 1
 TRUE or FALSE in hash indexing. More...
 
dict_index_tindex
 Index for which the adaptive hash index has been created, or NULL if the page does not exist in the index. More...
 
Debug fields
rw_lock_t debug_latch
 In the debug version, each thread which bufferfixes the block acquires an s-latch here; so we can use the debug utilities in sync0rw. More...
 

General fields

buf_page_t page
 page information; this must be the first field, so that buf_pool->page_hash can point to buf_page_t or buf_block_t More...
 
byteframe
 pointer to buffer frame which is of size UNIV_PAGE_SIZE, and aligned to an address divisible by UNIV_PAGE_SIZE More...
 
BPageLock lock
 read-write lock of the buffer frame More...
 
bool in_unzip_LRU_list
 TRUE if the page is in the decompressed LRU list; used in debugging. More...
 
bool in_withdraw_list
 
unsigned lock_hash_val: 32
 hashed value of the page address in the record lock hash table; protected by buf_block_t::lock (or buf_block_t::mutex in buf_page_get_gen(), buf_page_init_for_read() and buf_page_create()) More...
 
 UT_LIST_NODE_T (buf_block_t) unzip_LRU
 node of the decompressed LRU list; a block is in the unzip_LRU list if page.state == BUF_BLOCK_FILE_PAGE and page.zip.data != NULL. More...
 

Detailed Description

The buffer control block structure.

Member Function Documentation

◆ get_next_page_no()

page_no_t buf_block_t::get_next_page_no ( ) const
inline

Get the next page number of the current buffer block.

Returns
next page number of the current buffer block.

◆ get_page_id()

const page_id_t& buf_block_t::get_page_id ( ) const
inline

Get the page number and space id of the current buffer block.

Returns
page number of the current buffer block.

◆ get_page_no()

page_no_t buf_block_t::get_page_no ( ) const
inline

Get the page number of the current buffer block.

Returns
page number of the current buffer block.

◆ get_page_type()

page_type_t buf_block_t::get_page_type ( ) const
inline

Get the page type of the current buffer block.

Returns
page type of the current buffer block.

◆ get_page_type_str()

const char * buf_block_t::get_page_type_str ( ) const

Get the page type of the current buffer block as string.

Get the page type as a string.

Returns
page type of the current buffer block as string.
the page type as a string.

◆ get_prev_page_no()

page_no_t buf_block_t::get_prev_page_no ( ) const
inline

Get the prev page number of the current buffer block.

Returns
prev page number of the current buffer block.

◆ UT_LIST_NODE_T()

buf_block_t::UT_LIST_NODE_T ( buf_block_t  )

node of the decompressed LRU list; a block is in the unzip_LRU list if page.state == BUF_BLOCK_FILE_PAGE and page.zip.data != NULL.

Protected by both LRU_list_mutex and the block mutex.

Member Data Documentation

◆ curr_left_side

unsigned buf_block_t::curr_left_side

TRUE or FALSE in hash indexing.

◆ curr_n_bytes

unsigned buf_block_t::curr_n_bytes

number of bytes in hash indexing

◆ curr_n_fields

unsigned buf_block_t::curr_n_fields

prefix length for hash indexing: number of full fields

◆ debug_latch

rw_lock_t buf_block_t::debug_latch

In the debug version, each thread which bufferfixes the block acquires an s-latch here; so we can use the debug utilities in sync0rw.

◆ frame

byte* buf_block_t::frame

pointer to buffer frame which is of size UNIV_PAGE_SIZE, and aligned to an address divisible by UNIV_PAGE_SIZE

◆ in_unzip_LRU_list

bool buf_block_t::in_unzip_LRU_list

TRUE if the page is in the decompressed LRU list; used in debugging.

◆ in_withdraw_list

bool buf_block_t::in_withdraw_list

◆ index

dict_index_t* buf_block_t::index

Index for which the adaptive hash index has been created, or NULL if the page does not exist in the index.

Note that it does not guarantee that the index is complete, though: there may have been hash collisions, record deletions, etc.

◆ left_side

volatile bool buf_block_t::left_side

true or false, depending on whether the leftmost record of several records with the same prefix should be indexed in the hash index

◆ lock

BPageLock buf_block_t::lock

read-write lock of the buffer frame

◆ lock_hash_val

unsigned buf_block_t::lock_hash_val

hashed value of the page address in the record lock hash table; protected by buf_block_t::lock (or buf_block_t::mutex in buf_page_get_gen(), buf_page_init_for_read() and buf_page_create())

◆ made_dirty_with_no_latch

bool buf_block_t::made_dirty_with_no_latch

true if block has been made dirty without acquiring X/SX latch as the block belongs to temporary tablespace and block is always accessed by a single thread.

◆ modify_clock

uint64_t buf_block_t::modify_clock

This clock is incremented every time a pointer to a record on the page may become obsolete; this is used in the optimistic cursor positioning: if the modify clock has not changed, we know that the pointer is still valid; this field may be changed if the thread (1) owns the LRU list mutex and the page is not bufferfixed, or (2) the thread has an x-latch on the block, or (3) the block must belong to an intrinsic table.

◆ mutex

BPageMutex buf_block_t::mutex

mutex protecting this block: state (also protected by the buffer pool mutex), io_fix, buf_fix_count, and accessed; we introduce this new mutex in InnoDB-5.1 to relieve contention on the buffer pool mutex

◆ n_bytes

volatile ulint buf_block_t::n_bytes

recommended prefix length for hash search: number of bytes in an incomplete last field

◆ n_fields

volatile ulint buf_block_t::n_fields

recommended prefix length for hash search: number of full fields

◆ n_hash_helps

ulint buf_block_t::n_hash_helps

counter which controls building of a new hash index for the page

◆ n_pointers

ulint buf_block_t::n_pointers

used in debugging: the number of pointers in the adaptive hash index pointing to this frame; protected by atomic memory access or btr_search_own_all().

◆ page

buf_page_t buf_block_t::page

page information; this must be the first field, so that buf_pool->page_hash can point to buf_page_t or buf_block_t


The documentation for this struct was generated from the following files: