Skip to content

Commit 2202afd

Browse files
committed
Merge 10.0 into 10.1
2 parents b885426 + c051eab commit 2202afd

File tree

8 files changed

+133
-8
lines changed

8 files changed

+133
-8
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB;
2+
INSERT INTO t VALUES(1);
3+
BEGIN;
4+
INSERT INTO t VALUES(2);
5+
DELETE FROM t WHERE a=2;
6+
# Normal MariaDB shutdown would roll back the above transaction.
7+
# We want the transaction to remain open, so we will kill the server
8+
# after ensuring that any non-transactional files are clean.
9+
FLUSH TABLES;
10+
# Create another transaction that will be recovered as COMMITTED.
11+
BEGIN;
12+
SET DEBUG_SYNC='after_trx_committed_in_memory SIGNAL committed WAIT_FOR ever';
13+
COMMIT;
14+
SET DEBUG_SYNC='now WAIT_FOR committed';
15+
# Ensure that the above incomplete transactions become durable.
16+
SET GLOBAL innodb_flush_log_at_trx_commit=1;
17+
BEGIN;
18+
INSERT INTO t VALUES(-10000);
19+
ROLLBACK;
20+
SELECT * FROM t;
21+
a
22+
1
23+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
24+
SELECT * FROM t;
25+
a
26+
1
27+
UPDATE t SET a=3 WHERE a=1;
28+
ERROR HY000: Table 't' is read only
29+
# Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED.
30+
# In earlier versions, this would return the last committed version
31+
# (empty table)!
32+
SELECT * FROM t;
33+
a
34+
1
35+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
36+
SELECT * FROM t;
37+
a
38+
1
39+
SELECT * FROM t;
40+
a
41+
1
42+
DROP TABLE t;
43+
NOT FOUND /Rolled back recovered transaction [^0]/ in mysqld.1.err
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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

storage/innobase/lock/lock0lock.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7940,7 +7940,10 @@ lock_trx_release_locks(
79407940
}
79417941
mutex_exit(&trx_sys->mutex);
79427942
} else {
7943-
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE));
7943+
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE)
7944+
|| (trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY)
7945+
&& trx->is_recovered
7946+
&& !UT_LIST_GET_LEN(trx->lock.trx_locks)));
79447947
}
79457948

79467949
/* The transition of trx->state to TRX_STATE_COMMITTED_IN_MEMORY

storage/innobase/trx/trx0trx.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2015, 2017, MariaDB Corporation.
4+
Copyright (c) 2015, 2018, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -1256,6 +1256,8 @@ trx_commit_in_memory(
12561256
trx->read_view = NULL;
12571257

12581258
if (lsn) {
1259+
DEBUG_SYNC_C("after_trx_committed_in_memory");
1260+
12591261
if (trx->insert_undo != NULL) {
12601262

12611263
trx_undo_insert_cleanup(trx);

storage/innobase/trx/trx0undo.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2014, 2017, MariaDB Corporation.
4+
Copyright (c) 2014, 2018, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -1989,7 +1989,9 @@ trx_undo_insert_cleanup(
19891989

19901990
mutex_exit(&(rseg->mutex));
19911991

1992-
trx_undo_seg_free(undo);
1992+
if (!srv_read_only_mode) {
1993+
trx_undo_seg_free(undo);
1994+
}
19931995

19941996
mutex_enter(&(rseg->mutex));
19951997

storage/xtradb/lock/lock0lock.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8042,7 +8042,10 @@ lock_trx_release_locks(
80428042
}
80438043
mutex_exit(&trx_sys->mutex);
80448044
} else {
8045-
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE));
8045+
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE)
8046+
|| (trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY)
8047+
&& trx->is_recovered
8048+
&& !UT_LIST_GET_LEN(trx->lock.trx_locks)));
80468049
}
80478050

80488051
/* The transition of trx->state to TRX_STATE_COMMITTED_IN_MEMORY

storage/xtradb/trx/trx0trx.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2015, 2017, MariaDB Corporation.
4+
Copyright (c) 2015, 2018, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -1472,6 +1472,8 @@ trx_commit_in_memory(
14721472
if (lsn) {
14731473
ulint flush_log_at_trx_commit;
14741474

1475+
DEBUG_SYNC_C("after_trx_committed_in_memory");
1476+
14751477
if (trx->insert_undo != NULL) {
14761478

14771479
trx_undo_insert_cleanup(trx);

storage/xtradb/trx/trx0undo.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2014, 2017, MariaDB Corporation.
4+
Copyright (c) 2014, 2018, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -1989,7 +1989,9 @@ trx_undo_insert_cleanup(
19891989

19901990
mutex_exit(&(rseg->mutex));
19911991

1992-
trx_undo_seg_free(undo);
1992+
if (!srv_read_only_mode) {
1993+
trx_undo_seg_free(undo);
1994+
}
19931995

19941996
mutex_enter(&(rseg->mutex));
19951997

0 commit comments

Comments
 (0)