Commit 34dafb7e authored by Eugene Kosov's avatar Eugene Kosov

redo log mics fixes

os_file_flush_data_func(): fix builds on POSIX OSs where fdatasync()
is not avaiable

log_t::files::flush_data_only(): rename from fdatasync()

log_t::files::fsync(): removed and replaced with flush_data_only().
It will flush everything we need for using redo log files.
parent b19760b8
...@@ -18614,7 +18614,7 @@ checkpoint_now_set(THD*, st_mysql_sys_var*, void*, const void* save) ...@@ -18614,7 +18614,7 @@ checkpoint_now_set(THD*, st_mysql_sys_var*, void*, const void* save)
? log_sys.append_on_checkpoint->size() : 0) ? log_sys.append_on_checkpoint->size() : 0)
< log_sys.lsn) { < log_sys.lsn) {
log_make_checkpoint(); log_make_checkpoint();
log_sys.log.fdatasync(); log_sys.log.flush_data_only();
} }
dberr_t err = fil_write_flushed_lsn(log_sys.lsn); dberr_t err = fil_write_flushed_lsn(log_sys.lsn);
......
...@@ -553,10 +553,8 @@ struct log_t{ ...@@ -553,10 +553,8 @@ struct log_t{
@param[in] total_offset offset in log files treated as a single file @param[in] total_offset offset in log files treated as a single file
@param[in] buf buffer from which to write */ @param[in] buf buffer from which to write */
void write(size_t total_offset, span<byte> buf); void write(size_t total_offset, span<byte> buf);
/** flushes OS page cache for all log files */
void fsync();
/** flushes OS page cache (excluding metadata!) for all log files */ /** flushes OS page cache (excluding metadata!) for all log files */
void fdatasync(); void flush_data_only();
/** closes all log files */ /** closes all log files */
void close_files(); void close_files();
......
...@@ -641,24 +641,7 @@ void log_t::files::write(size_t total_offset, span<byte> buf) ...@@ -641,24 +641,7 @@ void log_t::files::write(size_t total_offset, span<byte> buf)
} }
} }
void log_t::files::fsync() void log_t::files::flush_data_only()
{
ut_ad(files.size() == file_names.size());
log_sys.pending_flushes.fetch_add(1, std::memory_order_acquire);
for (auto it= files.begin(), end= files.end(); it != end; ++it)
{
if (!os_file_flush(*it))
{
const auto idx= std::distance(files.begin(), it);
ib::fatal() << "os_file_flush(" << file_names[idx] << ") failed";
}
}
log_sys.pending_flushes.fetch_sub(1, std::memory_order_release);
log_sys.flushes.fetch_add(1, std::memory_order_release);
}
void log_t::files::fdatasync()
{ {
ut_ad(files.size() == file_names.size()); ut_ad(files.size() == file_names.size());
...@@ -880,7 +863,7 @@ log_write_flush_to_disk_low() ...@@ -880,7 +863,7 @@ log_write_flush_to_disk_low()
calling os_event_set()! */ calling os_event_set()! */
ut_a(log_sys.n_pending_flushes == 1); /* No other threads here */ ut_a(log_sys.n_pending_flushes == 1); /* No other threads here */
log_sys.log.fdatasync(); log_sys.log.flush_data_only();
log_mutex_enter(); log_mutex_enter();
log_sys.flushed_to_disk_lsn = log_sys.current_flush_lsn; log_sys.flushed_to_disk_lsn = log_sys.current_flush_lsn;
...@@ -1307,7 +1290,7 @@ void log_write_checkpoint_info(lsn_t end_lsn) ...@@ -1307,7 +1290,7 @@ void log_write_checkpoint_info(lsn_t end_lsn)
: LOG_CHECKPOINT_1, : LOG_CHECKPOINT_1,
{buf, OS_FILE_LOG_BLOCK_SIZE}); {buf, OS_FILE_LOG_BLOCK_SIZE});
log_sys.log.fdatasync(); log_sys.log.flush_data_only();
log_mutex_enter(); log_mutex_enter();
...@@ -1785,7 +1768,7 @@ logs_empty_and_mark_files_at_shutdown(void) ...@@ -1785,7 +1768,7 @@ logs_empty_and_mark_files_at_shutdown(void)
/* Ensure that all buffered changes are written to the /* Ensure that all buffered changes are written to the
redo log before fil_close_all_files(). */ redo log before fil_close_all_files(). */
log_sys.log.fdatasync(); log_sys.log.flush_data_only();
} else { } else {
lsn = srv_start_lsn; lsn = srv_start_lsn;
} }
......
...@@ -4626,7 +4626,7 @@ os_normalize_path( ...@@ -4626,7 +4626,7 @@ os_normalize_path(
} }
bool os_file_flush_data_func(os_file_t file) { bool os_file_flush_data_func(os_file_t file) {
#ifdef _WIN32 #if defined(_WIN32) || !defined(HAVE_FDATASYNC) || HAVE_DECL_FDATASYNC == 0
return os_file_flush_func(file); return os_file_flush_func(file);
#else #else
bool success= fdatasync(file) != -1; bool success= fdatasync(file) != -1;
......
...@@ -421,7 +421,7 @@ MY_ATTRIBUTE((warn_unused_result, nonnull)) ...@@ -421,7 +421,7 @@ MY_ATTRIBUTE((warn_unused_result, nonnull))
static dberr_t create_log_files_rename(char *logfilename, size_t dirnamelen, static dberr_t create_log_files_rename(char *logfilename, size_t dirnamelen,
lsn_t lsn, std::string &logfile0) lsn_t lsn, std::string &logfile0)
{ {
log_sys.log.fsync(); log_sys.log.flush_data_only();
ut_ad(!srv_log_files_created); ut_ad(!srv_log_files_created);
ut_d(srv_log_files_created= true); ut_d(srv_log_files_created= true);
...@@ -1132,7 +1132,7 @@ srv_prepare_to_delete_redo_log_files( ...@@ -1132,7 +1132,7 @@ srv_prepare_to_delete_redo_log_files(
log_write_up_to(flushed_lsn, true); log_write_up_to(flushed_lsn, true);
log_sys.log.fsync(); log_sys.log.flush_data_only();
ut_ad(flushed_lsn == log_get_lsn()); ut_ad(flushed_lsn == log_get_lsn());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment