File: xa_rollback_failure_before_gtid_externalization.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (110 lines) | stat: -rw-r--r-- 3,515 bytes parent folder | download
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# ==== Purpose ====
#
# This script tests server behavior when a crash occurs during the
# execution of `XA ROLLBACK`, just before the GTID is added to
# GTID_EXECUTED.
#
# ==== Requirements ====
#
# After server restart:
# R1. The GTID_EXECUTED variable should be updated.
# R2. There shouldn't be any pending XA transactions visible with `XA
#     RECOVER`.
#
# ==== Implementation ====
#
# 1. Setup scenario: create table and insert some records.
# 2. Start and execute an XA transaction containing an insert until before
#    `XA ROLLBACK`.
# 3. Take the `GTID_EXECUTED` state.
# 4. Crash the server during `XA ROLLBACK` execution before the GTID is
#    added to GTID_EXECUTED.
# 5. Restart server and check:
#    a. Error log for messages stating that recovery process didn't find
#       any transaction needing recovery.
#    b. The GTID_EXECUTED variable was updated.
#    c. There aren't any pending XA transaction listed in the output of `XA
#       RECOVER`.
#    d. There aren't changes to the table.
#
# ==== References ====
#
# WL#11300: Crash-safe XA + binary log
#
# Related tests;
#   see extra/xa_crash_safe_tests/setup.inc
#
--source include/not_valgrind.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--let $option_name = log_bin
--let $option_value = 0
--source include/only_with_option.inc
--let $option_name = gtid_mode
--let $option_value = 'ON'
--source include/only_with_option.inc

# 1. Setup scenario: create table and insert some records.
#
--let $xid_data = xid1
--let $xid = `SELECT CONCAT("X'", LOWER(HEX('$xid_data')), "',X'',1")`
--source extra/xa_crash_safe_tests/setup.inc
--let $uuid = 72e9b9d8-8a89-11ec-8f56-6f896ffede71
RESET MASTER;

# 2. Start and execute an XA transaction containing an insert until before
#    `XA ROLLBACK`.
#
--connect(con1, localhost, root,,)
--connection con1
--eval SET @@SESSION.gtid_next = '$uuid:1'
--eval XA START $xid
INSERT INTO t1 VALUES (1);
--eval XA END $xid
--eval XA PREPARE $xid

# 3. Take the `GTID_EXECUTED` state.
#
--connection default
--let $before_gtid_executed = `SELECT @@GLOBAL.gtid_executed`

# 4. Crash the server during `XA ROLLBACK` execution before the GTID is
#    added to GTID_EXECUTED.
#
--let $auxiliary_connection = default
--let $statement_connection = con1
--let $statement = SET @@SESSION.gtid_next = '$uuid:2'; XA ROLLBACK $xid
--let $sync_point = before_gtid_externalization
--source include/execute_to_conditional_timestamp_sync_point.inc
--source include/dbug_crash_safe.inc
--source extra/xa_crash_safe_tests/cleanup_connection.inc

# 5. Restart server and check:
#
--source include/start_mysqld.inc

# 5.a. Error log for messages stating that recovery process didn't find
#      any transaction needing recovery.
#
--let $assert_select = in InnoDB engine. No attempts to commit, rollback or prepare any transactions.
--source extra/xa_crash_safe_tests/assert_recovery_message.inc

# 5.b. The GTID_EXECUTED variable was updated.
#
--let $after_gtid_executed = `SELECT @@GLOBAL.gtid_executed`
--let $assert_text = GTID_EXECUTED has been updated
--let $assert_cond = "$before_gtid_executed" != "$after_gtid_executed"
--source include/assert.inc

# 5.c. There aren't any pending XA transaction listed in the output of `XA
#       RECOVER`.
#
--let $expected_prepared_xa_count = 0
--source extra/xa_crash_safe_tests/assert_xa_recover.inc

# 5.d. There aren't changes to the table.
#
--let $expected_row_count = 1
--source extra/xa_crash_safe_tests/assert_row_count.inc

DROP TABLE t1;