MySQL 8.0.31
Source Code Documentation
buf0rea.h File Reference

The database buffer read. More...

#include "buf0buf.h"
#include "buf0types.h"

Go to the source code of this file.

Functions

ulint buf_read_page_low (dberr_t *err, bool sync, ulint type, ulint mode, const page_id_t &page_id, const page_size_t &page_size, bool unzip)
 Low-level function which reads a page asynchronously from a file to the buffer buf_pool if it is not already there, in which case does nothing. More...
 
bool buf_read_page (const page_id_t &page_id, const page_size_t &page_size)
 High-level function which reads a page asynchronously from a file to the buffer buf_pool if it is not already there. More...
 
bool buf_read_page_background (const page_id_t &page_id, const page_size_t &page_size, bool sync)
 High-level function which reads a page asynchronously from a file to the buffer buf_pool if it is not already there. More...
 
ulint buf_read_ahead_random (const page_id_t &page_id, const page_size_t &page_size, bool inside_ibuf)
 Applies a random read-ahead in buf_pool if there are at least a threshold value of accessed pages from the random read-ahead area. More...
 
ulint buf_read_ahead_linear (const page_id_t &page_id, const page_size_t &page_size, bool inside_ibuf)
 Applies linear read-ahead if in the buf_pool the page is a border page of a linear read-ahead area and all the pages in the area have been accessed. More...
 
void buf_read_ibuf_merge_pages (bool sync, const space_id_t *space_ids, const page_no_t *page_nos, ulint n_stored)
 Issues read requests for pages which the ibuf module wants to read in, in order to contract the insert buffer tree. More...
 
void buf_read_recv_pages (bool sync, space_id_t space_id, const page_no_t *page_nos, ulint n_stored)
 Issues read requests for pages which recovery wants to read in. More...
 

Variables

Modes used in read-ahead
constexpr uint32_t BUF_READ_IBUF_PAGES_ONLY = 131
 read only pages belonging to the insert buffer tree More...
 
constexpr uint32_t BUF_READ_ANY_PAGE = 132
 read any page More...
 

Detailed Description

The database buffer read.

Created 11/5/1995 Heikki Tuuri

Function Documentation

◆ buf_read_ahead_linear()

ulint buf_read_ahead_linear ( const page_id_t page_id,
const page_size_t page_size,
bool  inside_ibuf 
)

Applies linear read-ahead if in the buf_pool the page is a border page of a linear read-ahead area and all the pages in the area have been accessed.

Does not read any page if the read-ahead mechanism is not activated. Note that the algorithm looks at the 'natural' adjacent successor and predecessor of the page, which on the leaf level of a B-tree are the next and previous page in the chain of leaves. To know these, the page specified in (space, offset) must already be present in the buf_pool. Thus, the natural way to use this function is to call it when a page in the buf_pool is accessed the first time, calling this function just after it has been bufferfixed. NOTE 1: as this function looks at the natural predecessor and successor fields on the page, what happens, if these are not initialized to any sensible value? No problem, before applying read-ahead we check that the area to read is within the span of the space, if not, read-ahead is not applied. An uninitialized value may result in a useless read operation, but only very improbably. NOTE 2: the calling thread may own latches on pages: to avoid deadlocks this function must be written such that it cannot end up waiting for these latches! NOTE 3: the calling thread must want access to the page given: this rule is set to prevent unintended read-aheads performed by ibuf routines, a situation which could result in a deadlock if the OS does not support asynchronous io.

Parameters
[in]page_idpage id; see NOTE 3 above
[in]page_sizepage size
[in]inside_ibuftrue if we are inside ibuf routine
Returns
number of page read requests issued

◆ buf_read_ahead_random()

ulint buf_read_ahead_random ( const page_id_t page_id,
const page_size_t page_size,
bool  inside_ibuf 
)

Applies a random read-ahead in buf_pool if there are at least a threshold value of accessed pages from the random read-ahead area.

