mirror of
https://github.com/MariaDB/server.git
synced 2025-11-07 22:36:14 +01:00
It was possible that a log checkpoint was completed and the server killed between the time that fil_ibd_create() durably wrote a FILE_CREATE record, and the initialization of the tablespace. This could lead to a failure to start up after the server was killed during TRUNCATE TABLE or any table-rebuilding operation such as OPTIMIZE TABLE. In the case of TRUNCATE TABLE, an attempt to rename a file #sql-ibNNN.ibd (the contents of the table before truncation) to tablename.ibd would fail, because both files existed and the file tablename.ibd would have been filled with NUL bytes. It was possible to resume from this error by deleting the file tablename.ibd and restarting the server. We will prevent this class of errors by ensuring that both the FILE_CREATE record and the records written by fsp_header_init() will be part of the same atomic transaction, which must be durably written before any file is created or allocated. NOTE: There is another possible crash recovery problem, which we are not attempting to solve here and which will be covered by the subsequent change (MDEV-38026). If fil_ibd_create() fails to create the file and the server were killed, recovery would not even attempt to create the file at all. fil_space_t::create(): Remove the DBUG_EXECUTE_IF fault injection that was the only cause of return nullptr. This allows us to simplify several callers. fil_space_t::set_stopped(), fil_space_t::clear_stopped(): Accessor functions for fil_ibd_create() for preventing any concurrent access to an incompletely created tablespace. fil_ibd_create(): In a single atomic mini-transaction, write the FILE_CREATE record as well as the log for initializing the tablespace. After durably writing the log, create the file in the file system Only after the file has been successfully created and allocated, open the tablespace for business. Finally, release the exclusive page latches so that the header pages may be written to the file. fil_ibd_open(): Move some fault injection from fil_space_t::create() to a higher level, to the place where an existing file is being opened. Reviewed by: Thirunarayanan Balathandayuthapani Tested by: Saahil Alam |
||
|---|---|---|
| .. | ||
| fsp0file.cc | ||
| fsp0fsp.cc | ||
| fsp0space.cc | ||
| fsp0sysspace.cc | ||