Skip to content

Commit 57fbc60

Browse files
committed
Merge branch 'merge/merge-innodb-5.6' into 10.0
5.6.32
2 parents 309c08c + b4f97a1 commit 57fbc60

File tree

8 files changed

+108
-22
lines changed

8 files changed

+108
-22
lines changed

storage/innobase/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/innobase/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);

storage/innobase/handler/ha_innodb.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6966,6 +6966,7 @@ dberr_t
69666966
ha_innobase::innobase_lock_autoinc(void)
69676967
/*====================================*/
69686968
{
6969+
DBUG_ENTER("ha_innobase::innobase_lock_autoinc");
69696970
dberr_t error = DB_SUCCESS;
69706971

69716972
ut_ad(!srv_read_only_mode);
@@ -7005,6 +7006,8 @@ ha_innobase::innobase_lock_autoinc(void)
70057006
/* Fall through to old style locking. */
70067007

70077008
case AUTOINC_OLD_STYLE_LOCKING:
7009+
DBUG_EXECUTE_IF("die_if_autoinc_old_lock_style_used",
7010+
ut_ad(0););
70087011
error = row_lock_table_autoinc_for_mysql(prebuilt);
70097012

70107013
if (error == DB_SUCCESS) {
@@ -7018,7 +7021,7 @@ ha_innobase::innobase_lock_autoinc(void)
70187021
ut_error;
70197022
}
70207023

7021-
return(error);
7024+
DBUG_RETURN(error);
70227025
}
70237026

70247027
/********************************************************************//**
@@ -11895,7 +11898,7 @@ ha_innobase::optimize(
1189511898
if (innodb_optimize_fulltext_only) {
1189611899
if (prebuilt->table->fts && prebuilt->table->fts->cache
1189711900
&& !dict_table_is_discarded(prebuilt->table)) {
11898-
fts_sync_table(prebuilt->table, false, true);
11901+
fts_sync_table(prebuilt->table, false, true, false);
1189911902
fts_optimize_table(prebuilt->table);
1190011903
}
1190111904
return(HA_ADMIN_OK);

storage/innobase/handler/i_s.cc

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -2963,15 +2963,26 @@ i_s_fts_deleted_generic_fill(
29632963
DBUG_RETURN(0);
29642964
}
29652965

2966-
deleted = fts_doc_ids_create();
2966+
/* Prevent DDL to drop fts aux tables. */
2967+
rw_lock_s_lock(&dict_operation_lock);
29672968

29682969
user_table = dict_table_open_on_name(
29692970
fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE);
29702971

29712972
if (!user_table) {
2973+
rw_lock_s_unlock(&dict_operation_lock);
2974+
2975+
DBUG_RETURN(0);
2976+
} else if (!dict_table_has_fts_index(user_table)) {
2977+
dict_table_close(user_table, FALSE, FALSE);
2978+
2979+
rw_lock_s_unlock(&dict_operation_lock);
2980+
29722981
DBUG_RETURN(0);
29732982
}
29742983

2984+
deleted = fts_doc_ids_create();
2985+
29752986
trx = trx_allocate_for_background();
29762987
trx->op_info = "Select for FTS DELETE TABLE";
29772988

@@ -2999,6 +3010,8 @@ i_s_fts_deleted_generic_fill(
29993010

30003011
dict_table_close(user_table, FALSE, FALSE);
30013012

3013+
rw_lock_s_unlock(&dict_operation_lock);
3014+
30023015
DBUG_RETURN(0);
30033016
}
30043017

@@ -3372,6 +3385,12 @@ i_s_fts_index_cache_fill(
33723385
DBUG_RETURN(0);
33733386
}
33743387

3388+
if (user_table->fts == NULL || user_table->fts->cache == NULL) {
3389+
dict_table_close(user_table, FALSE, FALSE);
3390+
3391+
DBUG_RETURN(0);
3392+
}
3393+
33753394
cache = user_table->fts->cache;
33763395

33773396
ut_a(cache);
@@ -3806,10 +3825,15 @@ i_s_fts_index_table_fill(
38063825
DBUG_RETURN(0);
38073826
}
38083827

