diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-04-04 21:22:43 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-04-06 21:25:43 +0300 |
commit | 71f9552fd83ad155d541b2c2aa7c835f93cc47d3 (patch) | |
tree | da451c14a3ec3f5d31f680c1a7020946fd240781 | |
parent | c56ae2dfbd65ea63fc2b06323c8bcacaf49240af (diff) | |
download | mariadb-git-71f9552fd83ad155d541b2c2aa7c835f93cc47d3.tar.gz |
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.
-rw-r--r-- | storage/innobase/buf/buf0rea.cc | 6 | ||||
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 12 | ||||
-rw-r--r-- | storage/innobase/include/fil0fil.h | 15 | ||||
-rw-r--r-- | storage/innobase/include/log0recv.h | 4 | ||||
-rw-r--r-- | storage/innobase/log/log0log.cc | 9 | ||||
-rw-r--r-- | storage/innobase/log/log0recv.cc | 4 |
6 files changed, 19 insertions, 31 deletions
diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index 372b1c5e0a0..22891af5d67 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -1,7 +1,7 @@ /***************************************************************************** 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--; diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 623aa38be38..be594ec83c1 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -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 @@ func_exit: 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 @@ func_exit: node->name = new_file_name; } - if (!recv_recovery_on) { + if (!recv_recovery_is_on()) { log_mutex_exit(); } diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 7cb9f4098a4..72a66b497a2 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1,7 +1,7 @@ /***************************************************************************** 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); } } diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index 267f8f6778d..959ed15e9d7 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -1,7 +1,7 @@ /***************************************************************************** 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 diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 13b98cda34a..516d92164c4 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -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 diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 4651fa20521..15bc6e1727c 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -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); |