File: rpl_perfschema_applier_xa_status.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 (87 lines) | stat: -rw-r--r-- 3,277 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
# ==== Purpose ====
#
# Verify that on slave server, appropriate XA_STATE is reported in Performance
# Schema tables for XA transactions.
#
# ==== Implementation ====
#
# 1) On Master start one XA transaction named 'xatest' and set the state to
# 'PREPARED'.
# 2) On slave wait till the applier thread applies the 'XA PREPARE' statement.
# 3) Verify that the XA_STATE is reported as 'PREPARED' in performance schema
# table.
# 4) On Master COMMIT the XA transaction.
# 5) On slave verify that the XA_STATE is reported as 'COMMITTED'
#
# ==== References ====
#
# Bug#25940184: P_S TRANSACTION INSTRUMENTATION DOES NOT WORK PROPERLY FOR
# XA ON SLAVE
--source include/rpl_connection_slave.inc
TRUNCATE TABLE performance_schema.events_transactions_current;

--echo ---- Setup ----
--source include/rpl_connection_master.inc
--let $master_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
CREATE TABLE t ( f INT) ENGINE=INNODB;

--echo ---- XA PREPARE ----
XA START 'xatest';
INSERT INTO t VALUES (10);
XA END 'xatest';
XA PREPARE 'xatest';

# Sync on a different connection, since we can't run queries on a
# connection that has an XA transaction in PREPARED state.
--connection default
--source include/sync_slave_sql_with_master.inc

--echo # Wait for XA_STATE to become PREPARED on slave
# It is not enough to only use sync_slave_sql_with_master.inc, because
# the XA state is updated after the GTID state and the replication
# positions.  Hence we also *wait* for the XA state to change.
--let $wait_condition = SELECT COUNT(*) = 1 FROM performance_schema.events_transactions_current WHERE XID_GTRID = 'xatest' AND XA_STATE = 'PREPARED'
--source include/wait_condition_or_abort.inc

--echo # Expecting one prepared transaction
XA RECOVER;

if ($gtid_mode == ON)
{
  --let $gno_0 = 2
  --let $expected_gtid = $master_uuid:$gno_0
  --echo Waiting until gtid is MASTER_UUID:$gno_0
  --let $wait_condition = SELECT GTID = '$expected_gtid' FROM performance_schema.events_transactions_current where XID_GTRID = 'xatest' AND XA_STATE = 'PREPARED'
  --source include/wait_condition_or_abort.inc
}

--echo ---- XA COMMIT ----
--source include/rpl_connection_master.inc
XA COMMIT 'xatest';
--source include/sync_slave_sql_with_master.inc

--echo # Wait for XA_STATE to become COMMITTED on slave
--let $wait_condition = SELECT COUNT(*) = 1 FROM performance_schema.events_transactions_current WHERE XID_GTRID = 'xatest' AND XA_STATE = 'COMMITTED'
--source include/wait_condition_or_abort.inc

--echo # Expecting no prepared transactions
XA RECOVER;

if ($gtid_mode == ON)
{
  --let $gno_0 = 3
  --let $expected_gtid = $master_uuid:$gno_0
  --echo Waiting until gtid is MASTER_UUID:$gno_0
  # We need the "XA_STATE='COMMITTED'" condition, since there
  # can be multiple rows having XID_GTRID='xatest' in case XA PREPARE
  # and XA COMMIT were handled by different applier worker threads.
  --let $wait_condition = SELECT GTID = '$expected_gtid' FROM performance_schema.events_transactions_current where XID_GTRID = 'xatest' AND XA_STATE = 'COMMITTED'
  --source include/wait_condition_or_abort.inc
}

--let $diff_tables=master:t,slave:t
--source include/diff_tables.inc

--source include/rpl_connection_master.inc
DROP TABLE t;
--source include/sync_slave_sql_with_master.inc