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