# 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 @@ -1851,6 +1851,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. */ @@ -1877,15 +1879,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); } /*---------------------------------------------------*/ @@ -1898,12 +1902,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 */ @@ -1911,7 +1910,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 @@ -48,6 +48,11 @@ #define INNODB_VERSION_MINOR 1 #define INNODB_VERSION_BUGFIX 4 +#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: @@ -58,13 +63,15 @@ (INNODB_VERSION_MAJOR << 8 | INNODB_VERSION_MINOR) /* auxiliary macros to help creating the version as string */ -#define __INNODB_VERSION(a, b, c) (#a "." #b "." #c) -#define _INNODB_VERSION(a, b, c) __INNODB_VERSION(a, b, c) +#define __INNODB_VERSION(a, b, c, d) (#a "." #b "." #c "-" #d) +#define _INNODB_VERSION(a, b, c, d) __INNODB_VERSION(a, b, c, d) + #define INNODB_VERSION_STR \ _INNODB_VERSION(INNODB_VERSION_MAJOR, \ INNODB_VERSION_MINOR, \ - INNODB_VERSION_BUGFIX) + INNODB_VERSION_BUGFIX, \ + PERCONA_INNODB_VERSION) #define REFMAN "http://dev.mysql.com/doc/refman/5.1/en/" 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 @@ -1194,6 +1194,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 @@ -2032,7 +2032,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) {