MySQL 26.7.0
Source Code Documentation
dblwr::recv::Pages Class Reference

Pages recovered from the doublewrite buffer. More...

Public Types

using Buffers = std::vector< Page *, ut::allocator< Page * > >
 
using Page_entries = std::vector< Page_entry, ut::allocator< Page_entry > >
 

Public Member Functions

 Pages ()
 Default constructor. More...
 
 ~Pages () noexcept
 Destructor. More...
 
void add (page_no_t page_no, const byte *page, uint32_t n_bytes) noexcept
 Add a page frame to the doublewrite recovery buffer. More...
 
void add_entry (Page_entry &pg_entry)
 Add a page entry from reduced doublewrite buffer to vector. More...
 
void done_loading_prepare_for_recovery () noexcept
 Indicates that all add() calls were done, and it is time to prepare this data structure for subsequent recover() calls. More...
 
const bytefind (const page_id_t &page_id) const noexcept
 Find a doublewrite copy of a page. More...
 
const byteget_first_page_content_for_recovery (space_id_t space_id, page_size_t page_size, const std::string &file_path, const byte *page_content) const
 Checks if content of the first page provided from the specified space requires recovery from the Double-write Buffer. More...
 
void dblwr_recover_page (const fil_space_t &space, page_no_t page_no, byte *dblwr_page) noexcept
 Checks if Double-write recovery of the specified tablespace page is needed. More...
 
bool is_actual_page_corrupted (const fil_space_t &space, const page_id_t &page_id)
 Checks if page in tablespace is corrupted or an all-zero page. More...
 
std::optional< lsn_tget_max_lsn_of_reduced_page_entries (const page_id_t &page_id) const noexcept
 Check if page was logged in reduced doublewrite buffer mode, and if so also return the maximum page LSN mentioned for all entries for this page ID. More...
 
void recover (fil_space_t &space) noexcept
 Restore corrupted pages of the tablespace from the double write buffer. More...
 
void check_missing_tablespaces () const noexcept
 Check if some pages could be restored because of missing tablespace IDs. More...
 
Buffersget_pages () noexcept
 Object the vector of pages. More...
 

Private Member Functions

void detect_corruption_from_reduced_entries (const fil_space_t &space) noexcept
 Checks if there are any corrupted pages in the tablespace that can be found in the reduced double write buffer. More...
 
 Pages (const Pages &)=delete
 
 Pages (Pages &&)=delete
 
Pagesoperator= (Pages &&)=delete
 
Pagesoperator= (const Pages &)=delete
 

Private Attributes

Buffers m_pages
 Recovered doublewrite buffer page frames. More...
 
Page_entries m_page_entries
 Page entries from reduced doublewrite buffer. More...
 
std::unordered_set< space_id_tm_recovered_spaces
 
bool m_is_sorted {true}
 Initially true. More...
 

Detailed Description

Pages recovered from the doublewrite buffer.

Member Typedef Documentation

◆ Buffers

using dblwr::recv::Pages::Buffers = std::vector<Page *, ut::allocator<Page *> >

◆ Page_entries

Constructor & Destructor Documentation

◆ Pages() [1/3]

dblwr::recv::Pages::Pages ( )
inline

Default constructor.

◆ ~Pages()

dblwr::recv::Pages::~Pages ( )
inlinenoexcept

Destructor.

◆ Pages() [2/3]

dblwr::recv::Pages::Pages ( const Pages )
privatedelete

◆ Pages() [3/3]

dblwr::recv::Pages::Pages ( Pages &&  )
privatedelete

Member Function Documentation

◆ add()

void recv::Pages::add ( page_no_t  page_no,
const byte page,
uint32_t  n_bytes 
)
noexcept

Add a page frame to the doublewrite recovery buffer.

Parameters
[in]page_noPage number in the doublewrite buffer
[in]pagePage contents
[in]n_bytesSize in bytes

◆ add_entry()

void dblwr::recv::Pages::add_entry ( Page_entry pg_entry)
inline

Add a page entry from reduced doublewrite buffer to vector.

Parameters
[in]pg_entryReduced doublewrite buffer entry

◆ check_missing_tablespaces()

void recv::Pages::check_missing_tablespaces ( ) const
noexcept

Check if some pages could be restored because of missing tablespace IDs.

◆ dblwr_recover_page()

void recv::Pages::dblwr_recover_page ( const fil_space_t space,
page_no_t  page_no,
byte dblwr_page 
)
noexcept

Checks if Double-write recovery of the specified tablespace page is needed.

Checks if the provided image of the dblwr_page from the Double-write buffer is usable (non-zero and not corrupted) and if so, checks if the space 's page page_no is corrupted, in which case it uses the provided dblwr_page image to restore it. In case of any errors (IO errors, out of bounds space access) we crash the server as it means the tablespace is corrupted beyond our ability to recover and we should not attempt any more actions.

