1 /*
2 Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #include <ndb_global.h>
26 #include <ndbd_exit_codes.h>
27
28 typedef struct ErrStruct {
29 int faultId;
30 ndbd_exit_classification classification;
31 const char* text;
32 } ErrStruct;
33
34 /**
35 * Shorter names in table below
36 */
37
38 #define XST_S ndbd_exit_st_success
39 #define XST_U ndbd_exit_st_unknown
40 #define XST_P ndbd_exit_st_permanent
41 #define XST_R ndbd_exit_st_temporary
42 #define XST_I ndbd_exit_st_filesystem_error
43
44 #define XNE ndbd_exit_cl_none
45 #define XUE ndbd_exit_cl_unknown
46 #define XIE ndbd_exit_cl_internal_error
47 #define XCE ndbd_exit_cl_configuration_error
48 #define XAE ndbd_exit_cl_arbitration_error
49 #define XRE ndbd_exit_cl_restart_error
50 #define XCR ndbd_exit_cl_resource_configuration_error
51 #define XFF ndbd_exit_cl_filesystem_full_error
52 #define XFI ndbd_exit_cl_filesystem_inconsistency_error
53 #define XFL ndbd_exit_cl_filesystem_limit
54
55 static const ErrStruct errArray[] =
56 {
57 {NDBD_EXIT_GENERIC, XRE, "Generic error"},
58 {NDBD_EXIT_PRGERR, XIE, "Assertion"},
59 {NDBD_EXIT_NODE_NOT_IN_CONFIG, XCE,
60 "node id in the configuration has the wrong type, (i.e. not an NDB node)"},
61 {NDBD_EXIT_SYSTEM_ERROR, XIE,
62 "System error, node killed during node restart by other node"},
63 {NDBD_EXIT_INDEX_NOTINRANGE, XIE, "Array index out of range"},
64 {NDBD_EXIT_ARBIT_SHUTDOWN, XAE, "Node lost connection to other nodes and "
65 "can not form a unpartitioned cluster, please investigate if there are "
66 "error(s) on other node(s)"},
67 {NDBD_EXIT_PARTITIONED_SHUTDOWN, XAE, "Partitioned cluster detected. "
68 "Please check if cluster is already running"},
69 {NDBD_EXIT_NODE_DECLARED_DEAD, XAE,
70 "Node declared dead. See error log for details"},
71 {NDBD_EXIT_POINTER_NOTINRANGE, XIE, "Pointer too large"},
72 {NDBD_EXIT_SR_OTHERNODEFAILED, XRE, "Another node failed during system "
73 "restart, please investigate error(s) on other node(s)"},
74 {NDBD_EXIT_NODE_NOT_DEAD, XRE, "Internal node state conflict, "
75 "most probably resolved by restarting node again"},
76 {NDBD_EXIT_SR_REDOLOG, XFI, "Error while reading the REDO log"},
77 {NDBD_EXIT_SR_SCHEMAFILE, XFI, "Error while reading the schema file"},
78 /* Currently unused? */
79 {2311, XIE, "Conflict when selecting restart type"},
80 {NDBD_EXIT_NO_MORE_UNDOLOG, XCR,
81 "No more free UNDO log, increase UndoIndexBuffer"},
82 {NDBD_EXIT_SR_UNDOLOG, XFI,
83 "Error while reading the datapages and UNDO log"},
84 {NDBD_EXIT_SINGLE_USER_MODE, XRE, "Data node is not allowed to get added "
85 "to the cluster while it is in single user mode"},
86 {NDBD_EXIT_MEMALLOC, XCE, "Memory allocation failure, "
87 "please decrease some configuration parameters"},
88 {NDBD_EXIT_BLOCK_JBUFCONGESTION, XIE, "Job buffer congestion"},
89 {NDBD_EXIT_TIME_QUEUE_SHORT, XIE, "Error in short time queue"},
90 {NDBD_EXIT_TIME_QUEUE_LONG, XIE, "Error in long time queue"},
91 {NDBD_EXIT_TIME_QUEUE_DELAY, XIE, "Error in time queue, too long delay"},
92 {NDBD_EXIT_TIME_QUEUE_INDEX, XIE, "Time queue index out of range"},
93 {NDBD_EXIT_BLOCK_BNR_ZERO, XIE, "Send signal error"},
94 {NDBD_EXIT_WRONG_PRIO_LEVEL, XIE, "Wrong priority level when sending signal"},
95 {NDBD_EXIT_NDBREQUIRE, XIE, "Internal program error (failed ndbrequire)"},
96 {NDBD_EXIT_NDBASSERT, XIE, "Internal program error (failed ndbassert)"},
97 {NDBD_EXIT_ERROR_INSERT, XNE, "Error insert executed" },
98 /* this error message is complemented by additional info when generated */
99 {NDBD_EXIT_INVALID_CONFIG, XCE,
100 "Invalid configuration received from Management Server"},
101
102 {NDBD_EXIT_RESOURCE_ALLOC_ERROR, XCE,
103 "Resource allocation error, please review the configuration"},
104
105 {NDBD_EXIT_NO_MORE_REDOLOG, XCR,
106 "Fatal error due to end of REDO log. Increase NoOfFragmentLogFiles or FragmentLogFileSize" },
107
108 /* this error message is complemented by additional info when
109 generated, such as signal, and text
110 */
111 {NDBD_EXIT_OS_SIGNAL_RECEIVED, XIE, "Error OS signal received"},
112
113 {NDBD_EXIT_SR_RESTARTCONFLICT, XRE,
114 "Partial system restart causing conflicting file systems"},
115
116 /* VM */
117 {NDBD_EXIT_OUT_OF_LONG_SIGNAL_MEMORY, XCR,
118 "Signal lost, out of long signal memory, please increase LongMessageBuffer"},
119 {NDBD_EXIT_WATCHDOG_TERMINATE, XIE, "WatchDog terminate, internal error "
120 "or massive overload on the machine running this node"},
121 {NDBD_EXIT_SIGNAL_LOST_SEND_BUFFER_FULL, XCR,
122 "Signal lost, out of send buffer memory, please increase SendBufferMemory or lower the load"},
123 {NDBD_EXIT_SIGNAL_LOST, XIE, "Signal lost (unknown reason)"},
124 {NDBD_EXIT_ILLEGAL_SIGNAL, XIE,
125 "Illegal signal (version mismatch a possibility)"},
126 {NDBD_EXIT_CONNECTION_SETUP_FAILED, XCE, "Connection setup failed"},
127
128 /* Ndbcntr */
129 {NDBD_EXIT_RESTART_TIMEOUT, XCE,
130 "Total restart time too long, consider increasing StartFailureTimeout "
131 "or investigate error(s) on other node(s)"},
132 {NDBD_EXIT_RESTART_DURING_SHUTDOWN, XRE,
133 "Node started while node shutdown in progress. "
134 "Please wait until shutdown complete before starting node"},
135
136 /* DIH */
137 {NDBD_EXIT_MAX_CRASHED_REPLICAS, XFL,
138 "Too many crashed replicas (8 consecutive node restart failures)"},
139 {NDBD_EXIT_MASTER_FAILURE_DURING_NR, XRE,
140 "Unhandled master failure during node restart"},
141 {NDBD_EXIT_LOST_NODE_GROUP, XAE,
142 "All nodes in a node group are unavailable"},
143 {NDBD_EXIT_NO_RESTORABLE_REPLICA, XFI,
144 "Unable to find a restorable replica"},
145
146 /* ACC */
147 {NDBD_EXIT_SR_OUT_OF_INDEXMEMORY, XCR,
148 "Out of index memory during system restart, please increase IndexMemory"},
149
150 /* TUP */
151 {NDBD_EXIT_SR_OUT_OF_DATAMEMORY, XCR,
152 "Out of data memory during system restart, please increase DataMemory"},
153
154 /* Ndbfs error messages */
155 /* Most codes will have additional info, such as OS error code */
156 {NDBD_EXIT_AFS_NOPATH, XIE, "No file system path"},
157 {2802, XIE, "Channel is full"},
158 {2803, XIE, "No more threads"},
159 {NDBD_EXIT_AFS_PARAMETER, XIE, "Bad parameter"},
160 {NDBD_EXIT_AFS_INVALIDPATH, XCE, "Illegal file system path"},
161 {NDBD_EXIT_AFS_MAXOPEN, XCR,
162 "Max number of open files exceeded, please increase MaxNoOfOpenFiles"},
163 {NDBD_EXIT_AFS_ALREADY_OPEN, XIE, "File has already been opened"},
164
165 {NDBD_EXIT_AFS_ENVIRONMENT , XIE, "Environment error using file"},
166 {NDBD_EXIT_AFS_TEMP_NO_ACCESS , XIE, "Temporary on access to file"},
167 {NDBD_EXIT_AFS_DISK_FULL , XFF, "The file system is full"},
168 {NDBD_EXIT_AFS_PERMISSION_DENIED , XCE, "Received permission denied for file"},
169 {NDBD_EXIT_AFS_INVALID_PARAM , XCE, "Invalid parameter for file"},
170 {NDBD_EXIT_AFS_UNKNOWN , XIE, "Unknown file system error"},
171 {NDBD_EXIT_AFS_NO_MORE_RESOURCES , XIE,
172 "System reports no more file system resources"},
173 {NDBD_EXIT_AFS_NO_SUCH_FILE , XFI, "File not found"},
174 {NDBD_EXIT_AFS_READ_UNDERFLOW , XFI, "Read underflow"},
175
176 {NDBD_EXIT_INVALID_LCP_FILE, XFI, "Invalid LCP" },
177 {NDBD_EXIT_INSUFFICENT_NODES, XRE, "Insufficent nodes for system restart" },
178
179 {NDBD_EXIT_UNSUPPORTED_VERSION, XRE, "Unsupported version" },
180
181 {NDBD_EXIT_RESTORE_SCHEMA, XCR, "Failure to restore schema" },
182
183 {NDBD_EXIT_GRACEFUL_SHUTDOWN_ERROR, XNE,
184 "Graceful shutdown not 100% possible due to mixed ndbd versions" },
185
186 /* Sentinel */
187 {0, XUE,
188 "No message slogan found (please report a bug if you get this error code)"}
189 };
190
191 typedef struct StatusExitMessage {
192 ndbd_exit_status status;
193 const char * message;
194 } StatusExitMessage;
195
196 typedef struct StatusExitClassification {
197 ndbd_exit_status status;
198 ndbd_exit_classification classification;
199 const char * message;
200 } StatusExitClassification;
201
202 /**
203 * Mapping between classification and status
204 */
205 static
206 const
207 StatusExitMessage StatusExitMessageMapping[] = {
208 { XST_S, "Success"},
209 { XST_U ,"Unknown"},
210 { XST_P, "Permanent error, external action needed"},
211 { XST_R, "Temporary error, restart node"},
212 { XST_I, "Ndbd file system error, restart node initial"}
213 };
214
215 static
216 const
217 int NbExitStatus = sizeof(StatusExitMessageMapping)/sizeof(StatusExitMessage);
218
219 static
220 const
221 StatusExitClassification StatusExitClassificationMapping[] = {
222 { XST_S, XNE, "No error"},
223 { XST_U, XUE, "Unknown"},
224 { XST_R, XIE, "Internal error, programming error or missing error message, "
225 "please report a bug"},
226 { XST_P, XCE, "Configuration error"},
227 { XST_R, XAE, "Arbitration error"},
228 { XST_R, XRE, "Restart error"},
229 { XST_P, XCR, "Resource configuration error"},
230 { XST_P, XFF, "File system full"},
231 { XST_I, XFI, "Ndbd file system inconsistency error, please report a bug"},
232 { XST_I, XFL, "Ndbd file system limit exceeded"}
233 };
234
235 static const int NbExitClassification =
236 sizeof(StatusExitClassificationMapping)/sizeof(StatusExitClassification);
237
ndbd_exit_message(int faultId,ndbd_exit_classification * cl)238 const char *ndbd_exit_message(int faultId, ndbd_exit_classification *cl)
239 {
240 int i = 0;
241 while (errArray[i].faultId != faultId && errArray[i].faultId != 0)
242 i++;
243 *cl = errArray[i].classification;
244 return errArray[i].text;
245 }
246
247 static const char* empty_xstring = "";
248
249 const
ndbd_exit_classification_message(ndbd_exit_classification classification,ndbd_exit_status * status)250 char *ndbd_exit_classification_message(ndbd_exit_classification classification,
251 ndbd_exit_status *status)
252 {
253 int i;
254 for (i= 0; i < NbExitClassification; i++)
255 {
256 if (StatusExitClassificationMapping[i].classification == classification)
257 {
258 *status = StatusExitClassificationMapping[i].status;
259 return StatusExitClassificationMapping[i].message;
260 }
261 }
262 *status = XST_U;
263 return empty_xstring;
264 }
265
ndbd_exit_status_message(ndbd_exit_status status)266 const char *ndbd_exit_status_message(ndbd_exit_status status)
267 {
268 int i;
269 for (i= 0; i < NbExitStatus; i++)
270 if (StatusExitMessageMapping[i].status == status)
271 return StatusExitMessageMapping[i].message;
272 return empty_xstring;
273 }
274
ndbd_exit_string(int err_no,char * str,unsigned int size)275 int ndbd_exit_string(int err_no, char *str, unsigned int size)
276 {
277 unsigned int len;
278
279 ndbd_exit_classification cl;
280 ndbd_exit_status st;
281 const char *msg = ndbd_exit_message(err_no, &cl);
282 if (msg[0] != '\0' && cl != XUE)
283 {
284 const char *cl_msg = ndbd_exit_classification_message(cl, &st);
285 const char *st_msg = ndbd_exit_status_message(st);
286
287 len = my_snprintf(str, size-1, "%s: %s: %s", msg, st_msg, cl_msg);
288 str[size-1]= '\0';
289
290 return len;
291 }
292 return -1;
293 }
294