Commit 250799f9 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.2 into 10.3

parents a2335b79 169c0099
CREATE TABLE t1(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES;
INSERT INTO t1 VALUES(1);
CREATE TABLE t2(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES;
INSERT INTO t1 VALUES(2);
SET GLOBAL innodb_flush_log_at_trx_commit=1;
INSERT INTO t2 VALUES(2);
# Kill the server
# Corrupt the pages
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
SELECT * FROM t1;
a
1
2
SELECT * FROM t2;
a
2
CHECK TABLE t1,t2;
Table Op Msg_type Msg_text
test.t1 check status OK
test.t2 check status OK
DROP TABLE t1, t2;
--source include/have_innodb.inc
--source include/have_file_key_management_plugin.inc
--disable_query_log
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
call mtr.add_suppression("Plugin 'InnoDB' init function returned error");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page");
call mtr.add_suppression("InnoDB: Failed to read file '.*test.t1\\.ibd' at offset 3: Table is encrypted but decrypt failed");
call mtr.add_suppression("InnoDB: The page \\[page id: space=\\d+, page number=3\\] in file '.*test.t1\\.ibd' cannot be decrypted");
call mtr.add_suppression("InnoDB: Table in tablespace \\d+ encrypted. However key management plugin or used key_version \\d+ is not found or used encryption algorithm or method does not match. Can't continue opening the table.");
--enable_query_log
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
CREATE TABLE t1(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES;
INSERT INTO t1 VALUES(1);
# Force a redo log checkpoint.
--source include/restart_mysqld.inc
--source ../../suite/innodb/include/no_checkpoint_start.inc
CREATE TABLE t2(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES;
INSERT INTO t1 VALUES(2);
SET GLOBAL innodb_flush_log_at_trx_commit=1;
INSERT INTO t2 VALUES(2);
--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1,t2;
--source ../../suite/innodb/include/no_checkpoint_end.inc
--echo # Corrupt the pages
perl;
my $ps = $ENV{INNODB_PAGE_SIZE};
my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd";
open(FILE, "+<$file") || die "Unable to open $file";
binmode FILE;
seek (FILE, $ENV{INNODB_PAGE_SIZE} * 3, SEEK_SET) or die "seek";
print FILE "junk";
close FILE or die "close";
$file = "$ENV{MYSQLD_DATADIR}/test/t2.ibd";
open(FILE, "+<$file") || die "Unable to open $file";
binmode FILE;
# Corrupt pages 1 to 3. MLOG_INIT_FILE_PAGE2 should protect us!
# Unfortunately, we are not immune to page 0 corruption.
seek (FILE, $ps, SEEK_SET) or die "seek";
print FILE chr(0xff) x ($ps * 3);
close FILE or die "close";
EOF
--source include/start_mysqld.inc
--error ER_UNKNOWN_STORAGE_ENGINE
SELECT * FROM t1;
let $restart_parameters=--innodb_force_recovery=1;
--source include/restart_mysqld.inc
SELECT * FROM t1;
SELECT * FROM t2;
CHECK TABLE t1,t2;
DROP TABLE t1, t2;
CREATE TABLE t1(a BIGINT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
CREATE TABLE t2(a BIGINT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(2);
SET GLOBAL innodb_flush_log_at_trx_commit=1;
INSERT INTO t2 VALUES(1);
# Kill the server
# Corrupt the pages
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
SELECT * FROM t1;
a
0
2
SELECT * FROM t2;
a
1
CHECK TABLE t1,t2;
Table Op Msg_type Msg_text
test.t1 check status OK
test.t2 check status OK
DROP TABLE t1, t2;
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
# #
CREATE TABLE t1 (a INT NOT NULL, b INT UNIQUE) ENGINE=InnoDB; CREATE TABLE t1 (a INT NOT NULL, b INT UNIQUE) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,2); INSERT INTO t1 VALUES (1,2);
ALTER TABLE t1 ADD PRIMARY KEY(a), ALGORITHM=INPLACE; ALTER TABLE t1 ADD PRIMARY KEY(a), LOCK=SHARED, ALGORITHM=INPLACE;
ALTER TABLE t1 DROP INDEX b, ADD INDEX (b); ALTER TABLE t1 DROP INDEX b, ADD INDEX (b), LOCK=SHARED;
# Kill the server # Kill the server
FOUND 1 /scan .*: multi-log rec MLOG_FILE_CREATE2.*page .*:0/ in mysqld.1.err FOUND 2 /scan \d+: multi-log rec MLOG_FILE_CREATE2 len \d+ page \d+:0/ in mysqld.1.err
FOUND 1 /scan .*: log rec MLOG_INDEX_LOAD/ in mysqld.1.err FOUND 3 /scan \d+: log rec MLOG_INDEX_LOAD/ in mysqld.1.err
CHECK TABLE t1; CHECK TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
......
--source include/have_innodb.inc
--disable_query_log
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
call mtr.add_suppression("Plugin 'InnoDB' init function returned error");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page");
call mtr.add_suppression("InnoDB: Failed to read file '.*test.t1\\.ibd' at offset 3: Page read from tablespace is corrupted.");
--enable_query_log
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
CREATE TABLE t1(a BIGINT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
# Force a redo log checkpoint.
--source include/restart_mysqld.inc
--source ../include/no_checkpoint_start.inc
CREATE TABLE t2(a BIGINT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(2);
SET GLOBAL innodb_flush_log_at_trx_commit=1;
INSERT INTO t2 VALUES(1);
--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1,t2;
--source ../include/no_checkpoint_end.inc
--echo # Corrupt the pages
perl;
my $ps = $ENV{INNODB_PAGE_SIZE};
my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd";
open(FILE, "+<$file") || die "Unable to open $file";
binmode FILE;
sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n";
die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
# Replace the a=1 with a=0.
$page =~ s/\x80\x0\x0\x0\x0\x0\x0\x1/\x80\x0\x0\x0\x0\x0\x0\x0/;
sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n";
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
close FILE or die "close";
$file = "$ENV{MYSQLD_DATADIR}/test/t2.ibd";
open(FILE, "+<$file") || die "Unable to open $file";
binmode FILE;
# Corrupt pages 1 to 3. MLOG_INIT_FILE_PAGE2 should protect us!
# Unfortunately, we are not immune to page 0 corruption.
seek (FILE, $ps, SEEK_SET) or die "seek";
print FILE chr(0xff) x ($ps * 3);
close FILE or die "close";
EOF
--source include/start_mysqld.inc
--error ER_UNKNOWN_STORAGE_ENGINE
SELECT * FROM t1;
let $restart_parameters=--innodb_force_recovery=1;
--source include/restart_mysqld.inc
SELECT * FROM t1;
SELECT * FROM t2;
CHECK TABLE t1,t2;
DROP TABLE t1, t2;
...@@ -19,9 +19,9 @@ CREATE TABLE t1 (a INT NOT NULL, b INT UNIQUE) ENGINE=InnoDB; ...@@ -19,9 +19,9 @@ CREATE TABLE t1 (a INT NOT NULL, b INT UNIQUE) ENGINE=InnoDB;
# MLOG_INDEX_LOAD will not be emitted for empty tables. Insert a row. # MLOG_INDEX_LOAD will not be emitted for empty tables. Insert a row.
INSERT INTO t1 VALUES (1,2); INSERT INTO t1 VALUES (1,2);
# We should get two MLOG_INDEX_LOAD for this. # We should get two MLOG_INDEX_LOAD for this.
ALTER TABLE t1 ADD PRIMARY KEY(a), ALGORITHM=INPLACE; ALTER TABLE t1 ADD PRIMARY KEY(a), LOCK=SHARED, ALGORITHM=INPLACE;
# And one MLOG_INDEX_LOAD for this. # And one MLOG_INDEX_LOAD for this.
ALTER TABLE t1 DROP INDEX b, ADD INDEX (b); ALTER TABLE t1 DROP INDEX b, ADD INDEX (b), LOCK=SHARED;
--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1; --let CLEANUP_IF_CHECKPOINT=DROP TABLE t1;
--source include/no_checkpoint_end.inc --source include/no_checkpoint_end.inc
...@@ -32,10 +32,10 @@ ALTER TABLE t1 DROP INDEX b, ADD INDEX (b); ...@@ -32,10 +32,10 @@ ALTER TABLE t1 DROP INDEX b, ADD INDEX (b);
let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err; let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_ABORT=NOT FOUND; let SEARCH_ABORT=NOT FOUND;
# ensure that we have exactly 2 records there. # ensure that we have exactly 2 records there.
let SEARCH_PATTERN=scan .*: multi-log rec MLOG_FILE_CREATE2.*page .*:0; let SEARCH_PATTERN=scan \d+: multi-log rec MLOG_FILE_CREATE2 len \d+ page \d+:0;
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
# ensure that we have exactly 3 records there. # ensure that we have exactly 3 records there.
let SEARCH_PATTERN=scan .*: log rec MLOG_INDEX_LOAD; let SEARCH_PATTERN=scan \d+: log rec MLOG_INDEX_LOAD;
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
CHECK TABLE t1; CHECK TABLE t1;
......
...@@ -5612,7 +5612,15 @@ buf_page_create( ...@@ -5612,7 +5612,15 @@ buf_page_create(
buf_block_free(free_block); buf_block_free(free_block);
return(buf_page_get_with_no_latch(page_id, page_size, mtr)); if (!recv_recovery_is_on()) {
return buf_page_get_with_no_latch(page_id, page_size,
mtr);
}
mutex_exit(&recv_sys->mutex);
block = buf_page_get_with_no_latch(page_id, page_size, mtr);
mutex_enter(&recv_sys->mutex);
return block;
} }
/* If we get here, the page was not in buf_pool: init it there */ /* If we get here, the page was not in buf_pool: init it there */
...@@ -5678,7 +5686,9 @@ buf_page_create( ...@@ -5678,7 +5686,9 @@ buf_page_create(
/* Delete possible entries for the page from the insert buffer: /* Delete possible entries for the page from the insert buffer:
such can exist if the page belonged to an index which was dropped */ such can exist if the page belonged to an index which was dropped */
if (!recv_recovery_is_on()) {
ibuf_merge_or_delete_for_page(NULL, page_id, &page_size, TRUE); ibuf_merge_or_delete_for_page(NULL, page_id, &page_size, TRUE);
}
frame = block->frame; frame = block->frame;
...@@ -5693,6 +5703,7 @@ buf_page_create( ...@@ -5693,6 +5703,7 @@ buf_page_create(
(3) key_version on encrypted pages (not page 0:0) */ (3) key_version on encrypted pages (not page 0:0) */
memset(frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, 0, 8); memset(frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, 0, 8);
memset(frame + FIL_PAGE_LSN, 0, 8);
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ut_a(++buf_dbg_counter % 5771 || buf_validate()); ut_a(++buf_dbg_counter % 5771 || buf_validate());
......
...@@ -4033,7 +4033,7 @@ static int innodb_init_params() ...@@ -4033,7 +4033,7 @@ static int innodb_init_params()
if (innobase_open_files > open_files_limit) { if (innobase_open_files > open_files_limit) {
ib::warn() << "innodb_open_files " << innobase_open_files ib::warn() << "innodb_open_files " << innobase_open_files
<< " should not be greater" << " should not be greater"
<< "than the open_files_limit " << open_files_limit; << " than the open_files_limit " << open_files_limit;
if (innobase_open_files > tc_size) { if (innobase_open_files > tc_size) {
innobase_open_files = tc_size; innobase_open_files = tc_size;
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2016, 2018, MariaDB Corporation. Copyright (c) 2016, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -4433,7 +4433,8 @@ ibuf_merge_or_delete_for_page( ...@@ -4433,7 +4433,8 @@ ibuf_merge_or_delete_for_page(
ulint dops[IBUF_OP_COUNT]; ulint dops[IBUF_OP_COUNT];
ut_ad(block == NULL || page_id == block->page.id); ut_ad(block == NULL || page_id == block->page.id);
ut_ad(block == NULL || buf_block_get_io_fix(block) == BUF_IO_READ); ut_ad(block == NULL || buf_block_get_io_fix(block) == BUF_IO_READ
|| recv_recovery_is_on());
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE
|| trx_sys_hdr_page(page_id) || trx_sys_hdr_page(page_id)
......
...@@ -235,6 +235,15 @@ class page_id_t { ...@@ -235,6 +235,15 @@ class page_id_t {
} }
bool operator!=(const page_id_t& rhs) const { return !(*this == rhs); } bool operator!=(const page_id_t& rhs) const { return !(*this == rhs); }
bool operator<(const page_id_t& rhs) const
{
if (m_space == rhs.m_space) {
return m_page_no < rhs.m_page_no;
}
return m_space < rhs.m_space;
}
/** Retrieve the tablespace id. /** Retrieve the tablespace id.
@return tablespace id */ @return tablespace id */
uint32_t space() const { return m_space; } uint32_t space() const { return m_space; }
......
...@@ -84,6 +84,9 @@ struct fil_space_t { ...@@ -84,6 +84,9 @@ struct fil_space_t {
Protected by log_sys.mutex. Protected by log_sys.mutex.
If and only if this is nonzero, the If and only if this is nonzero, the
tablespace will be in named_spaces. */ tablespace will be in named_spaces. */
/** Log sequence number of the latest MLOG_INDEX_LOAD record
that was found while parsing the redo log */
lsn_t enable_lsn;
bool stop_new_ops; bool stop_new_ops;
/*!< we set this true when we start /*!< we set this true when we start
deleting a single-table tablespace. deleting a single-table tablespace.
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2018, MariaDB Corporation. Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -255,8 +255,7 @@ or have been introduced in MySQL 5.7 or 8.0: ...@@ -255,8 +255,7 @@ or have been introduced in MySQL 5.7 or 8.0:
===================================================================== =====================================================================
The flags below only exist in fil_space_t::flags, not in FSP_SPACE_FLAGS: The flags below only exist in fil_space_t::flags, not in FSP_SPACE_FLAGS:
===================================================================== =====================================================================
25: DATA_DIR 27: DATA_DIR
26..27: ATOMIC_WRITES
28..31: COMPRESSION_LEVEL 28..31: COMPRESSION_LEVEL
*/ */
...@@ -264,9 +263,9 @@ The flags below only exist in fil_space_t::flags, not in FSP_SPACE_FLAGS: ...@@ -264,9 +263,9 @@ The flags below only exist in fil_space_t::flags, not in FSP_SPACE_FLAGS:
#define FSP_FLAGS_MEM_MASK (~0U << FSP_FLAGS_MEM_DATA_DIR) #define FSP_FLAGS_MEM_MASK (~0U << FSP_FLAGS_MEM_DATA_DIR)
/** Zero relative shift position of the DATA_DIR flag */ /** Zero relative shift position of the DATA_DIR flag */
#define FSP_FLAGS_MEM_DATA_DIR 25 #define FSP_FLAGS_MEM_DATA_DIR 27
/** Zero relative shift position of the COMPRESSION_LEVEL field */ /** Zero relative shift position of the COMPRESSION_LEVEL field */
#define FSP_FLAGS_MEM_COMPRESSION_LEVEL 26 #define FSP_FLAGS_MEM_COMPRESSION_LEVEL 28
/** Zero relative shift position of the POST_ANTELOPE field */ /** Zero relative shift position of the POST_ANTELOPE field */
#define FSP_FLAGS_POS_POST_ANTELOPE 0 #define FSP_FLAGS_POS_POST_ANTELOPE 0
......
This diff is collapsed.
...@@ -4933,23 +4933,28 @@ row_merge_build_indexes( ...@@ -4933,23 +4933,28 @@ row_merge_build_indexes(
if (indexes[i]->type & DICT_FTS) { if (indexes[i]->type & DICT_FTS) {
row_fts_psort_info_destroy(psort_info, merge_info); row_fts_psort_info_destroy(psort_info, merge_info);
fts_psort_initiated = false; fts_psort_initiated = false;
} else if (error != DB_SUCCESS || !online) { } else if (dict_index_is_spatial(indexes[i])) {
/* Do not apply any online log. */ /* We never disable redo logging for
creating SPATIAL INDEX. Avoid writing any
unnecessary MLOG_INDEX_LOAD record. */
} else if (old_table != new_table) { } else if (old_table != new_table) {
ut_ad(!sort_idx->online_log); ut_ad(!sort_idx->online_log);
ut_ad(sort_idx->online_status ut_ad(sort_idx->online_status
== ONLINE_INDEX_COMPLETE); == ONLINE_INDEX_COMPLETE);
} else {
if (dict_index_is_spatial(indexes[i])) {
/* We never disable redo logging for
creating SPATIAL INDEX. Avoid writing any
unnecessary MLOG_INDEX_LOAD record. */
} else if (FlushObserver* flush_observer = } else if (FlushObserver* flush_observer =
trx->get_flush_observer()) { trx->get_flush_observer()) {
if (error != DB_SUCCESS) {
flush_observer->interrupted();
}
flush_observer->flush(); flush_observer->flush();
row_merge_write_redo(indexes[i]); row_merge_write_redo(indexes[i]);
} }
if (old_table != new_table
|| (indexes[i]->type & (DICT_FTS | DICT_SPATIAL))
|| error != DB_SUCCESS || !online) {
/* Do not apply any online log. */
} else {
if (global_system_variables.log_warnings > 2) { if (global_system_variables.log_warnings > 2) {
sql_print_information( sql_print_information(
"InnoDB: Online DDL : Applying" "InnoDB: Online DDL : Applying"
...@@ -5056,13 +5061,7 @@ row_merge_build_indexes( ...@@ -5056,13 +5061,7 @@ row_merge_build_indexes(
flush_observer->flush(); flush_observer->flush();
trx->remove_flush_observer(); if (old_table != new_table) {
if (trx_is_interrupted(trx)) {
error = DB_INTERRUPTED;
}
if (error == DB_SUCCESS && old_table != new_table) {
for (const dict_index_t* index for (const dict_index_t* index
= dict_table_get_first_index(new_table); = dict_table_get_first_index(new_table);
index != NULL; index != NULL;
...@@ -5073,6 +5072,12 @@ row_merge_build_indexes( ...@@ -5073,6 +5072,12 @@ row_merge_build_indexes(
} }
} }
} }
trx->remove_flush_observer();
if (trx_is_interrupted(trx)) {
error = DB_INTERRUPTED;
}
} }
DBUG_RETURN(error); DBUG_RETURN(error);
......
...@@ -1984,7 +1984,8 @@ dberr_t srv_start(bool create_new_db) ...@@ -1984,7 +1984,8 @@ dberr_t srv_start(bool create_new_db)
recv_apply_hashed_log_recs(true); recv_apply_hashed_log_recs(true);
if (recv_sys->found_corrupt_log) { if (recv_sys->found_corrupt_log
|| recv_sys->found_corrupt_fs) {
return(srv_init_abort(DB_CORRUPTION)); return(srv_init_abort(DB_CORRUPTION));
} }
......
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