diff options
Diffstat (limited to 'storage/xtradb')
-rw-r--r-- | storage/xtradb/buf/buf0buf.cc | 21 | ||||
-rw-r--r-- | storage/xtradb/handler/handler0alter.cc | 84 | ||||
-rw-r--r-- | storage/xtradb/include/univ.i | 4 | ||||
-rw-r--r-- | storage/xtradb/log/log0online.cc | 41 | ||||
-rw-r--r-- | storage/xtradb/row/row0ins.cc | 6 | ||||
-rw-r--r-- | storage/xtradb/row/row0mysql.cc | 12 |
6 files changed, 97 insertions, 71 deletions
diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 44ad78b1f9a..b03aafb6fc7 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2013, 2018, MariaDB Corporation. +Copyright (c) 2013, 2019, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -924,7 +924,10 @@ buf_page_is_corrupted( /* Check whether the checksum fields have correct values */ - if (srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_NONE) { + const srv_checksum_algorithm_t curr_algo = + static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm); + + if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) { return(false); } @@ -956,9 +959,6 @@ buf_page_is_corrupted( return(false); } - const srv_checksum_algorithm_t curr_algo = - static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm); - switch (curr_algo) { case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: return !buf_page_is_checksum_valid_crc32( @@ -987,9 +987,7 @@ buf_page_is_corrupted( for writing checksums because we assume that the chance of it matching is higher. */ - if (srv_checksum_algorithm - == SRV_CHECKSUM_ALGORITHM_CRC32) { - + if (curr_algo == SRV_CHECKSUM_ALGORITHM_CRC32) { crc32 = buf_calc_page_crc32(read_buf); crc32_inited = true; @@ -999,7 +997,7 @@ buf_page_is_corrupted( return true; } } else { - ut_ad(srv_checksum_algorithm + ut_ad(curr_algo == SRV_CHECKSUM_ALGORITHM_INNODB); if (checksum_field2 @@ -1028,8 +1026,7 @@ buf_page_is_corrupted( for writing checksums because we assume that the chance of it matching is higher. */ - if (srv_checksum_algorithm - == SRV_CHECKSUM_ALGORITHM_CRC32) { + if (curr_algo == SRV_CHECKSUM_ALGORITHM_CRC32) { if (!crc32_inited) { crc32 = buf_calc_page_crc32(read_buf); @@ -1042,7 +1039,7 @@ buf_page_is_corrupted( return true; } } else { - ut_ad(srv_checksum_algorithm + ut_ad(curr_algo == SRV_CHECKSUM_ALGORITHM_INNODB); if (checksum_field1 diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index 2a5a7af1467..b36010b822a 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, 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 @@ -3811,12 +3811,14 @@ check_if_ok_to_rename: continue; } + dict_foreign_t* foreign; + for (dict_foreign_set::iterator it = prebuilt->table->foreign_set.begin(); it != prebuilt->table->foreign_set.end(); ++it) { - dict_foreign_t* foreign = *it; + foreign = *it; const char* fid = strchr(foreign->id, '/'); DBUG_ASSERT(fid); @@ -3827,7 +3829,6 @@ check_if_ok_to_rename: if (!my_strcasecmp(system_charset_info, fid, drop->name)) { - drop_fk[n_drop_fk++] = foreign; goto found_fk; } } @@ -3836,12 +3837,19 @@ check_if_ok_to_rename: drop->type_name(), drop->name); goto err_exit; found_fk: + for (ulint i = n_drop_fk; i--; ) { + if (drop_fk[i] == foreign) { + goto dup_fk; + } + } + drop_fk[n_drop_fk++] = foreign; +dup_fk: continue; } DBUG_ASSERT(n_drop_fk > 0); DBUG_ASSERT(n_drop_fk - == ha_alter_info->alter_info->drop_list.elements); + <= ha_alter_info->alter_info->drop_list.elements); } else { drop_fk = NULL; } @@ -4712,7 +4720,7 @@ err_exit: rename_foreign: trx->op_info = "renaming column in SYS_FOREIGN_COLS"; - std::list<dict_foreign_t*> fk_evict; + std::set<dict_foreign_t*> fk_evict; bool foreign_modified; for (dict_foreign_set::const_iterator it = user_table->foreign_set.begin(); @@ -4752,7 +4760,7 @@ rename_foreign: } if (foreign_modified) { - fk_evict.push_back(foreign); + fk_evict.insert(foreign); } } @@ -4794,7 +4802,7 @@ rename_foreign: } if (foreign_modified) { - fk_evict.push_back(foreign); + fk_evict.insert(foreign); } } @@ -5190,7 +5198,7 @@ commit_try_rebuild( & Alter_inplace_info::DROP_FOREIGN_KEY) || ctx->num_to_drop_fk > 0); DBUG_ASSERT(ctx->num_to_drop_fk - == ha_alter_info->alter_info->drop_list.elements); + <= ha_alter_info->alter_info->drop_list.elements); for (dict_index_t* index = dict_table_get_first_index(rebuilt_table); index; @@ -5444,7 +5452,7 @@ commit_try_norebuild( & Alter_inplace_info::DROP_FOREIGN_KEY) || ctx->num_to_drop_fk > 0); DBUG_ASSERT(ctx->num_to_drop_fk - == ha_alter_info->alter_info->drop_list.elements); + <= ha_alter_info->alter_info->drop_list.elements); for (ulint i = 0; i < ctx->num_to_add_index; i++) { dict_index_t* index = ctx->add_index[i]; @@ -5765,7 +5773,6 @@ ha_innobase::commit_inplace_alter_table( Alter_inplace_info* ha_alter_info, bool commit) { - dberr_t error; ha_innobase_inplace_ctx* ctx0 = static_cast<ha_innobase_inplace_ctx*> (ha_alter_info->handler_ctx); @@ -5845,7 +5852,7 @@ ha_innobase::commit_inplace_alter_table( transactions collected during crash recovery could be holding InnoDB locks only, not MySQL locks. */ - error = row_merge_lock_table( + dberr_t error = row_merge_lock_table( prebuilt->trx, ctx->old_table, LOCK_X); if (error != DB_SUCCESS) { @@ -6030,9 +6037,9 @@ rollback_trx: file operations that will be performed in commit_cache_rebuild(), and if none, generate the redo log for these operations. */ - error = fil_mtr_rename_log(ctx->old_table, - ctx->new_table, - ctx->tmp_name, &mtr); + dberr_t error = fil_mtr_rename_log( + ctx->old_table, ctx->new_table, ctx->tmp_name, + &mtr); if (error != DB_SUCCESS) { /* Out of memory or a problem will occur when renaming files. */ @@ -6157,39 +6164,30 @@ rollback_trx: /* Rename the tablespace files. */ commit_cache_rebuild(ctx); - error = innobase_update_foreign_cache(ctx, user_thd); - if (error != DB_SUCCESS) { - goto foreign_fail; + if (innobase_update_foreign_cache(ctx, user_thd) + != DB_SUCCESS + && prebuilt->trx->check_foreigns) { +foreign_fail: + push_warning_printf( + user_thd, + Sql_condition::WARN_LEVEL_WARN, + ER_ALTER_INFO, + "failed to load FOREIGN KEY" + " constraints"); } } else { - error = innobase_update_foreign_cache(ctx, user_thd); + bool fk_fail = innobase_update_foreign_cache( + ctx, user_thd) != DB_SUCCESS; - if (error != DB_SUCCESS) { -foreign_fail: - /* The data dictionary cache - should be corrupted now. The - best solution should be to - kill and restart the server, - but the *.frm file has not - been replaced yet. */ - my_error(ER_CANNOT_ADD_FOREIGN, - MYF(0)); - sql_print_error( - "InnoDB: dict_load_foreigns()" - " returned %u for %s", - (unsigned) error, - thd_query_string(user_thd) - ->str); - ut_ad(0); - } else { - if (!commit_cache_norebuild( - ctx, table, trx)) { - ut_a(!prebuilt->trx->check_foreigns); - } + if (!commit_cache_norebuild(ctx, table, trx)) { + fk_fail = true; + ut_ad(!prebuilt->trx->check_foreigns); + } - innobase_rename_columns_cache( - ha_alter_info, table, - ctx->new_table); + innobase_rename_columns_cache(ha_alter_info, table, + ctx->new_table); + if (fk_fail && prebuilt->trx->check_foreigns) { + goto foreign_fail; } } DBUG_INJECT_CRASH("ib_commit_inplace_crash", diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index 7da0dfe4728..6d1520bc6a3 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -45,10 +45,10 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 41 +#define INNODB_VERSION_BUGFIX 42 #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 84.1 +#define PERCONA_INNODB_VERSION 84.2 #endif /* Enable UNIV_LOG_ARCHIVE in XtraDB */ diff --git a/storage/xtradb/log/log0online.cc b/storage/xtradb/log/log0online.cc index 42e92ea6f0e..bc1667e1c20 100644 --- a/storage/xtradb/log/log0online.cc +++ b/storage/xtradb/log/log0online.cc @@ -1864,6 +1864,8 @@ log_online_purge_changed_page_bitmaps( for (i = 0; i < bitmap_files.count; i++) { + char full_bmp_file_name[2 * FN_REFLEN + 2]; + /* We consider the end LSN of the current bitmap, derived from the start LSN of the subsequent bitmap file, to determine whether to remove the current bitmap. Note that bitmap_files @@ -1879,8 +1881,45 @@ log_online_purge_changed_page_bitmaps( break; } + + /* In some non-trivial cases the sequence of .xdb files may + have gaps. For instance: + ib_modified_log_1_0.xdb + ib_modified_log_2_<mmm>.xdb + ib_modified_log_4_<nnn>.xdb + Adding this check as a safety precaution. */ + if (bitmap_files.files[i].name[0] == '\0') + continue; + + /* If redo log tracking is enabled, reuse 'bmp_file_home' + from 'log_bmp_sys'. Otherwise, compose the full '.xdb' file + path from 'srv_data_home', adding a path separator if + necessary. */ + if (log_bmp_sys != NULL) { + ut_snprintf(full_bmp_file_name, + sizeof(full_bmp_file_name), + "%s%s", log_bmp_sys->bmp_file_home, + bitmap_files.files[i].name); + } + else { + char separator[2] = {0, 0}; + const size_t srv_data_home_len = + strlen(srv_data_home); + + ut_a(srv_data_home_len < FN_REFLEN); + if (srv_data_home_len != 0 && + srv_data_home[srv_data_home_len - 1] != + SRV_PATH_SEPARATOR) { + separator[0] = SRV_PATH_SEPARATOR; + } + ut_snprintf(full_bmp_file_name, + sizeof(full_bmp_file_name), "%s%s%s", + srv_data_home, separator, + bitmap_files.files[i].name); + } + if (!os_file_delete_if_exists(innodb_file_bmp_key, - bitmap_files.files[i].name)) { + full_bmp_file_name)) { os_file_get_last_error(TRUE); result = TRUE; diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc index b14d43e4f42..476c18680f3 100644 --- a/storage/xtradb/row/row0ins.cc +++ b/storage/xtradb/row/row0ins.cc @@ -56,6 +56,7 @@ Created 4/20/1996 Heikki Tuuri #include "m_string.h" #ifdef WITH_WSREP +#include <mysql/service_wsrep.h> #include "../../../wsrep/wsrep_api.h" #include "wsrep_mysqld_c.h" #endif /* WITH_WSREP */ @@ -1657,6 +1658,9 @@ run_again: if (check_ref) { err = DB_SUCCESS; #ifdef WITH_WSREP + if (!wsrep_on(trx->mysql_thd)) { + goto end_scan; + } enum wsrep_key_type key_type; if (upd_node != NULL) { key_type = WSREP_KEY_SHARED; @@ -1673,7 +1677,7 @@ run_again: } err = wsrep_append_foreign_key( - thr_get_trx(thr), + trx, foreign, rec, check_index, diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index 6c11dd78d7a..93a4db98e7b 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -5132,18 +5132,6 @@ row_rename_table_for_mysql( goto funct_exit; } - /* Wait for background fts sync to finish */ - for (retry = 1; dict_fts_index_syncing(table); ++retry) { - DICT_BG_YIELD(trx); - if (retry % 100 == 0) { - ib_logf(IB_LOG_LEVEL_INFO, - "Unable to rename table %s to new name" - " %s because FTS sync is running on table." - " Retrying\n", - old_name, new_name); - } - } - /* We use the private SQL parser of Innobase to generate the query graphs needed in updating the dictionary data from system tables. */ |