Parameters
[in]spaceTablespace the page belongs to
[in]page_noPage number in the tablespace
[in]dblwr_pageData loaded from Double-write buffer to write to <space, page_no>

◆ detect_corruption_from_reduced_entries()

void recv::Pages::detect_corruption_from_reduced_entries ( const fil_space_t space)
privatenoexcept

Checks if there are any corrupted pages in the tablespace that can be found in the reduced double write buffer.

Scans the stored double write buffer reduced entries for mentions of pages from the specified space, and for each such page checks if tablespace file contains a corrupted version of it and if so, we abort the Server. We cannot recover page because the entire page is not logged only an entry of space_id, page_id, LSN is logged. It is expected that the user restores from backup.

Parameters
[in]spaceTablespace to check in reduced pages.

◆ done_loading_prepare_for_recovery()

void recv::Pages::done_loading_prepare_for_recovery ( )
noexcept

Indicates that all add() calls were done, and it is time to prepare this data structure for subsequent recover() calls.

◆ find()

const byte * recv::Pages::find ( const page_id_t page_id) const
noexcept

Find a doublewrite copy of a page.

Parameters
[in]page_idPage number to lookup
Returns
page frame
Return values
nullptrif no page was found

◆ get_first_page_content_for_recovery()

const byte * recv::Pages::get_first_page_content_for_recovery ( space_id_t  space_id,
page_size_t  page_size,
const std::string &  file_path,
const byte page_content 
) const

Checks if content of the first page provided from the specified space requires recovery from the Double-write Buffer.

If the supplied page_content has a valid not corrupted page, no action is taken. If it is not, then we try to get a non-corrupted copy from the Double-write Buffer. If there are any entries in the Reduced Double-write pages list, we may crash.

Parameters
[in]space_idID of the space to be checked.
[in]page_sizePage size structure to use for the tablespace page manipulation.
[in]file_pathPath of a file to be used for error reporting.
[in]page_contentContent of the first page of the specified tablespace read from the disk. The buffer must hold at least page_size.physical() bytes.
Returns
pointer to page_content if the page does not require recovery, a pointer to page contents from the Double-write Buffer or nullptr if page_content is corrupted, but there's no valid image of it in the Double-write Buffer to restore it from.

◆ get_max_lsn_of_reduced_page_entries()

std::optional< lsn_t > dblwr::recv::Pages::get_max_lsn_of_reduced_page_entries ( const page_id_t page_id) const
inlinenoexcept

Check if page was logged in reduced doublewrite buffer mode, and if so also return the maximum page LSN mentioned for all entries for this page ID.

Parameters
[in]page_idPage number to lookup
Return values
MaximumLSN of the reduced entries for the specified page ID, if any is found.

◆ get_pages()

Buffers & dblwr::recv::Pages::get_pages ( )
inlinenoexcept

Object the vector of pages.

Returns
the vector of pages.

◆ is_actual_page_corrupted()

bool dblwr::recv::Pages::is_actual_page_corrupted ( const fil_space_t space,
const page_id_t page_id 
)

Checks if page in tablespace is corrupted or an all-zero page.

Parameters
[in]spaceTablespace object
[in]page_idPage number to check for corruption
Returns
true if corrupted or page is all zero bytes.

◆ operator=() [1/2]

Pages & dblwr::recv::Pages::operator= ( const Pages )
privatedelete

◆ operator=() [2/2]

Pages & dblwr::recv::Pages::operator= ( Pages &&  )
privatedelete

◆ recover()

void recv::Pages::recover ( fil_space_t space)
noexcept

Restore corrupted pages of the tablespace from the double write buffer.

Iterates over the previously loaded double write buffer pages, but only ones that are not corrupted, searching for mentions of pages from the specified space, and for each such page checks if tablespace file contains a corrupted version of it and if so, restores it from the backup in image found in double write buffer page, unless this is impossible because the double write buffer page does not contain the body (in reduced, detect-only mode). In case of any errors (IO errors, out of bounds space access) we crash the server.

Parameters
[in]spaceTablespace to restore pages in.

Member Data Documentation

◆ m_is_sorted

bool dblwr::recv::Pages::m_is_sorted {true}
private

Initially true.

Transitions to false whenever add() or add_entry() is called, and to true in done_loading_prepare_for_recovery(). Calling find(), get_max_lsn_of_reduced_page_entries(), get_first_page_content_for_recovery(), and recover() is only allowed when true.

◆ m_page_entries

Page_entries dblwr::recv::Pages::m_page_entries
private

Page entries from reduced doublewrite buffer.

◆ m_pages

Buffers dblwr::recv::Pages::m_pages
private

Recovered doublewrite buffer page frames.

◆ m_recovered_spaces

std::unordered_set<space_id_t> dblwr::recv::Pages::m_recovered_spaces
private

The documentation for this class was generated from the following file: