summaryrefslogtreecommitdiff
path: root/storage/innobase/srv/srv0start.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/srv/srv0start.cc')
-rw-r--r--storage/innobase/srv/srv0start.cc295
1 files changed, 130 insertions, 165 deletions
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index a507b29ffa2..a1368c5146c 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -55,7 +55,6 @@ Created 2/16/1996 Heikki Tuuri
#include "buf0dblwr.h"
#include "buf0dump.h"
#include "os0file.h"
-#include "os0thread.h"
#include "fil0fil.h"
#include "fil0crypt.h"
#include "fsp0fsp.h"
@@ -96,12 +95,11 @@ Created 2/16/1996 Heikki Tuuri
#include "row0row.h"
#include "row0mysql.h"
#include "btr0pcur.h"
-#include "os0event.h"
#include "zlib.h"
#include "ut0crc32.h"
/** We are prepared for a situation that we have this many threads waiting for
-a semaphore inside InnoDB. srv_start() sets the value. */
+a transactional lock inside InnoDB. srv_start() sets the value. */
ulint srv_max_n_threads;
/** Log sequence number at shutdown */
@@ -118,8 +116,6 @@ incomplete transactions */
bool srv_startup_is_before_trx_rollback_phase;
/** TRUE if the server is being started */
bool srv_is_being_started;
-/** TRUE if SYS_TABLESPACES is available for lookups */
-bool srv_sys_tablespaces_open;
/** TRUE if the server was successfully started */
bool srv_was_started;
/** The original value of srv_log_file_size (innodb_log_file_size) */
@@ -128,13 +124,13 @@ static ulonglong srv_log_file_size_requested;
static bool srv_start_has_been_called;
/** Whether any undo log records can be generated */
-UNIV_INTERN bool srv_undo_sources;
+bool srv_undo_sources;
#ifdef UNIV_DEBUG
/** InnoDB system tablespace to set during recovery */
-UNIV_INTERN uint srv_sys_space_size_debug;
+uint srv_sys_space_size_debug;
/** whether redo log file have been created at startup */
-UNIV_INTERN bool srv_log_file_created;
+bool srv_log_file_created;
#endif /* UNIV_DEBUG */
/** whether some background threads that create redo log have been started */
@@ -253,7 +249,11 @@ static dberr_t create_log_file(bool create_new_db, lsn_t lsn,
}
DBUG_PRINT("ib_log", ("After innodb_log_abort_6"));
- DBUG_ASSERT(!buf_pool.any_io_pending());
+ ut_ad(!os_aio_pending_reads());
+ ut_ad(!os_aio_pending_writes());
+ ut_d(mysql_mutex_lock(&buf_pool.flush_list_mutex));
+ ut_ad(!buf_pool.get_oldest_modification(0));
+ ut_d(mysql_mutex_unlock(&buf_pool.flush_list_mutex));
DBUG_EXECUTE_IF("innodb_log_abort_7", return DB_ERROR;);
DBUG_PRINT("ib_log", ("After innodb_log_abort_7"));
@@ -487,15 +487,12 @@ static ulint trx_rseg_get_n_undo_tablespaces()
static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i)
{
bool success;
- char undo_name[sizeof "innodb_undo000"];
ulint space_id= 0;
ulint fsp_flags= 0;
if (create)
{
space_id= srv_undo_space_id_start + i;
- snprintf(undo_name, sizeof(undo_name),
- "innodb_undo%03u", static_cast<unsigned>(space_id));
switch (srv_checksum_algorithm) {
case SRV_CHECKSUM_ALGORITHM_FULL_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32:
@@ -522,7 +519,8 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i)
{
page_t *page= static_cast<byte*>(aligned_malloc(srv_page_size,
srv_page_size));
- dberr_t err= os_file_read(IORequestRead, fh, page, 0, srv_page_size);
+ dberr_t err= os_file_read(IORequestRead, fh, page, 0, srv_page_size,
+ nullptr);
if (err != DB_SUCCESS)
{
err_exit:
@@ -550,7 +548,6 @@ err_exit:
}
space_id= id;
- snprintf(undo_name, sizeof undo_name, "innodb_undo%03u", id);
aligned_free(page);
}
@@ -562,14 +559,14 @@ err_exit:
fil_set_max_space_id_if_bigger(space_id);
- fil_space_t *space= fil_space_t::create(undo_name, space_id, fsp_flags,
- FIL_TYPE_TABLESPACE, NULL,
+ fil_space_t *space= fil_space_t::create(space_id, fsp_flags,
+ FIL_TYPE_TABLESPACE, nullptr,
FIL_ENCRYPTION_DEFAULT, true);
ut_a(fil_validate());
ut_a(space);
fil_node_t *file= space->add(name, fh, 0, false, true);
- mutex_enter(&fil_system.mutex);
+ mysql_mutex_lock(&fil_system.mutex);
if (create)
{
@@ -584,7 +581,7 @@ err_exit:
fil_system.n_open--;
}
- mutex_exit(&fil_system.mutex);
+ mysql_mutex_unlock(&fil_system.mutex);
return space_id;
}
@@ -603,11 +600,7 @@ srv_check_undo_redo_logs_exists()
/* Check if any undo tablespaces exist */
for (ulint i = 1; i <= srv_undo_tablespaces; ++i) {
- snprintf(
- name, sizeof(name),
- "%s%cundo%03zu",
- srv_undo_dir, OS_PATH_SEPARATOR,
- i);
+ snprintf(name, sizeof name, "%s/undo%03zu", srv_undo_dir, i);
fh = os_file_create(
innodb_data_file_key, name,
@@ -665,8 +658,7 @@ static dberr_t srv_all_undo_tablespaces_open(bool create_new_db, ulint n_undo)
for (ulint i= 0; i < n_undo; ++i)
{
char name[OS_FILE_MAX_PATH];
- snprintf(name, sizeof name, "%s%cundo%03zu", srv_undo_dir,
- OS_PATH_SEPARATOR, i + 1);
+ snprintf(name, sizeof name, "%s/undo%03zu", srv_undo_dir, i + 1);
ulint space_id= srv_undo_tablespace_open(create_new_db, name, i);
if (!space_id)
{
@@ -696,8 +688,7 @@ static dberr_t srv_all_undo_tablespaces_open(bool create_new_db, ulint n_undo)
++i)
{
char name[OS_FILE_MAX_PATH];
- snprintf(name, sizeof(name),
- "%s%cundo%03zu", srv_undo_dir, OS_PATH_SEPARATOR, i);
+ snprintf(name, sizeof name, "%s/undo%03zu", srv_undo_dir, i);
if (!srv_undo_tablespace_open(create_new_db, name, i))
break;
++srv_undo_tablespaces_open;
@@ -731,8 +722,7 @@ srv_undo_tablespaces_init(bool create_new_db)
for (ulint i= 0; i < srv_undo_tablespaces; ++i)
{
char name[OS_FILE_MAX_PATH];
- snprintf(name, sizeof name, "%s%cundo%03zu",
- srv_undo_dir, OS_PATH_SEPARATOR, i + 1);
+ snprintf(name, sizeof name, "%s/undo%03zu", srv_undo_dir, i + 1);
if (dberr_t err= srv_undo_tablespace_create(name))
{
ib::error() << "Could not create undo tablespace '" << name << "'.";
@@ -764,10 +754,12 @@ srv_undo_tablespaces_init(bool create_new_db)
mtr_t mtr;
for (ulint i= 0; i < srv_undo_tablespaces; ++i)
{
- mtr.start();
- fsp_header_init(fil_space_get(srv_undo_space_id_start + i),
- SRV_UNDO_TABLESPACE_SIZE_IN_PAGES, &mtr);
- mtr.commit();
+ mtr.start();
+ dberr_t err= fsp_header_init(fil_space_get(srv_undo_space_id_start + i),
+ SRV_UNDO_TABLESPACE_SIZE_IN_PAGES, &mtr);
+ mtr.commit();
+ if (err)
+ return err;
}
}
@@ -813,10 +805,13 @@ srv_open_tmp_tablespace(bool create_new_db)
mtr_t mtr;
mtr.start();
mtr.set_log_mode(MTR_LOG_NO_REDO);
- fsp_header_init(fil_system.temp_space,
- srv_tmp_space.get_sum_of_sizes(),
- &mtr);
+ err = fsp_header_init(fil_system.temp_space,
+ srv_tmp_space.get_sum_of_sizes(),
+ &mtr);
mtr.commit();
+ if (err == DB_SUCCESS) {
+ err = trx_temp_rseg_create(&mtr);
+ }
} else {
/* This file was just opened in the code above! */
ib::error() << "The innodb_temporary"
@@ -832,10 +827,8 @@ srv_open_tmp_tablespace(bool create_new_db)
static void srv_shutdown_threads()
{
ut_ad(!srv_undo_sources);
- srv_shutdown_state = SRV_SHUTDOWN_EXIT_THREADS;
-
- lock_sys.timeout_timer.reset();
srv_master_timer.reset();
+ srv_shutdown_state = SRV_SHUTDOWN_EXIT_THREADS;
if (purge_sys.enabled()) {
srv_purge_shutdown();
@@ -857,11 +850,6 @@ static void srv_shutdown_bg_undo_sources()
ut_ad(!srv_read_only_mode);
fts_optimize_shutdown();
dict_stats_shutdown();
- while (row_get_background_drop_list_len_low())
- {
- srv_inc_activity_count();
- os_thread_yield();
- }
srv_undo_sources= false;
}
}
@@ -983,7 +971,11 @@ same_size:
}
ut_ad(flushed_lsn == log_sys.get_lsn());
- ut_ad(!buf_pool.any_io_pending());
+ ut_ad(!os_aio_pending_reads());
+ ut_ad(!os_aio_pending_writes());
+ ut_d(mysql_mutex_lock(&buf_pool.flush_list_mutex));
+ ut_ad(!buf_pool.get_oldest_modification(0));
+ ut_d(mysql_mutex_unlock(&buf_pool.flush_list_mutex));
DBUG_RETURN(flushed_lsn);
}
@@ -1010,6 +1002,9 @@ static dberr_t find_and_check_log_file(bool &log_file_found)
if (is_operation_restore())
return DB_NOT_FOUND;
+ /* This might be first start after mariabackup
+ copy-back or move-back. */
+ srv_start_after_restore= true;
return DB_SUCCESS;
}
@@ -1040,7 +1035,9 @@ static dberr_t find_and_check_log_file(bool &log_file_found)
header, checkpoint page 1, empty, checkpoint page 2, redo log page(s).
Mariabackup --prepare would create an empty LOG_FILE_NAME. Tolerate it. */
- if (size != 0 && size <= OS_FILE_LOG_BLOCK_SIZE * 4)
+ if (size == 0)
+ srv_start_after_restore= true;
+ else if (size <= OS_FILE_LOG_BLOCK_SIZE * 4)
{
ib::error() << "Log file " << logfile0 << " size " << size
<< " is too small";
@@ -1052,6 +1049,11 @@ static dberr_t find_and_check_log_file(bool &log_file_found)
return DB_SUCCESS;
}
+static tpool::task_group rollback_all_recovered_group(1);
+static tpool::task rollback_all_recovered_task(trx_rollback_all_recovered,
+ nullptr,
+ &rollback_all_recovered_group);
+
/** Start InnoDB.
@param[in] create_new_db whether to create a new database
@return DB_SUCCESS or error code */
@@ -1076,7 +1078,7 @@ dberr_t srv_start(bool create_new_db)
}
high_level_read_only = srv_read_only_mode
- || srv_force_recovery > SRV_FORCE_NO_IBUF_MERGE
+ || srv_force_recovery >= SRV_FORCE_NO_UNDO_LOG_SCAN
|| srv_sys_space.created_new_raw();
srv_started_redo = false;
@@ -1091,8 +1093,6 @@ dberr_t srv_start(bool create_new_db)
ib::info() << "!!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!";
#endif
- ib::info() << MUTEX_TYPE;
-
ib::info() << "Compressed tables use zlib " ZLIB_VERSION
#ifdef UNIV_ZIP_DEBUG
" with validation"
@@ -1110,7 +1110,7 @@ dberr_t srv_start(bool create_new_db)
if (srv_start_has_been_called) {
ib::error() << "Startup called second time"
" during the process lifetime."
- " In the MySQL Embedded Server Library"
+ " In the MariaDB Embedded Server Library"
" you cannot call server_init() more than"
" once during the process lifetime.";
}
@@ -1124,37 +1124,24 @@ dberr_t srv_start(bool create_new_db)
mysql_stage_register("innodb", srv_stages,
static_cast<int>(UT_ARR_SIZE(srv_stages)));
- /* Set the maximum number of threads which can wait for a semaphore
- inside InnoDB: this is the 'sync wait array' size */
-
- srv_max_n_threads = 1 /* io_ibuf_thread */
- + 1 /* io_log_thread */
- + 1 /* srv_print_monitor_task */
- + 1 /* srv_purge_coordinator_thread */
- + 1 /* buf_dump_thread */
- + 1 /* dict_stats_thread */
- + 1 /* fts_optimize_thread */
- + 1 /* trx_rollback_all_recovered */
- + 128 /* added as margin, for use of
- InnoDB Memcached etc. */
- + 1/* buf_flush_page_cleaner */
- + max_connections
- + srv_n_read_io_threads
- + srv_n_write_io_threads
- + srv_n_purge_threads
- /* FTS Parallel Sort */
- + fts_sort_pll_degree * FTS_NUM_AUX_INDEX
- * max_connections;
+ srv_max_n_threads =
+ 1 /* dict_stats_thread */
+ + 1 /* fts_optimize_thread */
+ + 128 /* safety margin */
+ + max_connections;
srv_boot();
ib::info() << my_crc32c_implementation();
if (!srv_read_only_mode) {
+ mysql_mutex_init(srv_monitor_file_mutex_key,
+ &srv_monitor_file_mutex, nullptr);
+ mysql_mutex_init(srv_misc_tmpfile_mutex_key,
+ &srv_misc_tmpfile_mutex, nullptr);
+ }
- mutex_create(LATCH_ID_SRV_MONITOR_FILE,
- &srv_monitor_file_mutex);
-
+ if (!srv_read_only_mode) {
if (srv_innodb_status) {
srv_monitor_file_name = static_cast<char*>(
@@ -1190,9 +1177,6 @@ dberr_t srv_start(bool create_new_db)
}
}
- mutex_create(LATCH_ID_SRV_MISC_TMPFILE,
- &srv_misc_tmpfile_mutex);
-
srv_misc_tmpfile = os_file_create_tmpfile();
if (!srv_misc_tmpfile && err == DB_SUCCESS) {
@@ -1220,6 +1204,11 @@ dberr_t srv_start(bool create_new_db)
ib::info() << "Using Linux native AIO";
}
#endif
+#ifdef HAVE_URING
+ if (srv_use_native_aio) {
+ ib::info() << "Using liburing";
+ }
+#endif
fil_system.create(srv_file_per_table ? 50000 : 5000);
@@ -1406,17 +1395,18 @@ file_checked:
ut_ad(fil_system.sys_space->id == 0);
compile_time_assert(TRX_SYS_SPACE == 0);
compile_time_assert(IBUF_SPACE_ID == 0);
- fsp_header_init(fil_system.sys_space,
- uint32_t(sum_of_new_sizes), &mtr);
+ ut_a(fsp_header_init(fil_system.sys_space,
+ uint32_t(sum_of_new_sizes), &mtr)
+ == DB_SUCCESS);
ulint ibuf_root = btr_create(
DICT_CLUSTERED | DICT_IBUF, fil_system.sys_space,
- DICT_IBUF_ID_MIN, nullptr, &mtr);
+ DICT_IBUF_ID_MIN, nullptr, &mtr, &err);
mtr_commit(&mtr);
if (ibuf_root == FIL_NULL) {
- return(srv_init_abort(DB_ERROR));
+ return srv_init_abort(err);
}
ut_ad(ibuf_root == IBUF_TREE_ROOT_PAGE_NO);
@@ -1425,8 +1415,7 @@ file_checked:
the first rollback segment before the double write buffer.
All the remaining rollback segments will be created later,
after the double write buffer has been created. */
- trx_sys_create_sys_pages();
- err = trx_lists_init_at_db_start();
+ err = trx_sys_create_sys_pages(&mtr);
if (err != DB_SUCCESS) {
return(srv_init_abort(err));
@@ -1489,6 +1478,9 @@ file_checked:
if (err != DB_SUCCESS) {
return srv_init_abort(err);
}
+ if (srv_operation != SRV_OPERATION_RESTORE) {
+ dict_sys.load_sys_tables();
+ }
err = trx_lists_init_at_db_start();
if (err != DB_SUCCESS) {
return srv_init_abort(err);
@@ -1496,6 +1488,7 @@ file_checked:
break;
case SRV_OPERATION_RESTORE_DELTA:
case SRV_OPERATION_BACKUP:
+ case SRV_OPERATION_BACKUP_NO_DEFER:
ut_ad("wrong mariabackup mode" == 0);
}
@@ -1506,8 +1499,8 @@ file_checked:
recv_sys.apply(true);
- if (recv_sys.found_corrupt_log
- || recv_sys.found_corrupt_fs) {
+ if (recv_sys.is_corrupt_log()
+ || recv_sys.is_corrupt_fs()) {
return(srv_init_abort(DB_CORRUPTION));
}
@@ -1531,28 +1524,27 @@ file_checked:
if (sum_of_new_sizes > 0) {
/* New data file(s) were added */
mtr.start();
- mtr.x_lock_space(fil_system.sys_space,
- __FILE__, __LINE__);
+ mtr.x_lock_space(fil_system.sys_space);
buf_block_t* block = buf_page_get(
page_id_t(0, 0), 0,
RW_SX_LATCH, &mtr);
+ /* The first page of the system tablespace
+ should already have been successfully
+ accessed earlier during startup. */
+ ut_a(block);
ulint size = mach_read_from_4(
FSP_HEADER_OFFSET + FSP_SIZE
- + block->frame);
+ + block->page.frame);
ut_ad(size == fil_system.sys_space
->size_in_header);
size += sum_of_new_sizes;
mtr.write<4>(*block,
FSP_HEADER_OFFSET + FSP_SIZE
- + block->frame, size);
+ + block->page.frame, size);
fil_system.sys_space->size_in_header
= uint32_t(size);
mtr.commit();
- /* Immediately write the log record about
- increased tablespace size to disk, so that it
- is durable even if mysqld would crash
- quickly */
- log_buffer_flush_to_disk();
+ log_write_up_to(mtr.commit_lsn(), true);
}
}
@@ -1562,7 +1554,7 @@ file_checked:
buf_block_t* block = buf_page_get(page_id_t(0, 0), 0,
RW_S_LATCH, &mtr);
ut_ad(mach_read_from_4(FSP_SIZE + FSP_HEADER_OFFSET
- + block->frame)
+ + block->page.frame)
== fil_system.sys_space->size_in_header);
mtr.commit();
}
@@ -1617,7 +1609,11 @@ file_checked:
ut_ad(srv_force_recovery <= SRV_FORCE_IGNORE_CORRUPT);
ut_ad(recv_no_log_write);
err = fil_write_flushed_lsn(log_sys.get_lsn());
- DBUG_ASSERT(!buf_pool.any_io_pending());
+ ut_ad(!os_aio_pending_reads());
+ ut_ad(!os_aio_pending_writes());
+ ut_d(mysql_mutex_lock(&buf_pool.flush_list_mutex));
+ ut_ad(!buf_pool.get_oldest_modification(0));
+ ut_d(mysql_mutex_unlock(&buf_pool.flush_list_mutex));
log_sys.log.close_file();
if (err == DB_SUCCESS) {
bool trunc = srv_operation
@@ -1661,7 +1657,11 @@ file_checked:
threads until creating a log checkpoint at the
end of create_log_file(). */
ut_d(recv_no_log_write = true);
- DBUG_ASSERT(!buf_pool.any_io_pending());
+ ut_ad(!os_aio_pending_reads());
+ ut_ad(!os_aio_pending_writes());
+ ut_d(mysql_mutex_lock(&buf_pool.flush_list_mutex));
+ ut_ad(!buf_pool.get_oldest_modification(0));
+ ut_d(mysql_mutex_unlock(&buf_pool.flush_list_mutex));
DBUG_EXECUTE_IF("innodb_log_abort_3",
return(srv_init_abort(DB_ERROR)););
@@ -1721,8 +1721,7 @@ file_checked:
/* Note: When creating the extra rollback segments during an upgrade
we violate the latching order, even if the change buffer is empty.
- We make an exception in sync0sync.cc and check srv_is_being_started
- for that violation. It cannot create a deadlock because we are still
+ It cannot create a deadlock because we are still
running in single threaded mode essentially. Only the IO threads
should be running at this stage. */
@@ -1732,7 +1731,7 @@ file_checked:
if (!create_new_db) {
ut_ad(high_level_read_only
- || srv_force_recovery <= SRV_FORCE_NO_IBUF_MERGE);
+ || srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN);
/* Validate a few system page types that were left
uninitialized before MySQL or MariaDB 5.5. */
@@ -1746,6 +1745,11 @@ file_checked:
page_id_t(IBUF_SPACE_ID,
FSP_IBUF_HEADER_PAGE_NO),
0, RW_X_LATCH, &mtr);
+ if (UNIV_UNLIKELY(!block)) {
+ corrupted_old_page:
+ mtr.commit();
+ return srv_init_abort(DB_CORRUPTION);
+ }
fil_block_check_type(*block, FIL_PAGE_TYPE_SYS, &mtr);
/* Already MySQL 3.23.53 initialized
FSP_IBUF_TREE_ROOT_PAGE_NO to
@@ -1753,16 +1757,25 @@ file_checked:
block = buf_page_get(
page_id_t(TRX_SYS_SPACE, TRX_SYS_PAGE_NO),
0, RW_X_LATCH, &mtr);
+ if (UNIV_UNLIKELY(!block)) {
+ goto corrupted_old_page;
+ }
fil_block_check_type(*block, FIL_PAGE_TYPE_TRX_SYS,
&mtr);
block = buf_page_get(
page_id_t(TRX_SYS_SPACE,
FSP_FIRST_RSEG_PAGE_NO),
0, RW_X_LATCH, &mtr);
+ if (UNIV_UNLIKELY(!block)) {
+ goto corrupted_old_page;
+ }
fil_block_check_type(*block, FIL_PAGE_TYPE_SYS, &mtr);
block = buf_page_get(
page_id_t(TRX_SYS_SPACE, FSP_DICT_HDR_PAGE_NO),
0, RW_X_LATCH, &mtr);
+ if (UNIV_UNLIKELY(!block)) {
+ goto corrupted_old_page;
+ }
fil_block_check_type(*block, FIL_PAGE_TYPE_SYS, &mtr);
mtr.commit();
}
@@ -1773,7 +1786,7 @@ file_checked:
should guarantee that there is at most one data
dictionary transaction active at a time. */
if (!high_level_read_only
- && srv_force_recovery < SRV_FORCE_NO_TRX_UNDO) {
+ && srv_force_recovery <= SRV_FORCE_NO_TRX_UNDO) {
/* If the following call is ever removed, the
first-time ha_innobase::open() must hold (or
acquire and release) a table lock that
@@ -1787,17 +1800,7 @@ file_checked:
trx_rollback_recovered(false);
}
- /* FIXME: Skip the following if srv_read_only_mode,
- while avoiding "Allocated tablespace ID" warnings. */
- if (srv_force_recovery <= SRV_FORCE_NO_IBUF_MERGE) {
- /* Open or Create SYS_TABLESPACES and SYS_DATAFILES
- so that tablespace names and other metadata can be
- found. */
- err = dict_create_or_check_sys_tablespace();
- if (err != DB_SUCCESS) {
- return(srv_init_abort(err));
- }
-
+ if (srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN) {
/* The following call is necessary for the insert
buffer to work with multiple tablespaces. We must
know the mapping between space id's and .ibd file
@@ -1819,30 +1822,15 @@ file_checked:
&& !srv_read_only_mode) {
/* Drop partially created indexes. */
row_merge_drop_temp_indexes();
- /* Drop garbage tables. */
- row_mysql_drop_garbage_tables();
-
- /* Drop any auxiliary tables that were not
- dropped when the parent table was
- dropped. This can happen if the parent table
- was dropped but the server crashed before the
- auxiliary tables were dropped. */
- fts_drop_orphaned_tables();
-
/* Rollback incomplete non-DDL transactions */
trx_rollback_is_active = true;
- os_thread_create(trx_rollback_all_recovered);
+ srv_thread_pool->submit_task(&rollback_all_recovered_task);
}
}
srv_startup_is_before_trx_rollback_phase = false;
if (!srv_read_only_mode) {
- /* timer task which watches the timeouts
- for lock waits */
- lock_sys.timeout_timer.reset(srv_thread_pool->create_timer(
- lock_wait_timeout_task));
-
DBUG_EXECUTE_IF("innodb_skip_monitors", goto skip_monitors;);
/* Create the task which warns of long semaphore waits */
srv_start_periodic_timer(srv_monitor_timer, srv_monitor_task,
@@ -1864,14 +1852,7 @@ skip_monitors:
}
}
- /* Create the SYS_FOREIGN and SYS_FOREIGN_COLS system tables */
- err = dict_create_or_check_foreign_constraint_tables();
- if (err == DB_SUCCESS) {
- err = dict_create_or_check_sys_tablespace();
- if (err == DB_SUCCESS) {
- err = dict_create_or_check_sys_virtual();
- }
- }
+ err = dict_sys.create_or_check_sys_tables();
switch (err) {
case DB_SUCCESS:
break;
@@ -1895,21 +1876,11 @@ skip_monitors:
return(srv_init_abort(err));
}
- trx_temp_rseg_create();
-
if (srv_force_recovery < SRV_FORCE_NO_BACKGROUND) {
srv_start_periodic_timer(srv_master_timer, srv_master_callback, 1000);
}
}
- if (!srv_read_only_mode
- && srv_operation <= SRV_OPERATION_EXPORT_RESTORED
- && srv_force_recovery < SRV_FORCE_NO_BACKGROUND) {
- srv_init_purge_tasks();
- purge_sys.coordinator_startup();
- srv_wake_purge_thread_if_not_active();
- }
-
srv_is_being_started = false;
if (srv_print_verbose_log) {
@@ -1953,10 +1924,8 @@ skip_monitors:
/* Create thread(s) that handles key rotation. This is
needed already here as log_preflush_pool_modified_pages
will flush dirty pages and that might need e.g.
- fil_crypt_threads_event. */
- fil_system_enter();
+ fil_crypt_threads_cond. */
fil_crypt_threads_init();
- fil_system_exit();
/* Initialize online defragmentation. */
btr_defragment_init();
@@ -1988,7 +1957,7 @@ void innodb_preshutdown()
if (trx_sys.is_initialised())
while (trx_sys.any_active_transactions())
- os_thread_sleep(1000);
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
srv_shutdown_bg_undo_sources();
srv_purge_shutdown();
@@ -2006,6 +1975,7 @@ void innodb_shutdown()
switch (srv_operation) {
case SRV_OPERATION_BACKUP:
case SRV_OPERATION_RESTORE_DELTA:
+ case SRV_OPERATION_BACKUP_NO_DEFER:
break;
case SRV_OPERATION_RESTORE:
case SRV_OPERATION_RESTORE_EXPORT:
@@ -2046,13 +2016,13 @@ void innodb_shutdown()
ut_ad(dict_sys.is_initialised() || !srv_was_started);
ut_ad(trx_sys.is_initialised() || !srv_was_started);
- ut_ad(buf_dblwr.is_initialised() || !srv_was_started
+ ut_ad(buf_dblwr.is_created() || !srv_was_started
|| srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);
ut_ad(lock_sys.is_initialised() || !srv_was_started);
ut_ad(log_sys.is_initialised() || !srv_was_started);
ut_ad(ibuf.index || !innodb_change_buffering || !srv_was_started
- || srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE);
+ || srv_force_recovery >= SRV_FORCE_NO_DDL_UNDO);
dict_stats_deinit();
@@ -2082,13 +2052,12 @@ void innodb_shutdown()
trx_pool_close();
if (!srv_read_only_mode) {
- mutex_free(&srv_monitor_file_mutex);
- mutex_free(&srv_misc_tmpfile_mutex);
+ mysql_mutex_destroy(&srv_monitor_file_mutex);
+ mysql_mutex_destroy(&srv_misc_tmpfile_mutex);
}
dict_sys.close();
btr_search_sys_free();
- row_mysql_close();
srv_free();
fil_system.close();
pars_lexer_close();
@@ -2096,7 +2065,6 @@ void innodb_shutdown()
ut_ad(buf_pool.is_initialised() || !srv_was_started);
buf_pool.close();
- sync_check_close();
srv_sys_space.shutdown();
if (srv_tmp_space.get_sanity_check_status()) {
@@ -2133,17 +2101,14 @@ srv_get_meta_data_filename(
char* path;
/* Make sure the data_dir_path is set. */
- dict_get_and_save_data_dir_path(table, false);
-
- if (DICT_TF_HAS_DATA_DIR(table->flags)) {
- ut_a(table->data_dir_path);
+ dict_get_and_save_data_dir_path(table);
- path = fil_make_filepath(
- table->data_dir_path, table->name.m_name, CFG, true);
- } else {
- path = fil_make_filepath(NULL, table->name.m_name, CFG, false);
- }
+ const char* data_dir_path = DICT_TF_HAS_DATA_DIR(table->flags)
+ ? table->data_dir_path : nullptr;
+ ut_ad(!DICT_TF_HAS_DATA_DIR(table->flags) || data_dir_path);
+ path = fil_make_filepath(data_dir_path, table->name, CFG,
+ data_dir_path != nullptr);
ut_a(path);
len = strlen(path);
ut_a(max_len >= len);