Skip to content

Commit

Permalink
Cleanup: Remove OS_FILE_ON_ERROR_NO_EXIT
Browse files Browse the repository at this point in the history
Ever since commit 412ee03
or commit a440d6e
InnoDB should generally not abort when failing to open or create files.
In Datafile::open_or_create() we had failed to set the flag
to avoid abort() on failure, but everywhere else we were setting it.

We may still call abort() via os_file_handle_error().

Reviewed by: Vladislav Vaintroub
  • Loading branch information
dr-m committed Feb 20, 2024
1 parent 7f7329f commit 3dd7b0a
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 312 deletions.
3 changes: 1 addition & 2 deletions storage/innobase/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1900,8 +1900,7 @@ inline void log_t::write_checkpoint(lsn_t end_lsn) noexcept
ut_ad(!log.is_opened());
bool success;
log.m_file=
os_file_create_func(get_log_file_path().c_str(),
OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
os_file_create_func(get_log_file_path().c_str(), OS_FILE_OPEN,
OS_FILE_NORMAL, OS_LOG_FILE, false, &success);
ut_a(success);
ut_a(log.is_opened());
Expand Down
5 changes: 2 additions & 3 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ static bool fil_node_open_file_low(fil_node_t *node)
bool success;
node->handle= os_file_create(innodb_data_file_key, node->name,
node->is_raw_disk
? OS_FILE_OPEN_RAW | OS_FILE_ON_ERROR_NO_EXIT
: OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
? OS_FILE_OPEN_RAW : OS_FILE_OPEN,
OS_FILE_AIO, type,
srv_read_only_mode, &success);

Expand Down Expand Up @@ -1922,7 +1921,7 @@ fil_ibd_create(

file = os_file_create(
innodb_data_file_key, path,
OS_FILE_CREATE | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_CREATE,
OS_FILE_AIO, type, srv_read_only_mode, &success);

if (!success) {
Expand Down
47 changes: 23 additions & 24 deletions storage/innobase/include/os0file.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,21 @@ struct pfs_os_file_t

/** Options for os_file_create_func @{ */
enum os_file_create_t {
OS_FILE_OPEN = 51, /*!< to open an existing file (if
doesn't exist, error) */
OS_FILE_CREATE, /*!< to create new file (if
exists, error) */
OS_FILE_OPEN_RAW, /*!< to open a raw device or disk
partition */
OS_FILE_OPEN_RETRY, /*!< open with retry */

/** Flags that can be combined with the above values. Please ensure
that the above values stay below 128. */

OS_FILE_ON_ERROR_NO_EXIT = 128, /*!< do not exit on unknown errors */
OS_FILE_ON_ERROR_SILENT = 256 /*!< don't print diagnostic messages to
the log unless it is a fatal error,
this flag is only used if
ON_ERROR_NO_EXIT is set */
/** create a new file */
OS_FILE_CREATE= 0,
/** open an existing file */
OS_FILE_OPEN,
/** retry opening an existing file */
OS_FILE_OPEN_RETRY,
/** open a raw block device */
OS_FILE_OPEN_RAW,

/** do not display diagnostic messages */
OS_FILE_ON_ERROR_SILENT= 4,

OS_FILE_CREATE_SILENT= OS_FILE_CREATE | OS_FILE_ON_ERROR_SILENT,
OS_FILE_OPEN_SILENT= OS_FILE_OPEN | OS_FILE_ON_ERROR_SILENT,
OS_FILE_OPEN_RETRY_SILENT= OS_FILE_OPEN_RETRY | OS_FILE_ON_ERROR_SILENT
};

static const ulint OS_FILE_READ_ONLY = 333;
Expand Down Expand Up @@ -346,7 +345,7 @@ A simple function to open or create a file.
pfs_os_file_t
os_file_create_simple_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success);
Expand All @@ -355,7 +354,7 @@ os_file_create_simple_func(
os_file_create_simple_no_error_handling(), not directly this function!
A simple function to open or create a file.
@param[in] name name of the file or path as a null-terminated string
@param[in] create_mode create mode
@param[in] create_mode OS_FILE_CREATE or OS_FILE_OPEN
@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
OS_FILE_READ_ALLOW_DELETE; the last option
is used by a backup program reading the file
Expand All @@ -366,7 +365,7 @@ A simple function to open or create a file.
pfs_os_file_t
os_file_create_simple_no_error_handling_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success)
Expand Down Expand Up @@ -400,7 +399,7 @@ Opens an existing file or creates a new.
pfs_os_file_t
os_file_create_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint purpose,
ulint type,
bool read_only,
Expand Down Expand Up @@ -598,7 +597,7 @@ pfs_os_file_t
pfs_os_file_create_simple_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success,
Expand All @@ -614,7 +613,7 @@ monitor file creation/open.
@param[in] key Performance Schema Key
@param[in] name name of the file or path as a null-terminated
string
@param[in] create_mode create mode
@param[in] create_mode OS_FILE_CREATE or OS_FILE_OPEN
@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
OS_FILE_READ_ALLOW_DELETE; the last option is
used by a backup program reading the file
Expand All @@ -629,7 +628,7 @@ pfs_os_file_t
pfs_os_file_create_simple_no_error_handling_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success,
Expand Down Expand Up @@ -662,7 +661,7 @@ pfs_os_file_t
pfs_os_file_create_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint purpose,
ulint type,
bool read_only,
Expand Down
8 changes: 4 additions & 4 deletions storage/innobase/include/os0file.inl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pfs_os_file_t
pfs_os_file_create_simple_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success,
Expand Down Expand Up @@ -80,7 +80,7 @@ monitor file creation/open.
@param[in] key Performance Schema Key
@param[in] name name of the file or path as a null-terminated
string
@param[in] create_mode create mode
@param[in] create_mode OS_FILE_CREATE or OS_FILE_OPEN
@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
OS_FILE_READ_ALLOW_DELETE; the last option is
used by a backup program reading the file
Expand All @@ -95,7 +95,7 @@ pfs_os_file_t
pfs_os_file_create_simple_no_error_handling_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success,
Expand Down Expand Up @@ -146,7 +146,7 @@ pfs_os_file_t
pfs_os_file_create_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint purpose,
ulint type,
bool read_only,
Expand Down
3 changes: 1 addition & 2 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,7 @@ log_t::resize_start_status log_t::resize_start(os_offset_t size) noexcept
resize_lsn.store(1, std::memory_order_relaxed);
resize_target= 0;
resize_log.m_file=
os_file_create_func(path.c_str(),
OS_FILE_CREATE | OS_FILE_ON_ERROR_NO_EXIT,
os_file_create_func(path.c_str(), OS_FILE_CREATE,
OS_FILE_NORMAL, OS_LOG_FILE, false, &success);
if (success)
{
Expand Down
8 changes: 3 additions & 5 deletions storage/innobase/log/log0recv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,7 @@ static struct
inside recv_sys_t::recover_deferred(). */
bool success;
handle= os_file_create(innodb_data_file_key, filename,
OS_FILE_CREATE | OS_FILE_ON_ERROR_NO_EXIT |
OS_FILE_ON_ERROR_SILENT,
OS_FILE_CREATE_SILENT,
OS_FILE_AIO, OS_DATA_FILE, false, &success);
}
space->add(filename, handle, size, false, false);
Expand Down Expand Up @@ -1714,7 +1713,7 @@ dberr_t recv_sys_t::find_checkpoint()
std::string path{get_log_file_path()};
bool success;
os_file_t file{os_file_create_func(path.c_str(),
OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_OPEN,
OS_FILE_NORMAL, OS_LOG_FILE,
srv_read_only_mode, &success)};
if (file == OS_FILE_CLOSED)
Expand Down Expand Up @@ -1744,8 +1743,7 @@ dberr_t recv_sys_t::find_checkpoint()
{
path= get_log_file_path(LOG_FILE_NAME_PREFIX).append(std::to_string(i));
file= os_file_create_func(path.c_str(),
OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT |
OS_FILE_ON_ERROR_SILENT,
OS_FILE_OPEN_SILENT,
OS_FILE_NORMAL, OS_LOG_FILE, true, &success);
if (file == OS_FILE_CLOSED)
break;
Expand Down
Loading

0 comments on commit 3dd7b0a

Please sign in to comment.