1 /* Copyright (c) 2003-2005 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
17 /* This program deals with error handling */
19 #include <ndb_global.h>
22 #include <NdbTest.hpp>
23 #include <NDBT_Error.hpp>
27 ErrorData::ErrorData()
29 errorCountArray
= new Uint32
[6000];
33 temporary_resource_error
= true;
34 insufficient_space_error
= false;
35 node_recovery_error
= true;
36 overload_error
= true;
38 internal_error
= true;
40 application_error
= false;
43 ErrorData::~ErrorData()
45 delete [] errorCountArray
;
49 //-------------------------------------------------------------------
50 // Error Handling routines
51 //-------------------------------------------------------------------
53 int ErrorData::handleErrorCommon(const NdbError
& error
)
56 if (error
.code
> 6000) {
57 if (user_error
== true) {
62 errorCountArray
[error
.code
]++;
63 switch(error
.classification
){
64 case NdbError::NoDataFound
:
65 case NdbError::ConstraintViolation
:
66 if (key_error
== true) {
70 case NdbError::TemporaryResourceError
:
71 if (temporary_resource_error
== true) {
75 case NdbError::InsufficientSpace
:
76 if (insufficient_space_error
== true) {
80 case NdbError::NodeRecoveryError
:
81 if (node_recovery_error
== true) {
86 case NdbError::UnknownResultError
:
87 if(error
.code
== 4012){
90 if(error
.code
== 4115){
93 if(error
.code
== 4007 && node_recovery_error
== true){
97 case NdbError::OverloadError
:
98 if (overload_error
== true) {
99 NdbSleep_MilliSleep(50);
103 case NdbError::TimeoutExpired
:
104 if (timeout_error
== true) {
108 case NdbError::InternalError
:
109 if (internal_error
== true) {
113 case NdbError::ApplicationError
:
114 if (application_error
== true) {
118 case NdbError::UserDefinedError
:
119 if (user_error
== true) {
126 if(error
.status
== NdbError::TemporaryError
)
130 }//handleErrorCommon()
133 void ErrorData::printErrorCounters(NdbOut
& out
) const
136 for (localLoop
= 0; localLoop
< 6000; localLoop
++) {
137 int errCount
= (int)errorCountArray
[localLoop
];
139 out
<< "NDBT: ErrorCode = " << localLoop
<< " occurred ";
140 out
<< errCount
<< " times" << endl
;
143 }//printErrorCounters()
146 void ErrorData::printSettings(NdbOut
& out
)
148 out
<< "Key Errors are ";
149 if (key_error
== false) {
150 out
<< "disallowed" << endl
;
152 out
<< "allowed" << endl
;
154 out
<< "Temporary Resource Errors are ";
155 if (temporary_resource_error
== false) {
156 out
<< "disallowed" << endl
;
158 out
<< "allowed" << endl
;
160 if (internal_error
== true) {
161 out
<< "Insufficient Space Errors are ";
163 if (insufficient_space_error
== false) {
164 out
<< "disallowed" << endl
;
166 out
<< "allowed" << endl
;
168 out
<< "Node Recovery Errors are ";
169 if (node_recovery_error
== false) {
170 out
<< "disallowed" << endl
;
172 out
<< "allowed" << endl
;
174 out
<< "Overload Errors are ";
175 if (overload_error
== false) {
176 out
<< "disallowed" << endl
;
178 out
<< "allowed" << endl
;
180 out
<< "Timeout Errors are ";
181 if (timeout_error
== false) {
182 out
<< "disallowed" << endl
;
184 out
<< "allowed" << endl
;
186 out
<< "Internal NDB Errors are ";
187 if (internal_error
== false) {
188 out
<< "disallowed" << endl
;
190 out
<< "allowed" << endl
;
192 out
<< "User logic reported Errors are ";
193 if (user_error
== false) {
194 out
<< "disallowed" << endl
;
196 out
<< "allowed" << endl
;
198 out
<< "Application Errors are ";
199 if (application_error
== false) {
200 out
<< "disallowed" << endl
;
202 out
<< "allowed" << endl
;
207 void ErrorData::printCmdLineArgs(NdbOut
& out
)
209 out
<< " -key_err Allow key errors" << endl
;
210 out
<< " -no_key_err Disallow key errors (default)" << endl
;
211 out
<< " -temp_res_err Allow temporary resource errors (default)";
213 out
<< " -no_temp_res_err Disallow temporary resource errors" << endl
;
214 out
<< " -ins_space_err Allow insufficient space errors" << endl
;
215 out
<< " -no_ins_space_err Disallow insufficient space errors (default)";
217 out
<< " -noderec_err Allow Node Recovery errors (default)" << endl
;
218 out
<< " -no_noderec_err Disallow Node Recovery errors" << endl
;
219 out
<< " -overload_err Allow Overload errors (default)" << endl
;
220 out
<< " -no_overload_err Disallow Overload errors" << endl
;
221 out
<< " -timeout_err Allow Time-out errors (default)" << endl
;
222 out
<< " -no_timeout_err Disallow Time-out errors" << endl
;
223 out
<< " -internal_err Allow Internal NDB errors" << endl
;
224 out
<< " -no_internal_err Disallow Internal NDB errors (default)";
225 out
<< " -user_err Allow user logic reported errors (default)";
227 out
<< " -no_user_err Disallow user logic reported errors";
230 }//printCmdLineArgs()
233 bool ErrorData::parseCmdLineArg(const char** argv
, int & i
)
235 bool ret_Value
= true;
236 if (strcmp(argv
[i
], "-key_err") == 0){
238 } else if (strcmp(argv
[i
], "-no_key_err") == 0){
240 } else if (strcmp(argv
[i
], "-temp_res_err") == 0){
241 temporary_resource_error
= true;
242 } else if (strcmp(argv
[i
], "-no_temp_res_err") == 0){
243 temporary_resource_error
= false;
244 } else if (strcmp(argv
[i
], "-ins_space_err") == 0){
245 insufficient_space_error
= true;
246 } else if (strcmp(argv
[i
], "-no_ins_space_err") == 0){
247 insufficient_space_error
= false;
248 } else if (strcmp(argv
[i
], "-noderec_err") == 0){
249 node_recovery_error
= true;
250 } else if (strcmp(argv
[i
], "-no_noderec_err") == 0){
251 node_recovery_error
= false;
252 } else if (strcmp(argv
[i
], "-overload_err") == 0){
253 overload_error
= true;
254 } else if (strcmp(argv
[i
], "-no_overload_err") == 0){
255 overload_error
= false;
256 } else if (strcmp(argv
[i
], "-timeout_err") == 0){
257 timeout_error
= true;
258 } else if (strcmp(argv
[i
], "-no_timeout_err") == 0){
259 timeout_error
= false;
260 } else if (strcmp(argv
[i
], "-internal_err") == 0){
261 internal_error
= true;
262 } else if (strcmp(argv
[i
], "-no_internal_err") == 0){
263 internal_error
= false;
264 } else if (strcmp(argv
[i
], "-user_err") == 0){
266 } else if (strcmp(argv
[i
], "-no_user_err") == 0){
274 void ErrorData::resetErrorCounters()
276 for (int i
= 0; i
< 6000; i
++){
277 errorCountArray
[i
] = 0 ;