From f5c5d23a209c0e193c369220dade6261bb71a561 Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Wed, 10 Nov 2010 21:27:10 -0800 Subject: [PATCH 1/2] Port fix for Bug #48026 to 5.1 built-in and plugin: Log start and end of InnoDB buffer pool initialization to the error log --- storage/innobase/srv/srv0start.c | 22 ++++++++++++++++++++++ storage/innodb_plugin/ChangeLog | 6 ++++++ storage/innodb_plugin/srv/srv0start.c | 20 ++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c index 9d057110d11..4c4360f819e 100644 --- a/storage/innobase/srv/srv0start.c +++ b/storage/innobase/srv/srv0start.c @@ -1247,6 +1247,23 @@ innobase_start_or_create_for_mysql(void) fil_init(srv_max_n_open_files); + /* Print time to initialize the buffer pool */ + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Initializing buffer pool, size ="); + + if (srv_pool_size * UNIV_PAGE_SIZE >= 1024 * 1024 * 1024) { + fprintf(stderr, + " %.1fG\n", + ((double) (srv_pool_size * UNIV_PAGE_SIZE)) + / (1024 * 1024 * 1024)); + } else { + fprintf(stderr, + " %.1fM\n", + ((double) (srv_pool_size * UNIV_PAGE_SIZE)) + / (1024 * 1024)); + } + if (srv_use_awe) { fprintf(stderr, "InnoDB: Using AWE: Memory window is %lu MB" @@ -1267,6 +1284,8 @@ innobase_start_or_create_for_mysql(void) srv_pool_size); } + ut_print_timestamp(stderr); + if (ret == NULL) { fprintf(stderr, "InnoDB: Fatal error: cannot allocate the memory" @@ -1275,6 +1294,9 @@ innobase_start_or_create_for_mysql(void) return(DB_ERROR); } + fprintf(stderr, + " InnoDB: Completed initialization of buffer pool\n"); + fsp_init(); log_init(); diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index f99c49d63f6..eaf16a923da 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,9 @@ +2010-11-10 The InnoDB Team + + * srv/srv0start.c: + Fix Bug #48026 Log start and end of InnoDB buffer pool + initialization to the error log + 2010-11-03 The InnoDB Team * include/btr0btr.h, include/btr0btr.ic, dict/dict0crea.c: diff --git a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/srv0start.c index f823b72fbc1..73f8f319704 100644 --- a/storage/innodb_plugin/srv/srv0start.c +++ b/storage/innodb_plugin/srv/srv0start.c @@ -1286,8 +1286,25 @@ innobase_start_or_create_for_mysql(void) fil_init(srv_file_per_table ? 50000 : 5000, srv_max_n_open_files); + /* Print time to initialize the buffer pool */ + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Initializing buffer pool, size ="); + + if (srv_buf_pool_size >= 1024 * 1024 * 1024) { + fprintf(stderr, + " %.1fG\n", + ((double) srv_buf_pool_size) / (1024 * 1024 * 1024)); + } else { + fprintf(stderr, + " %.1fM\n", + ((double) srv_buf_pool_size) / (1024 * 1024)); + } + ret = buf_pool_init(); + ut_print_timestamp(stderr); + if (ret == NULL) { fprintf(stderr, "InnoDB: Fatal error: cannot allocate the memory" @@ -1296,6 +1313,9 @@ innobase_start_or_create_for_mysql(void) return(DB_ERROR); } + fprintf(stderr, + " InnoDB: Completed initialization of buffer pool\n"); + #ifdef UNIV_DEBUG /* We have observed deadlocks with a 5MB buffer pool but the actual lower limit could very well be a little higher. */ From 8b7eaab37d7513e2927b662b43edb0104d8daa5f Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Wed, 10 Nov 2010 21:32:12 -0800 Subject: [PATCH 2/2] Fix Bug #48026 Log start and end of InnoDB buffer pool initialization to the error log rb://513 approved by Sunny Bains --- storage/innodb_plugin/ChangeLog | 6 ++++++ storage/innodb_plugin/dict/dict0dict.c | 11 +++++++++-- storage/innodb_plugin/handler/handler0alter.cc | 11 ++++++----- storage/innodb_plugin/include/dict0dict.h | 3 ++- storage/innodb_plugin/row/row0merge.c | 2 +- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index eaf16a923da..86b0c153704 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,9 @@ +2010-11-10 The InnoDB Team + + * dict/dict0dict.c, handler/handler0alter.cc, include/dict0dict.h + row/row0merge.c: + Fix Bug #55084 Innodb crash and corruption after alter table + 2010-11-10 The InnoDB Team * srv/srv0start.c: diff --git a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/dict0dict.c index 2adae4afffb..774e7f213e8 100644 --- a/storage/innodb_plugin/dict/dict0dict.c +++ b/storage/innodb_plugin/dict/dict0dict.c @@ -4842,7 +4842,8 @@ void dict_table_replace_index_in_foreign_list( /*=====================================*/ dict_table_t* table, /*!< in/out: table */ - dict_index_t* index) /*!< in: index to be replaced */ + dict_index_t* index, /*!< in: index to be replaced */ + const trx_t* trx) /*!< in: transaction handle */ { dict_foreign_t* foreign; @@ -4853,7 +4854,13 @@ dict_table_replace_index_in_foreign_list( if (foreign->foreign_index == index) { dict_index_t* new_index = dict_foreign_find_equiv_index(foreign); - ut_a(new_index); + + /* There must exist an alternative index if + check_foreigns (FOREIGN_KEY_CHECKS) is on, + since ha_innobase::prepare_drop_index had done + the check before we reach here. */ + + ut_a(new_index || !trx->check_foreigns); foreign->foreign_index = new_index; } diff --git a/storage/innodb_plugin/handler/handler0alter.cc b/storage/innodb_plugin/handler/handler0alter.cc index e936bfafa0e..517445f7e69 100644 --- a/storage/innodb_plugin/handler/handler0alter.cc +++ b/storage/innodb_plugin/handler/handler0alter.cc @@ -1012,12 +1012,13 @@ ha_innobase::prepare_drop_index( index->to_be_dropped = TRUE; } - /* If FOREIGN_KEY_CHECK = 1 you may not drop an index defined + /* If FOREIGN_KEY_CHECKS = 1 you may not drop an index defined for a foreign key constraint because InnoDB requires that both - tables contain indexes for the constraint. Note that CREATE - INDEX id ON table does a CREATE INDEX and DROP INDEX, and we - can ignore here foreign keys because a new index for the - foreign key has already been created. + tables contain indexes for the constraint. Such index can + be dropped only if FOREIGN_KEY_CHECKS is set to 0. + Note that CREATE INDEX id ON table does a CREATE INDEX and + DROP INDEX, and we can ignore here foreign keys because a + new index for the foreign key has already been created. We check for the foreign key constraints after marking the candidate indexes for deletion, because when we check for an diff --git a/storage/innodb_plugin/include/dict0dict.h b/storage/innodb_plugin/include/dict0dict.h index 44db7b3df1d..7b02111fb87 100644 --- a/storage/innodb_plugin/include/dict0dict.h +++ b/storage/innodb_plugin/include/dict0dict.h @@ -318,7 +318,8 @@ void dict_table_replace_index_in_foreign_list( /*=====================================*/ dict_table_t* table, /*!< in/out: table */ - dict_index_t* index); /*!< in: index to be replaced */ + dict_index_t* index, /*!< in: index to be replaced */ + const trx_t* trx); /*!< in: transaction handle */ /*********************************************************************//** Checks if a index is defined for a foreign key constraint. Index is a part of a foreign key constraint if the index is referenced by foreign key diff --git a/storage/innodb_plugin/row/row0merge.c b/storage/innodb_plugin/row/row0merge.c index 05d77ad7f19..160edd32fbf 100644 --- a/storage/innodb_plugin/row/row0merge.c +++ b/storage/innodb_plugin/row/row0merge.c @@ -2043,7 +2043,7 @@ row_merge_drop_index( /* Replace this index with another equivalent index for all foreign key constraints on this table where this index is used */ - dict_table_replace_index_in_foreign_list(table, index); + dict_table_replace_index_in_foreign_list(table, index, trx); dict_index_remove_from_cache(table, index); trx->op_info = "";