diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2019-01-07 00:06:24 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2019-01-07 19:45:50 +0400 |
commit | c66db377d75b40c42f336223ac865e4820698e55 (patch) | |
tree | 3b77041683f7512629967d77c4235d0ee220ef86 | |
parent | aa2db754196c03e26b70b40987c75bedb75b5e32 (diff) | |
download | mariadb-git-c66db377d75b40c42f336223ac865e4820698e55.tar.gz |
MDEV-17441 - InnoDB transition to C++11 atomics
Replaced srv_fatal_semaphore_wait_threshold juggling with
btr_validate_index_running counter.
Removed last argument of btr_validate_index(): always false.
Simplified away btr_validate_spatial_index().
-rw-r--r-- | storage/innobase/btr/btr0btr.cc | 70 | ||||
-rw-r--r-- | storage/innobase/btr/btr0bulk.cc | 2 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 13 | ||||
-rw-r--r-- | storage/innobase/include/btr0btr.h | 4 | ||||
-rw-r--r-- | storage/innobase/include/srv0srv.h | 1 | ||||
-rw-r--r-- | storage/innobase/row/row0upd.cc | 2 | ||||
-rw-r--r-- | storage/innobase/sync/sync0arr.cc | 2 |
7 files changed, 22 insertions, 72 deletions
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 9e71dbe2889..1b3ea2eb487 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -44,6 +44,8 @@ Created 6/2/1994 Heikki Tuuri #include "dict0boot.h" #include "row0sel.h" /* row_search_max_autoinc() */ +Atomic_counter<uint32_t> btr_validate_index_running; + /**************************************************************//** Checks if the page in the cursor can be merged with given page. If necessary, re-organize the merge_page. @@ -4641,7 +4643,7 @@ btr_print_index( mtr_commit(&mtr); - ut_ad(btr_validate_index(index, 0, false)); + ut_ad(btr_validate_index(index, 0)); } #endif /* UNIV_BTR_PRINT */ @@ -5462,57 +5464,16 @@ node_ptr_fails: } /**************************************************************//** -Do an index level validation of spaital index tree. -@return true if no error found */ -static -bool -btr_validate_spatial_index( -/*=======================*/ - dict_index_t* index, /*!< in: index */ - const trx_t* trx) /*!< in: transaction or NULL */ -{ - - mtr_t mtr; - bool ok = true; - - mtr_start(&mtr); - - mtr_x_lock(dict_index_get_lock(index), &mtr); - - page_t* root = btr_root_get(index, &mtr); - ulint n = btr_page_get_level(root); - -#ifdef UNIV_RTR_DEBUG - fprintf(stderr, "R-tree level is %lu\n", n); -#endif /* UNIV_RTR_DEBUG */ - - for (ulint i = 0; i <= n; ++i) { -#ifdef UNIV_RTR_DEBUG - fprintf(stderr, "Level %lu:\n", n - i); -#endif /* UNIV_RTR_DEBUG */ - - if (!btr_validate_level(index, trx, n - i, true)) { - ok = false; - break; - } - } - - mtr_commit(&mtr); - - return(ok); -} - -/**************************************************************//** Checks the consistency of an index tree. @return DB_SUCCESS if ok, error code if not */ dberr_t btr_validate_index( /*===============*/ dict_index_t* index, /*!< in: index */ - const trx_t* trx, /*!< in: transaction or NULL */ - bool lockout)/*!< in: true if X-latch index is intended */ + const trx_t* trx) /*!< in: transaction or NULL */ { dberr_t err = DB_SUCCESS; + bool lockout = dict_index_is_spatial(index); /* Full Text index are implemented by auxiliary tables, not the B-tree */ @@ -5520,13 +5481,6 @@ btr_validate_index( return(err); } - if (dict_index_is_spatial(index)) { - if(!btr_validate_spatial_index(index, trx)) { - err = DB_ERROR; - } - return(err); - } - mtr_t mtr; mtr_start(&mtr); @@ -5541,14 +5495,14 @@ btr_validate_index( page_t* root = btr_root_get(index, &mtr); - if (root == NULL && !index->is_readable()) { - err = DB_DECRYPTION_FAILED; + if (!root) { mtr_commit(&mtr); - return err; + return DB_CORRUPTION; } ulint n = btr_page_get_level(root); + btr_validate_index_running++; for (ulint i = 0; i <= n; ++i) { if (!btr_validate_level(index, trx, n - i, lockout)) { @@ -5558,6 +5512,14 @@ btr_validate_index( } mtr_commit(&mtr); + /* In theory we need release barrier here, so that + btr_validate_index_running decrement is guaranteed to + happen after latches are released. + + Original code issued SEQ_CST on update and non-atomic + access on load. Which means it had broken synchronisation + as well. */ + btr_validate_index_running--; return(err); } diff --git a/storage/innobase/btr/btr0bulk.cc b/storage/innobase/btr/btr0bulk.cc index 5cb07af3f66..c3a190155c1 100644 --- a/storage/innobase/btr/btr0bulk.cc +++ b/storage/innobase/btr/btr0bulk.cc @@ -1044,6 +1044,6 @@ BtrBulk::finish(dberr_t err) ut_ad(!sync_check_iterate(dict_sync_check())); - ut_ad(err != DB_SUCCESS || btr_validate_index(m_index, NULL, false)); + ut_ad(err != DB_SUCCESS || btr_validate_index(m_index, NULL)); return(err); } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 71736488ac5..7aa5781cba1 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -14429,20 +14429,9 @@ ha_innobase::check( if (!(check_opt->flags & T_QUICK) && !index->is_corrupted()) { - /* Enlarge the fatal lock wait timeout during - CHECK TABLE. */ - my_atomic_addlong( - &srv_fatal_semaphore_wait_threshold, - SRV_SEMAPHORE_WAIT_EXTENSION); dberr_t err = btr_validate_index( - index, m_prebuilt->trx, false); - - /* Restore the fatal lock wait timeout after - CHECK TABLE. */ - my_atomic_addlong( - &srv_fatal_semaphore_wait_threshold, - -SRV_SEMAPHORE_WAIT_EXTENSION); + index, m_prebuilt->trx); if (err != DB_SUCCESS) { is_ok = false; diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index 39175fc1f1d..42d7cb3d32b 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -804,8 +804,7 @@ dberr_t btr_validate_index( /*===============*/ dict_index_t* index, /*!< in: index */ - const trx_t* trx, /*!< in: transaction or 0 */ - bool lockout)/*!< in: true if X-latch index is intended */ + const trx_t* trx) /*!< in: transaction or 0 */ MY_ATTRIBUTE((warn_unused_result)); /*************************************************************//** @@ -853,5 +852,6 @@ btr_lift_page_up( /**************************************************************** Global variable controlling if scrubbing should be performed */ extern my_bool srv_immediate_scrub_data_uncompressed; +extern Atomic_counter<uint32_t> btr_validate_index_running; #endif diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index ee578a3e0c6..a905b652c29 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -535,7 +535,6 @@ extern uint srv_sys_space_size_debug; extern bool srv_log_files_created; #endif /* UNIV_DEBUG */ -#define SRV_SEMAPHORE_WAIT_EXTENSION 7200 extern ulint srv_dml_needed_delay; #define SRV_MAX_N_IO_THREADS 130 diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index b4f2b91881a..591ae238c43 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -2422,7 +2422,7 @@ row_upd_sec_index_entry( #ifdef UNIV_DEBUG mtr_commit(&mtr); mtr_start(&mtr); - ut_ad(btr_validate_index(index, 0, false)); + ut_ad(btr_validate_index(index, 0)); ut_ad(0); #endif /* UNIV_DEBUG */ break; diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc index 9b65cfa7b89..9fead862fa1 100644 --- a/storage/innobase/sync/sync0arr.cc +++ b/storage/innobase/sync/sync0arr.cc @@ -970,7 +970,7 @@ sync_array_print_long_waits_low( ulint i; /* For huge tables, skip the check during CHECK TABLE etc... */ - if (fatal_timeout > SRV_SEMAPHORE_WAIT_EXTENSION) { + if (btr_validate_index_running) { return(false); } |