~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/src/kernel/error/ndbd_exit_codes.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

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