Commit 1ca75ae1 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-19587 innodb_force_recovery=5 crash on DROP SCHEMA

At higher levels of innodb_force_recovery, the InnoDB transaction
subsystem will not be set up at all.

At slightly lower levels, recovered transactions will not be rolled back,
and DDL operations could hang due to locks being held at all.

Let us consistently refuse all writes if the predicate
high_level_read_only holds. We failed to refuse DROP TABLE
and DROP DATABASE. (Refusing DROP TABLE is a partial backport
from MDEV-19570 in the 10.5 branch.)
parent 96d9f033
......@@ -28,8 +28,10 @@ ERROR HY000: Error on rename of './test/t1' to './test/t3' (errno: 165 "Table is
truncate table t1;
ERROR HY000: Table 't1' is read only
drop table t1;
ERROR HY000: Table 't1' is read only
show tables;
Tables_in_test
t1
t2
# Restart the server with innodb_force_recovery as 5.
select * from t2;
......@@ -45,18 +47,21 @@ drop index idx on t2;
ERROR HY000: Can't create table `test`.`t2` (errno: 165 "Table is read only")
update t2 set f1=3 where f2=2;
ERROR HY000: Running in read-only mode
create table t1(f1 int not null)engine=innodb;
ERROR HY000: Can't create table `test`.`t1` (errno: 165 "Table is read only")
drop table t1;
ERROR 42S02: Unknown table 'test.t1'
create table t3(f1 int not null)engine=innodb;
ERROR HY000: Can't create table `test`.`t3` (errno: 165 "Table is read only")
drop table t3;
ERROR 42S02: Unknown table 'test.t3'
rename table t2 to t3;
ERROR HY000: Error on rename of './test/t2' to './test/t3' (errno: 165 "Table is read only")
truncate table t2;
ERROR HY000: Table 't2' is read only
drop table t2;
ERROR HY000: Table 't2' is read only
create schema db;
drop schema db;
show tables;
Tables_in_test
t1
t2
# Restart the server with innodb_force_recovery as 6.
select * from t2;
......@@ -72,10 +77,10 @@ drop index idx on t2;
ERROR HY000: Table 't2' is read only
update t2 set f1=3 where f2=2;
ERROR HY000: Table 't2' is read only
create table t1(f1 int not null)engine=innodb;
ERROR HY000: Can't create table `test`.`t1` (errno: 165 "Table is read only")
create table t3(f1 int not null)engine=innodb;
ERROR HY000: Can't create table `test`.`t3` (errno: 165 "Table is read only")
drop table t1;
ERROR 42S02: Unknown table 'test.t1'
ERROR HY000: Table 't1' is read only
rename table t2 to t3;
ERROR HY000: Error on rename of './test/t2' to './test/t3' (errno: 165 "Table is read only")
truncate table t2;
......@@ -84,6 +89,7 @@ drop table t2;
ERROR HY000: Table 't2' is read only
show tables;
Tables_in_test
t1
t2
# Restart the server with innodb_force_recovery=2
select * from t2;
......@@ -92,10 +98,9 @@ f1 f2
begin;
update t2 set f2=3;
connect con1,localhost,root,,;
create table t3(a int)engine=innodb;
# Force a redo log flush of the above uncommitted UPDATE
SET GLOBAL innodb_flush_log_at_trx_commit=1;
drop table t3;
drop table t1;
disconnect con1;
connection default;
# Kill the server
......
......@@ -51,6 +51,7 @@ rename table t1 to t3;
--error ER_OPEN_AS_READONLY
truncate table t1;
--error ER_OPEN_AS_READONLY
drop table t1;
show tables;
......@@ -76,10 +77,10 @@ drop index idx on t2;
update t2 set f1=3 where f2=2;
--error ER_CANT_CREATE_TABLE
create table t1(f1 int not null)engine=innodb;
create table t3(f1 int not null)engine=innodb;
--error ER_BAD_TABLE_ERROR
drop table t1;
drop table t3;
--error ER_ERROR_ON_RENAME
rename table t2 to t3;
......@@ -89,6 +90,9 @@ truncate table t2;
--error ER_OPEN_AS_READONLY
drop table t2;
create schema db;
drop schema db;
show tables;
--echo # Restart the server with innodb_force_recovery as 6.
......@@ -113,9 +117,9 @@ drop index idx on t2;
update t2 set f1=3 where f2=2;
--error ER_CANT_CREATE_TABLE
create table t1(f1 int not null)engine=innodb;
create table t3(f1 int not null)engine=innodb;
--error ER_BAD_TABLE_ERROR
--error ER_OPEN_AS_READONLY
drop table t1;
--error ER_ERROR_ON_RENAME
......@@ -137,10 +141,9 @@ 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;
drop table t1;
disconnect con1;
connection default;
......
......@@ -13118,8 +13118,7 @@ inline int ha_innobase::delete_table(const char* name, enum_sql_command sqlcom)
extension, in contrast to ::create */
normalize_table_name(norm_name, name);
if (srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_UNDO_LOG_SCAN) {
if (high_level_read_only) {
DBUG_RETURN(HA_ERR_TABLE_READONLY);
}
......@@ -13308,7 +13307,7 @@ innobase_drop_database(
DBUG_ASSERT(hton == innodb_hton_ptr);
if (srv_read_only_mode) {
if (high_level_read_only) {
return;
}
......
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