From 562c037b485b25f76fc7cb8e2c526d532450df7a Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 25 Nov 2019 22:32:24 +0700 Subject: MDEV-18115 Remove dummy tablespace for the redo log Redo log subsystem was decoupled from tablespace subsystem. It now manages file descriptors for redo log files by itself. FIL_TYPE_LOG: removed, code in various places was simplified SRV_LOG_SPACE_FIRST_ID: renamed to SRV_SPACE_ID_UPPER_BOUND to better match its purpose. Code in various places was simplified fil_n_log_flushes: replaced with log_sys::flushes fil_n_pending_log_flushes: replaced with log_sys::pending_flushes log_t::files::files: redo log file descriptors log_t::files::file_names: redo log file names log_t::files::set_file_names(): set file names without opening them log_t::files::open_files(): opens redo log files log_t::files::read(): treats several files as one big log_t::files::write(): treats several files as one big log_t::files::fsync(): flushes page cache to disk log_t::files::close_files(): closes redo log files fil_open_log_and_system_tablespace_files(): renamed to fil_open_system_tablespace_files() and obviously it now doesn't open redo log files global files[1000]: removed. Why it was needed at all? --- extra/mariabackup/xtrabackup.cc | 27 +++--- storage/innobase/buf/buf0buddy.cc | 4 +- storage/innobase/buf/buf0dump.cc | 4 +- storage/innobase/buf/buf0lru.cc | 2 +- storage/innobase/dict/dict0load.cc | 2 +- storage/innobase/fil/fil0fil.cc | 112 ++++------------------- storage/innobase/fsp/fsp0file.cc | 2 +- storage/innobase/fsp/fsp0fsp.cc | 2 - storage/innobase/handler/ha_innodb.cc | 2 +- storage/innobase/ibuf/ibuf0ibuf.cc | 2 +- storage/innobase/include/fil0fil.h | 26 +----- storage/innobase/include/fsp0types.h | 4 +- storage/innobase/include/log0log.h | 42 +++++++++ storage/innobase/include/srv0srv.h | 4 +- storage/innobase/log/log0log.cc | 137 +++++++++++++++++++--------- storage/innobase/log/log0recv.cc | 17 +--- storage/innobase/os/os0file.cc | 3 +- storage/innobase/row/row0import.cc | 2 +- storage/innobase/srv/srv0mon.cc | 4 +- storage/innobase/srv/srv0srv.cc | 7 +- storage/innobase/srv/srv0start.cc | 167 +++++++++++++--------------------- 21 files changed, 258 insertions(+), 314 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 4743ba25df6..41476805956 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3791,14 +3791,14 @@ xb_filters_free() } } -/*********************************************************************//** -Create log file metadata. */ +/**Create log file metadata. +@param[in] i log file number in group +@param[in,out] file_names redo log file names */ static void open_or_create_log_file( -/*====================*/ - fil_space_t* space, - ulint i) /*!< in: log file number in group */ + ulint i, + std::vector &file_names) { char name[FN_REFLEN]; ulint dirnamelen; @@ -3818,9 +3818,7 @@ open_or_create_log_file( ut_a(fil_validate()); - space->add(name, OS_FILE_CLOSED, - ulint(srv_log_file_size >> srv_page_size_shift), - false, false); + file_names.emplace_back(name); } /*********************************************************************** @@ -4080,14 +4078,16 @@ fail: log_sys.create(); log_sys.log.create(srv_n_log_files); - fil_space_t* space = fil_space_create( - "innodb_redo_log", SRV_LOG_SPACE_FIRST_ID, 0, - FIL_TYPE_LOG, NULL); + + std::vector file_names; for (ulint i = 0; i < srv_n_log_files; i++) { - open_or_create_log_file(space, i); + open_or_create_log_file(i, file_names); } + log_sys.log.set_file_names(std::move(file_names)); + log_sys.log.open_files(); + /* create extra LSN dir if it does not exist. */ if (xtrabackup_extra_lsndir &&!my_stat(xtrabackup_extra_lsndir,&stat_info,MYF(0)) @@ -5537,8 +5537,7 @@ static bool xtrabackup_prepare_func(char** argv) } /* Check whether the log is applied enough or not. */ - if ((srv_start_lsn || fil_space_get(SRV_LOG_SPACE_FIRST_ID)) - && srv_start_lsn < target_lsn) { + if (srv_start_lsn && srv_start_lsn < target_lsn) { msg("mariabackup: error: " "The log was only applied up to LSN " LSN_PF ", instead of " LSN_PF, diff --git a/storage/innobase/buf/buf0buddy.cc b/storage/innobase/buf/buf0buddy.cc index 7a7c3189add..0942a962b4d 100644 --- a/storage/innobase/buf/buf0buddy.cc +++ b/storage/innobase/buf/buf0buddy.cc @@ -39,7 +39,7 @@ safe to look at BUF_BUDDY_STAMP_OFFSET. The answer lies in following invariants: * All blocks allocated by buddy allocator are used for compressed page frame. -* A compressed table always have space_id < SRV_LOG_SPACE_FIRST_ID +* A compressed table always have space_id < SRV_SPACE_ID_UPPER_BOUND * BUF_BUDDY_STAMP_OFFSET always points to the space_id field in a frame. -- The above is true because we look at these fields when the @@ -67,7 +67,7 @@ are written.*/ /** Value that we stamp on all buffers that are currently on the zip_free list. This value is stamped at BUF_BUDDY_STAMP_OFFSET offset */ -#define BUF_BUDDY_STAMP_FREE SRV_LOG_SPACE_FIRST_ID +#define BUF_BUDDY_STAMP_FREE SRV_SPACE_ID_UPPER_BOUND /** Stamp value for non-free buffers. Will be overwritten by a non-zero value by the consumer of the block */ diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index ed404055b5e..c5f851fd1af 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -352,7 +352,7 @@ buf_dump( bpage = UT_LIST_GET_NEXT(LRU, bpage)) { ut_a(buf_page_in_file(bpage)); - if (bpage->id.space() >= SRV_LOG_SPACE_FIRST_ID) { + if (bpage->id.space() == SRV_TMP_SPACE_ID) { /* Ignore the innodb_temporary tablespace. */ continue; } @@ -679,7 +679,7 @@ buf_load() /* space_id for this iteration of the loop */ const ulint this_space_id = BUF_DUMP_SPACE(dump[i]); - if (this_space_id >= SRV_LOG_SPACE_FIRST_ID) { + if (this_space_id == SRV_TMP_SPACE_ID) { /* Ignore the innodb_temporary tablespace. */ continue; } diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index 8ac17bbdfd5..0e3cd4d47a5 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -1152,7 +1152,7 @@ not_found: " flush a page!" " Consider increasing innodb_buffer_pool_size." " Pending flushes (fsync) log: " - << fil_n_pending_log_flushes + << log_sys.get_pending_flushes() << "; buffer pool: " << fil_n_pending_tablespace_flushes << ". " << os_n_file_reads << " OS file reads, " diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index ebb8c4bc24f..4e258e0c324 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -2764,7 +2764,7 @@ dict_load_tablespace( { ut_ad(!table->is_temporary()); ut_ad(!table->space); - ut_ad(table->space_id < SRV_LOG_SPACE_FIRST_ID); + ut_ad(table->space_id < SRV_SPACE_ID_UPPER_BOUND); ut_ad(fil_system.sys_space); if (table->space_id == TRX_SYS_SPACE) { diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 859c49c0d15..64ff8a19c8b 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -162,11 +162,6 @@ const char* fil_path_to_mysql_datadir; /** Common InnoDB file extensions */ const char* dot_ext[] = { "", ".ibd", ".isl", ".cfg" }; -/** The number of fsyncs done to the log */ -ulint fil_n_log_flushes = 0; - -/** Number of pending redo log flushes */ -ulint fil_n_pending_log_flushes = 0; /** Number of pending tablespace flushes */ ulint fil_n_pending_tablespace_flushes = 0; @@ -228,7 +223,6 @@ fil_space_belongs_in_lru( { switch (space->purpose) { case FIL_TYPE_TEMPORARY: - case FIL_TYPE_LOG: return(false); case FIL_TYPE_TABLESPACE: return(fil_is_user_tablespace_id(space->id)); @@ -354,7 +348,6 @@ fil_space_get( mutex_enter(&fil_system.mutex); fil_space_t* space = fil_space_get_by_id(id); mutex_exit(&fil_system.mutex); - ut_ad(space == NULL || space->purpose != FIL_TYPE_LOG); return(space); } @@ -560,10 +553,6 @@ fail: goto fail; } - } else if (space->purpose == FIL_TYPE_LOG) { - node->handle = os_file_create( - innodb_log_file_key, node->name, OS_FILE_OPEN, - OS_FILE_AIO, OS_LOG_FILE, read_only_mode, &success); } else { node->handle = os_file_create( innodb_data_file_key, node->name, @@ -730,10 +719,6 @@ static void fil_flush_low(fil_space_t* space, bool metadata = false) case FIL_TYPE_IMPORT: fil_n_pending_tablespace_flushes++; break; - case FIL_TYPE_LOG: - fil_n_pending_log_flushes++; - fil_n_log_flushes++; - break; } #ifdef _WIN32 if (node->is_raw_disk) { @@ -773,9 +758,6 @@ skip_flush: case FIL_TYPE_IMPORT: fil_n_pending_tablespace_flushes--; continue; - case FIL_TYPE_LOG: - fil_n_pending_log_flushes--; - continue; } ut_ad(0); @@ -912,11 +894,6 @@ fil_mutex_enter_and_prepare_for_io( for (ulint count = 0;;) { mutex_enter(&fil_system.mutex); - if (space_id >= SRV_LOG_SPACE_FIRST_ID) { - /* We keep log files always open. */ - break; - } - fil_space_t* space = fil_space_get_by_id(space_id); if (space == NULL) { @@ -1214,8 +1191,7 @@ fil_space_create( ut_ad(fil_system.is_initialised()); ut_ad(fil_space_t::is_valid_flags(flags & ~FSP_FLAGS_MEM_MASK, id)); - ut_ad(purpose == FIL_TYPE_LOG - || srv_page_size == UNIV_PAGE_SIZE_ORIG || flags != 0); + ut_ad(srv_page_size == UNIV_PAGE_SIZE_ORIG || flags != 0); DBUG_EXECUTE_IF("fil_space_create_failure", return(NULL);); @@ -1286,7 +1262,7 @@ fil_space_create( UT_LIST_ADD_LAST(fil_system.space_list, space); - if (id < SRV_LOG_SPACE_FIRST_ID && id > fil_system.max_assigned_id) { + if (id < SRV_SPACE_ID_UPPER_BOUND && id > fil_system.max_assigned_id) { fil_system.max_assigned_id = id; } @@ -1332,16 +1308,16 @@ fil_assign_new_space_id( id++; - if (id > (SRV_LOG_SPACE_FIRST_ID / 2) && (id % 1000000UL == 0)) { + if (id > (SRV_SPACE_ID_UPPER_BOUND / 2) && (id % 1000000UL == 0)) { ib::warn() << "You are running out of new single-table" " tablespace id's. Current counter is " << id - << " and it must not exceed" << SRV_LOG_SPACE_FIRST_ID + << " and it must not exceed" <purpose) { - case FIL_TYPE_LOG: - break; case FIL_TYPE_TEMPORARY: case FIL_TYPE_TABLESPACE: case FIL_TYPE_IMPORT: @@ -1436,7 +1410,7 @@ fil_space_set_recv_size(ulint id, ulint size) { mutex_enter(&fil_system.mutex); ut_ad(size); - ut_ad(id < SRV_LOG_SPACE_FIRST_ID); + ut_ad(id < SRV_SPACE_ID_UPPER_BOUND); if (fil_space_t* space = fil_space_get_space(id)) { space->recv_size = size; @@ -1620,15 +1594,13 @@ void fil_system_t::close() ut_ad(!spaces); } -/*******************************************************************//** -Opens all log files and system tablespace data files. They stay open until the +/** Opens all system tablespace data files. They stay open until the database server shutdown. This should be called at a server startup after the -space objects for the log and the system tablespace have been created. The +space objects for the system tablespace have been created. The purpose of this operation is to make sure we never run out of file descriptors -if we need to read from the insert buffer or to write to the log. */ +if we need to read from the insert buffer. */ void -fil_open_log_and_system_tablespace_files(void) -/*==========================================*/ +fil_open_system_tablespace_files() { fil_space_t* space; @@ -1726,56 +1698,6 @@ fil_close_all_files(void) || UT_LIST_GET_LEN(fil_system.named_spaces) == 0); } -/*******************************************************************//** -Closes the redo log files. There must not be any pending i/o's or not -flushed modifications in the files. */ -void -fil_close_log_files( -/*================*/ - bool free) /*!< in: whether to free the memory object */ -{ - fil_space_t* space; - - mutex_enter(&fil_system.mutex); - - space = UT_LIST_GET_FIRST(fil_system.space_list); - - while (space != NULL) { - fil_node_t* node; - fil_space_t* prev_space = space; - - if (space->purpose != FIL_TYPE_LOG) { - space = UT_LIST_GET_NEXT(space_list, space); - continue; - } - - /* Log files are not in the fil_system.named_spaces list. */ - ut_ad(space->max_lsn == 0); - - for (node = UT_LIST_GET_FIRST(space->chain); - node != NULL; - node = UT_LIST_GET_NEXT(chain, node)) { - - if (node->is_open()) { - node->close(); - } - } - - space = UT_LIST_GET_NEXT(space_list, space); - - if (free) { - fil_space_detach(prev_space); - fil_space_free_low(prev_space); - } - } - - mutex_exit(&fil_system.mutex); - - if (free) { - log_sys.log.close(); - } -} - /*******************************************************************//** Sets the max tablespace id counter if the given number is bigger than the previous value. */ @@ -1784,7 +1706,7 @@ fil_set_max_space_id_if_bigger( /*===========================*/ ulint max_id) /*!< in: maximum known id */ { - if (max_id >= SRV_LOG_SPACE_FIRST_ID) { + if (max_id >= SRV_SPACE_ID_UPPER_BOUND) { ib::fatal() << "Max tablespace id is too high, " << max_id; } @@ -2717,7 +2639,7 @@ retry: for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system.space_list); space; space = UT_LIST_GET_NEXT(space_list, space)) { ulint id = space->id; - if (id && id < SRV_LOG_SPACE_FIRST_ID + if (id && space->purpose == FIL_TYPE_TABLESPACE && !strcmp(new_path, UT_LIST_GET_FIRST(space->chain)->name)) { @@ -2892,7 +2814,7 @@ fil_ibd_create( ut_ad(!is_system_tablespace(space_id)); ut_ad(!srv_read_only_mode); - ut_a(space_id < SRV_LOG_SPACE_FIRST_ID); + ut_a(space_id < SRV_SPACE_ID_UPPER_BOUND); ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE); ut_a(fil_space_t::is_valid_flags(flags & ~FSP_FLAGS_MEM_MASK, space_id)); @@ -4259,7 +4181,6 @@ fil_io( req_type.set_fil_node(node); ut_ad(!req_type.is_write() - || page_id.space() == SRV_LOG_SPACE_FIRST_ID || !fil_is_user_tablespace_id(page_id.space()) || offset == page_id.page_no() * zip_size); @@ -4314,7 +4235,6 @@ void fil_aio_callback(const tpool::aiocb *cb) mutex_enter(&fil_system.mutex); fil_node_complete_io(node, data->type); - ut_ad(node->space->purpose != FIL_TYPE_LOG); const ulint space_id= node->space->id; bool dblwr = node->space->use_doublewrite(); @@ -4403,7 +4323,7 @@ fil_flush(fil_space_t* space) /** Flush to disk the writes in file spaces of the given type possibly cached by the OS. -@param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_LOG */ +@param[in] purpose FIL_TYPE_TABLESPACE */ void fil_flush_file_spaces( fil_type_t purpose) @@ -4412,7 +4332,7 @@ fil_flush_file_spaces( ulint* space_ids; ulint n_space_ids; - ut_ad(purpose == FIL_TYPE_TABLESPACE || purpose == FIL_TYPE_LOG); + ut_ad(purpose == FIL_TYPE_TABLESPACE); mutex_enter(&fil_system.mutex); @@ -4755,7 +4675,7 @@ fil_names_dirty_and_write( char bogus_name[] = "./test/bogus file.ibd"; os_normalize_path(bogus_name); fil_name_write( - SRV_LOG_SPACE_FIRST_ID, 0, + SRV_SPACE_ID_UPPER_BOUND, 0, bogus_name, mtr); }); } diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc index 1ad73c83e1c..3e14ed62270 100644 --- a/storage/innobase/fsp/fsp0file.cc +++ b/storage/innobase/fsp/fsp0file.cc @@ -567,7 +567,7 @@ err_exit: goto err_exit; } - if (m_space_id >= SRV_LOG_SPACE_FIRST_ID) { + if (m_space_id >= SRV_SPACE_ID_UPPER_BOUND) { error_txt = "A bad Space ID was found"; goto err_exit; } diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 260de1eadea..1d1dc0ab266 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -135,8 +135,6 @@ fseg_alloc_free_page_low( @return pointer to the space header, page x-locked */ inline buf_block_t *fsp_get_header(const fil_space_t *space, mtr_t *mtr) { - ut_ad(space->purpose != FIL_TYPE_LOG); - buf_block_t *block= buf_page_get(page_id_t(space->id, 0), space->zip_size(), RW_SX_LATCH, mtr); buf_block_dbg_add_level(block, SYNC_FSP_PAGE); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index a61b5925db2..f335d40f3ad 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -18632,7 +18632,7 @@ checkpoint_now_set(THD*, st_mysql_sys_var*, void*, const void* save) ? log_sys.append_on_checkpoint->size() : 0) < log_sys.lsn) { log_make_checkpoint(); - fil_flush_file_spaces(FIL_TYPE_LOG); + log_sys.log.fsync(); } dberr_t err = fil_write_flushed_lsn(log_sys.lsn); diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 572d71317cd..b51fea1dee2 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -2472,7 +2472,7 @@ ibuf_merge_space( dtuple_t* tuple = ibuf_search_tuple_build(space, 0, heap); ulint n_pages = 0; - ut_ad(space < SRV_LOG_SPACE_FIRST_ID); + ut_ad(space < SRV_SPACE_ID_UPPER_BOUND); ibuf_mtr_start(&mtr); diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index c2deef8a2c0..32c14fb7b32 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -56,8 +56,6 @@ enum fil_type_t { FIL_TYPE_IMPORT, /** persistent tablespace (for system, undo log or tables) */ FIL_TYPE_TABLESPACE, - /** redo log covering changes to files of FIL_TYPE_TABLESPACE */ - FIL_TYPE_LOG }; /** Check if fil_type is any of FIL_TYPE_TEMPORARY, FIL_TYPE_IMPORT @@ -859,11 +857,6 @@ enum fil_encryption_t { #ifndef UNIV_INNOCHECKSUM -/** The number of fsyncs done to the log */ -extern ulint fil_n_log_flushes; - -/** Number of pending redo log flushes */ -extern ulint fil_n_pending_log_flushes; /** Number of pending tablespace flushes */ extern ulint fil_n_pending_tablespace_flushes; @@ -1074,28 +1067,19 @@ fil_space_get_size( /*===============*/ ulint id); /*!< in: space id */ -/*******************************************************************//** -Opens all log files and system tablespace data files. They stay open until the +/** Opens all system tablespace data files. They stay open until the database server shutdown. This should be called at a server startup after the -space objects for the log and the system tablespace have been created. The +space objects for the system tablespace have been created. The purpose of this operation is to make sure we never run out of file descriptors -if we need to read from the insert buffer or to write to the log. */ +if we need to read from the insert buffer. */ void -fil_open_log_and_system_tablespace_files(void); +fil_open_system_tablespace_files(); /*==========================================*/ /*******************************************************************//** Closes all open files. There must not be any pending i/o's or not flushed modifications in the files. */ void fil_close_all_files(void); -/*=====================*/ -/*******************************************************************//** -Closes the redo log files. There must not be any pending i/o's or not -flushed modifications in the files. */ -void -fil_close_log_files( -/*================*/ - bool free); /*!< in: whether to free the memory object */ /*******************************************************************//** Sets the max tablespace id counter if the given number is bigger than the previous value. */ @@ -1454,7 +1438,7 @@ fil_flush(fil_space_t* space); /** Flush to disk the writes in file spaces of the given type possibly cached by the OS. -@param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_LOG */ +@param[in] purpose FIL_TYPE_TABLESPACE */ void fil_flush_file_spaces( fil_type_t purpose); diff --git a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h index 69c5346a4f9..5057ed98aba 100644 --- a/storage/innobase/include/fsp0types.h +++ b/storage/innobase/include/fsp0types.h @@ -27,9 +27,11 @@ Created May 26, 2009 Vasil Dimov #ifndef fsp0types_h #define fsp0types_h +#include + /** The fil_space_t::id of the redo log. All persistent tablespaces have a smaller fil_space_t::id. */ -#define SRV_LOG_SPACE_FIRST_ID 0xFFFFFFF0U +static constexpr size_t SRV_SPACE_ID_UPPER_BOUND= 0xFFFFFFF0; /** The fil_space_t::id of the innodb_temporary tablespace. */ #define SRV_TMP_SPACE_ID 0xFFFFFFFEU diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index fac4ed4ece7..97e1d1dbcf6 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -38,6 +38,10 @@ Created 12/9/1995 Heikki Tuuri #include "log0types.h" #include "os0event.h" #include "os0file.h" +#include "span.h" +#include + +using st_::span; #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) @@ -454,6 +458,8 @@ static const ulonglong log_group_max_size = typedef ib_mutex_t LogSysMutex; typedef ib_mutex_t FlushOrderMutex; +extern my_bool srv_read_only_mode; + /** Redo log buffer */ struct log_t{ /** The original (not version-tagged) InnoDB redo log format */ @@ -534,11 +540,34 @@ struct log_t{ lsn_t lsn; /** the byte offset of the above lsn */ lsn_t lsn_offset; + public: /** used only in recovery: recovery scan succeeded up to this lsn in this log group */ lsn_t scanned_lsn; + /** file descriptors for all log files */ + std::vector files; + /** file names for all log files */ + std::vector file_names; + + /** simple setter, does not close or open log files */ + void set_file_names(std::vector names); + /** opens log files which must be closed prior this call */ + void open_files(); + /** reads buffer from log files + @param[in] total_offset offset in log files treated as a single file + @param[in] buf buffer where to read */ + void read(size_t total_offset, span buf); + /** writes buffer to log files + @param[in] total_offset offset in log files treated as a single file + @param[in] buf buffer from which to write */ + void write(size_t total_offset, span buf); + /** flushes OS page cache for all log files */ + void fsync(); + /** closes all log files */ + void close_files(); + /** @return whether the redo log is encrypted */ bool is_encrypted() const { return format & FORMAT_ENCRYPTED; } /** @return capacity in bytes */ @@ -571,6 +600,7 @@ struct log_t{ void close() { n_files = 0; + close_files(); } void set_lsn(lsn_t a_lsn); lsn_t get_lsn() const { return lsn; } @@ -593,6 +623,8 @@ struct log_t{ lsn_t flushed_to_disk_lsn; /*!< how far we have written the log AND flushed to disk */ + std::atomic pending_flushes; /*!< system calls in progress */ + std::atomic flushes; /*!< system calls counter */ ulint n_pending_flushes;/*!< number of currently pending flushes; protected by log_sys.mutex */ @@ -696,6 +728,16 @@ public: : OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM; } + size_t get_pending_flushes() const + { + return pending_flushes.load(std::memory_order_relaxed); + } + + size_t get_flushes() const + { + return flushes.load(std::memory_order_relaxed); + } + /** Initialise the redo log subsystem. */ void create(); diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 1d2155bfec7..0d2091979f5 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -889,9 +889,9 @@ struct export_var_t{ #endif ulint innodb_mem_dictionary; lsn_t innodb_os_log_written; /*!< srv_os_log_written */ - ulint innodb_os_log_fsyncs; /*!< fil_n_log_flushes */ + ulint innodb_os_log_fsyncs; /*!< n_log_flushes */ ulint innodb_os_log_pending_writes; /*!< srv_os_log_pending_writes */ - ulint innodb_os_log_pending_fsyncs; /*!< fil_n_pending_log_flushes */ + ulint innodb_os_log_pending_fsyncs; /*!< n_pending_log_flushes */ ulint innodb_pages_created; /*!< buf_pool->stat.n_pages_created */ ulint innodb_pages_read; /*!< buf_pool->stat.n_pages_read*/ ulint innodb_pages_written; /*!< buf_pool->stat.n_pages_written */ diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 9f9253e0b9c..7ca69648780 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -588,6 +588,90 @@ void log_t::create() } } +void log_t::files::set_file_names(std::vector names) +{ + file_names= std::move(names); +} + +void log_t::files::open_files() +{ + ut_ad(files.empty()); + files.reserve(file_names.size()); + for (const auto &name : file_names) + { + bool success; + files.push_back(os_file_create(innodb_log_file_key, name.c_str(), + OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT, + OS_FILE_NORMAL, OS_LOG_FILE, + srv_read_only_mode, &success)); + if (!success) + { + ib::fatal() << "os_file_create(" << name << ") failed"; + } + } +} + +void log_t::files::read(size_t total_offset, span buf) +{ + ut_ad(files.size() == file_names.size()); + + const size_t file_idx= total_offset / file_size; + const size_t offset= total_offset % file_size; + + if (const dberr_t err= os_file_read(IORequestRead, files[file_idx], + buf.data(), offset, buf.size())) + { + ib::fatal() << "os_file_read(" << file_names[file_idx] << ") returned " + << err; + } +} + +void log_t::files::write(size_t total_offset, span buf) +{ + ut_ad(files.size() == file_names.size()); + + const size_t file_idx= total_offset / file_size; + const size_t offset= total_offset % file_size; + + if (const dberr_t err= + os_file_write(IORequestWrite, file_names[file_idx].c_str(), + files[file_idx], buf.data(), offset, buf.size())) + { + ib::fatal() << "os_file_write(" << file_names[file_idx] << ") returned " + << err; + } +} + +void log_t::files::fsync() +{ + 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_add(1, std::memory_order_release); + log_sys.flushes.fetch_add(1, std::memory_order_release); +} + +void log_t::files::close_files() +{ + for (auto it= files.begin(), end= files.end(); it != end; ++it) + { + if (!os_file_close(*it)) + { + const auto idx= std::distance(files.begin(), it); + ib::fatal() << "os_file_close(" << file_names[idx] << ") failed"; + } + } + files.clear(); +} + /** Initialize the redo log. @param[in] n_files number of files */ void log_t::files::create(ulint n_files) @@ -651,13 +735,7 @@ log_file_header_flush( srv_stats.os_log_pending_writes.inc(); - const ulint page_no = ulint(dest_offset >> srv_page_size_shift); - - fil_io(IORequestLogWrite, true, - page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no), - 0, - ulint(dest_offset & (srv_page_size - 1)), - OS_FILE_LOG_BLOCK_SIZE, buf, NULL); + log_sys.log.write(dest_offset, buf); srv_stats.os_log_pending_writes.dec(); } @@ -758,12 +836,7 @@ loop: ut_a((next_offset >> srv_page_size_shift) <= ULINT_MAX); - const ulint page_no = ulint(next_offset >> srv_page_size_shift); - - fil_io(IORequestLogWrite, true, - page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no), - 0, - ulint(next_offset & (srv_page_size - 1)), write_len, buf, NULL); + log_sys.log.write(next_offset, {buf, write_len}); srv_stats.os_log_pending_writes.dec(); @@ -791,17 +864,10 @@ log_write_flush_to_disk_low() calling os_event_set()! */ ut_a(log_sys.n_pending_flushes == 1); /* No other threads here */ - bool do_flush = srv_file_flush_method != SRV_O_DSYNC; - - if (do_flush) { - fil_flush(SRV_LOG_SPACE_FIRST_ID); - } - + log_sys.log.fsync(); log_mutex_enter(); - if (do_flush) { - log_sys.flushed_to_disk_lsn = log_sys.current_flush_lsn; - } + log_sys.flushed_to_disk_lsn = log_sys.current_flush_lsn; log_sys.n_pending_flushes--; @@ -1173,11 +1239,8 @@ void log_header_read(ulint header) MONITOR_INC(MONITOR_LOG_IO); - fil_io(IORequestLogRead, true, - page_id_t(SRV_LOG_SPACE_FIRST_ID, - header >> srv_page_size_shift), - 0, header & (srv_page_size - 1), - OS_FILE_LOG_BLOCK_SIZE, log_sys.checkpoint_buf, NULL); + log_sys.log.read(header, + {log_sys.checkpoint_buf, OS_FILE_LOG_BLOCK_SIZE}); } /** Write checkpoint info to the log header and invoke log_mutex_exit(). @@ -1231,21 +1294,11 @@ void log_write_checkpoint_info(lsn_t end_lsn) /* Note: We alternate the physical place of the checkpoint info. See the (next_checkpoint_no & 1) below. */ - fil_io(IORequestLogWrite, true, - page_id_t(SRV_LOG_SPACE_FIRST_ID, 0), - 0, - (log_sys.next_checkpoint_no & 1) - ? LOG_CHECKPOINT_2 : LOG_CHECKPOINT_1, - OS_FILE_LOG_BLOCK_SIZE, - buf, nullptr); + log_sys.log.write((log_sys.next_checkpoint_no & 1) ? LOG_CHECKPOINT_2 + : LOG_CHECKPOINT_1, + {buf, OS_FILE_LOG_BLOCK_SIZE}); - switch (srv_flush_t(srv_file_flush_method)) { - case SRV_O_DSYNC: - case SRV_NOSYNC: - break; - default: - fil_flush(SRV_LOG_SPACE_FIRST_ID); - } + log_sys.log.fsync(); log_mutex_enter(); @@ -1723,7 +1776,7 @@ wait_suspend_loop: /* Ensure that all buffered changes are written to the redo log before fil_close_all_files(). */ - fil_flush_file_spaces(FIL_TYPE_LOG); + log_sys.log.fsync(); } else { lsn = srv_start_lsn; } diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index d410d629144..952d5b0bad6 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -899,13 +899,7 @@ loop: ut_a((source_offset >> srv_page_size_shift) <= ULINT_MAX); - const ulint page_no = ulint(source_offset >> srv_page_size_shift); - - fil_io(IORequestLogRead, true, - page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no), - 0, - ulint(source_offset & (srv_page_size - 1)), - len, buf, NULL); + log_sys.log.read(source_offset, {buf, len}); for (ulint l = 0; l < len; l += OS_FILE_LOG_BLOCK_SIZE, buf += OS_FILE_LOG_BLOCK_SIZE, @@ -1108,19 +1102,14 @@ static dberr_t recv_log_format_0_recover(lsn_t lsn, bool crypt) log_mutex_enter(); const lsn_t source_offset = log_sys.log.calc_lsn_offset(lsn); log_mutex_exit(); - const ulint page_no = ulint(source_offset >> srv_page_size_shift); byte* buf = log_sys.buf; static const char* NO_UPGRADE_RECOVERY_MSG = "Upgrade after a crash is not supported." " This redo log was created before MariaDB 10.2.2"; - fil_io(IORequestLogRead, true, - page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no), - 0, - ulint((source_offset & ~(OS_FILE_LOG_BLOCK_SIZE - 1)) - & (srv_page_size - 1)), - OS_FILE_LOG_BLOCK_SIZE, buf, NULL); + log_sys.log.read(source_offset & ~(OS_FILE_LOG_BLOCK_SIZE - 1), + {buf, OS_FILE_LOG_BLOCK_SIZE}); if (log_block_calc_checksum_format_0(buf) != log_block_get_checksum(buf) diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index e3183df8c97..57fe79dcae9 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -4220,7 +4220,7 @@ os_aio_print(FILE* file) ULINTPF " OS file reads, " ULINTPF " OS file writes, " ULINTPF " OS fsyncs\n", - fil_n_pending_log_flushes, + log_sys.get_pending_flushes(), fil_n_pending_tablespace_flushes, os_n_file_reads, os_n_file_writes, @@ -4478,7 +4478,6 @@ void fil_node_t::find_metadata(os_file_t file bool fil_node_t::read_page0(bool first) { ut_ad(mutex_own(&fil_system.mutex)); - ut_a(space->purpose != FIL_TYPE_LOG); const ulint psize = space->physical_size(); #ifndef _WIN32 struct stat statbuf; diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index d9feb3fb9db..22a628a0dca 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -3805,7 +3805,7 @@ row_import_for_mysql( ut_ad(!table->is_temporary()); ut_ad(table->space_id); - ut_ad(table->space_id < SRV_LOG_SPACE_FIRST_ID); + ut_ad(table->space_id < SRV_SPACE_ID_UPPER_BOUND); ut_ad(prebuilt->trx); ut_ad(!table->is_readable()); diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index c4cc8e86266..6eb7098574e 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -1774,12 +1774,12 @@ srv_mon_process_existing_counter( /* innodb_os_log_fsyncs */ case MONITOR_OVLD_OS_LOG_FSYNC: - value = fil_n_log_flushes; + value = log_sys.get_flushes(); break; /* innodb_os_log_pending_fsyncs */ case MONITOR_OVLD_OS_LOG_PENDING_FSYNC: - value = fil_n_pending_log_flushes; + value = log_sys.get_pending_flushes(); update_min = TRUE; break; diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 5d5023d83af..d7408222fd6 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1172,7 +1172,7 @@ srv_export_innodb_status(void) ulint(MONITOR_VALUE(MONITOR_OS_PENDING_WRITES)); export_vars.innodb_data_pending_fsyncs = - fil_n_pending_log_flushes + log_sys.get_pending_flushes() + fil_n_pending_tablespace_flushes; export_vars.innodb_data_fsyncs = os_n_fsyncs; @@ -1248,9 +1248,10 @@ srv_export_innodb_status(void) export_vars.innodb_os_log_written = srv_stats.os_log_written; - export_vars.innodb_os_log_fsyncs = fil_n_log_flushes; + export_vars.innodb_os_log_fsyncs = log_sys.get_flushes(); - export_vars.innodb_os_log_pending_fsyncs = fil_n_pending_log_flushes; + export_vars.innodb_os_log_pending_fsyncs + = log_sys.get_pending_flushes(); export_vars.innodb_os_log_pending_writes = srv_stats.os_log_pending_writes; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 4d733f3f03c..c659e2c2ced 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -168,9 +168,6 @@ static ulint srv_start_state; SRV_SHUTDOWN_CLEANUP and then to SRV_SHUTDOWN_LAST_PHASE, and so on */ enum srv_shutdown_t srv_shutdown_state = SRV_SHUTDOWN_NONE; -/** Files comprising the system tablespace */ -pfs_os_file_t files[1000]; - /** Name of srv_monitor_file */ static char* srv_monitor_file_name; std::unique_ptr srv_master_timer; @@ -251,19 +248,15 @@ srv_file_check_mode( } -/*********************************************************************//** -Creates a log file. +/** Creates a log file. +@param[in] name log file name @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((nonnull, warn_unused_result)) -dberr_t -create_log_file( -/*============*/ - pfs_os_file_t* file, /*!< out: file handle */ - const char* name) /*!< in: log file name */ +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t + create_log_file(const char* name) { bool ret; - *file = os_file_create( + pfs_os_file_t file = os_file_create( innodb_log_file_key, name, OS_FILE_CREATE|OS_FILE_ON_ERROR_NO_EXIT, OS_FILE_NORMAL, OS_LOG_FILE, srv_read_only_mode, &ret); @@ -276,14 +269,15 @@ create_log_file( ib::info() << "Setting log file " << name << " size to " << srv_log_file_size << " bytes"; - ret = os_file_set_size(name, *file, srv_log_file_size); + ret = os_file_set_size(name, file, srv_log_file_size); if (!ret) { + os_file_close(file); ib::error() << "Cannot set log file " << name << " size to " << srv_log_file_size << " bytes"; return(DB_ERROR); } - ret = os_file_close(*file); + ret = os_file_close(file); ut_a(ret); return(DB_SUCCESS); @@ -326,7 +320,7 @@ create_log_files( char* logfilename, /*!< in/out: buffer for log file name */ size_t dirnamelen, /*!< in: length of the directory path */ lsn_t lsn, /*!< in: FIL_PAGE_FILE_FLUSH_LSN value */ - char*& logfile0) /*!< out: name of the first log file */ + std::string& logfile0) /*!< out: name of the first log file */ { dberr_t err; @@ -350,52 +344,38 @@ create_log_files( DBUG_EXECUTE_IF("innodb_log_abort_7", return(DB_ERROR);); DBUG_PRINT("ib_log", ("After innodb_log_abort_7")); + std::vector file_names; + for (unsigned i = 0; i < srv_n_log_files; i++) { sprintf(logfilename + dirnamelen, "ib_logfile%u", i ? i : INIT_LOG_FILE0); - err = create_log_file(&files[i], logfilename); + err = create_log_file(logfilename); if (err != DB_SUCCESS) { return(err); } + + file_names.emplace_back(logfilename); } + logfile0 = file_names[0]; + log_sys.log.set_file_names(std::move(file_names)); + DBUG_EXECUTE_IF("innodb_log_abort_8", return(DB_ERROR);); DBUG_PRINT("ib_log", ("After innodb_log_abort_8")); /* We did not create the first log file initially as ib_logfile0, so that crash recovery cannot find it until it has been completed and renamed. */ - sprintf(logfilename + dirnamelen, "ib_logfile%u", INIT_LOG_FILE0); - - fil_space_t* log_space = fil_space_create( - "innodb_redo_log", SRV_LOG_SPACE_FIRST_ID, 0, FIL_TYPE_LOG, - NULL/* innodb_encrypt_log works at a different level */); - - ut_a(fil_validate()); - ut_a(log_space != NULL); - - const ulint size = ulint(srv_log_file_size >> srv_page_size_shift); - - logfile0 = log_space->add(logfilename, OS_FILE_CLOSED, size, - false, false)->name; - ut_a(logfile0); - - for (unsigned i = 1; i < srv_n_log_files; i++) { - - sprintf(logfilename + dirnamelen, "ib_logfile%u", i); - - log_space->add(logfilename, OS_FILE_CLOSED, size, - false, false); - } log_sys.log.create(srv_n_log_files); if (!log_set_capacity(srv_log_file_size_requested)) { return(DB_ERROR); } - fil_open_log_and_system_tablespace_files(); + log_sys.log.open_files(); + fil_open_system_tablespace_files(); /* Create a log checkpoint. */ log_mutex_enter(); @@ -438,54 +418,47 @@ create_log_files( @return error code @retval DB_SUCCESS on successful operation */ MY_ATTRIBUTE((warn_unused_result, nonnull)) -static -dberr_t -create_log_files_rename( -/*====================*/ - char* logfilename, /*!< in/out: buffer for log file name */ - size_t dirnamelen, /*!< in: length of the directory path */ - lsn_t lsn, /*!< in: FIL_PAGE_FILE_FLUSH_LSN value */ - char* logfile0) /*!< in/out: name of the first log file */ +static dberr_t create_log_files_rename(char *logfilename, size_t dirnamelen, + lsn_t lsn, std::string &logfile0) { - /* If innodb_flush_method=O_DSYNC, - we need to explicitly flush the log buffers. */ - fil_flush(SRV_LOG_SPACE_FIRST_ID); + log_sys.log.fsync(); - ut_ad(!srv_log_files_created); - ut_d(srv_log_files_created = true); + ut_ad(!srv_log_files_created); + ut_d(srv_log_files_created= true); - DBUG_EXECUTE_IF("innodb_log_abort_9", return(DB_ERROR);); - DBUG_PRINT("ib_log", ("After innodb_log_abort_9")); + DBUG_EXECUTE_IF("innodb_log_abort_9", return (DB_ERROR);); + DBUG_PRINT("ib_log", ("After innodb_log_abort_9")); - /* Close the log files, so that we can rename - the first one. */ - fil_close_log_files(false); + /* Close the log files, so that we can rename the first one. */ + log_sys.log.close_files(); - /* Rename the first log file, now that a log - checkpoint has been created. */ - sprintf(logfilename + dirnamelen, "ib_logfile%u", 0); + /* Rename the first log file, now that a log + checkpoint has been created. */ + sprintf(logfilename + dirnamelen, "ib_logfile%u", 0); - ib::info() << "Renaming log file " << logfile0 << " to " - << logfilename; + ib::info() << "Renaming log file " << logfile0 << " to " << logfilename; - log_mutex_enter(); - ut_ad(strlen(logfile0) == 2 + strlen(logfilename)); - dberr_t err = os_file_rename( - innodb_log_file_key, logfile0, logfilename) - ? DB_SUCCESS : DB_ERROR; + log_mutex_enter(); + ut_ad(logfile0.size() == 2 + strlen(logfilename)); + dberr_t err= + os_file_rename(innodb_log_file_key, logfile0.c_str(), logfilename) + ? DB_SUCCESS + : DB_ERROR; - /* Replace the first file with ib_logfile0. */ - strcpy(logfile0, logfilename); - log_mutex_exit(); + /* Replace the first file with ib_logfile0. */ + logfile0= logfilename; + log_sys.log.file_names[0]= logfilename; + log_mutex_exit(); - DBUG_EXECUTE_IF("innodb_log_abort_10", err = DB_ERROR;); + DBUG_EXECUTE_IF("innodb_log_abort_10", err= DB_ERROR;); - if (err == DB_SUCCESS) { - fil_open_log_and_system_tablespace_files(); - ib::info() << "New log files created, LSN=" << lsn; - } + if (err == DB_SUCCESS) + { + log_sys.log.open_files(); + ib::info() << "New log files created, LSN=" << lsn; + } - return(err); + return (err); } /** Create an undo tablespace file @@ -645,7 +618,7 @@ err_exit: } uint32_t id= mach_read_from_4(FIL_PAGE_SPACE_ID + page); - if (id == 0 || id >= SRV_LOG_SPACE_FIRST_ID || + if (id == 0 || id >= SRV_SPACE_ID_UPPER_BOUND || memcmp_aligned<4>(FIL_PAGE_SPACE_ID + page, FSP_HEADER_OFFSET + FSP_SPACE_ID + page, 4)) { @@ -1159,9 +1132,7 @@ srv_prepare_to_delete_redo_log_files( log_write_up_to(flushed_lsn, true); - /* If innodb_flush_method=O_DSYNC, - we need to explicitly flush the log buffers. */ - fil_flush(SRV_LOG_SPACE_FIRST_ID); + log_sys.log.fsync(); ut_ad(flushed_lsn == log_get_lsn()); @@ -1196,9 +1167,6 @@ dberr_t srv_start(bool create_new_db) dberr_t err = DB_SUCCESS; ulint srv_n_log_files_found = srv_n_log_files; mtr_t mtr; - char logfilename[10000]; - char* logfile0 = NULL; - size_t dirnamelen; unsigned i = 0; ut_ad(srv_operation == SRV_OPERATION_NORMAL @@ -1482,7 +1450,8 @@ dberr_t srv_start(bool create_new_db) return(srv_init_abort(err)); } - dirnamelen = strlen(srv_log_group_home_dir); + char logfilename[10000]; + size_t dirnamelen = strlen(srv_log_group_home_dir); ut_a(dirnamelen < (sizeof logfilename) - 10 - sizeof "ib_logfile"); memcpy(logfilename, srv_log_group_home_dir, dirnamelen); @@ -1497,6 +1466,7 @@ dberr_t srv_start(bool create_new_db) return srv_init_abort(DB_ERROR); } + std::string logfile0; if (create_new_db) { buf_flush_sync_all_buf_pools(); @@ -1627,32 +1597,19 @@ dberr_t srv_start(bool create_new_db) srv_n_log_files_found = i; - /* Create the in-memory file space objects. */ - - sprintf(logfilename + dirnamelen, "ib_logfile%u", 0); - - /* Disable the doublewrite buffer for log files. */ - fil_space_t* log_space = fil_space_create( - "innodb_redo_log", - SRV_LOG_SPACE_FIRST_ID, 0, - FIL_TYPE_LOG, - NULL /* no encryption yet */); - - ut_a(fil_validate()); - ut_a(log_space); - ut_a(srv_log_file_size <= log_group_max_size); - const ulint size = 1 + ulint((srv_log_file_size - 1) - >> srv_page_size_shift); + std::vector file_names; for (unsigned j = 0; j < srv_n_log_files_found; j++) { sprintf(logfilename + dirnamelen, "ib_logfile%u", j); - log_space->add(logfilename, OS_FILE_CLOSED, size, - false, false); + file_names.emplace_back(logfilename); } + log_sys.log.set_file_names(std::move(file_names)); + log_sys.log.open_files(); + log_sys.log.create(srv_n_log_files_found); if (!log_set_capacity(srv_log_file_size_requested)) { @@ -1665,7 +1622,7 @@ files_checked: tablespace: we keep them open until database shutdown */ - fil_open_log_and_system_tablespace_files(); + fil_open_system_tablespace_files(); ut_d(fil_system.sys_space->recv_size = srv_sys_space_size_debug); err = srv_undo_tablespaces_init(create_new_db); @@ -1892,7 +1849,7 @@ files_checked: buf_flush_sync_all_buf_pools(); err = fil_write_flushed_lsn(log_get_lsn()); ut_ad(!buf_pool_check_no_pending_io()); - fil_close_log_files(true); + log_sys.log.close_files(); if (err == DB_SUCCESS) { bool trunc = srv_operation == SRV_OPERATION_RESTORE; @@ -1955,7 +1912,7 @@ files_checked: /* Close and free the redo log files, so that we can replace them. */ - fil_close_log_files(true); + log_sys.log.close_files(); DBUG_EXECUTE_IF("innodb_log_abort_5", return(srv_init_abort(DB_ERROR));); -- cgit v1.2.1