MySQL 9.1.0
Source Code Documentation
|
The database buffer buf_pool. More...
#include "mtr0mtr.h"
#include "buf0flu.h"
#include "buf0lru.h"
#include "buf0rea.h"
#include "fsp0types.h"
#include "sync0debug.h"
#include "ut0new.h"
Classes | |
struct | buf_chunk_t |
A chunk of buffers. More... | |
Functions | |
static ulint | buf_pool_get_curr_size (void) |
Gets the current size of buffer buf_pool in bytes. More... | |
static ulint | buf_pool_index (const buf_pool_t *buf_pool) |
Calculates the index of a buffer pool to the buf_pool[] array. More... | |
static buf_pool_t * | buf_pool_from_bpage (const buf_page_t *bpage) |
Returns the buffer pool instance given a page instance. More... | |
static buf_pool_t * | buf_pool_from_block (const buf_block_t *block) |
Returns the buffer pool instance given a block instance. More... | |
static ulint | buf_pool_get_n_pages (void) |
Gets the current size of buffer buf_pool in pages. More... | |
static ulint | buf_page_get_freed_page_clock (const buf_page_t *bpage) |
Reads the freed_page_clock of a buffer block. More... | |
static ulint | buf_block_get_freed_page_clock (const buf_block_t *block) |
Reads the freed_page_clock of a buffer block. More... | |
static bool | buf_page_peek_if_young (const buf_page_t *bpage) |
Tells, for heuristics, if a block is still close enough to the MRU end of the LRU list meaning that it is not in danger of getting evicted and also implying that it has been accessed recently. More... | |
static bool | buf_page_peek_if_too_old (const buf_page_t *bpage) |
Recommends a move of a block to the start of the LRU list if there is danger of dropping from the buffer pool. More... | |
static enum buf_page_state | buf_page_get_state (const buf_page_t *bpage) |
Gets the state of a block. More... | |
static enum buf_page_state | buf_block_get_state (const buf_block_t *block) |
Gets the state of a block. More... | |
static bool | buf_page_is_private (const buf_page_t *bpage, bool hold_block_mutex, bool hold_zip_free_mutex) |
Assert that a given buffer pool page is private to the caller: no pointers to it exist in any buffer pool list or hash table. More... | |
static void | buf_page_set_state (buf_page_t *bpage, enum buf_page_state state) |
Sets the state of a block. More... | |
static void | buf_block_set_state (buf_block_t *block, enum buf_page_state state) |
Sets the state of a block. More... | |
static bool | buf_page_in_file (const buf_page_t *bpage) |
Determines if a block is mapped to a tablespace. More... | |
static bool | buf_page_belongs_to_unzip_LRU (const buf_page_t *bpage) |
Determines if a block should be on unzip_LRU list. More... | |
static BPageMutex * | buf_page_get_mutex (const buf_page_t *bpage) |
Gets the mutex of a block. More... | |
static buf_flush_t | buf_page_get_flush_type (const buf_page_t *bpage) |
Get the flush type of a page. More... | |
static void | buf_page_set_flush_type (buf_page_t *bpage, buf_flush_t flush_type) |
Set the flush type of a page. More... | |
static void | buf_block_set_file_page (buf_block_t *block, const page_id_t &page_id) |
Map a block to a file page. More... | |
static enum buf_io_fix | buf_page_get_io_fix (const buf_page_t *bpage) |
Gets the io_fix state of a block. More... | |
static enum buf_io_fix | buf_block_get_io_fix (const buf_block_t *block) |
Gets the io_fix state of a block. More... | |
static void | buf_page_set_io_fix (buf_page_t *bpage, enum buf_io_fix io_fix) |
Sets the io_fix state of a block. More... | |
static void | buf_block_set_io_fix (buf_block_t *block, enum buf_io_fix io_fix) |
Sets the io_fix state of a block. More... | |
static void | buf_page_set_sticky (buf_page_t *bpage) |
Makes a block sticky. More... | |
static void | buf_page_unset_sticky (buf_page_t *bpage) |
Removes stickiness of a block. More... | |
static bool | buf_page_can_relocate (const buf_page_t *bpage) |
Determine if a buffer block can be relocated in memory. More... | |
static bool | buf_page_is_old (const buf_page_t *bpage) |
Determine if a block has been flagged old. More... | |
static void | buf_page_set_old (buf_page_t *bpage, bool old) |
Flag a block old. More... | |
static std::chrono::steady_clock::time_point | buf_page_is_accessed (const buf_page_t *bpage) |
static void | buf_page_set_accessed (buf_page_t *bpage) |
Flag a block accessed. More... | |
static buf_block_t * | buf_page_get_block (buf_page_t *bpage) |
Gets the buf_block_t handle of a buffered file block if an uncompressed page frame exists, or NULL. More... | |
static buf_frame_t * | buf_block_get_frame (const buf_block_t *block) |
Gets a pointer to the memory frame of a block. More... | |
static buf_frame_t * | buf_frame_align (byte *ptr) |
static void | buf_ptr_get_fsp_addr (const void *ptr, space_id_t *space, fil_addr_t *addr) |
Gets the space id, page offset, and byte offset within page of a pointer pointing to a buffer frame containing a file page. More... | |
static buf_page_t * | buf_page_alloc_descriptor (void) |
Allocates a buf_page_t descriptor. More... | |
static void | buf_block_free (buf_block_t *block) |
Frees a buffer block which does not contain a file page. More... | |
static byte * | buf_frame_copy (byte *buf, const buf_frame_t *frame) |
Copies contents of a buffer frame to a given buffer. More... | |
static lsn_t | buf_page_get_newest_modification (const buf_page_t *bpage) |
static void | buf_block_modify_clock_inc (buf_block_t *block) |
Increment the modify clock. More... | |
static ulint | buf_block_fix (buf_page_t *bpage) |
Increments the bufferfix count. More... | |
static ulint | buf_block_fix (buf_block_t *block) |
Increments the bufferfix count. More... | |
static void | buf_block_buf_fix_inc_func (ut::Location location, buf_block_t *block) |
static ulint | buf_block_unfix (buf_page_t *bpage) |
Decrements the bufferfix count. More... | |
static ulint | buf_block_unfix (buf_block_t *block) |
Decrements the bufferfix count. More... | |
static void | buf_block_buf_fix_dec (buf_block_t *block) |
Decrements the bufferfix count. More... | |
static buf_pool_t * | buf_pool_get (const page_id_t &page_id) |
Returns the buffer pool instance given a page id. More... | |
static buf_pool_t * | buf_pool_from_array (ulint index) |
Returns the buffer pool instance given its array index. More... | |
static buf_page_t * | buf_page_hash_get_low (buf_pool_t *buf_pool, const page_id_t &page_id) |
Returns the control block of a file page, NULL if not found. More... | |
static buf_page_t * | buf_page_hash_get_locked (buf_pool_t *buf_pool, const page_id_t &page_id, rw_lock_t **lock, ulint lock_mode, bool watch) |
Returns the control block of a file page, NULL if not found. More... | |
static buf_block_t * | buf_block_hash_get_locked (buf_pool_t *buf_pool, const page_id_t &page_id, rw_lock_t **lock, ulint lock_mode) |
Returns the control block of a file page, NULL if not found. More... | |
static bool | buf_page_peek (const page_id_t &page_id) |
Returns true if the page can be found in the buffer pool hash table. More... | |
static void | buf_page_release_zip (buf_page_t *bpage) |
Releases a compressed-only page acquired with buf_page_get_zip(). More... | |
static void | buf_page_release_latch (buf_block_t *block, ulint rw_latch) |
Releases a latch, if specified. More... | |
static void | buf_block_dbg_add_level (buf_block_t *block, latch_level_t level) |
Adds latch level info for the rw-lock protecting the buffer frame. More... | |
static buf_block_t * | buf_get_nth_chunk_block (const buf_pool_t *buf_pool, ulint n, ulint *chunk_size) |
Get the nth chunk's buffer block in the specified buffer pool. More... | |
static ulint | buf_pool_size_align (ulint size) |
Calculate aligned buffer pool size based on srv_buf_pool_chunk_unit, if needed. More... | |
static ulint | buf_get_withdraw_depth (buf_pool_t *buf_pool) |
Return how many more pages must be added to the withdraw list to reach the withdraw target of the currently ongoing buffer pool resize. More... | |
The database buffer buf_pool.
Created 11/5/1995 Heikki Tuuri
|
inlinestatic |
Decrements the bufferfix count.
block | in/out: block to bufferunfix |
|
inlinestatic |
|
inlinestatic |
Adds latch level info for the rw-lock protecting the buffer frame.
This should be called in the debug version after a successful latching of a page if we know the latching order level of the acquired latch.
block | in: buffer page where we have acquired latch |
level | in: latching order level |
|
inlinestatic |
Increments the bufferfix count.
[in,out] | block | block to bufferfix |
|
inlinestatic |
Increments the bufferfix count.
[in,out] | bpage | block to bufferfix |
|
inlinestatic |
Frees a buffer block which does not contain a file page.
block | in, own: block to be freed |
|
inlinestatic |
Gets a pointer to the memory frame of a block.
block | in: pointer to the control block |
|
inlinestatic |
Reads the freed_page_clock of a buffer block.
block | in: block |
|
inlinestatic |
Gets the io_fix state of a block.
block | in: pointer to the control block |
|
inlinestatic |
Gets the state of a block.
block | in: pointer to the control block |
|
inlinestatic |
Returns the control block of a file page, NULL if not found.
If the block is found and lock is not NULL then the appropriate page_hash lock is acquired in the specified lock mode. Otherwise, mode value is ignored. It is up to the caller to release the lock. If the block is found and the lock is NULL then the page_hash lock is released by this function.
[in] | buf_pool | buffer pool instance |
[in] | page_id | page id |
[in,out] | lock | lock of the page hash acquired if bpage is found, NULL otherwise. If NULL is passed then the hash_lock is released by this function. |
[in] | lock_mode | RW_LOCK_X or RW_LOCK_S. Ignored if lock == NULL |
|
inlinestatic |
Increment the modify clock.
The caller must (1) block bufferfix count has to be zero, (2) own X or SX latch on the block->lock, or (3) operate on a thread-private temporary table
[in,out] | block | buffer block |
|
inlinestatic |
Map a block to a file page.
[in,out] | block | pointer to control block |
[in] | page_id | page id |
|
inlinestatic |
Sets the io_fix state of a block.
block | in/out: control block |
io_fix | in: io_fix state |
|
inlinestatic |
Sets the state of a block.
block | in/out: pointer to control block |
state | in: state |
|
inlinestatic |
Decrements the bufferfix count.
[in,out] | block | block to bufferunfix |
|
inlinestatic |
Decrements the bufferfix count.
[in,out] | bpage | block to bufferunfix |
|
inlinestatic |
|
inlinestatic |
Copies contents of a buffer frame to a given buffer.
buf | in: buffer to copy to |
frame | in: buffer frame |
|
inlinestatic |
Get the nth chunk's buffer block in the specified buffer pool.
buf_pool | in: buffer pool instance |
n | in: nth chunk in the buffer pool |
chunk_size | in: chunk size |
|
inlinestatic |
Return how many more pages must be added to the withdraw list to reach the withdraw target of the currently ongoing buffer pool resize.
[in] | buf_pool | buffer pool instance |
|
inlinestatic |
Allocates a buf_page_t descriptor.
This function must succeed. In case of failure we assert in this function.
|
inlinestatic |
Determines if a block should be on unzip_LRU list.
bpage | in: pointer to control block |
|
inlinestatic |
Determine if a buffer block can be relocated in memory.
The block can be dirty, but it must not be I/O-fixed or bufferfixed.
bpage | control block being relocated |
|
inlinestatic |
Gets the buf_block_t handle of a buffered file block if an uncompressed page frame exists, or NULL.
page frame exists, or NULL. The caller must hold either the appropriate hash lock in any mode, either the LRU list mutex. Note: even though bpage is not declared a const we don't update its value. It is safe to make this pure.
[in] | bpage | control block, or NULL |
|
inlinestatic |
Get the flush type of a page.
bpage | in: buffer page |
|
inlinestatic |
Reads the freed_page_clock of a buffer block.
bpage | in: block |
|
inlinestatic |
Gets the io_fix state of a block.
bpage | in: pointer to the control block |
|
inlinestatic |
Gets the mutex of a block.
bpage | in: pointer to control block |
|
inlinestatic |
|
inlinestatic |
Gets the state of a block.
bpage | in: pointer to the control block |
|
inlinestatic |
Returns the control block of a file page, NULL if not found.
If the block is found and lock is not NULL then the appropriate page_hash lock is acquired in the specified lock mode. Otherwise, mode value is ignored. It is up to the caller to release the lock. If the block is found and the lock is NULL then the page_hash lock is released by this function.
[in] | buf_pool | buffer pool instance |
[in] | page_id | page id |
[in,out] | lock | lock of the page hash acquired if bpage is found, NULL otherwise. If NULL is passed then the hash_lock is released by this function. |
[in] | lock_mode | RW_LOCK_X or RW_LOCK_S. Ignored if lock == NULL |
[in] | watch | if true, return watch sentinel also. |
|
inlinestatic |
Returns the control block of a file page, NULL if not found.
[in] | buf_pool | buffer pool instance |
[in] | page_id | page id |
|
inlinestatic |
Determines if a block is mapped to a tablespace.
bpage | in: pointer to control block |
|
inlinestatic |
|
inlinestatic |
Determine if a block has been flagged old.
[in] | bpage | control block |
|
inlinestatic |
Assert that a given buffer pool page is private to the caller: no pointers to it exist in any buffer pool list or hash table.
Accessing pages by iterating over buffer pool chunks is not considered here. Furthermore, assert that no buffer pool locks except for LRU list mutex and page hash are held.
[in] | bpage | pointer to a buffer pool page |
[in] | hold_block_mutex | flag whether holding block mutex |
[in] | hold_zip_free_mutex | flag whether holding zip free mutex |
|
inlinestatic |
Returns true if the page can be found in the buffer pool hash table.
NOTE that it is possible that the page is not yet read from disk, though.
[in] | page_id | page id |
|
inlinestatic |
Recommends a move of a block to the start of the LRU list if there is danger of dropping from the buffer pool.
NOTE: does not reserve the LRU list mutex.
[in] | bpage | block to make younger |
|
inlinestatic |
Tells, for heuristics, if a block is still close enough to the MRU end of the LRU list meaning that it is not in danger of getting evicted and also implying that it has been accessed recently.
The page must be either buffer-fixed, either its page hash must be locked.
[in] | bpage | block |
|
inlinestatic |
Releases a latch, if specified.
block | in: buffer block |
rw_latch | in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH |
|
inlinestatic |
Releases a compressed-only page acquired with buf_page_get_zip().
bpage | in: buffer block |
|
inlinestatic |
Flag a block accessed.
bpage | in/out: control block |
|
inlinestatic |
Set the flush type of a page.
bpage | in: buffer page |
flush_type | in: flush type |
|
inlinestatic |
Sets the io_fix state of a block.
bpage | in/out: control block |
io_fix | in: io_fix state |
|
inlinestatic |
Flag a block old.
[in] | bpage | control block |
[in] | old | old |
|
inlinestatic |
Sets the state of a block.
[in,out] | bpage | pointer to control block |
[in] | state | state |
|
inlinestatic |
Makes a block sticky.
A sticky block implies that even after we release the buf_pool->LRU_list_mutex and the block->mutex: it cannot be removed from the flush_list the block descriptor cannot be relocated it cannot be removed from the LRU list Note that: the block can still change its position in the LRU list the next and previous pointers can change.
[in,out] | bpage | control block |
|
inlinestatic |
Removes stickiness of a block.
bpage | in/out: control block |
|
inlinestatic |
Returns the buffer pool instance given its array index.
index | in: array index to get buffer pool instance from |
|
inlinestatic |
Returns the buffer pool instance given a block instance.
block | in: block |
|
inlinestatic |
Returns the buffer pool instance given a page instance.
bpage | in: buffer pool page |
|
inlinestatic |
Returns the buffer pool instance given a page id.
[in] | page_id | page id |
|
inlinestatic |
Gets the current size of buffer buf_pool in bytes.
|
inlinestatic |
Gets the current size of buffer buf_pool in pages.
|
inlinestatic |
Calculates the index of a buffer pool to the buf_pool[] array.
buf_pool | in: buffer pool |
Calculate aligned buffer pool size based on srv_buf_pool_chunk_unit, if needed.
[in] | size | size in bytes |
|
inlinestatic |
Gets the space id, page offset, and byte offset within page of a pointer pointing to a buffer frame containing a file page.
ptr | in: pointer to a buffer frame |
space | out: space id |
addr | out: page offset and byte offset |