MySQL 8.0.40
Source Code Documentation
|
The database buffer pool flush algorithm. More...
Go to the source code of this file.
Classes | |
class | Flush_observer |
We use Flush_observer to track flushing of non-redo logged pages in bulk create index(btr0load.cc).Since we disable redo logging during a index build, we need to make sure that all dirty pages modified by the index build are flushed to disk before any redo logged operations go to the index. More... | |
Functions | |
bool | buf_flush_page_cleaner_is_active () |
Checks if the page_cleaner is in active state. More... | |
void | buf_flush_remove (buf_page_t *bpage) |
Remove a block from the flush list of modified blocks. More... | |
void | buf_flush_relocate_on_flush_list (buf_page_t *bpage, buf_page_t *dpage) |
Relocates a buffer control block on the flush_list. More... | |
void | buf_flush_write_complete (buf_page_t *bpage) |
Updates the flush system data structures when a write is completed. More... | |
bool | page_is_uncompressed_type (const byte *page) |
Check if page type is uncompressed. More... | |
void | buf_flush_init_for_writing (const buf_block_t *block, byte *page, void *page_zip_, lsn_t newest_lsn, bool skip_checksum, bool skip_lsn_check) |
Initialize a page for writing to the tablespace. More... | |
bool | buf_flush_page_try (buf_pool_t *buf_pool, buf_block_t *block) |
Writes a flushable page asynchronously from the buffer pool to a file. More... | |
bool | buf_flush_do_batch (buf_pool_t *buf_pool, buf_flush_t type, ulint min_n, lsn_t lsn_limit, ulint *n_processed) |
Do flushing batch of a given type. More... | |
bool | buf_flush_lists (ulint min_n, lsn_t lsn_limit, ulint *n_processed) |
This utility flushes dirty blocks from the end of the flush list of all buffer pool instances. More... | |
bool | buf_flush_single_page_from_LRU (buf_pool_t *buf_pool) |
This function picks up a single page from the tail of the LRU list, flushes it (if it is dirty), removes it from page_hash and LRU list and puts it on the free list. More... | |
void | buf_flush_wait_batch_end (buf_pool_t *buf_pool, buf_flush_t flush_type) |
Waits until a flush batch of the given type ends. More... | |
void | buf_flush_wait_batch_end_wait_only (buf_pool_t *buf_pool, buf_flush_t type) |
Waits until a flush batch of the given type ends. More... | |
static void | buf_flush_note_modification (buf_block_t *block, lsn_t start_lsn, lsn_t end_lsn, Flush_observer *observer) |
This function should be called at a mini-transaction commit, if a page was modified in it. More... | |
static void | buf_flush_recv_note_modification (buf_block_t *block, lsn_t start_lsn, lsn_t end_lsn) |
This function should be called when recovery has modified a buffer page. More... | |
bool | buf_flush_ready_for_replace (buf_page_t *bpage) |
Returns true if the file page block is immediately suitable for replacement, i.e., the transition FILE_PAGE => NOT_USED allowed. More... | |
void | buf_flush_page_cleaner_disabled_debug_update (THD *thd, SYS_VAR *var, void *var_ptr, const void *save) |
Disables page cleaner threads (coordinator and workers). More... | |
void | buf_flush_page_cleaner_init () |
Initialize page_cleaner. More... | |
void | buf_flush_wait_LRU_batch_end () |
Wait for any possible LRU flushes that are in progress to end. More... | |
bool | buf_flush_validate (buf_pool_t *buf_pool) |
Validates the flush list. More... | |
void | buf_flush_init_flush_rbt (void) |
Initialize the red-black tree to speed up insertions into the flush_list during recovery process. More... | |
void | buf_flush_free_flush_rbt (void) |
Frees up the red-black tree. More... | |
bool | buf_flush_page (buf_pool_t *buf_pool, buf_page_t *bpage, buf_flush_t flush_type, bool sync) |
Writes a flushable page asynchronously from the buffer pool to a file. More... | |
bool | buf_flush_ready_for_flush (buf_page_t *bpage, buf_flush_t flush_type) |
Check if the block is modified and ready for flushing. More... | |
ulint | buf_pool_get_dirty_pages_count (buf_pool_t *buf_pool, space_id_t id, Flush_observer *observer) |
Check if there are any dirty pages that belong to a space id in the flush list in a particular buffer pool. More... | |
void | buf_flush_fsync () |
Executes fsync for all tablespaces, to fsync all pages written to disk. More... | |
void | buf_flush_sync_all_buf_pools () |
Synchronously flush dirty blocks from the end of the flush list of all buffer pool instances. More... | |
bool | buf_are_flush_lists_empty_validate () |
Checks if all flush lists are empty. More... | |
lsn_t | get_flush_sync_lsn () noexcept |
Get the lsn up to which data pages are to be synchronously flushed. More... | |
Variables | |
bool | innodb_page_cleaner_disabled_debug |
Value of MySQL global variable used to disable page cleaner. More... | |
os_event_t | buf_flush_event |
Event to synchronise with the flushing. More... | |
os_event_t | buf_flush_tick_event |
Event to wait for one flushing step. More... | |
The database buffer pool flush algorithm.
Created 11/5/1995 Heikki Tuuri
bool buf_are_flush_lists_empty_validate | ( | ) |
Checks if all flush lists are empty.
It is supposed to be used in single thread, during startup or shutdown. Hence it does not acquire lock and it is caller's responsibility to guarantee that flush lists are not changed in background.
bool buf_flush_do_batch | ( | buf_pool_t * | buf_pool, |
buf_flush_t | type, | ||
ulint | min_n, | ||
lsn_t | lsn_limit, | ||
ulint * | n_processed | ||
) |
Do flushing batch of a given type.
NOTE: The calling thread is not allowed to own any latches on pages!
[in,out] | buf_pool | buffer pool instance |
[in] | type | flush type |
[in] | min_n | wished minimum number of blocks flushed (it is not guaranteed that the actual number is that big, though) |
[in] | lsn_limit | in the case BUF_FLUSH_LIST all blocks whose oldest_modification is smaller than this should be flushed (if their number does not exceed min_n), otherwise ignored |
[out] | n_processed | the number of pages which were processed is passed back to caller. Ignored if NULL |
true | if a batch was queued successfully. |
false | if another batch of same type was already running. |
void buf_flush_free_flush_rbt | ( | void | ) |
Frees up the red-black tree.
void buf_flush_fsync | ( | ) |
Executes fsync for all tablespaces, to fsync all pages written to disk.
void buf_flush_init_flush_rbt | ( | void | ) |
Initialize the red-black tree to speed up insertions into the flush_list during recovery process.
Should be called at the start of recovery process before any page has been read/written.
void buf_flush_init_for_writing | ( | const buf_block_t * | block, |
byte * | page, | ||
void * | page_zip_, | ||
lsn_t | newest_lsn, | ||
bool | skip_checksum, | ||
bool | skip_lsn_check | ||
) |
Initialize a page for writing to the tablespace.
[in] | block | buffer block; NULL if bypassing the buffer pool |
[in,out] | page | page frame |
[in,out] | page_zip_ | compressed page, or NULL if uncompressed |
[in] | newest_lsn | newest modification LSN to the page |
[in] | skip_checksum | whether to disable the page checksum |
[in] | skip_lsn_check | true to skip check for LSN (in DEBUG) |
This utility flushes dirty blocks from the end of the flush list of all buffer pool instances.
NOTE: The calling thread is not allowed to own any latches on pages!
[in] | min_n | wished minimum number of blocks flushed (it is not guaranteed that the actual number is that big, though) |
[in] | lsn_limit | in the case BUF_FLUSH_LIST all blocks whose oldest_modification is smaller than this should be flushed (if their number does not exceed min_n), otherwise ignored |
[out] | n_processed | the number of pages which were processed is passed back to caller. Ignored if NULL. |
|
inlinestatic |
This function should be called at a mini-transaction commit, if a page was modified in it.
Puts the block to the list of modified blocks, if it not already in it.
[in] | block | block which is modified |
[in] | start_lsn | start lsn of the first mtr in a set of mtr's |
[in] | end_lsn | end lsn of the last mtr in the set of mtr's |
[in] | observer | flush observer |
bool buf_flush_page | ( | buf_pool_t * | buf_pool, |
buf_page_t * | bpage, | ||
buf_flush_t | flush_type, | ||
bool | sync | ||
) |
Writes a flushable page asynchronously from the buffer pool to a file.
NOTE: 1. in simulated aio we must call os_aio_simulated_wake_handler_threads after we have posted a batch of writes! 2. buf_page_get_mutex(bpage) must be held upon entering this function. The LRU list mutex must be held if flush_type == BUF_FLUSH_SINGLE_PAGE. Both mutexes will be released by this function if it returns true.
[in] | buf_pool | buffer pool instance |
[in] | bpage | buffer control block |
[in] | flush_type | type of flush |
[in] | sync | true if sync IO request |
void buf_flush_page_cleaner_disabled_debug_update | ( | THD * | thd, |
SYS_VAR * | var, | ||
void * | var_ptr, | ||
const void * | save | ||
) |
Disables page cleaner threads (coordinator and workers).
It's used by: SET GLOBAL innodb_page_cleaner_disabled_debug = 1 (0).
[in] | thd | thread handle |
[in] | var | pointer to system variable |
[out] | var_ptr | where the formal string goes |
[in] | save | immediate result from check function |
void buf_flush_page_cleaner_init | ( | ) |
Initialize page_cleaner.
bool buf_flush_page_cleaner_is_active | ( | ) |
Checks if the page_cleaner is in active state.
Checks if the page_cleaner is in active state.
bool buf_flush_page_try | ( | buf_pool_t * | buf_pool, |
buf_block_t * | block | ||
) |
Writes a flushable page asynchronously from the buffer pool to a file.
NOTE: block and LRU list mutexes must be held upon entering this function, and they will be released by this function after flushing. This is loosely based on buf_flush_batch() and buf_flush_page().
[in,out] | buf_pool | buffer pool instance |
[in,out] | block | buffer control block |
bool buf_flush_ready_for_flush | ( | buf_page_t * | bpage, |
buf_flush_t | flush_type | ||
) |
Check if the block is modified and ready for flushing.
Requires buf_page_get_mutex(bpage).
[in] | bpage | buffer control block, must be buf_page_in_file() |
[in] | flush_type | type of flush |
bool buf_flush_ready_for_replace | ( | buf_page_t * | bpage | ) |
Returns true if the file page block is immediately suitable for replacement, i.e., the transition FILE_PAGE => NOT_USED allowed.
The caller must hold the LRU list and block mutexes.
[in] | bpage | buffer control block, must be buf_page_in_file() and in the LRU list |
|
inlinestatic |
This function should be called when recovery has modified a buffer page.
[in] | block | block which is modified |
[in] | start_lsn | start lsn of the first mtr in a set of mtr's |
[in] | end_lsn | end lsn of the last mtr in the set of mtr's |
void buf_flush_relocate_on_flush_list | ( | buf_page_t * | bpage, |
buf_page_t * | dpage | ||
) |
Relocates a buffer control block on the flush_list.
Note that it is assumed that the contents of bpage has already been copied to dpage. in/out: destination block
Note that it is assumed that the contents of bpage have already been copied to dpage. IMPORTANT: When this function is called bpage and dpage are not exact copies of each other. For example, they both will have different "::state". Also the "::list" pointers in dpage may be stale. We need to use the current list node (bpage) to do the list manipulation because the list pointers could have changed between the time that we copied the contents of bpage to the dpage and the flush list manipulation below.
bpage | in/out: control block being moved |
dpage | in/out: destination block |
void buf_flush_remove | ( | buf_page_t * | bpage | ) |
Remove a block from the flush list of modified blocks.
[in] | bpage | pointer to the block in question |
bool buf_flush_single_page_from_LRU | ( | buf_pool_t * | buf_pool | ) |
This function picks up a single page from the tail of the LRU list, flushes it (if it is dirty), removes it from page_hash and LRU list and puts it on the free list.
It is called from user threads when they are unable to find a replaceable page at the tail of the LRU list i.e.: when the background LRU flushing in the page_cleaner thread is not fast enough to keep pace with the workload.
[in,out] | buf_pool | buffer pool instance |
void buf_flush_sync_all_buf_pools | ( | ) |
Synchronously flush dirty blocks from the end of the flush list of all buffer pool instances.
NOTE: The calling thread is not allowed to own any latches on pages!
bool buf_flush_validate | ( | buf_pool_t * | buf_pool | ) |
Validates the flush list.
void buf_flush_wait_batch_end | ( | buf_pool_t * | buf_pool, |
buf_flush_t | flush_type | ||
) |
Waits until a flush batch of the given type ends.
[in] | buf_pool | Buffer pool instance. |
[in] | flush_type | Flush type. |
void buf_flush_wait_batch_end_wait_only | ( | buf_pool_t * | buf_pool, |
buf_flush_t | type | ||
) |
Waits until a flush batch of the given type ends.
This is called by a thread that only wants to wait for a flush to end but doesn't do any flushing itself.
[in] | buf_pool | buffer pool instance |
[in] | type | BUF_FLUSH_LRU or BUF_FLUSH_LIST |
void buf_flush_wait_LRU_batch_end | ( | ) |
Wait for any possible LRU flushes that are in progress to end.
void buf_flush_write_complete | ( | buf_page_t * | bpage | ) |
Updates the flush system data structures when a write is completed.
[in] | bpage | pointer to the block in question |
ulint buf_pool_get_dirty_pages_count | ( | buf_pool_t * | buf_pool, |
space_id_t | id, | ||
Flush_observer * | observer | ||
) |
Check if there are any dirty pages that belong to a space id in the flush list in a particular buffer pool.
buf_pool | in: buffer pool |
id | in: space id to check |
observer | in: flush observer to check |
|
noexcept |
Get the lsn up to which data pages are to be synchronously flushed.
bool page_is_uncompressed_type | ( | const byte * | page | ) |
Check if page type is uncompressed.
[in] | page | page frame |
|
extern |
Event to synchronise with the flushing.
|
extern |
Event to wait for one flushing step.
|
extern |
Value of MySQL global variable used to disable page cleaner.