diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index ea67e4a895f..c267e45ebe6 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -500,9 +500,8 @@ void lock_sys_t::close() requesting record lock are brute force (BF). If they are check is this BF-BF wait correct and if not report BF wait and assert. -@param[in] lock_rec other waiting record lock -@param[in] trx trx requesting conflicting record lock -@param[in] type_mode lock type mode of requesting trx +@param lock other waiting lock +@param trx transaction requesting conflicting lock */ static void wsrep_assert_no_bf_bf_wait(const lock_t *lock, const trx_t *trx, const unsigned type_mode = LOCK_NONE) diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index e6772492ab9..00b92285677 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -4468,10 +4468,9 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) ut_d(mysql_mutex_unlock(&buf_pool.flush_list_mutex)); if (srv_force_recovery >= SRV_FORCE_NO_LOG_REDO) { - - ib::info() << "innodb_force_recovery=6 skips redo log apply"; - - return(DB_SUCCESS); + sql_print_information("InnoDB: innodb_force_recovery=6" + " skips redo log apply"); + return err; } mysql_mutex_lock(&log_sys.mutex); @@ -4487,13 +4486,9 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) ut_ad(RECV_SCAN_SIZE <= srv_log_buffer_size); - ut_ad(recv_sys.pages.empty()); contiguous_lsn = checkpoint_lsn; switch (log_sys.log.format) { - case 0: - mysql_mutex_unlock(&log_sys.mutex); - return DB_SUCCESS; default: if (end_lsn == 0) { break; @@ -4503,8 +4498,13 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) break; } recv_sys.set_corrupt_log(); + err_exit: + err = DB_ERROR; + /* fall through */ + func_exit: + case 0: mysql_mutex_unlock(&log_sys.mutex); - return(DB_ERROR); + return err; } size_t sizeof_checkpoint; @@ -4521,14 +4521,15 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) ut_ad(!recv_sys.is_corrupt_fs() || !srv_force_recovery); if (srv_read_only_mode && recv_needed_recovery) { - mysql_mutex_unlock(&log_sys.mutex); - return(DB_READ_ONLY); + read_only: + err = DB_READ_ONLY; + goto func_exit; } if (recv_sys.is_corrupt_log() && !srv_force_recovery) { - mysql_mutex_unlock(&log_sys.mutex); - ib::warn() << "Log scan aborted at LSN " << contiguous_lsn; - return(DB_ERROR); + sql_print_warning("InnoDB: Log scan aborted at LSN " LSN_PF, + contiguous_lsn); + goto err_exit; } /* If we fail to open a tablespace while looking for FILE_CHECKPOINT, we @@ -4536,14 +4537,12 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) would not be able to open an encrypted tablespace and the flag could be set. */ if (recv_sys.is_corrupt_fs()) { - mysql_mutex_unlock(&log_sys.mutex); - return DB_ERROR; + goto err_exit; } if (recv_sys.mlog_checkpoint_lsn == 0) { lsn_t scan_lsn = log_sys.log.scanned_lsn; if (!srv_read_only_mode && scan_lsn != checkpoint_lsn) { - mysql_mutex_unlock(&log_sys.mutex); ib::error err; err << "Missing FILE_CHECKPOINT"; if (end_lsn) { @@ -4551,7 +4550,7 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) } err << " between the checkpoint " << checkpoint_lsn << " and the end " << scan_lsn << "."; - return(DB_ERROR); + goto err_exit; } log_sys.log.scanned_lsn = checkpoint_lsn; @@ -4562,8 +4561,7 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) if ((recv_sys.is_corrupt_log() && !srv_force_recovery) || recv_sys.is_corrupt_fs()) { - mysql_mutex_unlock(&log_sys.mutex); - return(DB_ERROR); + goto err_exit; } } @@ -4593,19 +4591,17 @@ completed: } if (!recv_needed_recovery) { - - ib::info() - << "The log sequence number " << flush_lsn - << " in the system tablespace does not match" - " the log sequence number " - << checkpoint_lsn << " in the " - << LOG_FILE_NAME << "!"; + sql_print_information( + "InnoDB: The log sequence number " LSN_PF + " in the system tablespace does not match" + " the log sequence number " LSN_PF + " in the ib_logfile0!", + flush_lsn, checkpoint_lsn); if (srv_read_only_mode) { - ib::error() << "innodb_read_only" - " prevents crash recovery"; - mysql_mutex_unlock(&log_sys.mutex); - return(DB_READ_ONLY); + sql_print_error("InnoDB: innodb_read_only" + " prevents crash recovery"); + goto read_only; } recv_needed_recovery = true; @@ -4626,8 +4622,7 @@ completed: rescan, missing_tablespace); if (err != DB_SUCCESS) { - mysql_mutex_unlock(&log_sys.mutex); - return(err); + goto func_exit; } /* If there is any missing tablespace and rescan is needed @@ -4656,8 +4651,7 @@ completed: rescan, missing_tablespace); if (err != DB_SUCCESS) { - mysql_mutex_unlock(&log_sys.mutex); - return err; + goto func_exit; } rescan = true; @@ -4681,8 +4675,7 @@ completed: if ((recv_sys.is_corrupt_log() && !srv_force_recovery) || recv_sys.is_corrupt_fs()) { - mysql_mutex_unlock(&log_sys.mutex); - return(DB_ERROR); + goto err_exit; } ut_ad(contiguous_lsn <= recv_sys.recovered_lsn); @@ -4700,26 +4693,26 @@ completed: ut_ad(!rescan || recv_sys.pages.empty()); } - if (log_sys.is_physical() - && (log_sys.log.scanned_lsn < checkpoint_lsn - || log_sys.log.scanned_lsn < recv_max_page_lsn)) { - - ib::error() << "We scanned the log up to " - << log_sys.log.scanned_lsn - << ". A checkpoint was at " << checkpoint_lsn << " and" - " the maximum LSN on a database page was " - << recv_max_page_lsn << ". It is possible that the" - " database is now corrupt!"; - } - - if (recv_sys.recovered_lsn < checkpoint_lsn) { - mysql_mutex_unlock(&log_sys.mutex); - - ib::error() << "Recovered only to lsn:" - << recv_sys.recovered_lsn - << " checkpoint_lsn: " << checkpoint_lsn; - - return(DB_ERROR); + if (!log_sys.is_physical()) { + } else if (recv_sys.recovered_lsn < checkpoint_lsn + || recv_sys.recovered_lsn < end_lsn) { + sql_print_error("InnoDB: The log was only scanned up to " + LSN_PF ", while the current LSN at the " + "time of the latest checkpoint " LSN_PF + " was " LSN_PF "!", + recv_sys.recovered_lsn, + checkpoint_lsn, end_lsn); + goto err_exit; + } else if (log_sys.log.scanned_lsn < checkpoint_lsn + || log_sys.log.scanned_lsn < end_lsn + || log_sys.log.scanned_lsn < recv_max_page_lsn) { + sql_print_error("InnoDB: We scanned the log up to " LSN_PF + ". A checkpoint was at " LSN_PF + " and the maximum LSN on a database page was " + LSN_PF ". It is possible that the" + " database is now corrupt!", + log_sys.log.scanned_lsn, checkpoint_lsn, + recv_max_page_lsn); } log_sys.next_checkpoint_lsn = checkpoint_lsn; @@ -4751,20 +4744,19 @@ completed: log_sys.next_checkpoint_no = ++checkpoint_no; - DBUG_EXECUTE_IF("before_final_redo_apply", - mysql_mutex_unlock(&log_sys.mutex); - return DB_ERROR;); + DBUG_EXECUTE_IF("before_final_redo_apply", goto err_exit;); mysql_mutex_lock(&recv_sys.mutex); recv_sys.apply_log_recs = true; recv_no_ibuf_operations = false; ut_d(recv_no_log_write = srv_operation == SRV_OPERATION_RESTORE || srv_operation == SRV_OPERATION_RESTORE_EXPORT); + if (srv_operation == SRV_OPERATION_NORMAL) { err = recv_rename_files(); } - mysql_mutex_unlock(&recv_sys.mutex); recv_lsn_checks_on = true; + mysql_mutex_unlock(&recv_sys.mutex); /* The database is now ready to start almost normal processing of user transactions: transaction rollbacks and the application of the log @@ -4773,9 +4765,7 @@ completed: && !srv_force_recovery) { err = DB_CORRUPTION; } - - mysql_mutex_unlock(&log_sys.mutex); - return err; + goto func_exit; } bool recv_dblwr_t::validate_page(const page_id_t page_id, diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index ce415439653..eeff97f0603 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -1512,6 +1512,7 @@ int spider_db_append_key_hint( if (str->reserve( hint_str_len - 2 + SPIDER_SQL_INDEX_USE_LEN + SPIDER_SQL_OPEN_PAREN_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); hint_str += 2; str->q_append(SPIDER_SQL_INDEX_USE_STR, SPIDER_SQL_INDEX_USE_LEN); str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); @@ -1524,10 +1525,11 @@ int spider_db_append_key_hint( if (str->reserve( hint_str_len - 3 + SPIDER_SQL_INDEX_IGNORE_LEN + SPIDER_SQL_OPEN_PAREN_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); hint_str += 3; str->q_append(SPIDER_SQL_INDEX_IGNORE_STR, SPIDER_SQL_INDEX_IGNORE_LEN); str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - str->q_append(hint_str, hint_str_len - 2); + str->q_append(hint_str, hint_str_len - 3); str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); } else if (str->reserve(hint_str_len + SPIDER_SQL_SPACE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 27b07ea824c..20ee785e879 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -7686,8 +7686,8 @@ int spider_mbase_share::convert_key_hint_str() roop_count < (int) table_share->keys; roop_count++, tmp_key_hint++) { tmp_key_hint->length(0); - if (tmp_key_hint->append(spider_share->key_hint->ptr(), - spider_share->key_hint->length(), system_charset_info)) + if (tmp_key_hint->append(spider_share->key_hint[roop_count].ptr(), + spider_share->key_hint[roop_count].length(), system_charset_info)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } } else {