Browse Source
MDEV-11985 Make innodb_read_only shutdown more robust
MDEV-11985 Make innodb_read_only shutdown more robust
If InnoDB is started in innodb_read_only mode such that recovered incomplete transactions exist at startup (but the redo logs are clean), an assertion will fail at shutdown, because there would exist some non-prepared transactions. logs_empty_and_mark_files_at_shutdown(): Do not wait for incomplete transactions to finish if innodb_read_only or innodb_force_recovery>=3. Wait for purge to finish in only one place. trx_sys_close(): Relax the assertion that would fail first. trx_free_prepared(): Also free recovered TRX_STATE_ACTIVE transactions if innodb_read_only or innodb_force_recovery>=3. Also, revert my earlier fix to MySQL 5.7 because this fix is more generic: Bug#20874411 INNODB SHUTDOWN HANGS IF INNODB_FORCE_RECOVERY>=3 SKIPPED ANY ROLLBACK trx_undo_fake_prepared(): Remove. trx_sys_any_active_transactions(): Revert the changes.pull/303/head
6 changed files with 118 additions and 79 deletions
-
36mysql-test/suite/innodb/r/read_only_recovery.result
-
39mysql-test/suite/innodb/t/read_only_recovery.test
-
14storage/innobase/log/log0log.cc
-
74storage/innobase/trx/trx0sys.cc
-
6storage/innobase/trx/trx0trx.cc
-
28storage/innobase/trx/trx0undo.cc
@ -0,0 +1,36 @@ |
|||
connect con1, localhost, root; |
|||
CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB; |
|||
BEGIN; |
|||
INSERT INTO t VALUES(1),(2); |
|||
DELETE FROM t WHERE a=2; |
|||
connection default; |
|||
# Normal MariaDB shutdown would roll back the above transaction. |
|||
# We want the transaction to remain open, so we will kill the server |
|||
# after ensuring that any non-transactional files are clean. |
|||
FLUSH TABLES; |
|||
# Ensure that the above incomplete transaction becomes durable. |
|||
SET GLOBAL innodb_flush_log_at_trx_commit=1; |
|||
BEGIN; |
|||
INSERT INTO t VALUES(0); |
|||
ROLLBACK; |
|||
# Kill and restart: --innodb-force-recovery=3 |
|||
disconnect con1; |
|||
SELECT * FROM t; |
|||
a |
|||
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; |
|||
SELECT * FROM t; |
|||
a |
|||
1 |
|||
# Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED. |
|||
# In earlier versions, this would return the last committed version |
|||
# (empty table)! |
|||
SELECT * FROM t; |
|||
a |
|||
1 |
|||
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; |
|||
SELECT * FROM t; |
|||
a |
|||
1 |
|||
SELECT * FROM t; |
|||
a |
|||
DROP TABLE t; |
@ -0,0 +1,39 @@ |
|||
--source include/have_innodb.inc |
|||
# need to restart server |
|||
--source include/not_embedded.inc |
|||
|
|||
--connect(con1, localhost, root) |
|||
CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB; |
|||
BEGIN; |
|||
# Generate insert_undo log. |
|||
INSERT INTO t VALUES(1),(2); |
|||
# Generate update_undo log. |
|||
DELETE FROM t WHERE a=2; |
|||
--connection default |
|||
--echo # Normal MariaDB shutdown would roll back the above transaction. |
|||
--echo # We want the transaction to remain open, so we will kill the server |
|||
--echo # after ensuring that any non-transactional files are clean. |
|||
FLUSH TABLES; |
|||
--echo # Ensure that the above incomplete transaction becomes durable. |
|||
SET GLOBAL innodb_flush_log_at_trx_commit=1; |
|||
BEGIN; |
|||
INSERT INTO t VALUES(0); |
|||
ROLLBACK; |
|||
--let $restart_parameters= --innodb-force-recovery=3 |
|||
--source include/kill_and_restart_mysqld.inc |
|||
--disconnect con1 |
|||
SELECT * FROM t; |
|||
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; |
|||
SELECT * FROM t; |
|||
--let $restart_parameters= --innodb-read-only |
|||
--source include/restart_mysqld.inc |
|||
--echo # Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED. |
|||
--echo # In earlier versions, this would return the last committed version |
|||
--echo # (empty table)! |
|||
SELECT * FROM t; |
|||
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; |
|||
SELECT * FROM t; |
|||
--let $restart_parameters= |
|||
--source include/restart_mysqld.inc |
|||
SELECT * FROM t; |
|||
DROP TABLE t; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue