Debian Codegraph @

mysql-test/suite/ndb/t/ndb_TCtakeover_stall.test

raw
1 --source include/have_ndb.inc
2 --source include/have_ndb_debug.inc
3
4 --echo A client holding a row lock can cause node restart
5 --echo (CopyFrag) to stall until the row lock is released.
6 --echo
7 --echo Check that a stalled CopyFrag does not lead to
8 --echo TC takeover stall by :
9 --echo - Restarting a node
10 --echo - Stalling CopyFrag due to a rowlock
11 --echo - Causing starting node failure
12 --echo - Checking that TC takeover completes
13 --echo (As transactions can be committed in
14 --echo different epochs)
15
16 create table t1(id int primary key, val int) engine=ndb;
17
18 --disable_query_log
19 let $i = 0;
20 while($i < 10)
21 {
22 eval insert into t1 values ($i, $i);
23 inc $i;
24 }
25 --enable_query_log
26
27 select count(*) from t1;
28
29 # Restart one data node with -n (nowait)
30 # and ensure it stopped
31 --exec $NDB_MGM -e "2 restart -n" >> $NDB_TOOLS_OUTPUT
32 --exec $NDB_WAITER --nowait-nodes=1 --not-started > $NDB_TOOLS_OUTPUT
33
34 connect (conn1,localhost,root,,);
35 --connection conn1
36
37 # Begin a transaction, and let it take an exclusive lock on a row
38 begin;
39 select * from t1 where id = 1 for update;
40
41 --connection default
42
43 # See TC node. For a 2 data node cluster, it will be on the alive node
44 select tc_node_id from ndbinfo.cluster_operations;
45
46 # See the transaction state and the lock
47 select ndbinfo.cluster_transactions.state,
48 ndbinfo.cluster_operations.operation_type, ndbinfo.cluster_operations.state,
49 ndbinfo.cluster_locks.mode
50 from ndbinfo.cluster_transactions, ndbinfo.cluster_operations,
51 ndbinfo.cluster_locks
52 where
53 ndbinfo.cluster_transactions.transid = ndbinfo.cluster_locks.transid and
54 ndbinfo.cluster_locks.transid = ndbinfo.cluster_operations.transid;
55
56 --echo Starting the nowait node
57 --echo Eventually it will be waiting for the lock above
58 --exec $NDB_MGM -e "2 start" >> $NDB_TOOLS_OUTPUT
59
60 let $wait=30;
61 while ($wait)
62 {
63 # TODO : Could theoretically wait for 2 row locks claims on
64 # the same rowid to wait for 'stalled CopyFrag'
65 --sleep 1
66 #select * from ndbinfo.cluster_locks;
67 dec $wait;
68 }
69
70 --echo Kill the starting node
71 --echo This will result in TC takeover
72 --exec $NDB_MGM -e "2 ERROR 9999" >> $NDB_TOOLS_OUTPUT
73
74 --echo Sleeping 10 s for node failure to be detected
75 --echo and handling to start [and finish]
76 let $wait=10;
77 while ($wait)
78 {
79 --sleep 1
80 # select * from ndbinfo.cluster_locks;
81 dec $wait;
82 }
83
84 # Check that we can commit changes into different epochs
85 # - implies no GCP stall
86 # If TC takeover were stalled then GCP would stall and
87 # commits would all have the same epoch.
88 #
89
90 --disable_query_log
91 --disable_result_log
92
93 let $first_epoch = 0;
94 let $i = 0;
95 while($i < 10)
96 {
97 eval insert into t1 values ($i+10, $i+10);
98 inc $i;
99
100 select Variable_value into @epoch
101 from performance_schema.global_status
102 where Variable_name like 'Ndb_last_commit_epoch_session';
103
104 if ($first_epoch != 0)
105 {
106 let $latest_epoch=query_get_value(select @epoch as e, e, 1);
107 if ($latest_epoch != $first_epoch)
108 {
109 # Break out
110 let $i = 10;
111 }
112 }
113 if ($first_epoch == 0)
114 {
115 # Initial value
116 let $first_epoch=query_get_value(select @epoch as e, e, 1);
117 }
118
119 --sleep 1
120 }
121
122 --enable_result_log
123 --enable_query_log
124
125 if ($first_epoch != $latest_epoch)
126 {
127 --echo Test succeeded, no GCP stall
128 }
129
130 --echo Release lock to allow data node start to succeed
131 --connection conn1
132 rollback;
133
134 --connection default
135
136 --echo Wait for all data nodes to start
137 --exec $NDB_WAITER > $NDB_TOOLS_OUTPUT
138
139 --echo Started ok
140
141 drop table t1;
142
143 --remove_file $NDB_TOOLS_OUTPUT
144