Skip to content

Commit

Permalink
Merge 10.2 into 10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed May 7, 2018
2 parents 005d53f + e44ca6c commit 1a4c355
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 85 deletions.
27 changes: 27 additions & 0 deletions mysql-test/suite/innodb/r/alter_partitioned_debug.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
CREATE TABLE t1 (a INT, b VARCHAR(10)) ENGINE=InnoDB
PARTITION BY RANGE(a)
(PARTITION pa VALUES LESS THAN (3),
PARTITION pb VALUES LESS THAN (5));
INSERT INTO t1 VALUES(2,'two'),(2,'two'),(4,'four');
connect ddl,localhost,root,,test;
SET DEBUG_SYNC = 'inplace_after_index_build SIGNAL go WAIT_FOR done';
ALTER TABLE t1 ADD UNIQUE KEY (a,b(3));
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR go';
BEGIN;
SELECT * FROM t1 FOR UPDATE;
a b
2 two
2 two
4 four
SET DEBUG_SYNC = 'now SIGNAL done';
connection ddl;
ERROR 23000: Duplicate entry '2-two' for key 'a'
connection default;
DELETE FROM t1;
disconnect ddl;
SET DEBUG_SYNC = 'RESET';
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
34 changes: 34 additions & 0 deletions mysql-test/suite/innodb/t/alter_partitioned_debug.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--source include/have_innodb.inc
--source include/have_partition.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc

CREATE TABLE t1 (a INT, b VARCHAR(10)) ENGINE=InnoDB
PARTITION BY RANGE(a)
(PARTITION pa VALUES LESS THAN (3),
PARTITION pb VALUES LESS THAN (5));

INSERT INTO t1 VALUES(2,'two'),(2,'two'),(4,'four');

connect ddl,localhost,root,,test;
SET DEBUG_SYNC = 'inplace_after_index_build SIGNAL go WAIT_FOR done';
send ALTER TABLE t1 ADD UNIQUE KEY (a,b(3));

connection default;
SET DEBUG_SYNC = 'now WAIT_FOR go';
BEGIN;
SELECT * FROM t1 FOR UPDATE;
SET DEBUG_SYNC = 'now SIGNAL done';

connection ddl;
--error ER_DUP_ENTRY
reap;

connection default;
DELETE FROM t1;
disconnect ddl;

SET DEBUG_SYNC = 'RESET';

CHECK TABLE t1;
DROP TABLE t1;
4 changes: 2 additions & 2 deletions storage/innobase/dict/dict0defrag_bg.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*****************************************************************************
Copyright (c) 2016, MariaDB Corporation. All Rights Reserved.
Copyright (c) 2016, 2018, MariaDB Corporation.
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
Expand Down Expand Up @@ -232,7 +232,7 @@ dict_stats_process_entry_from_defrag_pool()
? dict_table_find_index_on_id(table, index_id)
: NULL;

