Commit 71f9552f authored by Marko Mäkelä's avatar Marko Mäkelä

recv_recovery_is_on(): Add UNIV_UNLIKELY

Normally, InnoDB is not in the process of executing crash recovery.
Provide a hint to the compiler that the recovery-related code paths
are rarely executed.
parent c56ae2df
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2018, MariaDB Corporation.
Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -186,13 +186,13 @@ buf_read_page_low(
thd_wait_end(NULL);
}
if (*err != DB_SUCCESS) {
if (UNIV_UNLIKELY(*err != DB_SUCCESS)) {
if (*err == DB_TABLESPACE_TRUNCATED) {
/* Remove the page which is outside the
truncated tablespace bounds when recovering
from a crash happened during a truncation */
buf_read_page_handle_error(bpage);
if (recv_recovery_on) {
if (recv_recovery_is_on()) {
mutex_enter(&recv_sys->mutex);
ut_ad(recv_sys->n_addrs > 0);
recv_sys->n_addrs--;
......
......@@ -1310,9 +1310,7 @@ fil_space_free(
rw_lock_x_unlock(&space->latch);
}
bool need_mutex = !recv_recovery_on;
if (need_mutex) {
if (!recv_recovery_is_on()) {
log_mutex_enter();
}
......@@ -1323,7 +1321,7 @@ fil_space_free(
UT_LIST_REMOVE(fil_system->named_spaces, space);
}
if (need_mutex) {
if (!recv_recovery_is_on()) {
log_mutex_exit();
}
......@@ -1394,7 +1392,7 @@ fil_space_create(
UT_LIST_INIT(space->chain, &fil_node_t::chain);
if ((purpose == FIL_TYPE_TABLESPACE || purpose == FIL_TYPE_IMPORT)
&& !recv_recovery_on
&& !recv_recovery_is_on()
&& id > fil_system->max_assigned_id) {
if (!fil_system->space_id_reuse_warned) {
......@@ -3493,7 +3491,7 @@ fil_rename_tablespace(
ut_ad(strchr(old_file_name, OS_PATH_SEPARATOR) != NULL);
ut_ad(strchr(new_file_name, OS_PATH_SEPARATOR) != NULL);
if (!recv_recovery_on) {
if (!recv_recovery_is_on()) {
fil_name_write_rename(id, old_file_name, new_file_name);
log_mutex_enter();
}
......@@ -3518,7 +3516,7 @@ fil_rename_tablespace(
node->name = new_file_name;
}
if (!recv_recovery_on) {
if (!recv_recovery_is_on()) {
log_mutex_exit();
}
......
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2018, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -1444,16 +1444,12 @@ fil_names_write_if_was_clean(
return(was_clean);
}
extern volatile bool recv_recovery_on;
/** During crash recovery, open a tablespace if it had not been opened
yet, to get valid size and flags.
@param[in,out] space tablespace */
inline
void
fil_space_open_if_needed(
fil_space_t* space)
inline void fil_space_open_if_needed(fil_space_t* space)
{
ut_d(extern volatile bool recv_recovery_on);
ut_ad(recv_recovery_on);
if (space->size == 0) {
......@@ -1461,10 +1457,7 @@ fil_space_open_if_needed(
until the files are opened for the first time.
fil_space_get_size() will open the file
and adjust the size and flags. */
#ifdef UNIV_DEBUG
ulint size =
#endif /* UNIV_DEBUG */
fil_space_get_size(space->id);
ut_d(ulint size =) fil_space_get_size(space->id);
ut_ad(size == space->size);
}
}
......
/*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -40,7 +40,7 @@ Created 9/20/1997 Heikki Tuuri
extern bool recv_writer_thread_active;
/** @return whether recovery is currently running. */
#define recv_recovery_is_on() recv_recovery_on
#define recv_recovery_is_on() UNIV_UNLIKELY(recv_recovery_on)
/** Find the latest checkpoint in the log header.
@param[out] max_field LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2
......
......@@ -2,7 +2,7 @@
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Google Inc.
Copyright (c) 2014, 2018, MariaDB Corporation.
Copyright (c) 2014, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
......@@ -1378,14 +1378,11 @@ synchronization objects!
this lsn
@return false if there was a flush batch of the same type running,
which means that we could not start this flush batch */
static
bool
log_preflush_pool_modified_pages(
lsn_t new_oldest)
static bool log_preflush_pool_modified_pages(lsn_t new_oldest)
{
bool success;
if (recv_recovery_on) {
if (recv_recovery_is_on()) {
/* If the recovery is running, we must first apply all
log records to their respective file pages to get the
right modify lsn values to these pages: otherwise, there
......
......@@ -673,7 +673,7 @@ DECLARE_THREAD(recv_writer_thread)(
mutex_enter(&recv_sys->writer_mutex);
if (!recv_recovery_on) {
if (!recv_recovery_is_on()) {
mutex_exit(&recv_sys->writer_mutex);
break;
}
......@@ -766,7 +766,7 @@ recv_sys_debug_free(void)
/* wake page cleaner up to progress */
if (!srv_read_only_mode) {
ut_ad(!recv_recovery_on);
ut_ad(!recv_recovery_is_on());
ut_ad(!recv_writer_thread_active);
os_event_reset(buf_flush_event);
os_event_set(recv_sys->flush_start);
......
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