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

Directories scanned during startup and the files discovered. More...

#include <fil0tablespace_scan.h>

Public Types

using Result = std::pair< std::string, Scanned_tablespace_dir_and_files::Space_scan_infos * >
 

Public Member Functions

 Scanned_tablespace_dirs ()
 Constructor. 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...
 
void clear ()
 Clear all the tablespace file data but leave the list of scanned directories in place. More...
 
bool erase_path (space_id_t space_id)
 Erase a space ID to filename mapping. More...
 
Result find_by_id (space_id_t space_id)
 
bool contains (const std::string &path) const
 Determine if this Fil_path contains the path provided. More...
 
std::string get_dirs () const
 Get the list of directories that InnoDB knows about. More...
 
void get_found_space_ids (std::vector< space_id_t > &space_ids)
 Get the list of tablespace IDs discovered. More...
 
void print_mapping ()
 

Private Types

using Scanned_dirs_and_files = std::vector< Scanned_tablespace_dir_and_files >
 first=dir path from the user, second=files found under first. More...
 
using Const_iter = Scanned_files::const_iterator
 

Private Member Functions

void print_duplicates (const Space_id_set &duplicates)
 Print the duplicate filenames for a tablespace ID to the log. More...
 
void warn_ignore (std::string path_in, const char *reason)
 Report a warning that a path is being ignored and include the reason. More...
 
void add_path (const std::string &str)
 Add a single path specification to this list of tablespace directories. More...
 
void add_paths (const std::string &str, const std::string &delimiters)
 Add a delimited list of path specifications to this list of tablespace directories. More...
 
void duplicate_check (const Const_iter &start, const Const_iter &end, size_t thread_id, std::mutex *mutex, Space_id_set *unique, Space_id_set *duplicates)
 Check for duplicate tablespace IDs. More...
 
Scanned_tablespace_dir_and_files::Space_read_info get_tablespace_info (const std::string &filename) const
 Get the tablespace ID from an .ibd and/or an undo tablespace. More...
 
Scanned_tablespace_dir_and_files::Space_read_info get_tablespace_info_heavy (const std::string &filename) const
 If normal file read isn't sufficient to get the space id and page size, use this heavy method which opens files by guessing different page sizes and read pages from file to determine space_id. More...
 

Private Attributes

Scanned_dirs_and_files m_scanned_dirs_and_files
 Directories scanned and the files discovered under them. More...
 
std::atomic_size_t m_checked
 Number of files checked. More...
 
Partition_file_names_upgrader m_partition_file_names_upgrader
 An object to handle partition file names during upgrade. More...
 

Detailed Description

Directories scanned during startup and the files discovered.

Member Typedef Documentation

◆ Const_iter

using ib::fil::Scanned_tablespace_dirs::Const_iter = Scanned_files::const_iterator
private

◆ Result

◆ Scanned_dirs_and_files

first=dir path from the user, second=files found under first.

Constructor & Destructor Documentation

◆ Scanned_tablespace_dirs()

ib::fil::Scanned_tablespace_dirs::Scanned_tablespace_dirs ( )
inline

Constructor.

Member Function Documentation

◆ add_path()

void ib::fil::Scanned_tablespace_dirs::add_path ( const std::string &  str)
private

Add a single path specification to this list of tablespace directories.

Convert it to an absolute path. Check if the path is valid. Ignore unreadable, duplicate or invalid directories.

Parameters
[in]strPath specification to tokenize

◆ add_paths()

void ib::fil::Scanned_tablespace_dirs::add_paths ( const std::string &  str,
const std::string &  delimiters 
)
private

Add a delimited list of path specifications to this list of tablespace directories.

Convert relative paths to absolute paths. Check if the paths are valid. Ignore unreadable, duplicate or invalid directories.

Parameters
[in]strPath specification to tokenize
[in]delimitersDelimiters

◆ add_scan_dir()

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

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::Scanned_tablespace_dirs::add_scan_dirs ( const std::string &  directories)

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

◆ clear()

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

Clear all the tablespace file data but leave the list of scanned directories in place.

◆ contains()

bool ib::fil::Scanned_tablespace_dirs::contains ( const std::string &  path) const
inline

Determine if this Fil_path contains the path provided.

Parameters
[in]pathfile or directory path to compare.
Returns
true if this Fil_path contains path

◆ duplicate_check()

void ib::fil::Scanned_tablespace_dirs::duplicate_check ( const Const_iter start,
const Const_iter end,
size_t  thread_id,
std::mutex *  mutex,
Space_id_set unique,
Space_id_set duplicates 
)
private

Check for duplicate tablespace IDs.

Parameters
[in]startStart of slice
[in]endEnd of slice
[in]thread_idThread ID
[in,out]mutexMutex protecting the global state
[in,out]uniqueTo check for duplicates
[in,out]duplicatesDuplicate space IDs found

◆ erase_path()

bool ib::fil::Scanned_tablespace_dirs::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

◆ find_by_id()

Result ib::fil::Scanned_tablespace_dirs::find_by_id ( space_id_t  space_id)
inline

◆ get_dirs()

std::string ib::fil::Scanned_tablespace_dirs::get_dirs ( ) const
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::Scanned_tablespace_dirs::get_found_space_ids ( std::vector< space_id_t > &  space_ids)
inline

Get the list of tablespace IDs discovered.

Parameters
[out]space_idsList of tablespace ids

◆ get_tablespace_info()

Scanned_tablespace_dir_and_files::Space_read_info ib::fil::Scanned_tablespace_dirs::get_tablespace_info ( const std::string &  filename) const
private

Get the tablespace ID from an .ibd and/or an undo tablespace.

If the read failed or the ID is 0 on the first page or there is a mismatch of space_ids stored in FSP_SPACE_ID and FIL_PAGE_SPACE_ID, then try finding the ID with get_tablespace_info_heavy(). This function should only be called during server startup.

Parameters
[in]filenameFile name to check
Returns
s_invalid_space_id if not found, otherwise the space ID

◆ get_tablespace_info_heavy()

Scanned_tablespace_dir_and_files::Space_read_info ib::fil::Scanned_tablespace_dirs::get_tablespace_info_heavy ( const std::string &  filename) const
private

If normal file read isn't sufficient to get the space id and page size, use this heavy method which opens files by guessing different page sizes and read pages from file to determine space_id.

◆ print_duplicates()

void ib::fil::Scanned_tablespace_dirs::print_duplicates ( const Space_id_set duplicates)
private

Print the duplicate filenames for a tablespace ID to the log.

Parameters
[in]duplicatesDuplicate tablespace IDs

◆ print_mapping()

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

◆ scan()

dberr_t ib::fil::Scanned_tablespace_dirs::scan ( )

Discover tablespaces by reading the header from IBD files.

Returns
DB_SUCCESS if all goes well

◆ warn_ignore()

void ib::fil::Scanned_tablespace_dirs::warn_ignore ( std::string  path_in,
const char *  reason 
)
private

Report a warning that a path is being ignored and include the reason.

Member Data Documentation

◆ m_checked

std::atomic_size_t ib::fil::Scanned_tablespace_dirs::m_checked
private

Number of files checked.

◆ m_partition_file_names_upgrader

Partition_file_names_upgrader ib::fil::Scanned_tablespace_dirs::m_partition_file_names_upgrader
private

An object to handle partition file names during upgrade.

◆ m_scanned_dirs_and_files

Scanned_dirs_and_files ib::fil::Scanned_tablespace_dirs::m_scanned_dirs_and_files
private

Directories scanned and the files discovered under them.


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