MySQL 26.7.0
Source Code Documentation
ib::fil::Tablespace_scanning Class Reference

Represents infrastructure needed for tablespace files scanning during server bootstrap. More...

#include <fil0tablespace_scan.h>

Public Member Functions

bool is_known_path (const std::string &path)
 Check if a path is known to InnoDB. More...
 
bool erase_path (space_id_t space_id)
 Erase a space ID to filename mapping. More...
 
void clear ()
 Free the data structures required for recovery. More...
 
void add_scan_dir (const std::string &directory)
 Normalize and save a directory to scan for IBD and IBU datafiles before recovery. More...
 
void add_scan_dirs (const std::string &directories)
 Normalize and save a list of directories to scan for IBD and IBU datafiles before recovery. More...
 
dberr_t scan ()
 Discover tablespaces by reading the header from IBD files. More...
 
std::string get_dirs ()
 Get the list of directories that InnoDB knows about. More...
 
bool is_tablespace_file_found (const space_id_t space_id)
 Check if file for a given space_id is found during scan. More...
 
std::optional< std::string > get_tablespace_file_by_id (space_id_t space_id)
 Fetch the file name opened for a space_id from the file map. More...
 
std::optional< size_t > get_tablespace_page_size (space_id_t space_id)
 Get the physical page size of a Tablespace given it's space id. More...
 
bool check_missing_tablespaces ()
 This function should be called after recovery has completed. More...
 
bool is_inited ()
 Returns true if mapping has been initialized. More...
 
bool is_cleared ()
 Returns true if mapping has been cleared. More...
 
void get_found_space_ids (std::vector< space_id_t > &space_ids)
 Returns the list of tablespace ids found during scan. More...
 
void print_mapping ()
 

Private Types

enum class  Scanning_state { UNINITED , INITED , CLEARED }
 

Private Member Functions

Scanned_tablespace_dirs::Result get_scanned_filename_by_space_id (space_id_t space_id)
 Fetch the file names opened for a space_id during recovery. More...
 

Private Attributes

Scanned_tablespace_dirs m_scanned_dirs
 Tablespace directories scanned at startup. More...
 
Scanning_state m_state {Scanning_state::UNINITED}
 

Friends

std::ostream & operator<< (std::ostream &stream, const Scanning_state &state)
 

Detailed Description

Represents infrastructure needed for tablespace files scanning during server bootstrap.

Member Enumeration Documentation

◆ Scanning_state

Enumerator
UNINITED 
INITED 
CLEARED 

Member Function Documentation

◆ add_scan_dir()

void ib::fil::Tablespace_scanning::add_scan_dir ( const std::string &  directory)
inline

Normalize and save a directory to scan for IBD and IBU datafiles before recovery.

Parameters
[in]directorydirectory to scan for IBD and IBU files

◆ add_scan_dirs()

void ib::fil::Tablespace_scanning::add_scan_dirs ( const std::string &  directories)
inline

Normalize and save a list of directories to scan for IBD and IBU datafiles before recovery.

Parameters
[in]directoriesDirectories to scan for IBD and IBU files

◆ check_missing_tablespaces()

bool ib::fil::Tablespace_scanning::check_missing_tablespaces ( )

This function should be called after recovery has completed.

Check for tablespace files for which we did not see any MLOG_FILE_DELETE or MLOG_FILE_RENAME record. These could not be recovered

Returns
true if there were some filenames missing for which we had to ignore redo log records during the apply phase

◆ clear()

void ib::fil::Tablespace_scanning::clear ( )
inline

Free the data structures required for recovery.

◆ erase_path()

bool ib::fil::Tablespace_scanning::erase_path ( space_id_t  space_id)
inline

Erase a space ID to filename mapping.

Parameters
[in]space_idTablespace ID to erase
Returns
true if successful

◆ get_dirs()

std::string ib::fil::Tablespace_scanning::get_dirs ( )
inline

Get the list of directories that InnoDB knows about.

Returns
the list of directories 'dir1;dir2;....;dirN'

◆ get_found_space_ids()

void ib::fil::Tablespace_scanning::get_found_space_ids ( std::vector< space_id_t > &  space_ids)
inline

Returns the list of tablespace ids found during scan.

Parameters
[out]space_idsList of tablespace ids discovered.

◆ get_scanned_filename_by_space_id()

Scanned_tablespace_dirs::Result ib::fil::Tablespace_scanning::get_scanned_filename_by_space_id ( space_id_t  space_id)
inlineprivate

Fetch the file names opened for a space_id during recovery.

Parameters
[in]space_idTablespace ID to lookup
Returns
pair of top level directory scanned and names that map to space_id or nullptr if not found.

◆ get_tablespace_file_by_id()

std::optional< std::string > ib::fil::Tablespace_scanning::get_tablespace_file_by_id ( space_id_t  space_id)

Fetch the file name opened for a space_id from the file map.

Parameters
[in]space_idtablespace ID
Returns
Tablespace file name if Tablespace with the id is found, nullopt otherwise

◆ get_tablespace_page_size()

std::optional< size_t > ib::fil::Tablespace_scanning::get_tablespace_page_size ( space_id_t  space_id)

Get the physical page size of a Tablespace given it's space id.

Parameters
[in]space_idTablespace id
Returns
Tablespace page size if Tablespace with the given id is found, nullopt otherwise

◆ is_cleared()

bool ib::fil::Tablespace_scanning::is_cleared ( )
inline

Returns true if mapping has been cleared.

◆ is_inited()

bool ib::fil::Tablespace_scanning::is_inited ( )
inline

Returns true if mapping has been initialized.

◆ is_known_path()

bool ib::fil::Tablespace_scanning::is_known_path ( const std::string &  path)
inline

Check if a path is known to InnoDB.

Parameters
[in]pathPath to check
Returns
true if path is known to InnoDB

◆ is_tablespace_file_found()

bool ib::fil::Tablespace_scanning::is_tablespace_file_found ( const space_id_t  space_id)
inline

Check if file for a given space_id is found during scan.

Parameters
[in]space_idTablespace id
Returns
true if file is found, false otherwise.

◆ print_mapping()

void ib::fil::Tablespace_scanning::print_mapping ( )
inline

◆ scan()

dberr_t ib::fil::Tablespace_scanning::scan ( )
inline

Discover tablespaces by reading the header from IBD files.

Returns
DB_SUCCESS if all goes well

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  stream,
const Scanning_state state 
)
friend

Member Data Documentation

◆ m_scanned_dirs

Scanned_tablespace_dirs ib::fil::Tablespace_scanning::m_scanned_dirs
private

Tablespace directories scanned at startup.

◆ m_state

Scanning_state ib::fil::Tablespace_scanning::m_state {Scanning_state::UNINITED}
private

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