Debian Codegraph @

mysql-test/suite/group_replication/t/gr_parallel_update_same_server.test

raw
1 ################################################################################
2 # This test will update in parallel, in the same member, N transactions
3 # with N different clients.
4 #
5 # The success of this test is determined by its termination. Any failure
6 # in the parallelism of a transaction shall make some transactions be
7 # rollback.
8 #
9 # Test:
10 # 0. The test requires one server.
11 # 1. With member ONLINE, create 20 clients connections. Create initial data.
12 # 2. Update the same row on server 1 in parallel by all clients.
13 # 3. Assert that the row has the expected value, the total number of updates.
14 # 4. Disconnect clients connections.
15 # 5. Clean up.
16 ################################################################################
17 --source include/have_group_replication_plugin.inc
18 --source include/group_replication.inc
19
20 --let $clients= 20
21 --let $updates= 100
22
23
24 --echo
25 --echo ################################################################
26 --echo # 1. Create clients connections.
27 --let $clients_counter= $clients
28 while($clients_counter > 0)
29 {
30 --connect(server1_$clients_counter, localhost,root,,,$MASTER_MYPORT)
31 --dec $clients_counter
32 }
33
34
35 --echo
36 --echo ################################################################
37 --echo # 2. Create initial data.
38 --let $rpl_connection_name= server1
39 --source include/rpl_connection.inc
40 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY, c2 INT NOT NULL) ENGINE=InnoDB;
41 INSERT INTO t1 (c1,c2) VALUES (0,0);
42 --source include/rpl_sync.inc
43
44
45 --echo
46 --echo ################################################################
47 --echo # 3. Update the same row on server 1 in parallel by all clients.
48 --disable_query_log
49 --let $updates_counter= $updates
50 while($updates_counter > 0)
51 {
52 --let $clients_counter= $clients
53 while($clients_counter > 0)
54 {
55 --connection server1_$clients_counter
56 --send UPDATE t1 SET c2=c2+1 WHERE c1=0
57 --dec $clients_counter
58 }
59
60 --let $clients_counter= $clients
61 while($clients_counter > 0)
62 {
63 --connection server1_$clients_counter
64 --reap
65 --dec $clients_counter
66 }
67
68 --dec $updates_counter
69 }
70 --enable_query_log
71
72
73 --echo
74 --echo ################################################################
75 --echo # 4. Assert that the row has the expected value, the total
76 --echo # number of updates.
77 --let $rpl_connection_name= server1
78 --source include/rpl_connection.inc
79
80 --let $assert_text= Table t1 must have 1 entry
81 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 1
82 --source include/assert.inc
83
84 --let $_total_updates= `SELECT $clients * $updates`
85 --let $assert_text= Table t1 entry must have total number of updates as c2 value
86 --let $assert_cond= [SELECT c2 FROM t1 WHERE c1=0] = $_total_updates
87 --source include/assert.inc
88
89
90 --echo
91 --echo ################################################################
92 --echo # 5. Disconnect clients connections.
93 --let $clients_counter= $clients
94 while($clients_counter > 0)
95 {
96 --disconnect server1_$clients_counter
97 --dec $clients_counter
98 }
99
100
101 --echo
102 --echo ################################################################
103 --echo # 6. Clean up,
104 DROP TABLE t1;
105 --source include/group_replication_end.inc