File: xa_recovery.test

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (73 lines) | stat: -rw-r--r-- 2,040 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--source include/have_innodb.inc
# Embedded server does not support restarting.
--source include/not_embedded.inc
--source include/no_valgrind_without_big.inc

# MDEV-8841 - close tables opened by previous tests, 
# so they don't get marked crashed when the server gets crashed
--disable_query_log
call mtr.add_suppression("Found [12] prepared XA transactions");
FLUSH TABLES;
--enable_query_log

CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
connect (con1,localhost,root);
XA START 'x'; UPDATE t1 set a=2; XA END 'x'; XA PREPARE 'x';
connect (con2,localhost,root);
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
XA START 'y'; INSERT INTO t2 VALUES (1); XA END 'y'; XA PREPARE 'y';
connection default;

# innodb_force_recovery=2 prevents the purge and tests that the fix of
# MDEV-13606 XA PREPARE transactions should survive innodb_force_recovery=1 or 2
# is present.
--let $restart_parameters= --innodb-force-recovery=2
--let $shutdown_timeout=0
--source include/restart_mysqld.inc
--let $restart_parameters=
--let $shutdown_timeout=

disconnect con1;
disconnect con2;
connect (con1,localhost,root);
--send SELECT * FROM t1 LOCK IN SHARE MODE

connection default;
let $wait_condition=
  select count(*) = 1 from information_schema.processlist
  where state = 'Sending data' and
        info = 'SELECT * FROM t1 LOCK IN SHARE MODE';
--source include/wait_condition.inc

SET innodb_lock_wait_timeout=1;
--error ER_LOCK_WAIT_TIMEOUT
DROP TABLE t2;

disconnect con1;

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
--disable_ps2_protocol
SELECT * FROM t1;
--enable_ps2_protocol
XA ROLLBACK 'x';
SELECT * FROM t1;

--error ER_LOCK_WAIT_TIMEOUT
DROP TABLE t2;
XA ROLLBACK 'y';
DROP TABLE t2;
CREATE TABLE t3(a INT PRIMARY KEY REFERENCES t1(a)) ENGINE=InnoDB;
XA START 'a';
INSERT INTO t3 SET a=1;
--error ER_NO_REFERENCED_ROW_2
INSERT INTO t3 SET a=42;
XA END 'a';
XA PREPARE 'a';

SET GLOBAL innodb_fast_shutdown=0;
--source include/restart_mysqld.inc

XA COMMIT 'a';
SELECT * FROM t3;
DROP TABLE t3,t1;