|
| 1 | +--source include/have_innodb.inc |
| 2 | +--source include/have_debug.inc |
| 3 | +--source include/have_debug_sync.inc |
| 4 | +# need to restart server |
| 5 | +--source include/not_embedded.inc |
| 6 | + |
| 7 | +--connect(con1, localhost, root) |
| 8 | +CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB; |
| 9 | +INSERT INTO t VALUES(1); |
| 10 | +BEGIN; |
| 11 | +# Generate insert_undo log. |
| 12 | +INSERT INTO t VALUES(2); |
| 13 | +# Generate update_undo log. |
| 14 | +DELETE FROM t WHERE a=2; |
| 15 | +--connect(con2, localhost, root) |
| 16 | +--echo # Normal MariaDB shutdown would roll back the above transaction. |
| 17 | +--echo # We want the transaction to remain open, so we will kill the server |
| 18 | +--echo # after ensuring that any non-transactional files are clean. |
| 19 | +FLUSH TABLES; |
| 20 | +--echo # Create another transaction that will be recovered as COMMITTED. |
| 21 | +BEGIN; |
| 22 | +# Generate multiple pages of both insert_undo and update_undo, so that |
| 23 | +# the state TRX_UNDO_CACHE will not be chosen. |
| 24 | +--disable_query_log |
| 25 | +let $n= 10000; |
| 26 | +while ($n) { |
| 27 | +dec $n; |
| 28 | +eval INSERT INTO t VALUES(-$n); |
| 29 | +eval DELETE FROM t WHERE a=-$n; |
| 30 | +} |
| 31 | +--enable_query_log |
| 32 | +SET DEBUG_SYNC='after_trx_committed_in_memory SIGNAL committed WAIT_FOR ever'; |
| 33 | +send COMMIT; |
| 34 | + |
| 35 | +connection default; |
| 36 | +SET DEBUG_SYNC='now WAIT_FOR committed'; |
| 37 | +--echo # Ensure that the above incomplete transactions become durable. |
| 38 | +SET GLOBAL innodb_flush_log_at_trx_commit=1; |
| 39 | +BEGIN; |
| 40 | +INSERT INTO t VALUES(-10000); |
| 41 | +ROLLBACK; |
| 42 | +--let $restart_parameters= --innodb-force-recovery=3 |
| 43 | +--let $shutdown_timeout= 0 |
| 44 | +--source include/restart_mysqld.inc |
| 45 | +--let $shutdown_timeout= 30 |
| 46 | +--disconnect con1 |
| 47 | +--disconnect con2 |
| 48 | +SELECT * FROM t; |
| 49 | +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; |
| 50 | +SELECT * FROM t; |
| 51 | +# refused on MySQL 5.6, MariaDB 10.0, 10.1, but not MariaDB 10.2+ |
| 52 | +--error ER_OPEN_AS_READONLY |
| 53 | +UPDATE t SET a=3 WHERE a=1; |
| 54 | +--let $restart_parameters= --innodb-read-only |
| 55 | +--source include/restart_mysqld.inc |
| 56 | +--echo # Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED. |
| 57 | +--echo # In earlier versions, this would return the last committed version |
| 58 | +--echo # (empty table)! |
| 59 | +SELECT * FROM t; |
| 60 | +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; |
| 61 | +SELECT * FROM t; |
| 62 | +--let $restart_parameters= |
| 63 | +--source include/restart_mysqld.inc |
| 64 | +SELECT * FROM t; |
| 65 | +DROP TABLE t; |
| 66 | +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; |
| 67 | +--let SEARCH_PATTERN= Rolled back recovered transaction [^0] |
| 68 | +--source include/search_pattern_in_file.inc |
0 commit comments