# name : innodb_fix_misc.patch # introduced : 11 or before # maintainer : Yasufumi # #!!! notice !!! # Any small change to this file in the main branch # should be done or reviewed by the maintainer! # # comment: http://lists.mysql.com/commits/112400 is applied also for innodb_plugin # to pass innodb_bug53756.test by innodb_plugin diff -ruN a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c --- a/storage/innobase/dict/dict0load.c 2010-12-04 15:37:50.559480289 +0900 +++ b/storage/innobase/dict/dict0load.c 2010-12-04 15:57:53.078513745 +0900 @@ -1868,6 +1868,8 @@ ut_ad(mutex_own(&(dict_sys->mutex))); + table = NULL; + /* NOTE that the operation of this function is protected by the dictionary mutex, and therefore no deadlocks can occur with other dictionary operations. */ @@ -1894,15 +1896,17 @@ BTR_SEARCH_LEAF, &pcur, &mtr); rec = btr_pcur_get_rec(&pcur); - if (!btr_pcur_is_on_user_rec(&pcur) - || rec_get_deleted_flag(rec, 0)) { + if (!btr_pcur_is_on_user_rec(&pcur)) { /* Not found */ + goto func_exit; + } - btr_pcur_close(&pcur); - mtr_commit(&mtr); - mem_heap_free(heap); - - return(NULL); + /* Find the first record that is not delete marked */ + while (rec_get_deleted_flag(rec, 0)) { + if (!btr_pcur_move_to_next_user_rec(&pcur, &mtr)) { + goto func_exit; + } + rec = btr_pcur_get_rec(&pcur); } /*---------------------------------------------------*/ @@ -1915,12 +1919,7 @@ /* Check if the table id in record is the one searched for */ if (table_id != mach_read_from_8(field)) { - - btr_pcur_close(&pcur); - mtr_commit(&mtr); - mem_heap_free(heap); - - return(NULL); + goto func_exit; } /* Now we get the table name from the record */ @@ -1928,7 +1927,7 @@ /* Load the table definition to memory */ table = dict_load_table(mem_heap_strdupl(heap, (char*) field, len), TRUE); - +func_exit: btr_pcur_close(&pcur); mtr_commit(&mtr); mem_heap_free(heap); diff -ruN a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc --- a/storage/innobase/handler/ha_innodb.cc 2010-12-04 15:57:13.035513990 +0900 +++ b/storage/innobase/handler/ha_innodb.cc 2010-12-04 15:57:53.084513775 +0900 @@ -12007,7 +12007,7 @@ &innobase_storage_engine, innobase_hton_name, "Innobase Oy", - "Supports transactions, row-level locking, and foreign keys", + "Percona-XtraDB, Supports transactions, row-level locking, and foreign keys", PLUGIN_LICENSE_GPL, innobase_init, /* Plugin Init */ NULL, /* Plugin Deinit */ diff -ruN a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i --- a/storage/innobase/include/univ.i 2010-12-04 15:57:13.050485224 +0900 +++ b/storage/innobase/include/univ.i 2010-12-04 15:57:53.091592933 +0900 @@ -53,6 +53,11 @@ #define INNODB_VERSION_MINOR 1 #define INNODB_VERSION_BUGFIX 5 +#ifndef PERCONA_INNODB_VERSION +#define PERCONA_INNODB_VERSION 12.1 +#endif + + /* The following is the InnoDB version as shown in SELECT plugin_version FROM information_schema.plugins; calculated in make_version_string() in sql/sql_show.cc like this: @@ -65,7 +70,8 @@ #define INNODB_VERSION_STR \ IB_TO_STR(INNODB_VERSION_MAJOR) "." \ IB_TO_STR(INNODB_VERSION_MINOR) "." \ - IB_TO_STR(INNODB_VERSION_BUGFIX) + IB_TO_STR(INNODB_VERSION_BUGFIX) "-" \ + IB_TO_STR(PERCONA_INNODB_VERSION) #define REFMAN "http://dev.mysql.com/doc/refman/" \ IB_TO_STR(MYSQL_MAJOR_VERSION) "." \ diff -ruN a/storage/innobase/mtr/mtr0log.c b/storage/innobase/mtr/mtr0log.c --- a/storage/innobase/mtr/mtr0log.c 2010-12-04 02:58:26.000000000 +0900 +++ b/storage/innobase/mtr/mtr0log.c 2011-02-03 15:17:14.000000000 +0900 @@ -408,7 +408,7 @@ ptr += 2; if (UNIV_UNLIKELY(offset >= UNIV_PAGE_SIZE) - || UNIV_UNLIKELY(len + offset) > UNIV_PAGE_SIZE) { + || UNIV_UNLIKELY(len + offset > UNIV_PAGE_SIZE)) { recv_sys->found_corrupt_log = TRUE; return(NULL); diff -ruN a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c --- a/storage/innobase/row/row0mysql.c 2010-12-04 15:37:50.598481116 +0900 +++ b/storage/innobase/row/row0mysql.c 2010-12-04 15:57:53.092563335 +0900 @@ -51,6 +51,7 @@ #include "btr0sea.h" #include "fil0fil.h" #include "ibuf0ibuf.h" +#include "ha_prototypes.h" /** Provide optional 4.x backwards compatibility for 5.0 and above */ UNIV_INTERN ibool row_rollback_on_timeout = FALSE; @@ -1194,6 +1195,13 @@ thr = que_fork_get_first_thr(prebuilt->ins_graph); + if (!prebuilt->mysql_has_locked && !(prebuilt->table->flags & (DICT_TF2_TEMPORARY << DICT_TF2_SHIFT))) { + fprintf(stderr, "InnoDB: Error: row_insert_for_mysql is called without ha_innobase::external_lock()\n"); + if (trx->mysql_thd != NULL) { + innobase_mysql_print_thd(stderr, trx->mysql_thd, 600); + } + } + if (prebuilt->sql_stat_start) { node->state = INS_NODE_SET_IX_LOCK; prebuilt->sql_stat_start = FALSE; diff -ruN a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c --- a/storage/innobase/row/row0sel.c 2010-12-04 15:52:23.494514495 +0900 +++ b/storage/innobase/row/row0sel.c 2010-12-04 16:01:38.320883699 +0900 @@ -3366,6 +3366,7 @@ ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint* offsets = offsets_; ibool table_lock_waited = FALSE; + ibool problematic_use = FALSE; rec_offs_init(offsets_); @@ -3732,6 +3733,17 @@ /* Do some start-of-statement preparations */ + if (!prebuilt->mysql_has_locked) { + if (!(prebuilt->table->flags & (DICT_TF2_TEMPORARY << DICT_TF2_SHIFT))) { + fprintf(stderr, "InnoDB: Error: row_search_for_mysql() is called without ha_innobase::external_lock()\n"); + if (trx->mysql_thd != NULL) { + innobase_mysql_print_thd(stderr, trx->mysql_thd, 600); + } + } + problematic_use = TRUE; + } +retry_check: + if (!prebuilt->sql_stat_start) { /* No need to set an intention lock or assign a read view */ @@ -3742,6 +3754,18 @@ " perform a consistent read\n" "InnoDB: but the read view is not assigned!\n", stderr); + if (problematic_use) { + fprintf(stderr, "InnoDB: It may be caused by calling " + "without ha_innobase::external_lock()\n" + "InnoDB: For the first-aid, avoiding the crash. " + "But it should be fixed ASAP.\n"); + if (prebuilt->table->flags & (DICT_TF2_TEMPORARY << DICT_TF2_SHIFT) + && trx->mysql_thd != NULL) { + innobase_mysql_print_thd(stderr, trx->mysql_thd, 600); + } + prebuilt->sql_stat_start = TRUE; + goto retry_check; + } trx_print(stderr, trx, 600); fputc('\n', stderr); ut_error; diff -ruN a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c --- a/storage/innobase/srv/srv0start.c 2010-12-04 15:57:13.073495392 +0900 +++ b/storage/innobase/srv/srv0start.c 2010-12-04 16:02:50.704884053 +0900 @@ -2153,7 +2153,7 @@ if (srv_print_verbose_log) { ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: %s started; " + " Percona XtraDB (http://www.percona.com) %s started; " "log sequence number %llu\n", INNODB_VERSION_STR, srv_start_lsn); } diff -ruN a/storage/innobase/trx/trx0purge.c b/storage/innobase/trx/trx0purge.c --- a/storage/innobase/trx/trx0purge.c 2010-11-03 07:01:13.000000000 +0900 +++ b/storage/innobase/trx/trx0purge.c 2010-12-04 15:57:53.106551154 +0900 @@ -1131,8 +1131,7 @@ /* If we cannot advance the 'purge view' because of an old 'consistent read view', then the DML statements cannot be delayed. Also, srv_max_purge_lag <= 0 means 'infinity'. */ - if (srv_max_purge_lag > 0 - && !UT_LIST_GET_LAST(trx_sys->view_list)) { + if (srv_max_purge_lag > 0) { float ratio = (float) trx_sys->rseg_history_len / srv_max_purge_lag; if (ratio > ULINT_MAX / 10000) {