summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera/t/galera_last_committed_id.test
blob: 6e1f0de7d0b95fa348d683ad9303b4ef06b258ab (plain)
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
#
# Tests functions WSREP_LAST_WRITTEN_GTID and WSREP_LAST_SEEN_GTID
#

--source include/galera_cluster.inc

# Returns domain-server-0 if no transactions have been run

SELECT WSREP_LAST_WRITTEN_GTID();

# WSREP_LAST_WRITTEN_GTID() should not be influenced by transactions written
# on other nodes or connections

--connection node_1
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);

--disable_query_log
--let $wsrep_last_written_id_conn_1 = `SELECT WSREP_LAST_WRITTEN_GTID()`
--enable_query_log

--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
--connection node_1a
--eval SELECT WSREP_LAST_WRITTEN_GTID() != '$wsrep_last_written_id_conn_1' AS wsrep_written_does_not_match_different_conn

--connection node_2
--eval SELECT WSREP_LAST_WRITTEN_GTID() != '$wsrep_last_written_id_conn_1' AS wsrep_written_does_not_match_different_nodes

# WSREP_LAST_SEEN_GTID() should be influenced by transactions written
# on other connections

--connection node_1
INSERT INTO t1 VALUES (1);
--disable_query_log
--let $wsrep_last_written_id_conn_1 = `SELECT WSREP_LAST_WRITTEN_GTID()`
--enable_query_log

--connection node_2
--disable_query_log
--eval SELECT WSREP_LAST_SEEN_GTID() = '$wsrep_last_written_id_conn_1' AS wsrep_last_written_seen_id_match
--enable_query_log

# Should not advance while a transaction is in progress

--connection node_1
SET AUTOCOMMIT=OFF;
START TRANSACTION;

--disable_query_log
--let $wsrep_last_written_id_before = `SELECT WSREP_LAST_WRITTEN_GTID()`
--enable_query_log
INSERT INTO t1 VALUES (1);
--disable_query_log
--eval SELECT WSREP_LAST_SEEN_GTID() = '$wsrep_last_written_id_before'
--eval SELECT WSREP_LAST_WRITTEN_GTID() = '$wsrep_last_written_id_before' AS wsrep_last_written_id_match
--enable_query_log

# Should only advance after the transaction has been commited

COMMIT;
--disable_query_log
--eval SELECT WSREP_LAST_WRITTEN_GTID() != 'wsrep_last_written_id_before' AS wsrep_last_written_id_advanced
--enable_query_log
SET AUTOCOMMIT=ON;

DROP TABLE t1;

--connection node_2
CALL mtr.add_suppression("Ignoring server id for non bootstrap node");