-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathgr_mem_cnt_check_err.inc
121 lines (108 loc) · 3.08 KB
/
gr_mem_cnt_check_err.inc
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Test is used to check correctness of allocation failure handling.
# Test sets debug key 'mem_alloc_number' + 'number of allocation',
# executes two statements:
# connect (con1, localhost, user1);
# $test_query
# and check if ER_DA_CONN_LIMIT is issued.
#
#
# Arguments:
# $memory_key = string memory key to fail allocation
# $test_query = string testing query
# $only_test = number tests only '$only_test' allocation.
# $start_from = number number of allocation from which test starts.
# $max_tests = number max number of tests.
# $validate_data = string table to check diffs, empty to disable
# $missing_key = number number not present on table until command succeeds
#
# Example:
# --let $only_test = 0
# --let $start_from = 1
# --let $max_tests = 1000
# --let $validate_data = server1:test.t1, server2:test.t1
# --let $memory_key = memory/group_rpl/write_set_encoded
# --let $missing_key = 1
# --let $test_query = INSERT INTO t1 (f0) VALUES ($missing_key)
# --source ../include/gr_mem_cnt_check_err.inc
--let $_saved_connection= $CURRENT_CONNECTION
connection default;
--disable_query_log
--disable_result_log
CREATE USER 'user1'@localhost;
GRANT USAGE ON *.* TO 'user1'@localhost;
GRANT RELOAD ON *.* TO 'user1'@localhost;
GRANT EXECUTE ON *.* TO 'user1'@localhost;
GRANT FILE ON *.* TO 'user1'@localhost;
let $min_tests = 1;
let $error_count = 0;
let $cnt = $start_from;
while ($cnt < $max_tests)
{
let $dbug_name = set global debug="+d, $memory_key, alloc_number$cnt";
if ($verbose)
{
--echo $dbug_name
}
if ($only_test)
{
let $dbug_name = set global debug="+d, $memory_key, alloc_number$only_test";
}
eval $dbug_name;
connect (con1, localhost, user1);
if (!$mysql_errno)
{
if ($validate_data)
{
--let $gtid_executed_before_query= `SELECT @@GLOBAL.GTID_EXECUTED`
}
--error ER_DA_CONN_LIMIT,0
eval $test_query;
if ($verbose)
{
--echo alloc_number = $cnt, error = $mysql_errno;
}
if ($mysql_errno)
{
inc $error_count;
}
if (!$mysql_errno)
{
if ($cnt > $min_tests)
{
let $cnt = $max_tests;
}
}
}
disconnect con1;
connection default;
if ($mysql_errno)
{
if ($validate_data)
{
--source include/rpl/sync.inc
--let $diff_tables = $validate_data
--source include/diff_tables.inc
--let $gtid_executed_after_query= `SELECT @@GLOBAL.GTID_EXECUTED`
--let $assert_text= 'GTID_EXECUTED before and after query must be equal'
--let $assert_cond= "$gtid_executed_before_query" = "$gtid_executed_after_query"
--source include/assert.inc
--let $assert_text= 'Assert key is not present on table'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.f0 = $missing_key, count, 1] = 0
--source include/assert.inc
}
}
if ($only_test)
{
let $cnt = $max_tests;
}
set global debug=default;
inc $cnt;
}
if ($error_count)
{
--echo $memory_key test passed.
}
DROP USER 'user1'@localhost;
--enable_query_log
--enable_result_log
--connection $_saved_connection