Commit 57fbc603 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'merge/merge-innodb-5.6' into 10.0

5.6.32
parents 309c08c1 b4f97a14
...@@ -265,13 +265,15 @@ FTS auxiliary INDEX table and clear the cache at the end. ...@@ -265,13 +265,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] sync sync state @param[in,out] sync sync state
@param[in] unlock_cache whether unlock cache lock when write node @param[in] unlock_cache whether unlock cache lock when write node
@param[in] wait whether wait when a sync is in progress @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 */ @return DB_SUCCESS if all OK */
static static
dberr_t dberr_t
fts_sync( fts_sync(
fts_sync_t* sync, fts_sync_t* sync,
bool unlock_cache, bool unlock_cache,
bool wait); bool wait,
bool has_dict);
/****************************************************************//** /****************************************************************//**
Release all resources help by the words rb tree e.g., the node ilist. */ Release all resources help by the words rb tree e.g., the node ilist. */
...@@ -3567,7 +3569,7 @@ fts_add_doc_by_id( ...@@ -3567,7 +3569,7 @@ fts_add_doc_by_id(
DBUG_EXECUTE_IF( DBUG_EXECUTE_IF(
"fts_instrument_sync_debug", "fts_instrument_sync_debug",
fts_sync(cache->sync, true, true); fts_sync(cache->sync, true, true, false);
); );
DEBUG_SYNC_C("fts_instrument_sync_request"); DEBUG_SYNC_C("fts_instrument_sync_request");
...@@ -4379,13 +4381,11 @@ fts_sync_index( ...@@ -4379,13 +4381,11 @@ fts_sync_index(
} }
/** Check if index cache has been synced completely /** Check if index cache has been synced completely
@param[in,out] sync sync state
@param[in,out] index_cache index cache @param[in,out] index_cache index cache
@return true if index is synced, otherwise false. */ @return true if index is synced, otherwise false. */
static static
bool bool
fts_sync_index_check( fts_sync_index_check(
fts_sync_t* sync,
fts_index_cache_t* index_cache) fts_index_cache_t* index_cache)
{ {
const ib_rbt_node_t* rbt_node; const ib_rbt_node_t* rbt_node;
...@@ -4408,14 +4408,36 @@ fts_sync_index_check( ...@@ -4408,14 +4408,36 @@ fts_sync_index_check(
return(true); return(true);
} }
/*********************************************************************//** /** Reset synced flag in index cache when rollback
Commit the SYNC, change state of processed doc ids etc. @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 */ @return DB_SUCCESS if all OK */
static MY_ATTRIBUTE((nonnull, warn_unused_result)) static MY_ATTRIBUTE((nonnull, warn_unused_result))
dberr_t dberr_t
fts_sync_commit( fts_sync_commit(
/*============*/ fts_sync_t* sync)
fts_sync_t* sync) /*!< in: sync state */
{ {
dberr_t error; dberr_t error;
trx_t* trx = sync->trx; trx_t* trx = sync->trx;
...@@ -4468,6 +4490,8 @@ fts_sync_commit( ...@@ -4468,6 +4490,8 @@ fts_sync_commit(
(double) n_nodes/ (double) elapsed_time); (double) n_nodes/ (double) elapsed_time);
} }
/* Avoid assertion in trx_free(). */
trx->dict_operation_lock_mode = 0;
trx_free_for_background(trx); trx_free_for_background(trx);
return(error); return(error);
...@@ -4490,6 +4514,10 @@ fts_sync_rollback( ...@@ -4490,6 +4514,10 @@ fts_sync_rollback(
index_cache = static_cast<fts_index_cache_t*>( index_cache = static_cast<fts_index_cache_t*>(
ib_vector_get(cache->indexes, i)); 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) { for (j = 0; fts_index_selector[j].value; ++j) {
if (index_cache->ins_graph[j] != NULL) { if (index_cache->ins_graph[j] != NULL) {
...@@ -4515,6 +4543,9 @@ fts_sync_rollback( ...@@ -4515,6 +4543,9 @@ fts_sync_rollback(
rw_lock_x_unlock(&cache->lock); rw_lock_x_unlock(&cache->lock);
fts_sql_rollback(trx); fts_sql_rollback(trx);
/* Avoid assertion in trx_free(). */
trx->dict_operation_lock_mode = 0;
trx_free_for_background(trx); trx_free_for_background(trx);
} }
...@@ -4523,13 +4554,15 @@ FTS auxiliary INDEX table and clear the cache at the end. ...@@ -4523,13 +4554,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] sync sync state @param[in,out] sync sync state
@param[in] unlock_cache whether unlock cache lock when write node @param[in] unlock_cache whether unlock cache lock when write node
@param[in] wait whether wait when a sync is in progress @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 */ @return DB_SUCCESS if all OK */
static static
dberr_t dberr_t
fts_sync( fts_sync(
fts_sync_t* sync, fts_sync_t* sync,
bool unlock_cache, bool unlock_cache,
bool wait) bool wait,
bool has_dict)
{ {
ulint i; ulint i;
dberr_t error = DB_SUCCESS; dberr_t error = DB_SUCCESS;
...@@ -4558,6 +4591,12 @@ fts_sync( ...@@ -4558,6 +4591,12 @@ fts_sync(
DEBUG_SYNC_C("fts_sync_begin"); DEBUG_SYNC_C("fts_sync_begin");
fts_sync_begin(sync); 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: begin_sync:
if (cache->total_size > fts_max_cache_size) { if (cache->total_size > fts_max_cache_size) {
/* Avoid the case: sync never finish when /* Avoid the case: sync never finish when
...@@ -4598,7 +4637,7 @@ fts_sync( ...@@ -4598,7 +4637,7 @@ fts_sync(
ib_vector_get(cache->indexes, i)); ib_vector_get(cache->indexes, i));
if (index_cache->index->to_be_dropped if (index_cache->index->to_be_dropped
|| fts_sync_index_check(sync, index_cache)) { || fts_sync_index_check(index_cache)) {
continue; continue;
} }
...@@ -4613,6 +4652,7 @@ fts_sync( ...@@ -4613,6 +4652,7 @@ fts_sync(
} }
rw_lock_x_lock(&cache->lock); rw_lock_x_lock(&cache->lock);
sync->interrupted = false;
sync->in_progress = false; sync->in_progress = false;
os_event_set(sync->event); os_event_set(sync->event);
rw_lock_x_unlock(&cache->lock); rw_lock_x_unlock(&cache->lock);
...@@ -4636,20 +4676,23 @@ FTS auxiliary INDEX table and clear the cache at the end. ...@@ -4636,20 +4676,23 @@ FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] table fts table @param[in,out] table fts table
@param[in] unlock_cache whether unlock cache when write node @param[in] unlock_cache whether unlock cache when write node
@param[in] wait whether wait for existing sync to finish @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. */ @return DB_SUCCESS on success, error code on failure. */
UNIV_INTERN UNIV_INTERN
dberr_t dberr_t
fts_sync_table( fts_sync_table(
dict_table_t* table, dict_table_t* table,
bool unlock_cache, bool unlock_cache,
bool wait) bool wait,
bool has_dict)
{ {
dberr_t err = DB_SUCCESS; dberr_t err = DB_SUCCESS;
ut_ad(table->fts); ut_ad(table->fts);
if (!dict_table_is_discarded(table) && table->fts->cache) { 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); return(err);
......
...@@ -2986,7 +2986,7 @@ fts_optimize_sync_table( ...@@ -2986,7 +2986,7 @@ fts_optimize_sync_table(
if (table) { if (table) {
if (dict_table_has_fts_index(table) && table->fts->cache) { 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); dict_table_close(table, FALSE, FALSE);
......
...@@ -6966,6 +6966,7 @@ dberr_t ...@@ -6966,6 +6966,7 @@ dberr_t
ha_innobase::innobase_lock_autoinc(void) ha_innobase::innobase_lock_autoinc(void)
/*====================================*/ /*====================================*/
{ {
DBUG_ENTER("ha_innobase::innobase_lock_autoinc");
dberr_t error = DB_SUCCESS; dberr_t error = DB_SUCCESS;
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
...@@ -7005,6 +7006,8 @@ ha_innobase::innobase_lock_autoinc(void) ...@@ -7005,6 +7006,8 @@ ha_innobase::innobase_lock_autoinc(void)
/* Fall through to old style locking. */ /* Fall through to old style locking. */
case AUTOINC_OLD_STYLE_LOCKING: case AUTOINC_OLD_STYLE_LOCKING:
DBUG_EXECUTE_IF("die_if_autoinc_old_lock_style_used",
ut_ad(0););
error = row_lock_table_autoinc_for_mysql(prebuilt); error = row_lock_table_autoinc_for_mysql(prebuilt);
if (error == DB_SUCCESS) { if (error == DB_SUCCESS) {
...@@ -7018,7 +7021,7 @@ ha_innobase::innobase_lock_autoinc(void) ...@@ -7018,7 +7021,7 @@ ha_innobase::innobase_lock_autoinc(void)
ut_error; ut_error;
} }
return(error); DBUG_RETURN(error);
} }
/********************************************************************//** /********************************************************************//**
...@@ -11895,7 +11898,7 @@ ha_innobase::optimize( ...@@ -11895,7 +11898,7 @@ ha_innobase::optimize(
if (innodb_optimize_fulltext_only) { if (innodb_optimize_fulltext_only) {
if (prebuilt->table->fts && prebuilt->table->fts->cache if (prebuilt->table->fts && prebuilt->table->fts->cache
&& !dict_table_is_discarded(prebuilt->table)) { && !dict_table_is_discarded(prebuilt->table)) {
fts_sync_table(prebuilt->table, false, true); fts_sync_table(prebuilt->table, false, true, false);
fts_optimize_table(prebuilt->table); fts_optimize_table(prebuilt->table);
} }
return(HA_ADMIN_OK); return(HA_ADMIN_OK);
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -2963,15 +2963,26 @@ i_s_fts_deleted_generic_fill( ...@@ -2963,15 +2963,26 @@ i_s_fts_deleted_generic_fill(
DBUG_RETURN(0); DBUG_RETURN(0);
} }
deleted = fts_doc_ids_create(); /* Prevent DDL to drop fts aux tables. */
rw_lock_s_lock(&dict_operation_lock);
user_table = dict_table_open_on_name( user_table = dict_table_open_on_name(
fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE); fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE);
if (!user_table) { if (!user_table) {
rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0);
} else if (!dict_table_has_fts_index(user_table)) {
dict_table_close(user_table, FALSE, FALSE);
rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
deleted = fts_doc_ids_create();
trx = trx_allocate_for_background(); trx = trx_allocate_for_background();
trx->op_info = "Select for FTS DELETE TABLE"; trx->op_info = "Select for FTS DELETE TABLE";
...@@ -2999,6 +3010,8 @@ i_s_fts_deleted_generic_fill( ...@@ -2999,6 +3010,8 @@ i_s_fts_deleted_generic_fill(
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, FALSE, FALSE);
rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -3372,6 +3385,12 @@ i_s_fts_index_cache_fill( ...@@ -3372,6 +3385,12 @@ i_s_fts_index_cache_fill(
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (user_table->fts == NULL || user_table->fts->cache == NULL) {
dict_table_close(user_table, FALSE, FALSE);
DBUG_RETURN(0);
}
cache = user_table->fts->cache; cache = user_table->fts->cache;
ut_a(cache); ut_a(cache);
...@@ -3806,10 +3825,15 @@ i_s_fts_index_table_fill( ...@@ -3806,10 +3825,15 @@ i_s_fts_index_table_fill(
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/* Prevent DDL to drop fts aux tables. */
rw_lock_s_lock(&dict_operation_lock);
user_table = dict_table_open_on_name( user_table = dict_table_open_on_name(
fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE); fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE);
if (!user_table) { if (!user_table) {
rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -3822,6 +3846,8 @@ i_s_fts_index_table_fill( ...@@ -3822,6 +3846,8 @@ i_s_fts_index_table_fill(
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, FALSE, FALSE);
rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -3957,14 +3983,21 @@ i_s_fts_config_fill( ...@@ -3957,14 +3983,21 @@ i_s_fts_config_fill(
fields = table->field; fields = table->field;
/* Prevent DDL to drop fts aux tables. */
rw_lock_s_lock(&dict_operation_lock);
user_table = dict_table_open_on_name( user_table = dict_table_open_on_name(
fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE); fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE);
if (!user_table) { if (!user_table) {
rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} else if (!dict_table_has_fts_index(user_table)) { } else if (!dict_table_has_fts_index(user_table)) {
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, FALSE, FALSE);
rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -4020,6 +4053,8 @@ i_s_fts_config_fill( ...@@ -4020,6 +4053,8 @@ i_s_fts_config_fill(
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, FALSE, FALSE);
rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -840,13 +840,15 @@ FTS auxiliary INDEX table and clear the cache at the end. ...@@ -840,13 +840,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] table fts table @param[in,out] table fts table
@param[in] unlock_cache whether unlock cache when write node @param[in] unlock_cache whether unlock cache when write node
@param[in] wait whether wait for existing sync to finish @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. */ @return DB_SUCCESS on success, error code on failure. */
UNIV_INTERN UNIV_INTERN
dberr_t dberr_t
fts_sync_table( fts_sync_table(
dict_table_t* table, dict_table_t* table,
bool unlock_cache, bool unlock_cache,
bool wait); bool wait,
bool has_dict);
/****************************************************************//** /****************************************************************//**
Free the query graph but check whether dict_sys->mutex is already Free the query graph but check whether dict_sys->mutex is already
......
...@@ -44,7 +44,7 @@ Created 1/20/1994 Heikki Tuuri ...@@ -44,7 +44,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MAJOR 5
#define INNODB_VERSION_MINOR 6 #define INNODB_VERSION_MINOR 6
#define INNODB_VERSION_BUGFIX 31 #define INNODB_VERSION_BUGFIX 32
/* The following is the InnoDB version as shown in /* The following is the InnoDB version as shown in
SELECT plugin_version FROM information_schema.plugins; SELECT plugin_version FROM information_schema.plugins;
......
...@@ -1987,7 +1987,7 @@ row_merge_read_clustered_index( ...@@ -1987,7 +1987,7 @@ row_merge_read_clustered_index(
/* Sync fts cache for other fts indexes to keep all /* Sync fts cache for other fts indexes to keep all
fts indexes consistent in sync_doc_id. */ fts indexes consistent in sync_doc_id. */
err = fts_sync_table(const_cast<dict_table_t*>(new_table), err = fts_sync_table(const_cast<dict_table_t*>(new_table),
false, true); false, true, false);
if (err == DB_SUCCESS) { if (err == DB_SUCCESS) {
fts_update_next_doc_id( fts_update_next_doc_id(
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2010, 2014, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
...@@ -1367,7 +1367,10 @@ srv_mon_set_module_control( ...@@ -1367,7 +1367,10 @@ srv_mon_set_module_control(
module */ module */
set_current_module = FALSE; set_current_module = FALSE;
} else if (module_id == MONITOR_ALL_COUNTER) { } else if (module_id == MONITOR_ALL_COUNTER) {
if (!(innodb_counter_info[ix].monitor_type
& MONITOR_GROUP_MODULE)) {
continue; continue;
}
} else { } else {
/* Hitting the next module, stop */ /* Hitting the next module, stop */
break; break;
......
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