Commit 4af45463 authored by Sunny Bains's avatar Sunny Bains

BUG#12739098 - 62401: ASSERTION TRX->ERROR_STATE == DB_SUCCESS, QUE0QUE.C LINE 1264 ON TRUNCATE

            
During FIC error handling the trx->error_state was not being set to DB_SUCCESS
after failure, before attempting the next DDL SQL operation. This reset to
DB_SUCCESS is somewhat of a requirement though not explicitly stated anywhere.
The fix is to reset it to DB_SUCCESS in row0merge.cc if row_merge_rename_indexes
or row_merge_drop_index functions fail, also reset to DB_SUCCESS at trx commit.
				          
rb://935 Approved by Jimmy Yang.
parent 17afdb90
...@@ -2012,7 +2012,7 @@ row_merge_drop_index( ...@@ -2012,7 +2012,7 @@ row_merge_drop_index(
tables in Innobase. Deleting a row from SYS_INDEXES table also tables in Innobase. Deleting a row from SYS_INDEXES table also
frees the file segments of the B-tree associated with the index. */ frees the file segments of the B-tree associated with the index. */
static const char str1[] = static const char sql[] =
"PROCEDURE DROP_INDEX_PROC () IS\n" "PROCEDURE DROP_INDEX_PROC () IS\n"
"BEGIN\n" "BEGIN\n"
/* Rename the index, so that it will be dropped by /* Rename the index, so that it will be dropped by
...@@ -2036,9 +2036,19 @@ row_merge_drop_index( ...@@ -2036,9 +2036,19 @@ row_merge_drop_index(
ut_a(trx->dict_operation_lock_mode == RW_X_LATCH); ut_a(trx->dict_operation_lock_mode == RW_X_LATCH);
err = que_eval_sql(info, str1, FALSE, trx); err = que_eval_sql(info, sql, FALSE, trx);
ut_a(err == DB_SUCCESS);
if (err != DB_SUCCESS) {
/* Even though we ensure that DDL transactions are WAIT
and DEADLOCK free, we could encounter other errors e.g.,
DB_TOO_MANY_TRANSACTIONS. */
trx->error_state = DB_SUCCESS;
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Error: row_merge_drop_index failed "
"with error code: %lu.\n", (ulint) err);
}
/* Replace this index with another equivalent index for all /* Replace this index with another equivalent index for all
foreign key constraints on this table where this index is used */ foreign key constraints on this table where this index is used */
...@@ -2290,7 +2300,7 @@ row_merge_rename_indexes( ...@@ -2290,7 +2300,7 @@ row_merge_rename_indexes(
/* We use the private SQL parser of Innobase to generate the /* We use the private SQL parser of Innobase to generate the
query graphs needed in renaming indexes. */ query graphs needed in renaming indexes. */
static const char rename_indexes[] = static const char sql[] =
"PROCEDURE RENAME_INDEXES_PROC () IS\n" "PROCEDURE RENAME_INDEXES_PROC () IS\n"
"BEGIN\n" "BEGIN\n"
"UPDATE SYS_INDEXES SET NAME=SUBSTR(NAME,1,LENGTH(NAME)-1)\n" "UPDATE SYS_INDEXES SET NAME=SUBSTR(NAME,1,LENGTH(NAME)-1)\n"
...@@ -2306,7 +2316,7 @@ row_merge_rename_indexes( ...@@ -2306,7 +2316,7 @@ row_merge_rename_indexes(
pars_info_add_dulint_literal(info, "tableid", table->id); pars_info_add_dulint_literal(info, "tableid", table->id);
err = que_eval_sql(info, rename_indexes, FALSE, trx); err = que_eval_sql(info, sql, FALSE, trx);
if (err == DB_SUCCESS) { if (err == DB_SUCCESS) {
dict_index_t* index = dict_table_get_first_index(table); dict_index_t* index = dict_table_get_first_index(table);
...@@ -2316,6 +2326,15 @@ row_merge_rename_indexes( ...@@ -2316,6 +2326,15 @@ row_merge_rename_indexes(
} }
index = dict_table_get_next_index(index); index = dict_table_get_next_index(index);
} while (index); } while (index);
} else {
/* Even though we ensure that DDL transactions are WAIT
and DEADLOCK free, we could encounter other errors e.g.,
DB_TOO_MANY_TRANSACTIONS. */
trx->error_state = DB_SUCCESS;
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Error: row_merge_rename_indexes "
"failed with error code: %lu.\n", (ulint) err);
} }
trx->op_info = ""; trx->op_info = "";
...@@ -2354,7 +2373,7 @@ row_merge_rename_tables( ...@@ -2354,7 +2373,7 @@ row_merge_rename_tables(
memcpy(old_name, old_table->name, strlen(old_table->name) + 1); memcpy(old_name, old_table->name, strlen(old_table->name) + 1);
} else { } else {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, "InnoDB: too long table name: '%s', " fprintf(stderr, " InnoDB: too long table name: '%s', "
"max length is %d\n", old_table->name, "max length is %d\n", old_table->name,
MAX_FULL_NAME_LEN); MAX_FULL_NAME_LEN);
ut_error; ut_error;
......
...@@ -1008,6 +1008,8 @@ trx_commit_off_kernel( ...@@ -1008,6 +1008,8 @@ trx_commit_off_kernel(
ut_ad(UT_LIST_GET_LEN(trx->trx_locks) == 0); ut_ad(UT_LIST_GET_LEN(trx->trx_locks) == 0);
UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx); UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx);
trx->error_state = DB_SUCCESS;
} }
/****************************************************************//** /****************************************************************//**
......
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