summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera/t/galera_sync_wait_upto.test
blob: 05353ac7a3ab56991ae83fa951ecd2a73c77a446 (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
70
71
72
#
# Tests the wsrep_sync_wait_upto variable.
#

--source include/galera_cluster.inc
--source include/have_debug_sync.inc

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

# Test with invalid values

--error ER_WRONG_ARGUMENTS
SELECT WSREP_SYNC_WAIT_UPTO_GTID(NULL);

--error ER_INCORRECT_GTID_STATE
SELECT WSREP_SYNC_WAIT_UPTO_GTID('a');

--error ER_INCORRECT_GTID_STATE
SELECT WSREP_SYNC_WAIT_UPTO_GTID(2);

--error ER_WRONG_ARGUMENTS
SELECT WSREP_SYNC_WAIT_UPTO_GTID('1-1-1,1-1-2');

# Expected starting seqno

--let $last_seen_gtid = `SELECT WSREP_LAST_SEEN_GTID()`
--let $s1 = `SELECT SUBSTR('$last_seen_gtid', LOCATE('-', '$last_seen_gtid') + LENGTH('-'))`
--let $start_seqno = `SELECT SUBSTR('$s1', LOCATE('-', '$s1') + LENGTH('-'))`

# If set to low value, expect no waiting

--disable_query_log
--let $lower_seqno = $start_seqno
--dec $lower_seqno
--eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('100-1-$lower_seqno') AS WSREP_SYNC_WAIT_UPTO;
--enable_query_log

# If set to current last_committed value no waiting

--disable_query_log
--let $wsrep_last_committed_gtid = `SELECT WSREP_LAST_SEEN_GTID()`
--eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('$wsrep_last_committed_gtid') AS WSREP_SYNC_WAIT_UPTO;
--enable_query_log


# Timeout if GTID is not received on time

--disable_query_log
--let $high_seqno = $start_seqno
--inc $high_seqno
--error ER_LOCK_WAIT_TIMEOUT
--eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('100-1-$high_seqno', 1) AS WSREP_SYNC_WAIT_UPTO;
--enable_query_log

# Wait for GTID value

--connection node_2
--disable_query_log
--let $wait_seqno = $start_seqno
--inc $wait_seqno
--send_eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('100-1-$wait_seqno') AS WSREP_SYNC_WAIT_UPTO
--enable_query_log

--connection node_1
INSERT INTO t1 VALUES (2);

--connection node_2
--reap

--connection node_1
DROP TABLE t1;