Skip to content

Commit bb8b658

Browse files
committed
Merge branch 'merge/merge-xtradb-5.6' into 10.0
2 parents 3629f62 + 93ab309 commit bb8b658

File tree

20 files changed

+280
-83
lines changed

20 files changed

+280
-83
lines changed

storage/xtradb/btr/btr0btr.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ btr_corruption_report(
7878
buf_block_get_zip_size(block),
7979
BUF_PAGE_PRINT_NO_CRASH);
8080
}
81-
buf_page_print(buf_block_get_frame_fast(block), 0, 0);
81+
buf_page_print(buf_nonnull_block_get_frame(block), 0, 0);
8282
}
8383

8484
#ifndef UNIV_HOTBACKUP
@@ -804,8 +804,10 @@ btr_height_get(
804804

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

808-
height = btr_page_get_level(buf_block_get_frame_fast(root_block), mtr);
809+
height = btr_page_get_level(buf_nonnull_block_get_frame(root_block),
810+
mtr);
809811

810812
/* Release the S latch on the root page. */
811813
mtr_memo_release(mtr, root_block, MTR_MEMO_PAGE_S_FIX);
@@ -1231,7 +1233,7 @@ btr_get_size(
12311233
SRV_CORRUPT_TABLE_CHECK(root,
12321234
{
12331235
mtr_commit(mtr);
1234-
return(0);
1236+
return(ULINT_UNDEFINED);
12351237
});
12361238

12371239
if (flag == BTR_N_LEAF_PAGES) {
@@ -2756,7 +2758,7 @@ btr_attach_half_pages(
27562758
}
27572759

27582760
/* Get the level of the split pages */
2759-
level = btr_page_get_level(buf_block_get_frame_fast(block), mtr);
2761+
level = btr_page_get_level(buf_nonnull_block_get_frame(block), mtr);
27602762
ut_ad(level
27612763
== btr_page_get_level(buf_block_get_frame(new_block), mtr));
27622764

@@ -4133,8 +4135,10 @@ btr_discard_page(
41334135

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

4136-
left_page_no = btr_page_get_prev(buf_block_get_frame_fast(block), mtr);
4137-
right_page_no = btr_page_get_next(buf_block_get_frame_fast(block), mtr);
4138+
left_page_no = btr_page_get_prev(buf_nonnull_block_get_frame(block),
4139+
mtr);
4140+
right_page_no = btr_page_get_next(buf_nonnull_block_get_frame(block),
4141+
mtr);
41384142

41394143
if (left_page_no != FIL_NULL) {
41404144
merge_block = btr_block_get(space, zip_size, left_page_no,

storage/xtradb/btr/btr0cur.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@ btr_cur_pessimistic_insert(
17511751
}
17521752
if (!page_rec_is_infimum(btr_cur_get_rec(cursor))
17531753
|| btr_page_get_prev(
1754-
buf_block_get_frame(
1754+
buf_nonnull_block_get_frame(
17551755
btr_cur_get_block(cursor)), mtr)
17561756
== FIL_NULL) {
17571757
/* split and inserted need to call
@@ -2220,7 +2220,7 @@ btr_cur_update_in_place(
22202220
if (page_zip
22212221
&& !(flags & BTR_KEEP_IBUF_BITMAP)
22222222
&& !dict_index_is_clust(index)
2223-
&& page_is_leaf(buf_block_get_frame(block))) {
2223+
&& page_is_leaf(buf_nonnull_block_get_frame(block))) {
22242224
/* Update the free bits in the insert buffer. */
22252225
ibuf_update_free_bits_zip(block, mtr);
22262226
}

storage/xtradb/buf/buf0flu.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ buf_flush_init_flush_rbt(void)
309309

310310
buf_flush_list_mutex_enter(buf_pool);
311311

312+
ut_ad(buf_pool->flush_rbt == NULL);
313+
312314
/* Create red black tree for speedy insertions in flush list. */
313315
buf_pool->flush_rbt = rbt_create(
314316
sizeof(buf_page_t*), buf_flush_block_cmp);

storage/xtradb/fil/fil0fil.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,9 @@ fil_close_all_files(void)
16801680
{
16811681
fil_space_t* space;
16821682

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

@@ -1719,6 +1722,9 @@ fil_close_log_files(
17191722
{
17201723
fil_space_t* space;
17211724

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

storage/xtradb/fts/fts0fts.cc

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
265265
@param[in,out] sync sync state
266266
@param[in] unlock_cache whether unlock cache lock when write node
267267
@param[in] wait whether wait when a sync is in progress
268+
@param[in] has_dict whether has dict operation lock
268269
@return DB_SUCCESS if all OK */
269270
static
270271
dberr_t
271272
fts_sync(
272273
fts_sync_t* sync,
273274
bool unlock_cache,
274-
bool wait);
275+
bool wait,
276+
bool has_dict);
275277

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

35683570
DBUG_EXECUTE_IF(
35693571
"fts_instrument_sync_debug",
3570-
fts_sync(cache->sync, true, true);
3572+
fts_sync(cache->sync, true, true, false);
35713573
);
35723574

35733575
DEBUG_SYNC_C("fts_instrument_sync_request");
@@ -4379,13 +4381,11 @@ fts_sync_index(
43794381
}
43804382

43814383
/** Check if index cache has been synced completely
4382-
@param[in,out] sync sync state
43834384
@param[in,out] index_cache index cache
43844385
@return true if index is synced, otherwise false. */
43854386
static
43864387
bool
43874388
fts_sync_index_check(
4388-
fts_sync_t* sync,
43894389
fts_index_cache_t* index_cache)
43904390
{
43914391
const ib_rbt_node_t* rbt_node;
@@ -4408,14 +4408,36 @@ fts_sync_index_check(
44084408
return(true);
44094409
}
44104410

4411-
/*********************************************************************//**
4412-
Commit the SYNC, change state of processed doc ids etc.
4411+
/** Reset synced flag in index cache when rollback
4412+
@param[in,out] index_cache index cache */
4413+
static
4414+
void
4415+
fts_sync_index_reset(
4416+
fts_index_cache_t* index_cache)
4417+
{
4418+
const ib_rbt_node_t* rbt_node;
4419+
4420+
for (rbt_node = rbt_first(index_cache->words);
4421+
rbt_node != NULL;
4422+
rbt_node = rbt_next(index_cache->words, rbt_node)) {
4423+
4424+
fts_tokenizer_word_t* word;
4425+
word = rbt_value(fts_tokenizer_word_t, rbt_node);
4426+
4427+
fts_node_t* fts_node;
4428+
fts_node = static_cast<fts_node_t*>(ib_vector_last(word->nodes));
4429+
4430+
fts_node->synced = false;
4431+
}
4432+
}
4433+
4434+
/** Commit the SYNC, change state of processed doc ids etc.
4435+
@param[in,out] sync sync state
44134436
@return DB_SUCCESS if all OK */
44144437
static MY_ATTRIBUTE((nonnull, warn_unused_result))
44154438
dberr_t
44164439
fts_sync_commit(
4417-
/*============*/
4418-
fts_sync_t* sync) /*!< in: sync state */
4440+
fts_sync_t* sync)
44194441
{
44204442
dberr_t error;
44214443
trx_t* trx = sync->trx;
@@ -4468,6 +4490,8 @@ fts_sync_commit(
44684490
(double) n_nodes/ (double) elapsed_time);
44694491
}
44704492

4493+
/* Avoid assertion in trx_free(). */
4494+
trx->dict_operation_lock_mode = 0;
44714495
trx_free_for_background(trx);
44724496

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

4517+
/* Reset synced flag so nodes will not be skipped
4518+
in the next sync, see fts_sync_write_words(). */
4519+
fts_sync_index_reset(index_cache);
4520+
44934521
for (j = 0; fts_index_selector[j].value; ++j) {
44944522

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

45174545
fts_sql_rollback(trx);
4546+
4547+
/* Avoid assertion in trx_free(). */
4548+
trx->dict_operation_lock_mode = 0;
45184549
trx_free_for_background(trx);
45194550
}
45204551

@@ -4523,13 +4554,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
45234554
@param[in,out] sync sync state
45244555
@param[in] unlock_cache whether unlock cache lock when write node
45254556
@param[in] wait whether wait when a sync is in progress
4557+
@param[in] has_dict whether has dict operation lock
45264558
@return DB_SUCCESS if all OK */
45274559
static
45284560
dberr_t
45294561
fts_sync(
45304562
fts_sync_t* sync,
45314563
bool unlock_cache,
4532-
bool wait)
4564+
bool wait,
4565+
bool has_dict)
45334566
{
45344567
ulint i;
45354568
dberr_t error = DB_SUCCESS;
@@ -4558,6 +4591,12 @@ fts_sync(
45584591
DEBUG_SYNC_C("fts_sync_begin");
45594592
fts_sync_begin(sync);
45604593

4594+
/* When sync in background, we hold dict operation lock
4595+
to prevent DDL like DROP INDEX, etc. */
4596+
if (has_dict) {
4597+
sync->trx->dict_operation_lock_mode = RW_S_LATCH;
4598+
}
4599+
45614600
begin_sync:
45624601
if (cache->total_size > fts_max_cache_size) {
45634602
/* Avoid the case: sync never finish when
@@ -4598,7 +4637,7 @@ fts_sync(
45984637
ib_vector_get(cache->indexes, i));
45994638

46004639
if (index_cache->index->to_be_dropped
4601-
|| fts_sync_index_check(sync, index_cache)) {
4640+
|| fts_sync_index_check(index_cache)) {
46024641
continue;
46034642
}
46044643

@@ -4613,6 +4652,7 @@ fts_sync(
46134652
}
46144653

46154654
rw_lock_x_lock(&cache->lock);
4655+
sync->interrupted = false;
46164656
sync->in_progress = false;
46174657
os_event_set(sync->event);
46184658
rw_lock_x_unlock(&cache->lock);
@@ -4636,20 +4676,23 @@ FTS auxiliary INDEX table and clear the cache at the end.
46364676
@param[in,out] table fts table
46374677
@param[in] unlock_cache whether unlock cache when write node
46384678
@param[in] wait whether wait for existing sync to finish
4679+
@param[in] has_dict whether has dict operation lock
46394680
@return DB_SUCCESS on success, error code on failure. */
46404681
UNIV_INTERN
46414682
dberr_t
46424683
fts_sync_table(
46434684
dict_table_t* table,
46444685
bool unlock_cache,
4645-
bool wait)
4686+
bool wait,
4687+
bool has_dict)
46464688
{
46474689
dberr_t err = DB_SUCCESS;
46484690

46494691
ut_ad(table->fts);
46504692

46514693
if (!dict_table_is_discarded(table) && table->fts->cache) {
4652-
err = fts_sync(table->fts->cache->sync, unlock_cache, wait);
4694+
err = fts_sync(table->fts->cache->sync,
4695+
unlock_cache, wait, has_dict);
46534696
}
46544697

46554698
return(err);

storage/xtradb/fts/fts0opt.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2986,7 +2986,7 @@ fts_optimize_sync_table(
29862986

29872987
if (table) {
29882988
if (dict_table_has_fts_index(table) && table->fts->cache) {
2989-
fts_sync_table(table, true, false);
2989+
fts_sync_table(table, true, false, true);
29902990
}
29912991

29922992
dict_table_close(table, FALSE, FALSE);

0 commit comments

Comments
 (0)