Skip to content

Commit

Permalink
MDEV-13818: Revert an incorrect change
Browse files Browse the repository at this point in the history
In commit d30f17a 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.
  • Loading branch information
dr-m committed Mar 8, 2019
1 parent 2d0dd62 commit 136d21c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions mysql-test/suite/innodb/r/innodb-index-online.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/suite/innodb/t/innodb-index-online.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
18 changes: 10 additions & 8 deletions storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5659,11 +5659,9 @@ prepare_inplace_alter_table_dict(
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 {
Expand Down Expand Up @@ -5693,10 +5691,6 @@ prepare_inplace_alter_table_dict(
/* 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(
Expand All @@ -5708,6 +5702,14 @@ prepare_inplace_alter_table_dict(

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;
Expand Down

0 comments on commit 136d21c

Please sign in to comment.