mariadb/mysql-test/suite/innodb/t/innodb_force_recovery.test
Marko Mäkelä 0288fa619f Do allow writes for innodb_force_recovery=2 or 3
While the primary purpose of innodb_force_recovery is to allow
data to be rescued from an InnoDB instance that would crash due
to some data corruption, the settings 1, 2, or 3 are relatively
safe to use and there is no need to prevent write transactions
in these modes.

The setting innodb_force_recovery=4 and above can cause database
corruption. For those modes, we already set the flag
high_level_read_only to disable modifications, except DROP TABLE.

MODIFICATIONS_NOT_ALLOWED_MSG_FORCE_RECOVERY: Remove. There is no
need to spam the error log for each refused DML operation. It suffices
to return an error to the client. There will be messages at startup
if innodb_read_only or innodb_force_recovery are preventing writes.
2017-06-23 09:54:31 +03:00

171 lines
4.2 KiB
Text

# Not supported in embedded
--source include/not_embedded.inc
# This test case needs InnoDB.
-- source include/have_innodb.inc
--disable_query_log
call mtr.add_suppression("InnoDB: Failed to find tablespace for table .* in the cache. Attempting to load the tablespace with space id");
call mtr.add_suppression("InnoDB: Allocated tablespace ID \\d+ for test.t[12], old maximum was");
--enable_query_log
create table t1(f1 int not null, f2 int not null, index idx(f2))engine=innodb;
create table t2(f1 int primary key, f2 int, index idx(f2))engine=innodb;
insert into t1 values(1, 2);
insert into t2 values(1, 2);
SET GLOBAL innodb_fast_shutdown = 0;
--echo # Restart the server with innodb_force_recovery as 4.
--let $restart_parameters= --innodb-force-recovery=4
--source include/restart_mysqld.inc
select * from t1;
--error ER_READ_ONLY_MODE
insert into t1 values(2, 3);
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error ER_CANT_CREATE_TABLE
alter table t1 add f3 int not null, algorithm=copy;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t1 add f3 int not null, algorithm=inplace;
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error ER_CANT_CREATE_TABLE
drop index idx on t1;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t1 drop index idx, algorithm=inplace;
--error ER_READ_ONLY_MODE
update t1 set f1=3 where f2=2;
--error ER_CANT_CREATE_TABLE
create table t3(f1 int not null)engine=innodb;
--error ER_BAD_TABLE_ERROR
drop table t3;
--error ER_ERROR_ON_RENAME
rename table t1 to t3;
--error ER_OPEN_AS_READONLY
truncate table t1;
drop table t1;
show tables;
--echo # Restart the server with innodb_force_recovery as 5.
--let $restart_parameters= --innodb-force-recovery=5
--source include/restart_mysqld.inc
select * from t2;
--error ER_READ_ONLY_MODE
insert into t2 values(2, 3);
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error ER_CANT_CREATE_TABLE
alter table t2 add f3 int not null, algorithm=copy;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t2 add f3 int not null, algorithm=inplace;
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error ER_CANT_CREATE_TABLE
drop index idx on t2;
--error ER_READ_ONLY_MODE
update t2 set f1=3 where f2=2;
--error ER_CANT_CREATE_TABLE
create table t1(f1 int not null)engine=innodb;
--error ER_BAD_TABLE_ERROR
drop table t1;
--error ER_ERROR_ON_RENAME
rename table t2 to t3;
--error ER_OPEN_AS_READONLY
truncate table t2;
--error ER_OPEN_AS_READONLY
drop table t2;
show tables;
--echo # Restart the server with innodb_force_recovery as 6.
--let $restart_parameters= --innodb-force-recovery=6
--source include/restart_mysqld.inc
select * from t2;
--error ER_OPEN_AS_READONLY
insert into t2 values(2, 3);
--error ER_OPEN_AS_READONLY
alter table t2 add f3 int not null, algorithm=copy;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t2 add f3 int not null, algorithm=inplace;
--error ER_OPEN_AS_READONLY
drop index idx on t2;
--error ER_OPEN_AS_READONLY
update t2 set f1=3 where f2=2;
--error ER_CANT_CREATE_TABLE
create table t1(f1 int not null)engine=innodb;
--error ER_BAD_TABLE_ERROR
drop table t1;
--error ER_ERROR_ON_RENAME
rename table t2 to t3;
--error ER_OPEN_AS_READONLY
truncate table t2;
--error ER_OPEN_AS_READONLY
drop table t2;
show tables;
--echo # Restart the server with innodb_force_recovery=2
--let $restart_parameters= --innodb-force-recovery=2
--source include/restart_mysqld.inc
select * from t2;
begin;
update t2 set f2=3;
connect (con1,localhost,root,,);
create table t3(a int)engine=innodb;
--echo # Force a redo log flush of the above uncommitted UPDATE
SET GLOBAL innodb_flush_log_at_trx_commit=1;
drop table t3;
disconnect con1;
connection default;
--source include/kill_mysqld.inc
--echo # Restart the server with innodb_force_recovery=3
--let $restart_parameters= --innodb-force-recovery=3
--source include/start_mysqld.inc
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
select * from t2;
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
select * from t2;
SET GLOBAL innodb_lock_wait_timeout=1;
--error ER_LOCK_WAIT_TIMEOUT
insert into t2 values(1,2);
insert into t2 values(9,10);
--let $restart_parameters=
--source include/restart_mysqld.inc
select * from t2;
drop table t2;
show tables;