summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-03-08 09:13:48 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-03-08 09:20:12 +0200
commit136d21c82f835dd85a53057c67d4476f5b971a47 (patch)
tree62f966c6ce639281e36b201f6deb6ee1207f5f03
parent2d0dd62cf7e824f5bbc8d0367730adcdaf0eed68 (diff)
downloadmariadb-git-136d21c82f835dd85a53057c67d4476f5b971a47.tar.gz
MDEV-13818: Revert an incorrect change
In commit d30f17af4969cc1ce34f1925f5ea2bced9c6f7e9 the change of the loop iteration broke another error handling path that did "goto error_handling_drop_uncached". Cover this code path with fault injection, and revert to the correct iteration. There are two fault injection labels innodb_OOM_prepare_inplace_alter. Their order was swapped in MDEV-11369, so that the label that used to be covered in an ADD INDEX code path would become unreachable because the label that is executed for any ALTER TABLE was executed first. Let us introduce the label innodb_OOM_prepare_add_index for the more specific case.
-rw-r--r--mysql-test/suite/innodb/r/innodb-index-online.result4
-rw-r--r--mysql-test/suite/innodb/t/innodb-index-online.test4
-rw-r--r--storage/innobase/handler/handler0alter.cc18
3 files changed, 18 insertions, 8 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-index-online.result b/mysql-test/suite/innodb/r/innodb-index-online.result
index cc900ff0201..a0227d31393 100644
--- a/mysql-test/suite/innodb/r/innodb-index-online.result
+++ b/mysql-test/suite/innodb/r/innodb-index-online.result
@@ -43,6 +43,10 @@ SET DEBUG_DBUG = '+d,innodb_OOM_inplace_alter';
CREATE UNIQUE INDEX c2 ON t1(c2);
ERROR HY000: Out of memory.
SET DEBUG_DBUG = @saved_debug_dbug;
+SET DEBUG_DBUG = '+d,innodb_OOM_prepare_add_index';
+ALTER TABLE t1 ADD KEY(c2), ADD KEY c3_10(c3(10)), ADD KEY c3_c2(c3(4),c2);
+ERROR HY000: Out of memory.
+SET DEBUG_DBUG = @saved_debug_dbug;
CREATE UNIQUE INDEX c2 ON t1(c2);
DROP INDEX c2 ON t1;
connection default;
diff --git a/mysql-test/suite/innodb/t/innodb-index-online.test b/mysql-test/suite/innodb/t/innodb-index-online.test
index 5d92b010e60..4cdbdb7c584 100644
--- a/mysql-test/suite/innodb/t/innodb-index-online.test
+++ b/mysql-test/suite/innodb/t/innodb-index-online.test
@@ -53,6 +53,10 @@ SET DEBUG_DBUG = '+d,innodb_OOM_inplace_alter';
--error ER_OUT_OF_RESOURCES
CREATE UNIQUE INDEX c2 ON t1(c2);
SET DEBUG_DBUG = @saved_debug_dbug;
+SET DEBUG_DBUG = '+d,innodb_OOM_prepare_add_index';
+--error ER_OUT_OF_RESOURCES
+ALTER TABLE t1 ADD KEY(c2), ADD KEY c3_10(c3(10)), ADD KEY c3_c2(c3(4),c2);
+SET DEBUG_DBUG = @saved_debug_dbug;
CREATE UNIQUE INDEX c2 ON t1(c2);
DROP INDEX c2 ON t1;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 84f0857dcb7..ae634c791b1 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -5659,11 +5659,9 @@ index_created:
if (index) {
dict_mem_index_free(index);
}
- a++;
error_handling_drop_uncached:
- while (a < ctx->num_to_add_index) {
- dict_mem_index_free(
- ctx->add_index[a++]);
+ while (++a < ctx->num_to_add_index) {
+ dict_mem_index_free(ctx->add_index[a]);
}
goto error_handling;
} else {
@@ -5693,10 +5691,6 @@ error_handling_drop_uncached:
/* No need to allocate a modification log. */
DBUG_ASSERT(!index->online_log);
} else {
- DBUG_EXECUTE_IF(
- "innodb_OOM_prepare_inplace_alter",
- error = DB_OUT_OF_MEMORY;
- goto error_handling_drop_uncached;);
rw_lock_x_lock(&ctx->add_index[a]->lock);
bool ok = row_log_allocate(
@@ -5708,6 +5702,14 @@ error_handling_drop_uncached:
rw_lock_x_unlock(&index->lock);
+ DBUG_EXECUTE_IF(
+ "innodb_OOM_prepare_add_index",
+ if (ok && a == 1) {
+ row_log_free(
+ index->online_log);
+ ok = false;
+ });
+
if (!ok) {
error = DB_OUT_OF_MEMORY;
goto error_handling_drop_uncached;