Commit 650ffcd3 authored by Marko Mäkelä's avatar Marko Mäkelä

Extend the innodb.log_corruption test.

Remove the dependency on unzip. Instead, generate the InnoDB files
with perl.

log_block_checksum_is_ok(): Correct the error message.

recv_scan_log_recs(): Remove the duplicated error message for
log block checksum mismatch.

innobase_start_or_create_for_mysql(): If the server is in read-only
mode or if innodb_force_recovery>=3, do not try to modify the system
tablespace. (If the doublewrite buffer or the non-core system tables
do not exist, do not try to create them.)

innodb_shutdown(): Relax a debug assertion. If the system tablespace
did not contain a doublewrite buffer and if we started up in
innodb_read_only mode or with innodb_force_recovery>=3, it will not
be created.

dict_create_or_check_sys_tablespace(): Set the flag
srv_sys_tablespaces_open when the tables exist.
parent 8481c70e
#
# empty. the real check happens in suite.pm
#
......@@ -68,8 +68,6 @@ sub skip_combinations {
unless $::mysqld_variables{'version-ssl-library'} =~ /OpenSSL (\S+)/
and $1 ge "1.0.1d";
$skip{'include/have_unzip.inc'} = 'no unzip executable' unless `unzip`;
%skip;
}
......
......@@ -11,7 +11,9 @@
# Test a corrupted MLOG_FILE_NAME record.
# valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2
# Test a corrupted MLOG_FILE_NAME record.
# valid header, invalid checkpoint 1, valid checkpoint 2
# valid header, invalid checkpoint 1, valid checkpoint 2, invalid block
# valid header, invalid checkpoint 1, valid checkpoint 2, invalid log record
ib_buffer_pool
ib_logfile0
ib_logfile1
ibdata1
......
......@@ -1679,6 +1679,11 @@ dict_create_or_check_foreign_constraint_tables(void)
return(DB_SUCCESS);
}
if (srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO) {
return(DB_READ_ONLY);
}
trx = trx_allocate_for_mysql();
trx_set_dict_operation(trx, TRX_DICT_OP_TABLE);
......@@ -1808,11 +1813,9 @@ dict_create_or_check_sys_virtual()
return(DB_SUCCESS);
}
if (srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO
|| srv_read_only_mode) {
ib::error() << "Cannot create sys_virtual system tables;"
" running in read-only mode.";
return(DB_ERROR);
if (srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO) {
return(DB_READ_ONLY);
}
trx = trx_allocate_for_mysql();
......@@ -2465,9 +2468,15 @@ dict_create_or_check_sys_tablespace(void)
if (sys_tablespaces_err == DB_SUCCESS
&& sys_datafiles_err == DB_SUCCESS) {
srv_sys_tablespaces_open = true;
return(DB_SUCCESS);
}
if (srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO) {
return(DB_READ_ONLY);
}
trx = trx_allocate_for_mysql();
trx_set_dict_operation(trx, TRX_DICT_OP_TABLE);
......@@ -2540,6 +2549,7 @@ dict_create_or_check_sys_tablespace(void)
if (err == DB_SUCCESS) {
ib::info() << "Tablespace and datafile system tables created.";
srv_sys_tablespaces_open = true;
}
/* Note: The master thread has not been started at this point. */
......
......@@ -1023,25 +1023,24 @@ recv_find_max_checkpoint(
/** Check the 4-byte checksum to the trailer checksum field of a log
block.
@param[in] log block
@param[in] block log block
@param[in] print_err whether to report checksum mismatch
@return whether the checksum matches */
bool
log_block_checksum_is_ok(
const byte* block, /*!< in: pointer to a log block */
bool print_err) /*!< in print error ? */
log_block_checksum_is_ok(const byte* block, bool print_err)
{
if (log_block_get_checksum(block) != log_block_calc_checksum(block) &&
print_err) {
ib::error() << " Log block checkpoint not correct."
bool valid
= log_block_get_checksum(block) == log_block_calc_checksum(block);
if (!valid && print_err) {
ib::error() << "Invalid log block checksum."
<< " block: " << log_block_get_hdr_no(block)
<< " checkpoint no: " << log_block_get_checkpoint_no(block)
<< " calc checkpoint: " << log_block_calc_checksum(block)
<< " stored checkpoint: " << log_block_get_checksum(block);
<< " expected: " << log_block_calc_checksum(block)
<< " found: " << log_block_get_checksum(block);
}
return(!innodb_log_checksums
|| log_block_get_checksum(block)
== log_block_calc_checksum(block));
return(valid || !innodb_log_checksums);
}
/** Try to parse a single log record body and also applies it if
......@@ -2778,12 +2777,6 @@ recv_scan_log_recs(
return (TRUE);
}
ib::error() << "Log block " << no <<
" at lsn " << scanned_lsn << " has valid"
" header, but checksum field contains "
<< log_block_get_checksum(log_block)
<< ", should be "
<< log_block_calc_checksum(log_block);
/* Garbage or an incompletely written log block.
This could be the result of killing the server
......
......@@ -2306,7 +2306,6 @@ innobase_start_or_create_for_mysql(void)
/* Open or Create SYS_TABLESPACES and SYS_DATAFILES
so that tablespace names and other metadata can be
found. */
srv_sys_tablespaces_open = true;
err = dict_create_or_check_sys_tablespace();
if (err != DB_SUCCESS) {
return(srv_init_abort(err));
......@@ -2435,7 +2434,8 @@ innobase_start_or_create_for_mysql(void)
}
/* Create the doublewrite buffer to a new tablespace */
if (buf_dblwr == NULL && !buf_dblwr_create()) {
if (!srv_read_only_mode && srv_force_recovery < SRV_FORCE_NO_TRX_UNDO
&& !buf_dblwr_create()) {
return(srv_init_abort(DB_ERROR));
}
......@@ -2503,20 +2503,22 @@ innobase_start_or_create_for_mysql(void)
/* Create the SYS_FOREIGN and SYS_FOREIGN_COLS system tables */
err = dict_create_or_check_foreign_constraint_tables();
if (err != DB_SUCCESS) {
return(srv_init_abort(err));
}
/* Create the SYS_TABLESPACES system table */
err = dict_create_or_check_sys_tablespace();
if (err != DB_SUCCESS) {
return(srv_init_abort(err));
if (err == DB_SUCCESS) {
err = dict_create_or_check_sys_tablespace();
if (err == DB_SUCCESS) {
err = dict_create_or_check_sys_virtual();
}
}
srv_sys_tablespaces_open = true;
/* Create the SYS_VIRTUAL system table */
err = dict_create_or_check_sys_virtual();
if (err != DB_SUCCESS) {
switch (err) {
case DB_SUCCESS:
break;
case DB_READ_ONLY:
if (srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO) {
break;
}
ib::error() << "Cannot create system tables in read-only mode";
/* fall through */
default:
return(srv_init_abort(err));
}
......@@ -2757,7 +2759,8 @@ innodb_shutdown()
ut_ad(dict_stats_event || !srv_was_started || srv_read_only_mode);
ut_ad(dict_sys || !srv_was_started);
ut_ad(trx_sys || !srv_was_started);
ut_ad(buf_dblwr || !srv_was_started);
ut_ad(buf_dblwr || !srv_was_started || srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);
ut_ad(lock_sys || !srv_was_started);
ut_ad(btr_search_sys || !srv_was_started);
ut_ad(ibuf || !srv_was_started);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment