summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-06-19 16:56:13 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-06-19 16:56:13 +0300
commit3a7201ea922f6d3373924c413fdb4b108f6208c5 (patch)
tree1dd4316340daba50d6d1f684c7137b47c7799541 /storage
parent578d8bfde53c42245f2a0641e7cc2af2ed8230cc (diff)
parentc73fa2d75fac7a057ae817bfaf142adb87ff2500 (diff)
downloadmariadb-git-3a7201ea922f6d3373924c413fdb4b108f6208c5.tar.gz
Merge 10.2 into bb-10.2-ext
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/btr/btr0bulk.cc7
-rw-r--r--storage/innobase/buf/buf0flu.cc11
-rw-r--r--storage/innobase/dict/dict0dict.cc9
-rw-r--r--storage/innobase/handler/ha_innodb.cc146
-rw-r--r--storage/innobase/handler/ha_innodb.h12
-rw-r--r--storage/innobase/handler/ha_innopart.cc31
-rw-r--r--storage/innobase/handler/handler0alter.cc1
-rw-r--r--storage/innobase/handler/i_s.cc3
-rw-r--r--storage/innobase/include/log0log.ic12
-rw-r--r--storage/innobase/include/sync0debug.h8
-rw-r--r--storage/innobase/include/sync0types.h163
-rw-r--r--storage/innobase/include/trx0i_s.h5
-rw-r--r--storage/innobase/include/trx0trx.h30
-rw-r--r--storage/innobase/log/log0log.cc38
-rw-r--r--storage/innobase/row/row0sel.cc64
-rw-r--r--storage/innobase/srv/srv0conc.cc35
-rw-r--r--storage/innobase/sync/sync0debug.cc39
-rw-r--r--storage/innobase/trx/trx0i_s.cc4
-rw-r--r--storage/innobase/trx/trx0trx.cc17
-rw-r--r--storage/myisam/ha_myisam.cc3
-rw-r--r--storage/xtradb/handler/ha_innodb.cc42
-rw-r--r--storage/xtradb/log/log0log.cc71
22 files changed, 133 insertions, 618 deletions
diff --git a/storage/innobase/btr/btr0bulk.cc b/storage/innobase/btr/btr0bulk.cc
index 9ff3bc5f6d1..8a954f9d3c3 100644
--- a/storage/innobase/btr/btr0bulk.cc
+++ b/storage/innobase/btr/btr0bulk.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2014, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -991,11 +992,7 @@ BtrBulk::finish(dberr_t err)
ut_ad(err == DB_SUCCESS);
}
-#ifdef UNIV_DEBUG
- dict_sync_check check(true);
-
- ut_ad(!sync_check_iterate(check));
-#endif /* UNIV_DEBUG */
+ ut_ad(!sync_check_iterate(dict_sync_check()));
ut_ad(err != DB_SUCCESS || btr_validate_index(m_index, NULL, false));
return(err);
diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc
index 05ab07229e3..791939f32dd 100644
--- a/storage/innobase/buf/buf0flu.cc
+++ b/storage/innobase/buf/buf0flu.cc
@@ -1870,15 +1870,8 @@ buf_flush_batch(
counts */
{
ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST);
-
-#ifdef UNIV_DEBUG
- {
- dict_sync_check check(true);
-
- ut_ad(flush_type != BUF_FLUSH_LIST
- || !sync_check_iterate(check));
- }
-#endif /* UNIV_DEBUG */
+ ut_ad(flush_type == BUF_FLUSH_LRU
+ || !sync_check_iterate(dict_sync_check()));
buf_pool_mutex_enter(buf_pool);
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index 63507e0a2c9..df36a320616 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -6114,14 +6114,7 @@ dict_set_corrupted(
ut_ad(mutex_own(&dict_sys->mutex));
ut_ad(!dict_table_is_comp(dict_sys->sys_tables));
ut_ad(!dict_table_is_comp(dict_sys->sys_indexes));
-
-#ifdef UNIV_DEBUG
- {
- dict_sync_check check(true);
-
- ut_ad(!sync_check_iterate(check));
- }
-#endif /* UNIV_DEBUG */
+ ut_ad(!sync_check_iterate(dict_sync_check()));
/* Mark the table as corrupted only if the clustered index
is corrupted */
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index b4e2983dbd3..b0a65fa2c13 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -1869,6 +1869,8 @@ void
innobase_srv_conc_exit_innodb(
row_prebuilt_t* prebuilt)
{
+ ut_ad(!sync_check_iterate(sync_check()));
+
#ifdef WITH_WSREP
if (wsrep_on(prebuilt->trx->mysql_thd) &&
wsrep_thd_is_BF(prebuilt->trx->mysql_thd, FALSE)) {
@@ -1877,13 +1879,6 @@ innobase_srv_conc_exit_innodb(
#endif /* WITH_WSREP */
trx_t* trx = prebuilt->trx;
-#ifdef BTR_CUR_HASH_ADAPT
-# ifdef UNIV_DEBUG
- btrsea_sync_check check(trx->has_search_latch);
-
- ut_ad(!sync_check_iterate(check));
-# endif /* UNIV_DEBUG */
-#endif /* BTR_CUR_HASH_ADAPT */
/* This is to avoid making an unnecessary function call. */
if (trx->declared_to_be_inside_innodb
@@ -1901,13 +1896,7 @@ innobase_srv_conc_force_exit_innodb(
/*================================*/
trx_t* trx) /*!< in: transaction handle */
{
-#ifdef BTR_CUR_HASH_ADAPT
-# ifdef UNIV_DEBUG
- btrsea_sync_check check(trx->has_search_latch);
-
- ut_ad(!sync_check_iterate(check));
-# endif /* UNIV_DEBUG */
-#endif /* BTR_CUR_HASH_ADAPT */
+ ut_ad(!sync_check_iterate(sync_check()));
/* This is to avoid making an unnecessary function call. */
if (trx->declared_to_be_inside_innodb) {
@@ -1994,13 +1983,7 @@ const char*
thd_innodb_tmpdir(
THD* thd)
{
-#ifdef BTR_CUR_HASH_ADAPT
-# ifdef UNIV_DEBUG
- trx_t* trx = thd_to_trx(thd);
- btrsea_sync_check check(trx->has_search_latch);
- ut_ad(!sync_check_iterate(check));
-# endif /* UNIV_DEBUG */
-#endif /* BTR_CUR_HASH_ADAPT */
+ ut_ad(!sync_check_iterate(sync_check()));
const char* tmp_dir = THDVAR(thd, tmpdir);
@@ -2036,28 +2019,6 @@ thd_to_trx_id(
#endif /* WITH_WSREP */
/********************************************************************//**
-Call this function when mysqld passes control to the client. That is to
-avoid deadlocks on the adaptive hash S-latch possibly held by thd. For more
-documentation, see handler.cc.
-@return 0 */
-inline
-int
-innobase_release_temporary_latches(
-/*===============================*/
- handlerton* hton, /*!< in: handlerton */
- THD* thd) /*!< in: MySQL thread */
-{
- DBUG_ASSERT(hton == innodb_hton_ptr);
-
- if (!srv_was_started) {
- } else if (trx_t* trx __attribute__((unused))= thd_to_trx(thd)) {
- trx_assert_no_search_latch(trx);
- }
-
- return(0);
-}
-
-/********************************************************************//**
Increments innobase_active_counter and every INNOBASE_WAKE_INTERVALth
time calls srv_active_wake_master_thread. This function should be used
when a single database operation may introduce a small need for
@@ -3384,7 +3345,6 @@ innobase_query_caching_of_table_permitted(
return(false);
}
- trx_assert_no_search_latch(trx);
innobase_srv_conc_force_exit_innodb(trx);
if (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)
@@ -3692,8 +3652,6 @@ ha_innobase::init_table_handle_for_HANDLER(void)
/* Initialize the m_prebuilt struct much like it would be inited in
external_lock */
- trx_assert_no_search_latch(m_prebuilt->trx);
-
innobase_srv_conc_force_exit_innodb(m_prebuilt->trx);
/* If the transaction is not started yet, start it */
@@ -3913,9 +3871,6 @@ innobase_init(
innobase_hton->flags =
HTON_SUPPORTS_EXTENDED_KEYS | HTON_SUPPORTS_FOREIGN_KEYS;
- innobase_hton->release_temporary_latches =
- innobase_release_temporary_latches;
-
#ifdef MYSQL_REPLACE_TRX_IN_THD
innobase_hton->replace_native_transaction_in_thd =
innodb_replace_trx_in_thd;
@@ -4808,12 +4763,6 @@ innobase_commit_ordered(
trx = check_trx_exists(thd);
TrxInInnoDB trx_in_innodb(trx);
- /* Since we will reserve the kernel mutex, we must not be holding the
- search system latch, or we will disobey the latching order. But we
- already released it in innobase_xa_prepare() (if not before), so just
- have an assert here.*/
- trx_assert_no_search_latch(trx);
-
if (!trx_is_registered_for_2pc(trx) && trx_is_started(trx)) {
/* We cannot throw error here; instead we will catch this error
again in innobase_commit() and report it from there. */
@@ -5025,12 +4974,6 @@ innobase_rollback_trx(
DBUG_ENTER("innobase_rollback_trx");
DBUG_PRINT("trans", ("aborting transaction"));
- /* Release a possible FIFO ticket and search latch. Since we will
- reserve the trx_sys->mutex, we have to release the search system
- latch first to obey the latching order. */
-
- trx_assert_no_search_latch(trx);
-
innobase_srv_conc_force_exit_innodb(trx);
/* If we had reserved the auto-inc lock for some table (if
@@ -6540,37 +6483,19 @@ initialize_auto_increment(dict_table_t* table, const Field* field)
dict_table_autoinc_unlock(table);
}
-/*****************************************************************//**
-Creates and opens a handle to a table which already exists in an InnoDB
-database.
-@return 1 if error, 0 if success */
-
+/** Open an InnoDB table
+@param[in] name table name
+@return error code
+@retval 0 on success */
int
-ha_innobase::open(
-/*==============*/
- const char* name, /*!< in: table name */
- int mode, /*!< in: not used */
- uint test_if_locked) /*!< in: not used */
+ha_innobase::open(const char* name, int, uint)
{
dict_table_t* ib_table;
char norm_name[FN_REFLEN];
- THD* thd;
dict_err_ignore_t ignore_err = DICT_ERR_IGNORE_NONE;
DBUG_ENTER("ha_innobase::open");
- UT_NOT_USED(mode);
- UT_NOT_USED(test_if_locked);
-
- thd = ha_thd();
-
- /* Under some cases MySQL seems to call this function while
- holding search latch(es). This breaks the latching order as
- we acquire dict_sys->mutex below and leads to a deadlock. */
- if (thd != NULL) {
- innobase_release_temporary_latches(ht, thd);
- }
-
normalize_table_name(norm_name, name);
m_user_thd = NULL;
@@ -6585,6 +6510,7 @@ ha_innobase::open(
m_upd_buf_size = 0;
char* is_part = is_partition(norm_name);
+ THD* thd = ha_thd();
/* Check whether FOREIGN_KEY_CHECKS is set to 0. If so, the table
can be opened even if some FK indexes are missing. If not, the table
@@ -7055,12 +6981,6 @@ ha_innobase::close()
{
DBUG_ENTER("ha_innobase::close");
- THD* thd = ha_thd();
-
- if (thd != NULL) {
- innobase_release_temporary_latches(ht, thd);
- }
-
row_prebuilt_free(m_prebuilt, FALSE);
if (m_upd_buf != NULL) {
@@ -13156,10 +13076,6 @@ create_table_info_t::initialize()
parent_trx = check_trx_exists(m_thd);
- /* In case MySQL calls this in the middle of a SELECT query, release
- possible adaptive hash latch to avoid deadlocks of threads */
-
- trx_assert_no_search_latch(parent_trx);
DBUG_RETURN(0);
}
@@ -14012,12 +13928,6 @@ innobase_drop_database(
THD* thd = current_thd;
- /* In case MySQL calls this in the middle of a SELECT
- query, release possible adaptive hash latch to avoid
- deadlocks of threads */
-
- trx_assert_no_search_latch(check_trx_exists(thd));
-
ulint len = 0;
char* ptr = strend(path) - 2;
@@ -14751,12 +14661,7 @@ ha_innobase::info_low(
update_thd(ha_thd());
- /* In case MySQL calls this in the middle of a SELECT query, release
- possible adaptive hash latch to avoid deadlocks of threads */
-
- m_prebuilt->trx->op_info = (char*)"returning various info to MariaDB";
-
- trx_assert_no_search_latch(m_prebuilt->trx);
+ m_prebuilt->trx->op_info = "returning various info to MariaDB";
ib_table = m_prebuilt->table;
DBUG_ASSERT(ib_table->n_ref_count > 0);
@@ -15603,12 +15508,7 @@ ha_innobase::update_table_comment(
update_thd(ha_thd());
- m_prebuilt->trx->op_info = (char*)"returning table comment";
-
- /* In case MySQL calls this in the middle of a SELECT query, release
- possible adaptive hash latch to avoid deadlocks of threads */
-
- trx_assert_no_search_latch(m_prebuilt->trx);
+ m_prebuilt->trx->op_info = "returning table comment";
#define SSTR( x ) reinterpret_cast< std::ostringstream & >( \
( std::ostringstream() << std::dec << x ) ).str()
@@ -15664,22 +15564,14 @@ ha_innobase::get_foreign_key_create_info(void)
update_thd(ha_thd());
- m_prebuilt->trx->op_info = (char*)"getting info on foreign keys";
-
- /* In case MySQL calls this in the middle of a SELECT query,
- release possible adaptive hash latch to avoid
- deadlocks of threads */
-
- trx_assert_no_search_latch(m_prebuilt->trx);
-
-
+ m_prebuilt->trx->op_info = "getting info on foreign keys";
/* Output the data to a temporary string */
std::string str = dict_print_info_on_foreign_keys(
TRUE, m_prebuilt->trx,
m_prebuilt->table);
- m_prebuilt->trx->op_info = (char*)"";
+ m_prebuilt->trx->op_info = "";
/* Allocate buffer for the string */
char* fk_str = (char*) my_malloc(str.length() + 1, MYF(0));
@@ -16682,8 +16574,6 @@ innodb_show_status(
trx_t* trx = check_trx_exists(thd);
- trx_assert_no_search_latch(trx);
-
innobase_srv_conc_force_exit_innodb(trx);
TrxInInnoDB trx_in_innodb(trx);
@@ -17999,12 +17889,6 @@ innobase_xa_prepare(
thd_get_xid(thd, (MYSQL_XID*) trx->xid);
- /* Release a possible FIFO ticket and search latch. Since we will
- reserve the trx_sys->mutex, we have to release the search system
- latch first to obey the latching order. */
-
- trx_assert_no_search_latch(trx);
-
innobase_srv_conc_force_exit_innodb(trx);
TrxInInnoDB trx_in_innodb(trx);
@@ -21333,7 +21217,7 @@ static MYSQL_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
static MYSQL_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Size of each log file in a log group.",
- NULL, NULL, 48*1024*1024L, 4*1024*1024L, LLONG_MAX, 1024*1024L);
+ NULL, NULL, 48 << 20, 1 << 20, 512ULL << 30, 1 << 20);
static MYSQL_SYSVAR_ULONG(log_files_in_group, srv_n_log_files,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h
index 717781fd65c..f9ad2007a5f 100644
--- a/storage/innobase/handler/ha_innodb.h
+++ b/storage/innobase/handler/ha_innodb.h
@@ -906,18 +906,6 @@ innodb_base_col_setup_for_stored(
/** whether this is a computed virtual column */
#define innobase_is_v_fld(field) ((field)->vcol_info && !(field)->stored_in_db())
-/** Release temporary latches.
-Call this function when mysqld passes control to the client. That is to
-avoid deadlocks on the adaptive hash S-latch possibly held by thd. For more
-documentation, see handler.cc.
-@param[in] hton Handlerton.
-@param[in] thd MySQL thread.
-@return 0 */
-int
-innobase_release_temporary_latches(
- handlerton* hton,
- THD* thd);
-
/** Always normalize table name to lower case on Windows */
#ifdef _WIN32
#define normalize_table_name(norm_name, name) \
diff --git a/storage/innobase/handler/ha_innopart.cc b/storage/innobase/handler/ha_innopart.cc
index 1041871805e..fb6f4b89a41 100644
--- a/storage/innobase/handler/ha_innopart.cc
+++ b/storage/innobase/handler/ha_innopart.cc
@@ -932,7 +932,6 @@ ha_innopart::open(
{
dict_table_t* ib_table;
char norm_name[FN_REFLEN];
- THD* thd;
DBUG_ENTER("ha_innopart::open");
@@ -942,16 +941,11 @@ ha_innopart::open(
ut_ad(table->part_info != NULL);
m_part_info = table->part_info;
}
- thd = ha_thd();
/* Under some cases MySQL seems to call this function while
holding search latch(es). This breaks the latching order as
we acquire dict_sys->mutex below and leads to a deadlock. */
- if (thd != NULL) {
- innobase_release_temporary_latches(ht, thd);
- }
-
normalize_table_name(norm_name, name);
m_user_thd = NULL;
@@ -1017,6 +1011,7 @@ share_error:
MONITOR_INC(MONITOR_TABLE_OPEN);
bool no_tablespace;
+ THD* thd = ha_thd();
/* TODO: Should we do this check for every partition during ::open()? */
/* TODO: refactor this in ha_innobase so it can increase code reuse. */
@@ -1372,15 +1367,8 @@ void ha_innopart::clear_ins_upd_nodes()
int
ha_innopart::close()
{
- THD* thd;
-
DBUG_ENTER("ha_innopart::close");
- thd = ha_thd();
- if (thd != NULL) {
- innobase_release_temporary_latches(ht, thd);
- }
-
ut_ad(m_pcur_parts == NULL);
ut_ad(m_clust_pcur_parts == NULL);
close_partitioning();
@@ -3032,11 +3020,6 @@ ha_innopart::records_in_range(
m_prebuilt->trx->op_info = (char*)"estimating records in index range";
- /* In case MySQL calls this in the middle of a SELECT query, release
- possible adaptive hash latch to avoid deadlocks of threads. */
-
- trx_assert_no_search_latch(m_prebuilt->trx);
-
active_index = keynr;
key = table->key_info + active_index;
@@ -3171,11 +3154,6 @@ ha_innopart::estimate_rows_upper_bound()
m_prebuilt->trx->op_info = "calculating upper bound for table rows";
- /* In case MySQL calls this in the middle of a SELECT query, release
- possible adaptive hash latch to avoid deadlocks of threads. */
-
- trx_assert_no_search_latch(m_prebuilt->trx);
-
for (uint i = m_part_info->get_first_used_partition();
i < m_tot_parts;
i = m_part_info->get_next_used_partition(i)) {
@@ -3287,12 +3265,7 @@ ha_innopart::info_low(
update_thd(ha_thd());
- /* In case MySQL calls this in the middle of a SELECT query, release
- possible adaptive hash latch to avoid deadlocks of threads. */
-
- m_prebuilt->trx->op_info = (char*)"returning various info to MySQL";
-
- trx_assert_no_search_latch(m_prebuilt->trx);
+ m_prebuilt->trx->op_info = "returning various info to MySQL";
ut_ad(m_part_share->get_table_part(0)->n_ref_count > 0);
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 416dd231e10..1eec22874d1 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -591,7 +591,6 @@ ha_innobase::check_if_supported_inplace_alter(
}
update_thd();
- trx_assert_no_search_latch(m_prebuilt->trx);
/* Change on engine specific table options require rebuild of the
table */
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 36ecc0b8a29..8f04f9d15ee 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -699,8 +699,7 @@ fill_innodb_trx_from_cache(
#ifdef BTR_CUR_HASH_ADAPT
/* trx_adaptive_hash_latched */
- OK(fields[IDX_TRX_ADAPTIVE_HASH_LATCHED]->store(
- row->trx_has_search_latch, true));
+ OK(fields[IDX_TRX_ADAPTIVE_HASH_LATCHED]->store(0, true));
#endif /* BTR_CUR_HASH_ADAPT */
/* trx_is_read_only*/
diff --git a/storage/innobase/include/log0log.ic b/storage/innobase/include/log0log.ic
index 82a94265776..1e09c263975 100644
--- a/storage/innobase/include/log0log.ic
+++ b/storage/innobase/include/log0log.ic
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -479,11 +480,11 @@ void
log_free_check(void)
/*================*/
{
-#ifdef UNIV_DEBUG
/* During row_log_table_apply(), this function will be called while we
are holding some latches. This is OK, as long as we are not holding
any latches on buffer blocks. */
+#ifdef UNIV_DEBUG
static const latch_level_t latches[] = {
SYNC_DICT, /* dict_sys->mutex during
commit_try_rebuild() */
@@ -491,13 +492,12 @@ log_free_check(void)
commit_try_rebuild() */
SYNC_INDEX_TREE /* index->lock */
};
-
- sync_allowed_latches check(
- latches, latches + sizeof(latches)/sizeof(*latches));
-
- ut_ad(!sync_check_iterate(check));
#endif /* UNIV_DEBUG */
+ ut_ad(!sync_check_iterate(
+ sync_allowed_latches(latches,
+ latches + UT_ARR_SIZE(latches))));
+
if (log_sys->check_flush_or_checkpoint) {
log_check_margins();
diff --git a/storage/innobase/include/sync0debug.h b/storage/innobase/include/sync0debug.h
index ba697b70e13..ecc742918f0 100644
--- a/storage/innobase/include/sync0debug.h
+++ b/storage/innobase/include/sync0debug.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -84,10 +84,10 @@ sync_check_find(latch_level_t level);
/** Checks that the level array for the current thread is empty.
Terminate iteration if the functor returns true.
-@param[in,out] functor called for each element.
-@return true if the functor returns true */
+@param[in] functor called for each element.
+@return true if the functor returns true for any element */
bool
-sync_check_iterate(sync_check_functor_t& functor);
+sync_check_iterate(const sync_check_functor_t& functor);
/** Acquires the debug mutex. We cannot use the mutex defined in sync0sync,
because the debug mutex is also acquired in sync0arr while holding the OS
diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h
index ec4503daa64..8a68f3d0cc6 100644
--- a/storage/innobase/include/sync0types.h
+++ b/storage/innobase/include/sync0types.h
@@ -1078,108 +1078,43 @@ struct latch_t {
/** Subclass this to iterate over a thread's acquired latch levels. */
struct sync_check_functor_t {
- virtual ~sync_check_functor_t() { }
- virtual bool operator()(const latch_level_t) = 0;
- virtual bool result() const = 0;
+ virtual bool operator()(const latch_level_t) const = 0;
};
-#ifdef BTR_CUR_HASH_ADAPT
-/** Functor to check whether the calling thread owns the btr search mutex. */
-struct btrsea_sync_check : public sync_check_functor_t {
-
- /** Constructor
- @param[in] has_search_latch true if owns the latch */
- explicit btrsea_sync_check(bool has_search_latch)
- :
- m_result(),
- m_has_search_latch(has_search_latch) { }
-
- /** Destructor */
- virtual ~btrsea_sync_check() { }
-
- /** Called for every latch owned by the calling thread.
- @param[in] level Level of the existing latch
- @return true if the predicate check is successful */
- virtual bool operator()(const latch_level_t level)
- {
- /* If calling thread doesn't hold search latch then
- check if there are latch level exception provided. */
-
- if (!m_has_search_latch
- && (level != SYNC_SEARCH_SYS
- && level != SYNC_FTS_CACHE)) {
-
- m_result = true;
-
- return(m_result);
- }
-
- return(false);
- }
-
- /** @return result from the check */
- virtual bool result() const
- {
- return(m_result);
- }
-
-private:
- /** True if all OK */
- bool m_result;
-
- /** If the caller owns the search latch */
- const bool m_has_search_latch;
-};
-#endif /* BTR_CUR_HASH_ADAPT */
-
-/** Functor to check for dictionay latching constraints. */
-struct dict_sync_check : public sync_check_functor_t {
-
- /** Constructor
- @param[in] dict_mutex_allow true if the dict mutex
- is allowed */
- explicit dict_sync_check(bool dict_mutex_allowed)
- :
- m_result(),
- m_dict_mutex_allowed(dict_mutex_allowed) { }
-
- /** Destructor */
- virtual ~dict_sync_check() { }
-
+/** Check that no latch is being held.
+@tparam some_allowed whether some latches are allowed to be held */
+template<bool some_allowed = false>
+struct sync_checker : public sync_check_functor_t
+{
/** Check the latching constraints
- @param[in] level The level held by the thread */
- virtual bool operator()(const latch_level_t level)
+ @param[in] level The level held by the thread
+ @return whether a latch violation was detected */
+ bool operator()(const latch_level_t level) const
{
- if (!m_dict_mutex_allowed
- || (level != SYNC_DICT
- && level != SYNC_DICT_OPERATION
- && level != SYNC_FTS_CACHE
- /* This only happens in recv_apply_hashed_log_recs. */
- && level != SYNC_RECV_WRITER
- && level != SYNC_NO_ORDER_CHECK)) {
-
- m_result = true;
-
- return(true);
+ if (some_allowed) {
+ switch (level) {
+ case SYNC_RECV_WRITER:
+ /* This only happens in
+ recv_apply_hashed_log_recs. */
+ case SYNC_DICT:
+ case SYNC_DICT_OPERATION:
+ case SYNC_FTS_CACHE:
+ case SYNC_NO_ORDER_CHECK:
+ return(false);
+ default:
+ return(true);
+ }
}
- return(false);
- }
-
- /** @return the result of the check */
- virtual bool result() const
- {
- return(m_result);
+ return(true);
}
-
-private:
- /** True if all OK */
- bool m_result;
-
- /** True if it is OK to hold the dict mutex */
- const bool m_dict_mutex_allowed;
};
+/** The strict latch checker (no InnoDB latches may be held) */
+typedef struct sync_checker<false> sync_check;
+/** The sloppy latch checker (can hold InnoDB dictionary or SQL latches) */
+typedef struct sync_checker<true> dict_sync_check;
+
/** Functor to check for given latching constraints. */
struct sync_allowed_latches : public sync_check_functor_t {
@@ -1189,9 +1124,7 @@ struct sync_allowed_latches : public sync_check_functor_t {
sync_allowed_latches(
const latch_level_t* from,
const latch_level_t* to)
- :
- m_result(),
- m_latches(from, to) { }
+ : begin(from), end(to) { }
/** Checks whether the given latch_t violates the latch constraint.
This object maintains a list of allowed latch levels, and if the given
@@ -1199,41 +1132,17 @@ struct sync_allowed_latches : public sync_check_functor_t {
then it is a violation.
@param[in] latch The latch level to check
- @return true if there is a latch ordering violation */
- virtual bool operator()(const latch_level_t level)
+ @return true if there is a latch violation */
+ bool operator()(const latch_level_t level) const
{
- for (latches_t::const_iterator it = m_latches.begin();
- it != m_latches.end();
- ++it) {
-
- if (level == *it) {
-
- m_result = false;
-
- /* No violation */
- return(false);
- }
- }
-
- return(true);
- }
-
- /** @return the result of the check */
- virtual bool result() const
- {
- return(m_result);
+ return(std::find(begin, end, level) == end);
}
private:
- /** Save the result of validation check here
- True if all OK */
- bool m_result;
-
- typedef std::vector<latch_level_t, ut_allocator<latch_level_t> >
- latches_t;
-
- /** List of latch levels that are allowed to be held */
- latches_t m_latches;
+ /** First element in an array of allowed latch levels */
+ const latch_level_t* const begin;
+ /** First element after the end of the array of allowed latch levels */
+ const latch_level_t* const end;
};
/** Get the latch id from a latch name.
diff --git a/storage/innobase/include/trx0i_s.h b/storage/innobase/include/trx0i_s.h
index 17a297527af..e02c5d88a29 100644
--- a/storage/innobase/include/trx0i_s.h
+++ b/storage/innobase/include/trx0i_s.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -162,10 +163,6 @@ struct i_s_trx_row_t {
/*!< check_foreigns in trx_t */
const char* trx_foreign_key_error;
/*!< detailed_error in trx_t */
-#ifdef BTR_CUR_HASH_ADAPT
- ibool trx_has_search_latch;
- /*!< has_search_latch in trx_t */
-#endif /* BTR_CUR_HASH_ADAPT */
ulint trx_is_read_only;
/*!< trx_t::read_only */
ulint trx_is_autocommit_non_locking;
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index 6274dec9f9d..b2d4952318c 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -58,15 +58,6 @@ class FlushObserver;
/** Dummy session used currently in MySQL interface */
extern sess_t* trx_dummy_sess;
-#ifdef BTR_CUR_HASH_ADAPT
-/** Assert that the transaction is not holding the adaptive hash index latch.
-@param[in] trx transaction */
-# define trx_assert_no_search_latch(trx) \
- ut_ad(!trx->has_search_latch)
-#else /* BTR_CUR_HASH_ADAPT */
-# define trx_assert_no_search_latch(trx)
-#endif
-
/** Set flush observer for the transaction
@param[in/out] trx transaction struct
@param[in] observer flush observer */
@@ -1072,11 +1063,6 @@ struct trx_t {
flush the log in
trx_commit_complete_for_mysql() */
ulint duplicates; /*!< TRX_DUP_IGNORE | TRX_DUP_REPLACE */
-#ifdef BTR_CUR_HASH_ADAPT
- bool has_search_latch;
- /*!< TRUE if this trx has latched the
- search system latch in S-mode */
-#endif /* BTR_CUR_HASH_ADAPT */
trx_dict_op_t dict_operation; /**< @see enum trx_dict_op_t */
/* Fields protected by the srv_conc_mutex. */
@@ -1508,17 +1494,11 @@ private:
}
/* Avoid excessive mutex acquire/release */
- if (++trx->in_depth > 1) {
+ if (trx->in_depth++) {
/* The transaction is already inside InnoDB. */
- ut_ad(trx->in_depth > 1);
return;
}
- /* Only the owning thread should release the latch. */
-
- ut_ad(trx->in_depth == 1);
- trx_assert_no_search_latch(trx);
-
trx_mutex_enter(trx);
wait(trx);
@@ -1543,16 +1523,10 @@ private:
ut_ad(trx->in_depth > 0);
- if (--trx->in_depth > 0) {
- ut_ad(trx->in_depth);
+ if (--trx->in_depth) {
return;
}
- /* Only the owning thread should release the latch. */
-
- ut_ad(trx->in_depth == 0);
- trx_assert_no_search_latch(trx);
-
trx_mutex_enter(trx);
ut_ad((trx->in_innodb & TRX_FORCE_ROLLBACK_MASK) > 0);
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
index d8e4ba6fe98..4f924e064a8 100644
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@ -677,14 +677,13 @@ log_set_capacity()
{
lsn_t margin;
ulint free;
- bool success = true;
- lsn_t smallest_capacity;
- log_mutex_enter();
-
- smallest_capacity = log_group_get_capacity(&log_sys->log);
+ lsn_t smallest_capacity = ((srv_log_file_size_requested
+ << srv_page_size_shift)
+ - LOG_FILE_HDR_SIZE)
+ * srv_n_log_files;
/* Add extra safety */
- smallest_capacity = smallest_capacity - smallest_capacity / 10;
+ smallest_capacity -= smallest_capacity / 10;
/* For each OS thread we must reserve so much free space in the
smallest log group that it can accommodate the log entries produced
@@ -694,15 +693,20 @@ log_set_capacity()
free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency)
+ LOG_CHECKPOINT_EXTRA_FREE;
if (free >= smallest_capacity / 2) {
- success = false;
-
- goto failure;
- } else {
- margin = smallest_capacity - free;
+ ib::error() << "Cannot continue operation. ib_logfiles are too"
+ " small for innodb_thread_concurrency="
+ << srv_thread_concurrency << ". The combined size of"
+ " ib_logfiles should be bigger than"
+ " 200 kB * innodb_thread_concurrency. "
+ << INNODB_PARAMETERS_MSG;
+ return(false);
}
+ margin = smallest_capacity - free;
margin = margin - margin / 10; /* Add still some extra safety */
+ log_mutex_enter();
+
log_sys->log_group_capacity = smallest_capacity;
log_sys->max_modified_age_async = margin
@@ -714,19 +718,9 @@ log_set_capacity()
/ LOG_POOL_CHECKPOINT_RATIO_ASYNC;
log_sys->max_checkpoint_age = margin;
-failure:
log_mutex_exit();
- if (!success) {
- ib::error() << "Cannot continue operation. ib_logfiles are too"
- " small for innodb_thread_concurrency="
- << srv_thread_concurrency << ". The combined size of"
- " ib_logfiles should be bigger than"
- " 200 kB * innodb_thread_concurrency. "
- << INNODB_PARAMETERS_MSG;
- }
-
- return(success);
+ return(true);
}
/** Initializes the redo logging subsystem. */
diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
index 3bae9bd25ac..fd0205ad153 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -2231,16 +2231,7 @@ stop_for_a_while:
btr_pcur_store_position(&(plan->pcur), &mtr);
mtr_commit(&mtr);
-
-#ifdef BTR_CUR_HASH_ADAPT
-# ifdef UNIV_DEBUG
- {
- btrsea_sync_check check(true);
-
- ut_ad(!sync_check_iterate(check));
- }
-# endif /* UNIV_DEBUG */
-#endif /* BTR_CUR_HASH_ADAPT */
+ ut_ad(!sync_check_iterate(sync_check()));
err = DB_SUCCESS;
goto func_exit;
@@ -2258,14 +2249,7 @@ commit_mtr_for_a_while:
mtr_commit(&mtr);
mtr_has_extra_clust_latch = FALSE;
-
-#ifdef UNIV_DEBUG
- {
- dict_sync_check check(true);
-
- ut_ad(!sync_check_iterate(check));
- }
-#endif /* UNIV_DEBUG */
+ ut_ad(!sync_check_iterate(dict_sync_check()));
goto table_loop;
@@ -2280,20 +2264,13 @@ lock_wait_or_error:
mtr_commit(&mtr);
-#ifdef UNIV_DEBUG
- {
- dict_sync_check check(true);
-
- ut_ad(!sync_check_iterate(check));
- }
-#endif /* UNIV_DEBUG */
-
func_exit:
#ifdef BTR_CUR_HASH_ADAPT
if (search_latch_locked) {
btr_search_s_unlock(index);
}
#endif /* BTR_CUR_HASH_ADAPT */
+ ut_ad(!sync_check_iterate(dict_sync_check()));
if (heap != NULL) {
mem_heap_free(heap);
@@ -3041,7 +3018,6 @@ row_sel_store_mysql_field_func(
mem_heap_t* heap;
/* Copy an externally stored field to a temporary heap */
- trx_assert_no_search_latch(prebuilt->trx);
ut_ad(field_no == templ->clust_rec_field_no);
ut_ad(templ->type != DATA_POINT);
@@ -3928,11 +3904,7 @@ row_sel_try_search_shortcut_for_mysql(
ut_ad(!prebuilt->templ_contains_blob);
btr_pcur_open_with_no_init(index, search_tuple, PAGE_CUR_GE,
- BTR_SEARCH_LEAF, pcur,
- (trx->has_search_latch)
- ? RW_S_LATCH
- : 0,
- mtr);
+ BTR_SEARCH_LEAF, pcur, RW_S_LATCH, mtr);
rec = btr_pcur_get_rec(pcur);
if (!page_rec_is_user_rec(rec)) {
@@ -4190,14 +4162,7 @@ row_search_mvcc(
DBUG_RETURN(DB_END_OF_INDEX);
}
-#ifdef BTR_CUR_HASH_ADAPT
-# ifdef UNIV_DEBUG
- {
- btrsea_sync_check check(trx->has_search_latch);
- ut_ad(!sync_check_iterate(check));
- }
-# endif /* UNIV_DEBUG */
-#endif /* BTR_CUR_HASH_ADAPT */
+ ut_ad(!sync_check_iterate(sync_check()));
if (dict_table_is_discarded(prebuilt->table)) {
@@ -4222,8 +4187,6 @@ row_search_mvcc(
&& (prebuilt->read_just_key
|| prebuilt->m_read_virtual_key);
- trx_assert_no_search_latch(trx);
-
/* Reset the new record lock info if srv_locks_unsafe_for_binlog
is set or session is using a READ COMMITED isolation level. Then
we are able to remove the record locks set here on an individual
@@ -4378,9 +4341,7 @@ row_search_mvcc(
and if we try that, we can deadlock on the adaptive
hash index semaphore! */
- trx_assert_no_search_latch(trx);
rw_lock_s_lock(btr_get_search_latch(index));
- trx->has_search_latch = true;
switch (row_sel_try_search_shortcut_for_mysql(
&rec, prebuilt, &offsets, &heap,
@@ -4435,7 +4396,6 @@ row_search_mvcc(
err = DB_SUCCESS;
rw_lock_s_unlock(btr_get_search_latch(index));
- trx->has_search_latch = false;
goto func_exit;
@@ -4446,7 +4406,6 @@ row_search_mvcc(
err = DB_RECORD_NOT_FOUND;
rw_lock_s_unlock(btr_get_search_latch(index));
- trx->has_search_latch = false;
/* NOTE that we do NOT store the cursor
position */
@@ -4464,7 +4423,6 @@ row_search_mvcc(
mtr_start(&mtr);
rw_lock_s_unlock(btr_get_search_latch(index));
- trx->has_search_latch = false;
}
}
#endif /* BTR_CUR_HASH_ADAPT */
@@ -4472,8 +4430,6 @@ row_search_mvcc(
/*-------------------------------------------------------------*/
/* PHASE 3: Open or restore index cursor position */
- trx_assert_no_search_latch(trx);
-
spatial_search = dict_index_is_spatial(index)
&& mode >= PAGE_CUR_CONTAIN;
@@ -5787,15 +5743,7 @@ func_exit:
}
}
-#ifdef BTR_CUR_HASH_ADAPT
-# ifdef UNIV_DEBUG
- {
- btrsea_sync_check check(trx->has_search_latch);
-
- ut_ad(!sync_check_iterate(check));
- }
-# endif /* UNIV_DEBUG */
-#endif /* BTR_CUR_HASH_ADAPT */
+ ut_ad(!sync_check_iterate(sync_check()));
DEBUG_SYNC_C("innodb_row_search_for_mysql_exit");
diff --git a/storage/innobase/srv/srv0conc.cc b/storage/innobase/srv/srv0conc.cc
index bf8a326a633..9f589b57d9c 100644
--- a/storage/innobase/srv/srv0conc.cc
+++ b/storage/innobase/srv/srv0conc.cc
@@ -197,11 +197,6 @@ srv_conc_enter_innodb_with_atomics(
(void) my_atomic_addlint(
&srv_conc.n_waiting, 1);
- /* Release possible search system latch this
- thread has */
-
- trx_assert_no_search_latch(trx);
-
thd_wait_begin(trx->mysql_thd, THD_WAIT_USER_LOCK);
notified_mysql = TRUE;
@@ -257,15 +252,7 @@ srv_conc_enter_innodb(
{
trx_t* trx = prebuilt->trx;
-#ifdef BTR_CUR_HASH_ADAPT
-# ifdef UNIV_DEBUG
- {
- btrsea_sync_check check(trx->has_search_latch);
-
- ut_ad(!sync_check_iterate(check));
- }
-# endif /* UNIV_DEBUG */
-#endif /* BTR_CUR_HASH_ADAPT */
+ ut_ad(!sync_check_iterate(sync_check()));
srv_conc_enter_innodb_with_atomics(trx);
}
@@ -279,15 +266,7 @@ srv_conc_force_enter_innodb(
trx_t* trx) /*!< in: transaction object associated with the
thread */
{
-#ifdef BTR_CUR_HASH_ADAPT
-# ifdef UNIV_DEBUG
- {
- btrsea_sync_check check(trx->has_search_latch);
-
- ut_ad(!sync_check_iterate(check));
- }
-# endif /* UNIV_DEBUG */
-#endif /* BTR_CUR_HASH_ADAPT */
+ ut_ad(!sync_check_iterate(sync_check()));
if (!srv_thread_concurrency) {
@@ -320,15 +299,7 @@ srv_conc_force_exit_innodb(
srv_conc_exit_innodb_with_atomics(trx);
-#ifdef BTR_CUR_HASH_ADAPT
-# ifdef UNIV_DEBUG
- {
- btrsea_sync_check check(trx->has_search_latch);
-
- ut_ad(!sync_check_iterate(check));
- }
-# endif /* UNIV_DEBUG */
-#endif /* BTR_CUR_HASH_ADAPT */
+ ut_ad(!sync_check_iterate(sync_check()));
}
/*********************************************************************//**
diff --git a/storage/innobase/sync/sync0debug.cc b/storage/innobase/sync/sync0debug.cc
index 11743e14be2..e43e87eb14e 100644
--- a/storage/innobase/sync/sync0debug.cc
+++ b/storage/innobase/sync/sync0debug.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2014, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -298,29 +298,23 @@ struct LatchDebug {
}
/** Iterate over a thread's latches.
- @param[in,out] functor The callback
+ @param[in] functor The callback
@return true if the functor returns true. */
- bool for_each(sync_check_functor_t& functor)
+ bool for_each(const sync_check_functor_t& functor)
UNIV_NOTHROW
{
- const Latches* latches = thread_latches();
-
- if (latches == 0) {
- return(functor.result());
- }
-
- Latches::const_iterator end = latches->end();
-
- for (Latches::const_iterator it = latches->begin();
- it != end;
- ++it) {
-
- if (functor(it->m_level)) {
- break;
+ if (const Latches* latches = thread_latches()) {
+ Latches::const_iterator end = latches->end();
+ for (Latches::const_iterator it = latches->begin();
+ it != end; ++it) {
+
+ if (functor(it->m_level)) {
+ return(true);
+ }
}
}
- return(functor.result());
+ return(false);
}
/** Removes a latch from the thread level array if it is found there.
@@ -1215,13 +1209,12 @@ sync_check_find(latch_level_t level)
/** Iterate over the thread's latches.
@param[in,out] functor called for each element.
-@return false if the sync debug hasn't been initialised
-@return the value returned by the functor */
+@return true if the functor returns true for any element */
bool
-sync_check_iterate(sync_check_functor_t& functor)
+sync_check_iterate(const sync_check_functor_t& functor)
{
- if (LatchDebug::instance() != NULL) {
- return(LatchDebug::instance()->for_each(functor));
+ if (LatchDebug* debug = LatchDebug::instance()) {
+ return(debug->for_each(functor));
}
return(false);
diff --git a/storage/innobase/trx/trx0i_s.cc b/storage/innobase/trx/trx0i_s.cc
index fcc50b8c76d..7854ad2ab5a 100644
--- a/storage/innobase/trx/trx0i_s.cc
+++ b/storage/innobase/trx/trx0i_s.cc
@@ -589,10 +589,6 @@ thd_done:
row->trx_foreign_key_error = NULL;
}
-#ifdef BTR_CUR_HASH_ADAPT
- row->trx_has_search_latch = (ibool) trx->has_search_latch;
-#endif /* BTR_CUR_HASH_ADAPT */
-
row->trx_is_read_only = trx->read_only;
row->trx_is_autocommit_non_locking = trx_is_autocommit_non_locking(trx);
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 315697403c4..7fdbd808a60 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -272,8 +272,6 @@ struct TrxFactory {
ut_a(trx->lock.wait_lock == NULL);
ut_a(trx->lock.wait_thr == NULL);
-
- trx_assert_no_search_latch(trx);
ut_a(trx->dict_operation_lock_mode == 0);
if (trx->lock.lock_heap != NULL) {
@@ -341,9 +339,6 @@ struct TrxFactory {
ut_a(trx->lock.wait_thr == NULL);
ut_a(trx->lock.wait_lock == NULL);
-
- trx_assert_no_search_latch(trx);
-
ut_a(trx->dict_operation_lock_mode == 0);
ut_a(UT_LIST_GET_LEN(trx->lock.trx_locks) == 0);
@@ -2413,13 +2408,6 @@ state_ok:
(ulong) n_rec_locks);
}
-#ifdef BTR_CUR_HASH_ADAPT
- if (trx->has_search_latch) {
- newline = TRUE;
- fputs(", holds adaptive hash latch", f);
- }
-#endif /* BTR_CUR_HASH_ADAPT */
-
if (trx->undo_no != 0) {
newline = TRUE;
fprintf(f, ", undo log entries " TRX_ID_FMT, trx->undo_no);
@@ -2551,11 +2539,6 @@ state_ok:
fprintf(f, "que state %lu ", (ulong) trx->lock.que_state);
}
- if (trx->has_search_latch) {
- newline = TRUE;
- fputs(", holds adaptive hash latch", f);
- }
-
if (trx->undo_no != 0) {
newline = TRUE;
fprintf(f, ", undo log entries " TRX_ID_FMT, trx->undo_no);
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 86f3bbb9bc5..871ee77b92b 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -1183,9 +1183,6 @@ int ha_myisam::repair(THD *thd, HA_CHECK &param, bool do_optimize)
share->state.dupp_key= MI_MAX_KEY;
strmov(fixed_name,file->filename);
- // Release latches since this can take a long time
- ha_release_temporary_latches(thd);
-
/*
Don't lock tables if we have used LOCK TABLE or if we come from
enable_index()
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index ba426dd3d3b..6097f87b43d 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -2123,39 +2123,6 @@ ha_innobase::is_fake_change_enabled(THD* thd)
}
/********************************************************************//**
-In XtraDB it is impossible for a transaction to own a search latch outside of
-InnoDB code, so there is nothing to release on demand. We keep this function to
-simplify maintenance.
-@return 0 */
-static
-int
-innobase_release_temporary_latches(
-/*===============================*/
- handlerton* hton MY_ATTRIBUTE((unused)), /*!< in: handlerton */
- THD* thd MY_ATTRIBUTE((unused))) /*!< in: MySQL thread */
-{
-#ifdef UNIV_DEBUG
- DBUG_ASSERT(hton == innodb_hton_ptr);
-
- if (!innodb_inited || thd == NULL) {
-
- return(0);
- }
-
- trx_t* trx = thd_to_trx(thd);
-
- if (trx != NULL) {
-#ifdef UNIV_SYNC_DEBUG
- ut_ad(!btr_search_own_any());
-#endif
- trx_search_latch_release_if_reserved(trx);
- }
-#endif
-
- return(0);
-}
-
-/********************************************************************//**
Increments innobase_active_counter and every INNOBASE_WAKE_INTERVALth
time calls srv_active_wake_master_thread. This function should be used
when a single database operation may introduce a small need for
@@ -3813,9 +3780,6 @@ innobase_init(
innobase_hton->flags = HTON_SUPPORTS_EXTENDED_KEYS |
HTON_SUPPORTS_FOREIGN_KEYS;
- innobase_hton->release_temporary_latches =
- innobase_release_temporary_latches;
-
innobase_hton->kill_query = innobase_kill_connection;
if (srv_file_per_table)
@@ -6262,9 +6226,6 @@ ha_innobase::open(
thd = ha_thd();
- /* No-op in XtraDB */
- innobase_release_temporary_latches(ht, thd);
-
normalize_table_name(norm_name, name);
user_thd = NULL;
@@ -6724,9 +6685,6 @@ ha_innobase::close()
thd = ha_thd();
- /* No-op in XtraDB */
- innobase_release_temporary_latches(ht, thd);
-
row_prebuilt_free(prebuilt, FALSE);
if (upd_buf != NULL) {
diff --git a/storage/xtradb/log/log0log.cc b/storage/xtradb/log/log0log.cc
index 3252cd793c9..833f3240369 100644
--- a/storage/xtradb/log/log0log.cc
+++ b/storage/xtradb/log/log0log.cc
@@ -860,43 +860,16 @@ ibool
log_calc_max_ages(void)
/*===================*/
{
- log_group_t* group;
lsn_t margin;
ulint free;
- ibool success = TRUE;
- lsn_t smallest_capacity;
- lsn_t archive_margin;
- lsn_t smallest_archive_margin;
-
- mutex_enter(&(log_sys->mutex));
-
- group = UT_LIST_GET_FIRST(log_sys->log_groups);
-
- ut_ad(group);
-
- smallest_capacity = LSN_MAX;
- smallest_archive_margin = LSN_MAX;
-
- while (group) {
- if (log_group_get_capacity(group) < smallest_capacity) {
- smallest_capacity = log_group_get_capacity(group);
- }
-
- archive_margin = log_group_get_capacity(group)
- - (group->file_size - LOG_FILE_HDR_SIZE)
- - LOG_ARCHIVE_EXTRA_MARGIN;
-
- if (archive_margin < smallest_archive_margin) {
-
- smallest_archive_margin = archive_margin;
- }
-
- group = UT_LIST_GET_NEXT(log_groups, group);
- }
+ lsn_t smallest_capacity = ((srv_log_file_size_requested
+ << srv_page_size_shift)
+ - LOG_FILE_HDR_SIZE)
+ * srv_n_log_files;
/* Add extra safety */
- smallest_capacity = smallest_capacity - smallest_capacity / 10;
+ smallest_capacity -= smallest_capacity / 10;
/* For each OS thread we must reserve so much free space in the
smallest log group that it can accommodate the log entries produced
@@ -906,15 +879,16 @@ log_calc_max_ages(void)
free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency)
+ LOG_CHECKPOINT_EXTRA_FREE;
if (free >= smallest_capacity / 2) {
- success = FALSE;
-
- goto failure;
- } else {
- margin = smallest_capacity - free;
+ ib_logf(IB_LOG_LEVEL_FATAL,
+ "The combined size of ib_logfiles"
+ " should be bigger than\n"
+ "InnoDB: 200 kB * innodb_thread_concurrency.");
}
-
+ margin = smallest_capacity - free;
margin = margin - margin / 10; /* Add still some extra safety */
+ mutex_enter(&log_sys->mutex);
+
log_sys->log_group_capacity = smallest_capacity;
log_sys->max_modified_age_async = margin
@@ -927,22 +901,17 @@ log_calc_max_ages(void)
log_sys->max_checkpoint_age = margin;
#ifdef UNIV_LOG_ARCHIVE
- log_sys->max_archived_lsn_age = smallest_archive_margin;
+ lsn_t archive_margin = smallest_capacity
+ - (srv_log_file_size_requested - LOG_FILE_HDR_SIZE)
+ - LOG_ARCHIVE_EXTRA_MARGIN;
+ log_sys->max_archived_lsn_age = archive_margin;
- log_sys->max_archived_lsn_age_async = smallest_archive_margin
- - smallest_archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
+ log_sys->max_archived_lsn_age_async = archive_margin
+ - archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
#endif /* UNIV_LOG_ARCHIVE */
-failure:
- mutex_exit(&(log_sys->mutex));
-
- if (!success) {
- ib_logf(IB_LOG_LEVEL_FATAL,
- "The combined size of ib_logfiles"
- " should be bigger than\n"
- "InnoDB: 200 kB * innodb_thread_concurrency.");
- }
+ mutex_exit(&log_sys->mutex);
- return(success);
+ return(true);
}
/******************************************************//**