if (!index || dict_index_is_corrupted(index)) {
if (!index || index->is_corrupted()) {
if (table) {
dict_table_close(table, TRUE, FALSE);
}
Expand Down
16 changes: 5 additions & 11 deletions storage/innobase/dict/dict0load.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2481,10 +2481,10 @@ dict_load_indexes(
}

ut_ad(index);
ut_ad(!dict_index_is_online_ddl(index));

/* Check whether the index is corrupted */
if (dict_index_is_corrupted(index)) {

if (index->is_corrupted()) {
ib::error() << "Index " << index->name
<< " of table " << table->name
<< " is corrupted";
Expand Down Expand Up @@ -3002,10 +3002,7 @@ dict_load_table_one(
table = NULL;
goto func_exit;
} else {
dict_index_t* clust_index;
clust_index = dict_table_get_first_index(table);

if (dict_index_is_corrupted(clust_index)) {
if (table->indexes.start->is_corrupted()) {
table->corrupted = true;
}
}
Expand Down Expand Up @@ -3056,14 +3053,11 @@ dict_load_table_one(

if (!srv_force_recovery
|| !index
|| !dict_index_is_clust(index)) {

|| !index->is_primary()) {
dict_table_remove_from_cache(table);
table = NULL;

} else if (dict_index_is_corrupted(index)
} else if (index->is_corrupted()
&& table->is_readable()) {

/* It is possible we force to load a corrupted
clustered index if srv_load_corrupted is set.
Mark the table as corrupted in this case */
Expand Down
7 changes: 3 additions & 4 deletions storage/innobase/dict/dict0stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,8 @@ dict_stats_should_ignore_index(
/*===========================*/
const dict_index_t* index) /*!< in: index */
{
return((index->type & DICT_FTS)
|| dict_index_is_corrupted(index)
|| dict_index_is_spatial(index)
return((index->type & (DICT_FTS | DICT_SPATIAL))
|| index->is_corrupted()
|| index->to_be_dropped
|| !index->is_committed());
}
Expand Down Expand Up @@ -2230,7 +2229,7 @@ dict_stats_update_persistent(
index = dict_table_get_first_index(table);

if (index == NULL
|| dict_index_is_corrupted(index)
|| index->is_corrupted()
|| (index->type | DICT_UNIQUE) != (DICT_CLUSTERED | DICT_UNIQUE)) {

/* Table definition is corrupt */
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/fts/fts0fts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6526,7 +6526,7 @@ fts_check_corrupt_index(
if (index->id == aux_table->index_id) {
ut_ad(index->type & DICT_FTS);
dict_table_close(table, true, false);
return(dict_index_is_corrupted(index));
return index->is_corrupted();
}
}

Expand Down
22 changes: 11 additions & 11 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9259,13 +9259,13 @@ ha_innobase::index_read(

dict_index_t* index = m_prebuilt->index;

if (index == NULL || dict_index_is_corrupted(index)) {
if (index == NULL || index->is_corrupted()) {
m_prebuilt->index_usable = FALSE;
DBUG_RETURN(HA_ERR_CRASHED);
}

if (!m_prebuilt->index_usable) {
DBUG_RETURN(dict_index_is_corrupted(index)
DBUG_RETURN(index->is_corrupted()
? HA_ERR_INDEX_CORRUPT
: HA_ERR_TABLE_DEF_CHANGED);
}
Expand Down Expand Up @@ -9523,14 +9523,14 @@ ha_innobase::change_active_index(
m_prebuilt->trx, m_prebuilt->index);

if (!m_prebuilt->index_usable) {
if (dict_index_is_corrupted(m_prebuilt->index)) {
if (m_prebuilt->index->is_corrupted()) {
char table_name[MAX_FULL_NAME_LEN + 1];

innobase_format_name(
table_name, sizeof table_name,
m_prebuilt->index->table->name.m_name);

if (dict_index_is_clust(m_prebuilt->index)) {
if (m_prebuilt->index->is_primary()) {
ut_ad(m_prebuilt->index->table->corrupted);
push_warning_printf(
m_user_thd, Sql_condition::WARN_LEVEL_WARN,
Expand Down Expand Up @@ -13380,7 +13380,7 @@ ha_innobase::records_in_range(
n_rows = HA_POS_ERROR;
goto func_exit;
}
if (dict_index_is_corrupted(index)) {
if (index->is_corrupted()) {
n_rows = HA_ERR_INDEX_CORRUPT;
goto func_exit;
}
Expand Down Expand Up @@ -14220,7 +14220,7 @@ ha_innobase::defragment_table(
for (index = dict_table_get_first_index(table); index;
index = dict_table_get_next_index(index)) {

if (dict_index_is_corrupted(index)) {
if (index->is_corrupted()) {
continue;
}

Expand Down Expand Up @@ -14417,7 +14417,7 @@ ha_innobase::check(
clustered index, we will do so here */
index = dict_table_get_first_index(m_prebuilt->table);

if (!dict_index_is_corrupted(index)) {
if (!index->is_corrupted()) {
dict_set_corrupted(
index, m_prebuilt->trx, "CHECK TABLE");
}
Expand Down Expand Up @@ -14455,7 +14455,7 @@ ha_innobase::check(
}

if (!(check_opt->flags & T_QUICK)
&& !dict_index_is_corrupted(index)) {
&& !index->is_corrupted()) {
/* Enlarge the fatal lock wait timeout during
CHECK TABLE. */
my_atomic_addlong(
Expand Down Expand Up @@ -14507,15 +14507,15 @@ ha_innobase::check(

DBUG_EXECUTE_IF(
"dict_set_index_corrupted",
if (!dict_index_is_clust(index)) {
if (!index->is_primary()) {
m_prebuilt->index_usable = FALSE;
// row_mysql_lock_data_dictionary(m_prebuilt->trx);
dict_set_corrupted(index, m_prebuilt->trx, "dict_set_index_corrupted");
// row_mysql_unlock_data_dictionary(m_prebuilt->trx);
});

if (UNIV_UNLIKELY(!m_prebuilt->index_usable)) {
if (dict_index_is_corrupted(m_prebuilt->index)) {
if (index->is_corrupted()) {
push_warning_printf(
m_user_thd,
Sql_condition::WARN_LEVEL_WARN,
Expand Down Expand Up @@ -14555,7 +14555,7 @@ ha_innobase::check(

DBUG_EXECUTE_IF(
"dict_set_index_corrupted",
if (!dict_index_is_clust(index)) {
if (!index->is_primary()) {
ret = DB_CORRUPTION;
});

Expand Down
17 changes: 7 additions & 10 deletions storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5232,8 +5232,7 @@ prepare_inplace_alter_table_dict(
= dict_table_get_first_index(user_table);
index != NULL;
index = dict_table_get_next_index(index)) {
if (!index->to_be_dropped
&& dict_index_is_corrupted(index)) {
if (!index->to_be_dropped && index->is_corrupted()) {
my_error(ER_CHECK_NO_SUCH_TABLE, MYF(0));
goto error_handled;
}
Expand All @@ -5243,8 +5242,7 @@ prepare_inplace_alter_table_dict(
= dict_table_get_first_index(user_table);
index != NULL;
index = dict_table_get_next_index(index)) {
if (!index->to_be_dropped
&& dict_index_is_corrupted(index)) {
if (!index->to_be_dropped && index->is_corrupted()) {
my_error(ER_CHECK_NO_SUCH_TABLE, MYF(0));
goto error_handled;
}
Expand Down Expand Up @@ -6322,8 +6320,7 @@ ha_innobase::prepare_inplace_alter_table(

if (indexed_table->corrupted
|| dict_table_get_first_index(indexed_table) == NULL
|| dict_index_is_corrupted(
dict_table_get_first_index(indexed_table))) {
|| dict_table_get_first_index(indexed_table)->is_corrupted()) {
/* The clustered index is corrupted. */
my_error(ER_CHECK_NO_SUCH_TABLE, MYF(0));
DBUG_RETURN(true);
Expand Down Expand Up @@ -6611,7 +6608,7 @@ ha_innobase::prepare_inplace_alter_table(
" with name %s", key->name);
} else {
ut_ad(!index->to_be_dropped);
if (!dict_index_is_clust(index)) {
if (!index->is_primary()) {
drop_index[n_drop_index++] = index;
} else {
drop_primary = index;
Expand Down Expand Up @@ -6712,7 +6709,7 @@ ha_innobase::prepare_inplace_alter_table(
for (dict_index_t* index = dict_table_get_first_index(indexed_table);
index != NULL; index = dict_table_get_next_index(index)) {

if (!index->to_be_dropped && dict_index_is_corrupted(index)) {
if (!index->to_be_dropped && index->is_corrupted()) {
my_error(ER_INDEX_CORRUPT, MYF(0), index->name());
goto err_exit;
}
Expand Down Expand Up @@ -8440,7 +8437,7 @@ commit_try_rebuild(
DBUG_ASSERT(dict_index_get_online_status(index)
== ONLINE_INDEX_COMPLETE);
DBUG_ASSERT(index->is_committed());
if (dict_index_is_corrupted(index)) {
if (index->is_corrupted()) {
my_error(ER_INDEX_CORRUPT, MYF(0), index->name());
DBUG_RETURN(true);
}
Expand Down Expand Up @@ -8689,7 +8686,7 @@ commit_try_norebuild(
DBUG_ASSERT(dict_index_get_online_status(index)
== ONLINE_INDEX_COMPLETE);
DBUG_ASSERT(!index->is_committed());
if (dict_index_is_corrupted(index)) {
if (index->is_corrupted()) {
/* Report a duplicate key
error for the index that was
flagged corrupted, most likely
Expand Down
12 changes: 1 addition & 11 deletions storage/innobase/include/dict0dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ dict_table_get_next_index(

/* Skip corrupted index */
#define dict_table_skip_corrupt_index(index) \
while (index && dict_index_is_corrupted(index)) { \
while (index && index->is_corrupted()) { \
index = dict_table_get_next_index(index); \
}

Expand Down Expand Up @@ -1769,16 +1769,6 @@ dict_table_is_corrupted(
const dict_table_t* table) /*!< in: table */
MY_ATTRIBUTE((nonnull, warn_unused_result));

/**********************************************************************//**
Check whether the index is corrupted.
@return nonzero for corrupted index, zero for valid indexes */
UNIV_INLINE
ulint
dict_index_is_corrupted(
/*====================*/
const dict_index_t* index) /*!< in: index */
MY_ATTRIBUTE((nonnull, warn_unused_result));

/**********************************************************************//**
Flags an index and table corrupted both in the data dictionary cache
and in the system table SYS_INDEXES. */
Expand Down
15 changes: 0 additions & 15 deletions storage/innobase/include/dict0dict.ic
Original file line number Diff line number Diff line change
Expand Up @@ -1390,21 +1390,6 @@ dict_table_is_corrupted(
return(table->corrupted);
}

/********************************************************************//**
Check whether the index is corrupted.
@return nonzero for corrupted index, zero for valid indexes */
UNIV_INLINE
ulint
dict_index_is_corrupted(
/*====================*/
const dict_index_t* index) /*!< in: index */
{
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);

return((index->type & DICT_CORRUPT)
|| (index->table && index->table->corrupted));
}

/********************************************************************//**
Check if the tablespace for the table has been discarded.
@return true if the tablespace has been discarded. */
Expand Down
10 changes: 10 additions & 0 deletions storage/innobase/include/dict0mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,9 @@ struct dict_index_t{
return DICT_CLUSTERED == (type & (DICT_CLUSTERED | DICT_IBUF));
}

/** @return whether the index is corrupted */
inline bool is_corrupted() const;

/** Determine how many fields of a given prefix can be set NULL.
@param[in] n_prefix number of fields in the prefix
@return number of fields 0..n_prefix-1 that can be set NULL */
Expand Down Expand Up @@ -1934,6 +1937,13 @@ inline bool dict_index_t::is_instant() const
return(n_core_fields != n_fields);
}

inline bool dict_index_t::is_corrupted() const
{
return UNIV_UNLIKELY(online_status >= ONLINE_INDEX_ABORTED
|| (type & DICT_CORRUPT)
|| (table && table->corrupted));
}

/*******************************************************************//**
Initialise the table lock list. */
void
Expand Down
3 changes: 1 addition & 2 deletions storage/innobase/row/row0ins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3774,8 +3774,7 @@ row_ins(
node->index = NULL; node->entry = NULL; break;);

/* Skip corrupted secondary index and its entry */
while (node->index && dict_index_is_corrupted(node->index)) {

while (node->index && node->index->is_corrupted()) {
node->index = dict_table_get_next_index(node->index);
node->entry = UT_LIST_GET_NEXT(tuple_list, node->entry);
}
Expand Down
Loading

0 comments on commit 1a4c355

Please sign in to comment.