34using Dirs = std::vector<std::string>;
65 std::unordered_map<space_id_t, Space_scan_infos>;
78 [[nodiscard]]
size_t add(Space_read_info space_info,
const std::string &name);
101 return (n_erased == 1);
115 space_ids.push_back(item.first);
122 const auto space_id =
info.first;
123 for (
const auto &scan_info :
info.second) {
124 ib::info() <<
"MAPPING : [" << space_id <<
"] = Name : '"
125 << scan_info.file_name
126 <<
"'. Page Size : " << scan_info.physical_page_size;
145#ifndef UNIV_HOTBACKUP
172 std::string &new_path);
193 std::pair<std::string,
228 if (
dir.erase_path(space_id)) {
242 const auto names =
dir.find_by_id(space_id);
244 if (names !=
nullptr) {
249 return (
Result{
"",
nullptr});
259 if (
dir.root().is_same_as(descendant) ||
260 dir.root().is_ancestor(descendant)) {
275 dirs.append(
dir.root());
281 ut_ad(!dirs.empty());
290 dir.get_space_ids(space_ids);
311 void warn_ignore(std::string path_in,
const char *reason);
324 void add_paths(
const std::string &
str,
const std::string &delimiters);
432 return (
result.second !=
nullptr);
442#ifndef UNIV_HOTBACKUP
494 return stream << static_cast<int>(state);
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:49
Wrapper for a path to a directory that may or may not exist.
Definition: fil0fil.h:971
static bool is_separator(char c)
Check if a character is a path separator ('\' or '/')
Definition: fil0fil.h:1338
const std::string & path() const
Definition: fil0fil.h:1025
A helper class to handle partition file names during server upgrade.
Definition: fil0tablespace_scan.h:142
void rename_partition_files(bool revert)
Rename partition files during upgrade.
Definition: fil0tablespace_scan.cc:604
static bool get_partition_file(const std::string &old_path, ib_file_suffix extn, std::string &new_path)
Get modified name for partition file.
Definition: fil0tablespace_scan.cc:689
void add_old_path(const std::string &path)
Add a path to the list of old paths for partitions.
Definition: fil0tablespace_scan.h:158
~Partition_file_names_upgrader()
Definition: fil0tablespace_scan.h:144
std::vector< std::string > m_old_paths
Old file paths during 5.7 upgrade.
Definition: fil0tablespace_scan.h:186
static void rename_partition_file(const std::string &old_path, ib_file_suffix extn, bool revert, bool import)
Rename partition file.
Definition: fil0tablespace_scan.cc:625
A directory and tablespace files discovered under it during startup.
Definition: fil0tablespace_scan.h:41
Space_id_to_scan_info m_id_to_scan_info
Mapping from tablespace ID to data filenames.
Definition: fil0tablespace_scan.h:135
void clear()
Clear all the tablespace data.
Definition: fil0tablespace_scan.h:105
std::vector< Space_scan_info > Space_scan_infos
Definition: fil0tablespace_scan.h:63
std::unordered_map< space_id_t, Space_scan_infos > Space_id_to_scan_info
Definition: fil0tablespace_scan.h:65
void print_mapping()
Definition: fil0tablespace_scan.h:120
void get_space_ids(std::vector< space_id_t > &space_ids)
Definition: fil0tablespace_scan.h:113
bool erase_path(space_id_t space_id)
Remove the entry for the space ID.
Definition: fil0tablespace_scan.h:97
Space_scan_infos * find_by_id(space_id_t space_id)
Get the file names that map to a space ID.
Definition: fil0tablespace_scan.h:83
const std::string & path() const
Definition: fil0tablespace_scan.h:111
Fil_path m_dir
Top level directory where the above files were found.
Definition: fil0tablespace_scan.h:138
size_t add(Space_read_info space_info, const std::string &name)
Add a space to filename mapping.
Definition: fil0tablespace_scan.cc:37
Scanned_tablespace_dir_and_files(const std::string &dir)
Default constructor.
Definition: fil0tablespace_scan.h:69
const Fil_path & root() const
Definition: fil0tablespace_scan.h:108
Directories scanned during startup and the files discovered.
Definition: fil0tablespace_scan.h:190
bool contains(const std::string &path) const
Determine if this Fil_path contains the path provided.
Definition: fil0tablespace_scan.h:255
void print_duplicates(const Space_id_set &duplicates)
Print the duplicate filenames for a tablespace ID to the log.
Definition: fil0tablespace_scan.cc:209
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.
Definition: fil0tablespace_scan.cc:152
void add_scan_dir(const std::string &directory)
Normalize and save a directory to scan for IBD and IBU datafiles before recovery.
Definition: fil0tablespace_scan.cc:248
void get_found_space_ids(std::vector< space_id_t > &space_ids)
Get the list of tablespace IDs discovered.
Definition: fil0tablespace_scan.h:288
std::string get_dirs() const
Get the list of directories that InnoDB knows about.
Definition: fil0tablespace_scan.h:269
Scanned_dirs_and_files m_scanned_dirs_and_files
Directories scanned and the files discovered under them.
Definition: fil0tablespace_scan.h:357
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.
Definition: fil0tablespace_scan.cc:556
std::vector< Scanned_tablespace_dir_and_files > Scanned_dirs_and_files
first=dir path from the user, second=files found under first.
Definition: fil0tablespace_scan.h:308
bool erase_path(space_id_t space_id)
Erase a space ID to filename mapping.
Definition: fil0tablespace_scan.h:226
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 o...
Definition: fil0tablespace_scan.cc:397
std::pair< std::string, Scanned_tablespace_dir_and_files::Space_scan_infos * > Result
Definition: fil0tablespace_scan.h:194
void clear()
Clear all the tablespace file data but leave the list of scanned directories in place.
Definition: fil0tablespace_scan.h:215
void add_path(const std::string &str)
Add a single path specification to this list of tablespace directories.
Definition: fil0tablespace_scan.cc:65
Scanned_tablespace_dirs()
Constructor.
Definition: fil0tablespace_scan.h:197
void add_paths(const std::string &str, const std::string &delimiters)
Add a delimited list of path specifications to this list of tablespace directories.
Definition: fil0tablespace_scan.cc:132
Partition_file_names_upgrader m_partition_file_names_upgrader
An object to handle partition file names during upgrade.
Definition: fil0tablespace_scan.h:363
void print_mapping()
Definition: fil0tablespace_scan.h:295
Scanned_files::const_iterator Const_iter
Definition: fil0tablespace_scan.h:326
dberr_t scan()
Discover tablespaces by reading the header from IBD files.
Definition: fil0tablespace_scan.cc:268
std::atomic_size_t m_checked
Number of files checked.
Definition: fil0tablespace_scan.h:360
Result find_by_id(space_id_t space_id)
Definition: fil0tablespace_scan.h:240
void warn_ignore(std::string path_in, const char *reason)
Report a warning that a path is being ignored and include the reason.
Definition: fil0tablespace_scan.cc:60
void add_scan_dirs(const std::string &directories)
Normalize and save a list of directories to scan for IBD and IBU datafiles before recovery.
Definition: fil0tablespace_scan.cc:256
Represents infrastructure needed for tablespace files scanning during server bootstrap.
Definition: fil0tablespace_scan.h:368
friend std::ostream & operator<<(std::ostream &stream, const Scanning_state &state)
Definition: fil0tablespace_scan.h:492
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.
Definition: fil0tablespace_scan.cc:740
bool is_tablespace_file_found(const space_id_t space_id)
Check if file for a given space_id is found during scan.
Definition: fil0tablespace_scan.h:430
void add_scan_dirs(const std::string &directories)
Normalize and save a list of directories to scan for IBD and IBU datafiles before recovery.
Definition: fil0tablespace_scan.h:405
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.
Definition: fil0tablespace_scan.cc:754
bool is_inited()
Returns true if mapping has been initialized.
Definition: fil0tablespace_scan.h:459
void get_found_space_ids(std::vector< space_id_t > &space_ids)
Returns the list of tablespace ids found during scan.
Definition: fil0tablespace_scan.h:468
Scanning_state m_state
Definition: fil0tablespace_scan.h:496
std::string get_dirs()
Get the list of directories that InnoDB knows about.
Definition: fil0tablespace_scan.h:425
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.
Definition: fil0tablespace_scan.h:483
bool is_known_path(const std::string &path)
Check if a path is known to InnoDB.
Definition: fil0tablespace_scan.h:373
void clear()
Free the data structures required for recovery.
Definition: fil0tablespace_scan.h:386
dberr_t scan()
Discover tablespaces by reading the header from IBD files.
Definition: fil0tablespace_scan.h:411
Scanning_state
Definition: fil0tablespace_scan.h:491
void print_mapping()
Definition: fil0tablespace_scan.h:474
bool check_missing_tablespaces()
This function should be called after recovery has completed.
Definition: fil0tablespace_scan.cc:765
void add_scan_dir(const std::string &directory)
Normalize and save a directory to scan for IBD and IBU datafiles before recovery.
Definition: fil0tablespace_scan.h:396
Scanned_tablespace_dirs m_scanned_dirs
Tablespace directories scanned at startup.
Definition: fil0tablespace_scan.h:489
bool is_cleared()
Returns true if mapping has been cleared.
Definition: fil0tablespace_scan.h:462
bool erase_path(space_id_t space_id)
Erase a space ID to filename mapping.
Definition: fil0tablespace_scan.h:380
The class info is used to emit informational log messages.
Definition: ut0log.h:183
Global error codes for the database.
dberr_t
Definition: db0err.h:39
@ DB_SUCCESS
Definition: db0err.h:43
ib_file_suffix
Common InnoDB file extensions.
Definition: fil0fil.h:943
bool lower_case_file_system
Definition: mysqld.cc:1306
ut::unique_ptr< ib::fil::Tablespace_scanning > tablespace_scanning
Definition: fil0fil.cc:1390
constexpr char FIL_PATH_SEPARATOR
Path separator e.g., 'dir;...;dirN'.
Definition: fil0types.h:131
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
static my_thread_id thread_id
Definition: my_thr_init.cc:60
static char * path
Definition: mysqldump.cc:151
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
std::string dir
Double write files location.
Definition: buf0dblwr.cc:81
Definition: fil0fil.cc:1392
std::vector< std::pair< uint16_t, std::string > > Scanned_files
Definition: fil0tablespace_scan.h:38
std::vector< std::string > Dirs
Definition: fil0tablespace_scan.h:34
std::set< space_id_t > Space_id_set
Definition: fil0tablespace_scan.h:33
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:943
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2284
const char * filename
Definition: pfs_example_component_population.cc:67
bool srv_downgrade_partition_files
Definition: srv0srv.cc:119
Definition: fil0tablespace_scan.h:45
size_t physical_page_size
Definition: fil0tablespace_scan.h:50
space_id_t space_id
Definition: fil0tablespace_scan.h:47
Structure to represent space information collected after directory scanning.
Definition: fil0tablespace_scan.h:55
size_t physical_page_size
Definition: fil0tablespace_scan.h:60
std::string file_name
Definition: fil0tablespace_scan.h:57
static const space_id_t TRX_SYS_SPACE
Space id of the transaction system page (the system tablespace)
Definition: trx0types.h:52
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:109
#define ut_a_eq(LHS, RHS)
Assert that LHS == RHS.
Definition: ut0dbg.h:91
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:97