Commit b4f6b678 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-13520 InnoDB attempts UPDATE with DB_TRX_ID=0 if innodb_force_recovery=3

trx_set_rw_mode(): Check the flag high_level_read_only instead
of testing srv_force_recovery (innodb_force_recovery) directly.
There is no need to prevent the creation of read-write transactions
if innodb_force_recovery=3 is used. Yes, in that mode any recovered
incomplete transactions will not be rolled back, but these transactions
will continue to hold locks on the records that they have modified.
If the new read-write transactions hit conflicts with already existing
(possibly recovered) transactions, the lock wait timeout mechanism
will work just fine.
parent a5e4365e
connect con1, localhost, root; connect con1, localhost, root;
CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t VALUES(1);
BEGIN; BEGIN;
INSERT INTO t VALUES(1),(2); INSERT INTO t VALUES(2);
DELETE FROM t WHERE a=2; DELETE FROM t WHERE a=2;
connection default; connection default;
# Normal MariaDB shutdown would roll back the above transaction. # Normal MariaDB shutdown would roll back the above transaction.
...@@ -16,20 +17,23 @@ ROLLBACK; ...@@ -16,20 +17,23 @@ ROLLBACK;
disconnect con1; disconnect con1;
SELECT * FROM t; SELECT * FROM t;
a a
1
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t; SELECT * FROM t;
a a
1 1
UPDATE t SET a=3 WHERE a=1;
# Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED. # Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED.
# In earlier versions, this would return the last committed version # In earlier versions, this would return the last committed version
# (empty table)! # (empty table)!
SELECT * FROM t; SELECT * FROM t;
a a
1 3
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t; SELECT * FROM t;
a a
1 3
SELECT * FROM t; SELECT * FROM t;
a a
3
DROP TABLE t; DROP TABLE t;
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
--connect(con1, localhost, root) --connect(con1, localhost, root)
CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t VALUES(1);
BEGIN; BEGIN;
# Generate insert_undo log. # Generate insert_undo log.
INSERT INTO t VALUES(1),(2); INSERT INTO t VALUES(2);
# Generate update_undo log. # Generate update_undo log.
DELETE FROM t WHERE a=2; DELETE FROM t WHERE a=2;
--connection default --connection default
...@@ -27,6 +28,7 @@ ROLLBACK; ...@@ -27,6 +28,7 @@ ROLLBACK;
SELECT * FROM t; SELECT * FROM t;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t; SELECT * FROM t;
UPDATE t SET a=3 WHERE a=1;
--let $restart_parameters= --innodb-read-only --let $restart_parameters= --innodb-read-only
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
--echo # Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED. --echo # Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED.
......
...@@ -3091,7 +3091,7 @@ trx_set_rw_mode( ...@@ -3091,7 +3091,7 @@ trx_set_rw_mode(
ut_ad(!trx->in_rw_trx_list); ut_ad(!trx->in_rw_trx_list);
ut_ad(!trx_is_autocommit_non_locking(trx)); ut_ad(!trx_is_autocommit_non_locking(trx));
if (srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO) { if (high_level_read_only) {
return; 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