Does not read any page, not even the one at the position (space, offset), if the read-ahead mechanism is not activated. NOTE 1: the calling thread may own latches on pages: to avoid deadlocks this function must be written such that it cannot end up waiting for these latches! NOTE 2: the calling thread must want access to the page given: this rule is set to prevent unintended read-aheads performed by ibuf routines, a situation which could result in a deadlock if the OS does not support asynchronous i/o.

Parameters
[in]page_idpage id of a page which the current thread wants to access
[in]page_sizepage size
[in]inside_ibuftrue if we are inside ibuf routine
Returns
number of page read requests issued; NOTE that if we read ibuf pages, it may happen that the page at the given page number does not get read even if we return a positive value!

◆ buf_read_ibuf_merge_pages()

void buf_read_ibuf_merge_pages ( bool  sync,
const space_id_t space_ids,
const page_no_t page_nos,
ulint  n_stored 
)

Issues read requests for pages which the ibuf module wants to read in, in order to contract the insert buffer tree.

Technically, this function is like a read-ahead function.

Parameters
[in]synctrue if the caller wants this function to wait for the highest address page to get read in, before this function returns.
[in]space_idsArray of space ids.
[in]page_nosArray of page numbers to read, with the highest page number the last in the array.
[in]n_storednumber of elements in the arrays.

◆ buf_read_page()

bool buf_read_page ( const page_id_t page_id,
const page_size_t page_size 
)

High-level function which reads a page asynchronously from a file to the buffer buf_pool if it is not already there.

Sets the io_fix flag and sets an exclusive lock on the buffer frame. The flag is cleared and the x-lock released by the i/o-handler thread.

Parameters
[in]page_idpage id
[in]page_sizepage size
Returns
true if page has been read in, false in case of failure

◆ buf_read_page_background()

bool buf_read_page_background ( const page_id_t page_id,
const page_size_t page_size,
bool  sync 
)

High-level function which reads a page asynchronously from a file to the buffer buf_pool if it is not already there.

Sets the io_fix flag and sets an exclusive lock on the buffer frame. The flag is cleared and the x-lock released by the i/o-handler thread.

Parameters
[in]page_idpage id
[in]page_sizepage size
[in]synctrue if synchronous aio is desired
Returns
true if page has been read in, false in case of failure

◆ buf_read_page_low()

ulint buf_read_page_low ( dberr_t err,
bool  sync,
ulint  type,
ulint  mode,
const page_id_t page_id,
const page_size_t page_size,
bool  unzip 
)

Low-level function which reads a page asynchronously from a file to the buffer buf_pool if it is not already there, in which case does nothing.

Sets the io_fix flag and sets an exclusive lock on the buffer frame. The flag is cleared and the x-lock released by an i/o-handler thread.

Parameters
[out]errDB_SUCCESS or DB_TABLESPACE_DELETED if we are trying to read from a non-existent tablespace or a tablespace which is just now being dropped
[in]syncwhether synchronous aio is desired
[in]typeRequest type
[in]modeBUF_READ_IBUF_PAGES_ONLY, ...
[in]page_idpage id
[in]page_sizepage size
[in]unziptrue=request uncompressed page
Returns
1 if a read request was queued, 0 if the page already resided in buf_pool, or if the page is in the doublewrite buffer blocks in which case it is never read into the pool, or if the tablespace does not exist or is being dropped

◆ buf_read_recv_pages()

void buf_read_recv_pages ( bool  sync,
space_id_t  space_id,
const page_no_t page_nos,
ulint  n_stored 
)

Issues read requests for pages which recovery wants to read in.

Parameters
[in]synctrue if the caller wants this function to wait for the highest address page to get read in, before this function returns
[in]space_idtablespace id
[in]page_nosarray of page numbers to read, with the highest page number the last in the array
[in]n_storednumber of page numbers in the array

Variable Documentation

◆ BUF_READ_ANY_PAGE

constexpr uint32_t BUF_READ_ANY_PAGE = 132
constexpr

read any page

◆ BUF_READ_IBUF_PAGES_ONLY

constexpr uint32_t BUF_READ_IBUF_PAGES_ONLY = 131
constexpr

read only pages belonging to the insert buffer tree