Skip to content

Commit

Permalink
Merge branch 'merge/merge-xtradb-5.6' into 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Sep 27, 2016
2 parents 3629f62 + 93ab309 commit bb8b658
Show file tree
Hide file tree
Showing 20 changed files with 280 additions and 83 deletions.
16 changes: 10 additions & 6 deletions storage/xtradb/btr/btr0btr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ btr_corruption_report(
buf_block_get_zip_size(block),
BUF_PAGE_PRINT_NO_CRASH);
}
buf_page_print(buf_block_get_frame_fast(block), 0, 0);
buf_page_print(buf_nonnull_block_get_frame(block), 0, 0);
}

#ifndef UNIV_HOTBACKUP
Expand Down Expand Up @@ -804,8 +804,10 @@ btr_height_get(

/* S latches the page */
root_block = btr_root_block_get(index, RW_S_LATCH, mtr);
ut_ad(root_block); // The index must not be corrupted

height = btr_page_get_level(buf_block_get_frame_fast(root_block), mtr);
height = btr_page_get_level(buf_nonnull_block_get_frame(root_block),
mtr);

/* Release the S latch on the root page. */
mtr_memo_release(mtr, root_block, MTR_MEMO_PAGE_S_FIX);
Expand Down Expand Up @@ -1231,7 +1233,7 @@ btr_get_size(
SRV_CORRUPT_TABLE_CHECK(root,
{
mtr_commit(mtr);
return(0);
return(ULINT_UNDEFINED);
});

if (flag == BTR_N_LEAF_PAGES) {
Expand Down Expand Up @@ -2756,7 +2758,7 @@ btr_attach_half_pages(
}

/* Get the level of the split pages */
level = btr_page_get_level(buf_block_get_frame_fast(block), mtr);
level = btr_page_get_level(buf_nonnull_block_get_frame(block), mtr);
ut_ad(level
== btr_page_get_level(buf_block_get_frame(new_block), mtr));

Expand Down Expand Up @@ -4133,8 +4135,10 @@ btr_discard_page(

/* Decide the page which will inherit the locks */

left_page_no = btr_page_get_prev(buf_block_get_frame_fast(block), mtr);
right_page_no = btr_page_get_next(buf_block_get_frame_fast(block), mtr);
left_page_no = btr_page_get_prev(buf_nonnull_block_get_frame(block),
mtr);
right_page_no = btr_page_get_next(buf_nonnull_block_get_frame(block),
mtr);

if (left_page_no != FIL_NULL) {
merge_block = btr_block_get(space, zip_size, left_page_no,
Expand Down
4 changes: 2 additions & 2 deletions storage/xtradb/btr/btr0cur.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ btr_cur_pessimistic_insert(
}
if (!page_rec_is_infimum(btr_cur_get_rec(cursor))
|| btr_page_get_prev(
buf_block_get_frame(
buf_nonnull_block_get_frame(
btr_cur_get_block(cursor)), mtr)
== FIL_NULL) {
/* split and inserted need to call
Expand Down Expand Up @@ -2220,7 +2220,7 @@ btr_cur_update_in_place(
if (page_zip
&& !(flags & BTR_KEEP_IBUF_BITMAP)
&& !dict_index_is_clust(index)
&& page_is_leaf(buf_block_get_frame(block))) {
&& page_is_leaf(buf_nonnull_block_get_frame(block))) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(block, mtr);
}
Expand Down
2 changes: 2 additions & 0 deletions storage/xtradb/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ buf_flush_init_flush_rbt(void)

buf_flush_list_mutex_enter(buf_pool);

ut_ad(buf_pool->flush_rbt == NULL);

/* Create red black tree for speedy insertions in flush list. */
buf_pool->flush_rbt = rbt_create(
sizeof(buf_page_t*), buf_flush_block_cmp);
Expand Down
6 changes: 6 additions & 0 deletions storage/xtradb/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,9 @@ fil_close_all_files(void)
{
fil_space_t* space;

// Must check both flags as it's possible for this to be called during
// server startup with srv_track_changed_pages == true but
// srv_redo_log_thread_started == false
if (srv_track_changed_pages && srv_redo_log_thread_started)
os_event_wait(srv_redo_log_tracked_event);

Expand Down Expand Up @@ -1719,6 +1722,9 @@ fil_close_log_files(
{
fil_space_t* space;

// Must check both flags as it's possible for this to be called during
// server startup with srv_track_changed_pages == true but
// srv_redo_log_thread_started == false
if (srv_track_changed_pages && srv_redo_log_thread_started)
os_event_wait(srv_redo_log_tracked_event);

Expand Down
67 changes: 55 additions & 12 deletions storage/xtradb/fts/fts0fts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] sync sync state
@param[in] unlock_cache whether unlock cache lock when write node
@param[in] wait whether wait when a sync is in progress
@param[in] has_dict whether has dict operation lock
@return DB_SUCCESS if all OK */
static
dberr_t
fts_sync(
fts_sync_t* sync,
bool unlock_cache,
bool wait);
bool wait,
bool has_dict);

/****************************************************************//**
Release all resources help by the words rb tree e.g., the node ilist. */
Expand Down Expand Up @@ -3567,7 +3569,7 @@ fts_add_doc_by_id(

DBUG_EXECUTE_IF(
"fts_instrument_sync_debug",
fts_sync(cache->sync, true, true);
fts_sync(cache->sync, true, true, false);
);

DEBUG_SYNC_C("fts_instrument_sync_request");
Expand Down Expand Up @@ -4379,13 +4381,11 @@ fts_sync_index(
}

/** Check if index cache has been synced completely
@param[in,out] sync sync state
@param[in,out] index_cache index cache
@return true if index is synced, otherwise false. */
static
bool
fts_sync_index_check(
fts_sync_t* sync,
fts_index_cache_t* index_cache)
{
const ib_rbt_node_t* rbt_node;
Expand All @@ -4408,14 +4408,36 @@ fts_sync_index_check(
return(true);
}

/*********************************************************************//**
Commit the SYNC, change state of processed doc ids etc.
/** Reset synced flag in index cache when rollback
@param[in,out] index_cache index cache */
static
void
fts_sync_index_reset(
fts_index_cache_t* index_cache)
{
const ib_rbt_node_t* rbt_node;

for (rbt_node = rbt_first(index_cache->words);
rbt_node != NULL;
rbt_node = rbt_next(index_cache->words, rbt_node)) {

fts_tokenizer_word_t* word;
word = rbt_value(fts_tokenizer_word_t, rbt_node);

fts_node_t* fts_node;
fts_node = static_cast<fts_node_t*>(ib_vector_last(word->nodes));

fts_node->synced = false;
}
}

/** Commit the SYNC, change state of processed doc ids etc.
@param[in,out] sync sync state
@return DB_SUCCESS if all OK */
static MY_ATTRIBUTE((nonnull, warn_unused_result))
dberr_t
fts_sync_commit(
/*============*/
fts_sync_t* sync) /*!< in: sync state */
fts_sync_t* sync)
{
dberr_t error;
trx_t* trx = sync->trx;
Expand Down Expand Up @@ -4468,6 +4490,8 @@ fts_sync_commit(
(double) n_nodes/ (double) elapsed_time);
}

/* Avoid assertion in trx_free(). */
trx->dict_operation_lock_mode = 0;
trx_free_for_background(trx);

return(error);
Expand All @@ -4490,6 +4514,10 @@ fts_sync_rollback(
index_cache = static_cast<fts_index_cache_t*>(
ib_vector_get(cache->indexes, i));

/* Reset synced flag so nodes will not be skipped
in the next sync, see fts_sync_write_words(). */
fts_sync_index_reset(index_cache);

for (j = 0; fts_index_selector[j].value; ++j) {

if (index_cache->ins_graph[j] != NULL) {
Expand All @@ -4515,6 +4543,9 @@ fts_sync_rollback(
rw_lock_x_unlock(&cache->lock);

fts_sql_rollback(trx);

/* Avoid assertion in trx_free(). */
trx->dict_operation_lock_mode = 0;
trx_free_for_background(trx);
}

Expand All @@ -4523,13 +4554,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] sync sync state
@param[in] unlock_cache whether unlock cache lock when write node
@param[in] wait whether wait when a sync is in progress
@param[in] has_dict whether has dict operation lock
@return DB_SUCCESS if all OK */
static
dberr_t
fts_sync(
fts_sync_t* sync,
bool unlock_cache,
bool wait)
bool wait,
bool has_dict)
{
ulint i;
dberr_t error = DB_SUCCESS;
Expand Down Expand Up @@ -4558,6 +4591,12 @@ fts_sync(
DEBUG_SYNC_C("fts_sync_begin");
fts_sync_begin(sync);

/* When sync in background, we hold dict operation lock
to prevent DDL like DROP INDEX, etc. */
if (has_dict) {
sync->trx->dict_operation_lock_mode = RW_S_LATCH;
}

begin_sync:
if (cache->total_size > fts_max_cache_size) {
/* Avoid the case: sync never finish when
Expand Down Expand Up @@ -4598,7 +4637,7 @@ fts_sync(
ib_vector_get(cache->indexes, i));

if (index_cache->index->to_be_dropped
|| fts_sync_index_check(sync, index_cache)) {
|| fts_sync_index_check(index_cache)) {
continue;
}

Expand All @@ -4613,6 +4652,7 @@ fts_sync(
}

rw_lock_x_lock(&cache->lock);
sync->interrupted = false;
sync->in_progress = false;
os_event_set(sync->event);
rw_lock_x_unlock(&cache->lock);
Expand All @@ -4636,20 +4676,23 @@ FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] table fts table
@param[in] unlock_cache whether unlock cache when write node
@param[in] wait whether wait for existing sync to finish
@param[in] has_dict whether has dict operation lock
@return DB_SUCCESS on success, error code on failure. */
UNIV_INTERN
dberr_t
fts_sync_table(
dict_table_t* table,
bool unlock_cache,
bool wait)
bool wait,
bool has_dict)
{
dberr_t err = DB_SUCCESS;

ut_ad(table->fts);

if (!dict_table_is_discarded(table) && table->fts->cache) {
err = fts_sync(table->fts->cache->sync, unlock_cache, wait);
err = fts_sync(table->fts->cache->sync,
unlock_cache, wait, has_dict);
}

return(err);
Expand Down
2 changes: 1 addition & 1 deletion storage/xtradb/fts/fts0opt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2986,7 +2986,7 @@ fts_optimize_sync_table(

if (table) {
if (dict_table_has_fts_index(table) && table->fts->cache) {
fts_sync_table(table, true, false);
fts_sync_table(table, true, false, true);
}

dict_table_close(table, FALSE, FALSE);
Expand Down
Loading

0 comments on commit bb8b658

Please sign in to comment.