Skip to content

Commit

Permalink
MDEV-27848: Remove unused wait/io/file/innodb/innodb_log_file
Browse files Browse the repository at this point in the history
The performance_schema counter wait/io/file/innodb/innodb_log_file
is always reported as 0.

The way how redo log writes are being waited for was refactored in
commit 30ea63b by the introduction
of flush_lock and write_lock. Even before that change, all the
wait/io/file/innodb/ counters were always 0 in my tests.

Moreover, if the PMEM interface that was introduced in
commit 3daef52
is being used, writes to the InnoDB log file will completely avoid
any system calls and performance_schema instrumentation.
In commit 685d958 also the reads
of the redo log (during recovery) would bypass any system calls.
  • Loading branch information
dr-m committed Feb 15, 2022
1 parent 3b06415 commit f1beeb5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 34 deletions.
15 changes: 7 additions & 8 deletions extra/mariabackup/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2274,10 +2274,10 @@ static bool innodb_init()

bool ret;
const std::string ib_logfile0{get_log_file_path()};
os_file_delete_if_exists(innodb_log_file_key, ib_logfile0.c_str(), nullptr);
pfs_os_file_t file= os_file_create(innodb_log_file_key, ib_logfile0.c_str(),
OS_FILE_CREATE, OS_FILE_NORMAL,
OS_DATA_FILE_NO_O_DIRECT, false, &ret);
os_file_delete_if_exists_func(ib_logfile0.c_str(), nullptr);
os_file_t file= os_file_create_func(ib_logfile0.c_str(),
OS_FILE_CREATE, OS_FILE_NORMAL,
OS_DATA_FILE_NO_O_DIRECT, false, &ret);
if (!ret)
{
invalid_log:
Expand All @@ -2298,13 +2298,12 @@ static bool innodb_init()

#ifdef _WIN32
DWORD len;
ret= WriteFile(os_file_t{file}, log_hdr_buf, sizeof log_hdr_buf,
ret= WriteFile(file, log_hdr_buf, sizeof log_hdr_buf,
&len, nullptr) && len == sizeof log_hdr_buf;
#else
ret= sizeof log_hdr_buf == write(os_file_t{file}, log_hdr_buf,
sizeof log_hdr_buf);
ret= sizeof log_hdr_buf == write(file, log_hdr_buf, sizeof log_hdr_buf);
#endif
if (!os_file_close(file) || !ret)
if (!os_file_close_func(file) || !ret)
goto invalid_log;
return false;
}
Expand Down
1 change: 0 additions & 1 deletion storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,6 @@ static PSI_thread_info all_innodb_threads[] = {
performance schema instrumented if "UNIV_PFS_IO" is defined */
static PSI_file_info all_innodb_files[] = {
PSI_KEY(innodb_data_file),
PSI_KEY(innodb_log_file),
PSI_KEY(innodb_temp_file)
};
# endif /* UNIV_PFS_IO */
Expand Down
6 changes: 3 additions & 3 deletions storage/innobase/include/log0log.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ std::string get_log_file_path(const char *filename= LOG_FILE_NAME);
static inline void delete_log_file(const char* suffix)
{
auto path = get_log_file_path(LOG_FILE_NAME_PREFIX).append(suffix);
os_file_delete_if_exists(innodb_log_file_key, path.c_str(), nullptr);
os_file_delete_if_exists_func(path.c_str(), nullptr);
}

struct completion_callback;
Expand Down Expand Up @@ -128,10 +128,10 @@ struct log_t;
class log_file_t
{
friend log_t;
pfs_os_file_t m_file;
os_file_t m_file{OS_FILE_CLOSED};
public:
log_file_t()= default;
log_file_t(pfs_os_file_t file) noexcept : m_file(file) {}
log_file_t(os_file_t file) noexcept : m_file(file) {}

/** Open a file
@return file size in bytes
Expand Down
1 change: 0 additions & 1 deletion storage/innobase/include/os0file.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ bool os_file_close_func(os_file_t file);

/* Keys to register InnoDB I/O with performance schema */
extern mysql_pfs_key_t innodb_data_file_key;
extern mysql_pfs_key_t innodb_log_file_key;
extern mysql_pfs_key_t innodb_temp_file_key;

/* Following four macros are instumentations to register
Expand Down
12 changes: 6 additions & 6 deletions storage/innobase/log/log0recv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1639,10 +1639,10 @@ dberr_t recv_sys_t::find_checkpoint()
file_checkpoint= 0;
std::string path{get_log_file_path()};
bool success;
pfs_os_file_t file= os_file_create(innodb_log_file_key, path.c_str(),
os_file_t file{os_file_create_func(path.c_str(),
OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_NORMAL, OS_LOG_FILE,
srv_read_only_mode, &success);
srv_read_only_mode, &success)};
if (file == OS_FILE_CLOSED)
return DB_ERROR;
const os_offset_t size{os_file_get_size(file)};
Expand All @@ -1665,10 +1665,10 @@ dberr_t recv_sys_t::find_checkpoint()
for (int i= 1; i < 101; i++)
{
path= get_log_file_path(LOG_FILE_NAME_PREFIX).append(std::to_string(i));
file= os_file_create(innodb_log_file_key, path.c_str(),
OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT |
OS_FILE_ON_ERROR_SILENT,
OS_FILE_NORMAL, OS_LOG_FILE, true, &success);
file= os_file_create_func(path.c_str(),
OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT |
OS_FILE_ON_ERROR_SILENT,
OS_FILE_NORMAL, OS_LOG_FILE, true, &success);
if (file == OS_FILE_CLOSED)
break;
const os_offset_t sz{os_file_get_size(file)};
Expand Down
1 change: 0 additions & 1 deletion storage/innobase/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ extern uint page_zip_level;
#ifdef UNIV_PFS_IO
/* Keys to register InnoDB I/O with performance schema */
mysql_pfs_key_t innodb_data_file_key;
mysql_pfs_key_t innodb_log_file_key;
mysql_pfs_key_t innodb_temp_file_key;
#endif

Expand Down
29 changes: 15 additions & 14 deletions storage/innobase/srv/srv0start.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,11 @@ static dberr_t create_log_file(bool create_new_db, lsn_t lsn)

std::string logfile0{get_log_file_path("ib_logfile101")};
bool ret;
pfs_os_file_t file = os_file_create(
innodb_log_file_key, logfile0.c_str(),
OS_FILE_CREATE|OS_FILE_ON_ERROR_NO_EXIT, OS_FILE_NORMAL,
OS_LOG_FILE, srv_read_only_mode, &ret);
os_file_t file{
os_file_create_func(logfile0.c_str(),
OS_FILE_CREATE | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_NORMAL, OS_LOG_FILE, false, &ret)
};

if (!ret) {
sql_print_error("InnoDB: Cannot create %.*s",
Expand Down Expand Up @@ -489,16 +490,16 @@ dberr_t
srv_check_undo_redo_logs_exists()
{
bool ret;
pfs_os_file_t fh;
os_file_t fh;
char name[OS_FILE_MAX_PATH];

/* Check if any undo tablespaces exist */
for (ulint i = 1; i <= srv_undo_tablespaces; ++i) {

snprintf(name, sizeof name, "%s/undo%03zu", srv_undo_dir, i);

fh = os_file_create(
innodb_data_file_key, name,
fh = os_file_create_func(
name,
OS_FILE_OPEN_RETRY
| OS_FILE_ON_ERROR_NO_EXIT
| OS_FILE_ON_ERROR_SILENT,
Expand All @@ -508,7 +509,7 @@ srv_check_undo_redo_logs_exists()
&ret);

if (ret) {
os_file_close(fh);
os_file_close_func(fh);
ib::error()
<< "undo tablespace '" << name << "' exists."
" Creating system tablespace with existing undo"
Expand All @@ -522,14 +523,14 @@ srv_check_undo_redo_logs_exists()
/* Check if redo log file exists */
auto logfilename = get_log_file_path();

fh = os_file_create(innodb_log_file_key, logfilename.c_str(),
OS_FILE_OPEN_RETRY | OS_FILE_ON_ERROR_NO_EXIT
| OS_FILE_ON_ERROR_SILENT,
OS_FILE_NORMAL, OS_LOG_FILE, srv_read_only_mode,
&ret);
fh = os_file_create_func(logfilename.c_str(),
OS_FILE_OPEN_RETRY | OS_FILE_ON_ERROR_NO_EXIT
| OS_FILE_ON_ERROR_SILENT,
OS_FILE_NORMAL, OS_LOG_FILE,
srv_read_only_mode, &ret);

if (ret) {
os_file_close(fh);
os_file_close_func(fh);
ib::error() << "redo log file '" << logfilename
<< "' exists. Creating system tablespace with"
" existing redo log file is not recommended."
Expand Down

0 comments on commit f1beeb5

Please sign in to comment.