diff options
Diffstat (limited to 'storage/innobase/dict')
-rw-r--r-- | storage/innobase/dict/dict0dict.cc | 66 | ||||
-rw-r--r-- | storage/innobase/dict/dict0mem.cc | 13 |
2 files changed, 46 insertions, 33 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index ae4cb0b845a..b2def1edffe 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -556,6 +556,8 @@ dict_table_close( indexes after an aborted online index creation */ { + + ibool drop_aborted; if (!dict_locked) { mutex_enter(&dict_sys->mutex); } @@ -563,6 +565,11 @@ dict_table_close( ut_ad(mutex_own(&dict_sys->mutex)); ut_a(table->n_ref_count > 0); + drop_aborted = try_drop + && table->drop_aborted + && table->n_ref_count == 1 + && dict_table_get_first_index(table); + --table->n_ref_count; /* Force persistent stats re-read upon next open of the table @@ -591,12 +598,6 @@ dict_table_close( if (!dict_locked) { table_id_t table_id = table->id; - ibool drop_aborted; - - drop_aborted = try_drop - && table->drop_aborted - && table->n_ref_count == 1 - && dict_table_get_first_index(table); mutex_exit(&dict_sys->mutex); @@ -2054,6 +2055,33 @@ dict_table_remove_from_cache_low( foreign->referenced_index = NULL; } + /* The check for dropped index should happen before we release + all the indexes */ + + if (lru_evict && table->drop_aborted) { + /* Do as dict_table_try_drop_aborted() does. */ + + trx_t* trx = trx_allocate_for_background(); + + ut_ad(mutex_own(&dict_sys->mutex)); +#ifdef UNIV_SYNC_DEBUG + ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX)); +#endif /* UNIV_SYNC_DEBUG */ + /* Mimic row_mysql_lock_data_dictionary(). */ + trx->dict_operation_lock_mode = RW_X_LATCH; + + trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); + + /* Silence a debug assertion in row_merge_drop_indexes(). */ + ut_d(table->n_ref_count++); + row_merge_drop_indexes(trx, table, TRUE); + ut_d(table->n_ref_count--); + ut_ad(table->n_ref_count == 0); + trx_commit_for_mysql(trx); + trx->dict_operation_lock_mode = 0; + trx_free_for_background(trx); + } + /* Remove the indexes from the cache */ for (index = UT_LIST_GET_LAST(table->indexes); @@ -2086,30 +2114,6 @@ dict_table_remove_from_cache_low( dict_table_autoinc_store(table); } - if (lru_evict && table->drop_aborted) { - /* Do as dict_table_try_drop_aborted() does. */ - - trx_t* trx = trx_allocate_for_background(); - - ut_ad(mutex_own(&dict_sys->mutex)); -#ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX)); -#endif /* UNIV_SYNC_DEBUG */ - /* Mimic row_mysql_lock_data_dictionary(). */ - trx->dict_operation_lock_mode = RW_X_LATCH; - - trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); - - /* Silence a debug assertion in row_merge_drop_indexes(). */ - ut_d(table->n_ref_count++); - row_merge_drop_indexes(trx, table, TRUE); - ut_d(table->n_ref_count--); - ut_ad(table->n_ref_count == 0); - trx_commit_for_mysql(trx); - trx->dict_operation_lock_mode = 0; - trx_free_for_background(trx); - } - size = mem_heap_get_size(table->heap) + strlen(table->name) + 1; ut_ad(dict_sys->size >= size); diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index b39e1e171ee..f5bfd49e9f6 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -300,11 +300,20 @@ dict_mem_table_col_rename_low( char* col_names; if (to_len > from_len) { + ulint table_size_before_rename_col + = mem_heap_get_size(table->heap); col_names = static_cast<char*>( mem_heap_alloc( table->heap, full_len + to_len - from_len)); - + ulint table_size_after_rename_col + = mem_heap_get_size(table->heap); + if (table_size_before_rename_col + != table_size_after_rename_col) { + dict_sys->size += + table_size_after_rename_col + - table_size_before_rename_col; + } memcpy(col_names, table->col_names, prefix_len); } else { col_names = const_cast<char*>(table->col_names); |