3828+
/* Prevent DDL to drop fts aux tables. */
3829+
rw_lock_s_lock(&dict_operation_lock);
3830+
38093831
user_table = dict_table_open_on_name(
38103832
fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE);
38113833

38123834
if (!user_table) {
3835+
rw_lock_s_unlock(&dict_operation_lock);
3836+
38133837
DBUG_RETURN(0);
38143838
}
38153839

@@ -3822,6 +3846,8 @@ i_s_fts_index_table_fill(
38223846

38233847
dict_table_close(user_table, FALSE, FALSE);
38243848

3849+
rw_lock_s_unlock(&dict_operation_lock);
3850+
38253851
DBUG_RETURN(0);
38263852
}
38273853

@@ -3957,14 +3983,21 @@ i_s_fts_config_fill(
39573983

39583984
fields = table->field;
39593985

3986+
/* Prevent DDL to drop fts aux tables. */
3987+
rw_lock_s_lock(&dict_operation_lock);
3988+
39603989
user_table = dict_table_open_on_name(
39613990
fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE);
39623991

39633992
if (!user_table) {
3993+
rw_lock_s_unlock(&dict_operation_lock);
3994+
39643995
DBUG_RETURN(0);
39653996
} else if (!dict_table_has_fts_index(user_table)) {
39663997
dict_table_close(user_table, FALSE, FALSE);
39673998

3999+
rw_lock_s_unlock(&dict_operation_lock);
4000+
39684001
DBUG_RETURN(0);
39694002
}
39704003

@@ -4020,6 +4053,8 @@ i_s_fts_config_fill(
40204053

40214054
dict_table_close(user_table, FALSE, FALSE);
40224055

4056+
rw_lock_s_unlock(&dict_operation_lock);
4057+
40234058
DBUG_RETURN(0);
40244059
}
40254060

storage/innobase/include/fts0fts.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,13 +840,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
840840
@param[in,out] table fts table
841841
@param[in] unlock_cache whether unlock cache when write node
842842
@param[in] wait whether wait for existing sync to finish
843+
@param[in] has_dict whether has dict operation lock
843844
@return DB_SUCCESS on success, error code on failure. */
844845
UNIV_INTERN
845846
dberr_t
846847
fts_sync_table(
847848
dict_table_t* table,
848849
bool unlock_cache,
849-
bool wait);
850+
bool wait,
851+
bool has_dict);
850852

851853
/****************************************************************//**
852854
Free the query graph but check whether dict_sys->mutex is already

storage/innobase/include/univ.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Created 1/20/1994 Heikki Tuuri
4444

4545
#define INNODB_VERSION_MAJOR 5
4646
#define INNODB_VERSION_MINOR 6
47-
#define INNODB_VERSION_BUGFIX 31
47+
#define INNODB_VERSION_BUGFIX 32
4848

4949
/* The following is the InnoDB version as shown in
5050
SELECT plugin_version FROM information_schema.plugins;

storage/innobase/row/row0merge.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,7 @@ row_merge_read_clustered_index(
19871987
/* Sync fts cache for other fts indexes to keep all
19881988
fts indexes consistent in sync_doc_id. */
19891989
err = fts_sync_table(const_cast<dict_table_t*>(new_table),
1990-
false, true);
1990+
false, true, false);
19911991

19921992
if (err == DB_SUCCESS) {
19931993
fts_update_next_doc_id(

storage/innobase/srv/srv0mon.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 2010, 2014, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2012, Facebook Inc.
55
66
This program is free software; you can redistribute it and/or modify it under
@@ -1367,7 +1367,10 @@ srv_mon_set_module_control(
13671367
module */
13681368
set_current_module = FALSE;
13691369
} else if (module_id == MONITOR_ALL_COUNTER) {
1370-
continue;
1370+
if (!(innodb_counter_info[ix].monitor_type
1371+
& MONITOR_GROUP_MODULE)) {
1372+
continue;
1373+
}
13711374
} else {
13721375
/* Hitting the next module, stop */
13731376
break;

0 commit comments

Comments
 (0)