Commit c66db377 authored by Sergey Vojtovich's avatar Sergey Vojtovich

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().
parent aa2db754
......@@ -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 */
......@@ -5461,47 +5463,6 @@ btr_validate_level(
return(ret);
}
/**************************************************************//**
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 */
......@@ -5509,10 +5470,10 @@ 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);
}
......
......@@ -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);
}
......@@ -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;
......
......@@ -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
......@@ -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
......
......@@ -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;
......
......@@ -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);
}
......
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