MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NDBT_Error.cpp
1 /*
2  Copyright (C) 2003-2006 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 /* NDBT_Error.cpp */
20 /* This program deals with error handling */
21 
22 #include <ndb_global.h>
23 #include <NdbMain.h>
24 #include <NdbOut.hpp>
25 #include <NdbTest.hpp>
26 #include <NDBT_Error.hpp>
27 #include <NdbSleep.h>
28 
29 
30 ErrorData::ErrorData()
31 {
32  errorCountArray = new Uint32[6000];
34 
35  key_error = false;
36  temporary_resource_error = true;
37  insufficient_space_error = false;
38  node_recovery_error = true;
39  overload_error = true;
40  timeout_error = true;
41  internal_error = true;
42  user_error = true;
43  application_error = false;
44 }
45 
46 ErrorData::~ErrorData()
47 {
48  delete [] errorCountArray;
49 }
50 
51 
52 //-------------------------------------------------------------------
53 // Error Handling routines
54 //-------------------------------------------------------------------
55 
56 int ErrorData::handleErrorCommon(const NdbError & error)
57 {
58  int retValue = 1;
59  if (error.code > 6000) {
60  if (user_error == true) {
61  retValue = 0;
62  }//if
63  return retValue;
64  }//if
65  errorCountArray[error.code]++;
66  switch(error.classification){
69  if (key_error == true) {
70  retValue = 0;
71  }//if
72  break;
74  if (temporary_resource_error == true) {
75  retValue = 0;
76  }//if
77  break;
79  if (insufficient_space_error == true) {
80  retValue = 0;
81  }//if
82  break;
84  if (node_recovery_error == true) {
85  retValue = 0;
86  }//if
87  break;
88 
90  if(error.code == 4012){
91  retValue = 0;
92  }
93  if(error.code == 4115){
94  retValue = 2;
95  }
96  if(error.code == 4007 && node_recovery_error == true){
97  retValue = 3;
98  }
99  break;
101  if (overload_error == true) {
102  NdbSleep_MilliSleep(50);
103  retValue = 0;
104  }//if
105  break;
107  if (timeout_error == true) {
108  retValue = 0;
109  }//if
110  break;
112  if (internal_error == true) {
113  retValue = 0;
114  }//if
115  break;
117  if (application_error == true) {
118  retValue = 0;
119  }//if
120  break;
122  if (user_error == true) {
123  retValue = 0;
124  }//if
125  break;
126  default:
127  break;
128  }//switch
129  if(error.status == NdbError::TemporaryError)
130  retValue = 0;
131 
132  return retValue;
133 }//handleErrorCommon()
134 
135 
136 void ErrorData::printErrorCounters(NdbOut & out) const
137 {
138  int localLoop;
139  for (localLoop = 0; localLoop < 6000; localLoop++) {
140  int errCount = (int)errorCountArray[localLoop];
141  if (errCount > 0) {
142  out << "NDBT: ErrorCode = " << localLoop << " occurred ";
143  out << errCount << " times" << endl;
144  }//if
145  }//for
146 }//printErrorCounters()
147 
148 
149 void ErrorData::printSettings(NdbOut & out)
150 {
151  out << "Key Errors are ";
152  if (key_error == false) {
153  out << "disallowed" << endl;
154  } else {
155  out << "allowed" << endl;
156  }//if
157  out << "Temporary Resource Errors are ";
158  if (temporary_resource_error == false) {
159  out << "disallowed" << endl;
160  } else {
161  out << "allowed" << endl;
162  }//if
163  if (internal_error == true) {
164  out << "Insufficient Space Errors are ";
165  }
166  if (insufficient_space_error == false) {
167  out << "disallowed" << endl;
168  } else {
169  out << "allowed" << endl;
170  }//if
171  out << "Node Recovery Errors are ";
172  if (node_recovery_error == false) {
173  out << "disallowed" << endl;
174  } else {
175  out << "allowed" << endl;
176  }//if
177  out << "Overload Errors are ";
178  if (overload_error == false) {
179  out << "disallowed" << endl;
180  } else {
181  out << "allowed" << endl;
182  }//if
183  out << "Timeout Errors are ";
184  if (timeout_error == false) {
185  out << "disallowed" << endl;
186  } else {
187  out << "allowed" << endl;
188  }//if
189  out << "Internal NDB Errors are ";
190  if (internal_error == false) {
191  out << "disallowed" << endl;
192  } else {
193  out << "allowed" << endl;
194  }//if
195  out << "User logic reported Errors are ";
196  if (user_error == false) {
197  out << "disallowed" << endl;
198  } else {
199  out << "allowed" << endl;
200  }//if
201  out << "Application Errors are ";
202  if (application_error == false) {
203  out << "disallowed" << endl;
204  } else {
205  out << "allowed" << endl;
206  }//if
207 }//printSettings
208 
209 
210 void ErrorData::printCmdLineArgs(NdbOut & out)
211 {
212  out << " -key_err Allow key errors" << endl;
213  out << " -no_key_err Disallow key errors (default)" << endl;
214  out << " -temp_res_err Allow temporary resource errors (default)";
215  out << endl;
216  out << " -no_temp_res_err Disallow temporary resource errors" << endl;
217  out << " -ins_space_err Allow insufficient space errors" << endl;
218  out << " -no_ins_space_err Disallow insufficient space errors (default)";
219  out << endl;
220  out << " -noderec_err Allow Node Recovery errors (default)" << endl;
221  out << " -no_noderec_err Disallow Node Recovery errors" << endl;
222  out << " -overload_err Allow Overload errors (default)" << endl;
223  out << " -no_overload_err Disallow Overload errors" << endl;
224  out << " -timeout_err Allow Time-out errors (default)" << endl;
225  out << " -no_timeout_err Disallow Time-out errors" << endl;
226  out << " -internal_err Allow Internal NDB errors" << endl;
227  out << " -no_internal_err Disallow Internal NDB errors (default)";
228  out << " -user_err Allow user logic reported errors (default)";
229  out << endl;
230  out << " -no_user_err Disallow user logic reported errors";
231  out << endl;
232 
233 }//printCmdLineArgs()
234 
235 
236 bool ErrorData::parseCmdLineArg(const char** argv, int & i)
237 {
238  bool ret_Value = true;
239  if (strcmp(argv[i], "-key_err") == 0){
240  key_error = true;
241  } else if (strcmp(argv[i], "-no_key_err") == 0){
242  key_error = false;
243  } else if (strcmp(argv[i], "-temp_res_err") == 0){
244  temporary_resource_error = true;
245  } else if (strcmp(argv[i], "-no_temp_res_err") == 0){
246  temporary_resource_error = false;
247  } else if (strcmp(argv[i], "-ins_space_err") == 0){
248  insufficient_space_error = true;
249  } else if (strcmp(argv[i], "-no_ins_space_err") == 0){
250  insufficient_space_error = false;
251  } else if (strcmp(argv[i], "-noderec_err") == 0){
252  node_recovery_error = true;
253  } else if (strcmp(argv[i], "-no_noderec_err") == 0){
254  node_recovery_error = false;
255  } else if (strcmp(argv[i], "-overload_err") == 0){
256  overload_error = true;
257  } else if (strcmp(argv[i], "-no_overload_err") == 0){
258  overload_error = false;
259  } else if (strcmp(argv[i], "-timeout_err") == 0){
260  timeout_error = true;
261  } else if (strcmp(argv[i], "-no_timeout_err") == 0){
262  timeout_error = false;
263  } else if (strcmp(argv[i], "-internal_err") == 0){
264  internal_error = true;
265  } else if (strcmp(argv[i], "-no_internal_err") == 0){
266  internal_error = false;
267  } else if (strcmp(argv[i], "-user_err") == 0){
268  user_error = true;
269  } else if (strcmp(argv[i], "-no_user_err") == 0){
270  user_error = false;
271  } else {
272  ret_Value = false;
273  }//if
274  return ret_Value;
275 }//bool parseCmdline
276 
278 {
279  for (int i = 0; i < 6000; i++){
280  errorCountArray[i] = 0 ;
281  }
282 }
283 
284 
285