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