| 1 |
CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; |
| 2 |
# Case 1: Server goes through graceful shutdown and is restarted |
| 3 |
connection default; |
| 4 |
INSERT INTO t1 VALUES (1); |
| 5 |
Performing --wsrep-recover ... |
| 6 |
Using --wsrep-start-position when starting mysqld ... |
| 7 |
Expect 100-10-2 |
| 8 |
SELECT WSREP_LAST_SEEN_GTID(); |
| 9 |
WSREP_LAST_SEEN_GTID() |
| 10 |
100-10-2 |
| 11 |
SELECT @@GLOBAL.gtid_binlog_pos; |
| 12 |
@@GLOBAL.gtid_binlog_pos |
| 13 |
100-10-2 |
| 14 |
SELECT * FROM t1; |
| 15 |
f1 |
| 16 |
1 |
| 17 |
# Case 2: Server is killed after the transaction gets prepared |
| 18 |
# but before it is written into binlog. As there is not GTID assigned, |
| 19 |
# the transaction must be rolled back during recovery. |
| 20 |
connect con, localhost, root; |
| 21 |
SET DEBUG_SYNC = "ha_commit_trans_after_prepare SIGNAL reached WAIT_FOR continue"; |
| 22 |
INSERT INTO t1 VALUES (2); |
| 23 |
connection default; |
| 24 |
SET DEBUG_SYNC = "now WAIT_FOR reached"; |
| 25 |
# Kill the server |
| 26 |
Performing --wsrep-recover ... |
| 27 |
Using --wsrep-start-position when starting mysqld ... |
| 28 |
Expect 100-10-2 |
| 29 |
SELECT WSREP_LAST_SEEN_GTID(); |
| 30 |
WSREP_LAST_SEEN_GTID() |
| 31 |
100-10-2 |
| 32 |
SELECT @@GLOBAL.gtid_binlog_pos; |
| 33 |
@@GLOBAL.gtid_binlog_pos |
| 34 |
100-10-2 |
| 35 |
Expect 1 |
| 36 |
SELECT * FROM t1; |
| 37 |
f1 |
| 38 |
1 |
| 39 |
disconnect con; |
| 40 |
# Case 3: Server is killed after the transaction gets written into binlog |
| 41 |
# but before it is committed in storage engine. In this case the |
| 42 |
# transaction must be committed during recovery as it had a valid |
| 43 |
# GTID assigned. |
| 44 |
connect con, localhost, root; |
| 45 |
SET DEBUG_SYNC = "commit_before_get_LOCK_commit_ordered SIGNAL reached WAIT_FOR continue"; |
| 46 |
INSERT INTO t1 VALUES (3); |
| 47 |
connection default; |
| 48 |
SET DEBUG_SYNC = "now WAIT_FOR reached"; |
| 49 |
# Kill the server |
| 50 |
Performing --wsrep-recover ... |
| 51 |
Using --wsrep-start-position when starting mysqld ... |
| 52 |
Expect 100-10-3 |
| 53 |
SELECT WSREP_LAST_SEEN_GTID(); |
| 54 |
WSREP_LAST_SEEN_GTID() |
| 55 |
100-10-3 |
| 56 |
SELECT @@GLOBAL.gtid_binlog_pos; |
| 57 |
@@GLOBAL.gtid_binlog_pos |
| 58 |
100-10-3 |
| 59 |
Expect 1 3 |
| 60 |
SELECT * FROM t1; |
| 61 |
f1 |
| 62 |
1 |
| 63 |
3 |
| 64 |
disconnect con; |
| 65 |
DROP TABLE t1; |