summaryrefslogtreecommitdiff
path: root/storage/innobase/include/fsp0file.h
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-05-17 18:12:33 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-05-17 18:12:33 +0300
commit86dc7b4d4cfe15a2d37f8b5f60c4fce5dba9491d (patch)
treeb23fd8a5ee30469841cf0013adf6cf4e892d56c8 /storage/innobase/include/fsp0file.h
parentc290c0d7e0d8184611d878be2adc7cd62ca773ef (diff)
downloadmariadb-git-86dc7b4d4cfe15a2d37f8b5f60c4fce5dba9491d.tar.gz
MDEV-24626 Remove synchronous write of page0 file during file creation
During data file creation, InnoDB holds dict_sys mutex, tries to write page 0 of the file and flushes the file. This not only causing unnecessary contention but also a deviation from the write-ahead logging protocol. The clean sequence of operations is that we first start a dictionary transaction and write SYS_TABLES and SYS_INDEXES records that identify the tablespace. Then, we durably write a FILE_CREATE record to the write-ahead log and create the file. Recovery should not unnecessarily insist that the first page of each data file that is referred to by the redo log is valid. It must be enough that page 0 of the tablespace can be initialized based on the redo log contents. We introduce a new data structure deferred_spaces that keeps track of corrupted-looking files during recovery. The data structure holds the last LSN of a FILE_ record referring to the data file, the tablespace identifier, and the last known file name. There are two scenarios can happen during recovery: i) Sufficient memory: InnoDB can reconstruct the tablespace after parsing all redo log records. ii) Insufficient memory(multiple apply phase): InnoDB should store the deferred tablespace redo logs even though tablespace is not present. InnoDB should start constructing the tablespace when it first encounters deferred tablespace id. Mariabackup copies the zero filled ibd file in backup_fix_ddl() as the extension of .new file. Mariabackup test case does page flushing when it deals with DDL operation during backup operation. fil_ibd_create(): Remove the write of page0 and flushing of file fil_ibd_load(): Return FIL_LOAD_DEFER if the tablespace has zero filled page0 Datafile: Clean up the error handling, and do not report errors if we are in the middle of recovery. The caller will check Datafile::m_defer. fil_node_t::deferred: Indicates whether the tablespace loading was deferred during recovery FIL_LOAD_DEFER: Returned by fil_ibd_load() to indicate that tablespace file was cannot be loaded. recv_sys_t::recover_deferred(): Invoke deferred_spaces.create() to initialize fil_space_t based on buffered metadata and records to initialize page 0. Ignore the flags in fil_name_t, because they are intentionally invalid. fil_name_process(): Update deferred_spaces. recv_sys_t::parse(): Store the redo log if the tablespace id is present in deferred spaces recv_sys_t::recover_low(): Should recover the first page of the tablespace even though the tablespace instance is not present recv_sys_t::apply(): Initialize the deferred tablespace before applying the deferred tablespace records recv_validate_tablespace(): Skip the validation for deferred_spaces. recv_rename_files(): Moved and revised from recv_sys_t::apply(). For deferred-recovery tablespaces, do not attempt to rename the file if a deferred-recovery tablespace is associated with the name. recv_recovery_from_checkpoint_start(): Invoke recv_rename_files() and initialize all deferred tablespaces before applying redo log. fil_node_t::read_page0(): Skip page0 validation if the tablespace is deferred buf_page_create_deferred(): A variant of buf_page_create() when the fil_space_t is not available yet This is joint work with Thirunarayanan Balathandayuthapani, who implemented an initial prototype.
Diffstat (limited to 'storage/innobase/include/fsp0file.h')
-rw-r--r--storage/innobase/include/fsp0file.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/storage/innobase/include/fsp0file.h b/storage/innobase/include/fsp0file.h
index 517b3f72499..3ec56c75476 100644
--- a/storage/innobase/include/fsp0file.h
+++ b/storage/innobase/include/fsp0file.h
@@ -324,6 +324,9 @@ public:
@return the first data page */
const byte* get_first_page() const { return(m_first_page); }
+ void set_space_id(ulint space_id) { m_space_id= space_id; }
+
+ void set_flags(ulint flags) { m_flags = flags; }
private:
/** Free the filepath buffer. */
void free_filepath();
@@ -443,6 +446,8 @@ protected:
ulint m_last_os_error;
public:
+ /** true if table is deferred during recovery */
+ bool m_defer=false;
/** Use the following to determine the uniqueness of this datafile. */
#ifdef _WIN32
/* Use fields dwVolumeSerialNumber, nFileIndexLow, nFileIndexHigh. */