MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventLogger.cpp
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 
20 #include <EventLogger.hpp>
21 #include <TransporterCallback.hpp>
22 
23 #include <NdbConfig.h>
24 #include <kernel/BlockNumbers.h>
25 #include <signaldata/ArbitSignalData.hpp>
26 #include <signaldata/FailRep.hpp>
27 #include <NodeState.hpp>
28 #include <version.h>
29 #include <ndb_version.h>
30 
31 #include <ndbd_exit_codes.h>
32 
33 #define make_uint64(a,b) (((Uint64)(a)) + (((Uint64)(b)) << 32))
34 
35 //
36 // PUBLIC
37 //
38 EventLoggerBase::~EventLoggerBase()
39 {
40 
41 }
42 
43 #define QQQQ char *m_text, size_t m_text_len, const Uint32* theData, Uint32 len
44 
45 void getTextConnected(QQQQ) {
46  BaseString::snprintf(m_text, m_text_len,
47  "Node %u Connected",
48  theData[1]);
49 }
50 void getTextConnectedApiVersion(QQQQ) {
51  char tmp[100];
52  Uint32 mysql_version = theData[3];
53  if (theData[2] < NDBD_SPLIT_VERSION)
54  mysql_version = 0;
55  BaseString::snprintf(m_text, m_text_len,
56  "Node %u: API %s",
57  theData[1],
58  ndbGetVersionString(theData[2], mysql_version, 0,
59  tmp, sizeof(tmp)));
60 }
61 
62 void getTextDisconnected(QQQQ) {
63  BaseString::snprintf(m_text, m_text_len,
64  "Node %u Disconnected",
65  theData[1]);
66 }
67 void getTextCommunicationClosed(QQQQ) {
68  //-----------------------------------------------------------------------
69  // REPORT communication to node closed.
70  //-----------------------------------------------------------------------
71  BaseString::snprintf(m_text, m_text_len,
72  "Communication to Node %u closed",
73  theData[1]);
74 }
75 void getTextCommunicationOpened(QQQQ) {
76  //-----------------------------------------------------------------------
77  // REPORT communication to node opened.
78  //-----------------------------------------------------------------------
79  BaseString::snprintf(m_text, m_text_len,
80  "Communication to Node %u opened",
81  theData[1]);
82 }
83 void getTextNDBStartStarted(QQQQ) {
84  //-----------------------------------------------------------------------
85  // Start of NDB has been initiated.
86  //-----------------------------------------------------------------------
87 
88  char tmp[100];
89  Uint32 mysql_version = theData[2];
90  if (theData[1] < NDBD_SPLIT_VERSION)
91  mysql_version = 0;
92  BaseString::snprintf(m_text, m_text_len,
93  "Start initiated (%s)",
94  ndbGetVersionString(theData[1], mysql_version, 0,
95  tmp, sizeof(tmp)));
96 }
97 void getTextNDBStopStarted(QQQQ) {
98  BaseString::snprintf(m_text, m_text_len,
99  "%s shutdown initiated",
100  (theData[1] == 1 ? "Cluster" : "Node"));
101 }
102 void getRestartAction(Uint32 action, BaseString &str)
103 {
104  if (action == 0)
105  return;
106  str.appfmt(", restarting");
107  if (action & 2)
108  str.appfmt(", no start");
109  if (action & 4)
110  str.appfmt(", initial");
111 }
112 void getTextNDBStopCompleted(QQQQ) {
113  BaseString action_str("");
114  BaseString signum_str("");
115  getRestartAction(theData[1], action_str);
116  if (theData[2])
117  signum_str.appfmt(" Initiated by signal %d.", theData[2]);
118  BaseString::snprintf(m_text, m_text_len,
119  "Node shutdown completed%s.%s",
120  action_str.c_str(),
121  signum_str.c_str());
122 }
123 void getTextNDBStopForced(QQQQ) {
124  BaseString action_str("");
125  BaseString reason_str("");
126  BaseString sphase_str("");
127  int signum = theData[2];
128  int error = theData[3];
129  int sphase = theData[4];
130  int extra = theData[5];
131  if (signum)
132  getRestartAction(theData[1],action_str);
133  if (signum)
134  reason_str.appfmt(" Initiated by signal %d.", signum);
135  if (error)
136  {
137  ndbd_exit_classification cl;
138  ndbd_exit_status st;
139  const char *msg = ndbd_exit_message(error, &cl);
140  const char *cl_msg = ndbd_exit_classification_message(cl, &st);
141  const char *st_msg = ndbd_exit_status_message(st);
142  reason_str.appfmt(" Caused by error %d: \'%s(%s). %s\'.",
143  error, msg, cl_msg, st_msg);
144  if (extra != 0)
145  reason_str.appfmt(" (extra info %d)", extra);
146  }
147  if (sphase < 255)
148  sphase_str.appfmt(" Occured during startphase %u.", sphase);
149  BaseString::snprintf(m_text, m_text_len,
150  "Forced node shutdown completed%s.%s%s",
151  action_str.c_str(), sphase_str.c_str(),
152  reason_str.c_str());
153 }
154 void getTextNDBStopAborted(QQQQ) {
155  BaseString::snprintf(m_text, m_text_len,
156  "Node shutdown aborted");
157 }
158 void getTextNDBStartCompleted(QQQQ) {
159  //-----------------------------------------------------------------------
160  // Start of NDB has been completed.
161  //-----------------------------------------------------------------------
162 
163  char tmp[100];
164  Uint32 mysql_version = theData[2];
165  if (theData[1] < NDBD_SPLIT_VERSION)
166  mysql_version = 0;
167  BaseString::snprintf(m_text, m_text_len,
168  "Started (%s)",
169  ndbGetVersionString(theData[1], mysql_version, 0,
170  tmp, sizeof(tmp)));
171 }
172 
173 void getTextSTTORRYRecieved(QQQQ) {
174  //-----------------------------------------------------------------------
175  // STTORRY recevied after restart finished.
176  //-----------------------------------------------------------------------
177  BaseString::snprintf(m_text, m_text_len,
178  "STTORRY received after restart finished");
179 }
180 void getTextStartPhaseCompleted(QQQQ) {
181  //-----------------------------------------------------------------------
182  // REPORT Start phase completed.
183  //-----------------------------------------------------------------------
184  const char *type = "<Unknown>";
185  switch((NodeState::StartType)theData[2]){
186  case NodeState::ST_INITIAL_START:
187  type = "(initial start)";
188  break;
189  case NodeState::ST_SYSTEM_RESTART:
190  type = "(system restart)";
191  break;
192  case NodeState::ST_NODE_RESTART:
193  type = "(node restart)";
194  break;
195  case NodeState::ST_INITIAL_NODE_RESTART:
196  type = "(initial node restart)";
197  break;
198  case NodeState::ST_ILLEGAL_TYPE:
199  type = "";
200  break;
201  default:
202  BaseString::snprintf(m_text, m_text_len,
203  "Start phase %u completed (unknown = %d)",
204  theData[1],
205  theData[2]);
206  return;
207  }
208  BaseString::snprintf(m_text, m_text_len,
209  "Start phase %u completed %s",
210  theData[1],
211  type);
212 }
213 void getTextCM_REGCONF(QQQQ) {
214  BaseString::snprintf(m_text, m_text_len,
215  "CM_REGCONF president = %u, own Node = %u, our dynamic id = %u/%u",
216  theData[2],
217  theData[1],
218  (theData[3] >> 16), (theData[3] & 0xFFFF));
219 }
220 void getTextCM_REGREF(QQQQ) {
221  const char* line = "";
222  switch (theData[3]) {
223  case 0:
224  line = "Busy";
225  break;
226  case 1:
227  line = "Election with wait = false";
228  break;
229  case 2:
230  line = "Election with wait = false";
231  break;
232  case 3:
233  line = "Not president";
234  break;
235  case 4:
236  line = "Election without selecting new candidate";
237  break;
238  default:
239  line = "No such cause";
240  break;
241  }//switch
242 
243  BaseString::snprintf(m_text, m_text_len,
244  "CM_REGREF from Node %u to our Node %u. Cause = %s",
245  theData[2],
246  theData[1],
247  line);
248 }
249 void getTextFIND_NEIGHBOURS(QQQQ) {
250  //-----------------------------------------------------------------------
251  // REPORT Node Restart copied a fragment.
252  //-----------------------------------------------------------------------
253  BaseString::snprintf(m_text, m_text_len,
254  "We are Node %u with dynamic ID %u, our left neighbour "
255  "is Node %u, our right is Node %u",
256  theData[1],
257  theData[4],
258  theData[2],
259  theData[3]);
260 }
261 void getTextNodeFailCompleted(QQQQ) {
262  //-----------------------------------------------------------------------
263  // REPORT Node failure phase completed.
264  //-----------------------------------------------------------------------
265  if (theData[1] == 0)
266  {
267  if (theData[3] != 0) {
268  BaseString::snprintf(m_text, m_text_len,
269  "Node %u completed failure of Node %u",
270  theData[3],
271  theData[2]);
272  } else {
273  BaseString::snprintf(m_text, m_text_len,
274  "All nodes completed failure of Node %u",
275  theData[2]);
276  }//if
277  } else {
278  const char* line = "";
279  if (theData[1] == DBTC){
280  line = "DBTC";
281  }else if (theData[1] == DBDICT){
282  line = "DBDICT";
283  }else if (theData[1] == DBDIH){
284  line = "DBDIH";
285  }else if (theData[1] == DBLQH){
286  line = "DBLQH";
287  }
288  BaseString::snprintf(m_text, m_text_len,
289  "Node failure of %u %s completed",
290  theData[2],
291  line);
292  }
293 }
294 void getTextNODE_FAILREP(QQQQ) {
295  BaseString::snprintf(m_text, m_text_len,
296  "Node %u has failed. The Node state at failure "
297  "was %u",
298  theData[1],
299  theData[2]);
300 }
301 void getTextArbitState(QQQQ) {
302  //-----------------------------------------------------------------------
303  // REPORT arbitrator found or lost.
304  //-----------------------------------------------------------------------
305  {
306  const ArbitSignalData* sd = (ArbitSignalData*)theData;
307  char ticketText[ArbitTicket::TextLength + 1];
308  char errText[ArbitCode::ErrTextLength + 1];
309  const unsigned code = sd->code & 0xFFFF;
310  const unsigned state = sd->code >> 16;
311  switch (code) {
312  case ArbitCode::ThreadStart:
313  BaseString::snprintf(m_text, m_text_len,
314  "President restarts arbitration thread [state=%u]",
315  state);
316  break;
317  case ArbitCode::PrepPart2:
318  sd->ticket.getText(ticketText, sizeof(ticketText));
319  BaseString::snprintf(m_text, m_text_len,
320  "Prepare arbitrator node %u [ticket=%s]",
321  sd->node, ticketText);
322  break;
323  case ArbitCode::PrepAtrun:
324  sd->ticket.getText(ticketText, sizeof(ticketText));
325  BaseString::snprintf(m_text, m_text_len,
326  "Receive arbitrator node %u [ticket=%s]",
327  sd->node, ticketText);
328  break;
329  case ArbitCode::ApiStart:
330  sd->ticket.getText(ticketText, sizeof(ticketText));
331  BaseString::snprintf(m_text, m_text_len,
332  "Started arbitrator node %u [ticket=%s]",
333  sd->node, ticketText);
334  break;
335  case ArbitCode::ApiFail:
336  BaseString::snprintf(m_text, m_text_len,
337  "Lost arbitrator node %u - process failure [state=%u]",
338  sd->node, state);
339  break;
340  case ArbitCode::ApiExit:
341  BaseString::snprintf(m_text, m_text_len,
342  "Lost arbitrator node %u - process exit [state=%u]",
343  sd->node, state);
344  break;
345  default:
346  ArbitCode::getErrText(code, errText, sizeof(errText));
347  BaseString::snprintf(m_text, m_text_len,
348  "Lost arbitrator node %u - %s [state=%u]",
349  sd->node, errText, state);
350  break;
351  }
352  }
353 }
354 
355 void getTextArbitResult(QQQQ) {
356  //-----------------------------------------------------------------------
357  // REPORT arbitration result (the failures may not reach us).
358  //-----------------------------------------------------------------------
359  {
360  const ArbitSignalData* sd = (ArbitSignalData*)theData;
361  char errText[ArbitCode::ErrTextLength + 1];
362  const unsigned code = sd->code & 0xFFFF;
363  const unsigned state = sd->code >> 16;
364  switch (code) {
365  case ArbitCode::LoseNodes:
366  BaseString::snprintf(m_text, m_text_len,
367  "Arbitration check lost - less than 1/2 nodes left");
368  break;
369  case ArbitCode::WinNodes:
370  BaseString::snprintf(m_text, m_text_len,
371  "Arbitration check won - all node groups and more than 1/2 nodes left");
372  break;
373  case ArbitCode::WinGroups:
374  BaseString::snprintf(m_text, m_text_len,
375  "Arbitration check won - node group majority");
376  break;
377  case ArbitCode::LoseGroups:
378  BaseString::snprintf(m_text, m_text_len,
379  "Arbitration check lost - missing node group");
380  break;
381  case ArbitCode::Partitioning:
382  BaseString::snprintf(m_text, m_text_len,
383  "Network partitioning - arbitration required");
384  break;
385  case ArbitCode::WinChoose:
386  BaseString::snprintf(m_text, m_text_len,
387  "Arbitration won - positive reply from node %u",
388  sd->node);
389  break;
390  case ArbitCode::LoseChoose:
391  BaseString::snprintf(m_text, m_text_len,
392  "Arbitration lost - negative reply from node %u",
393  sd->node);
394  break;
395  case ArbitCode::LoseNorun:
396  BaseString::snprintf(m_text, m_text_len,
397  "Network partitioning - no arbitrator available");
398  break;
399  case ArbitCode::LoseNocfg:
400  BaseString::snprintf(m_text, m_text_len,
401  "Network partitioning - no arbitrator configured");
402  break;
403  case ArbitCode::WinWaitExternal:{
404  char buf[8*4*2+1];
405  sd->mask.getText(buf);
406  BaseString::snprintf(m_text, m_text_len,
407  "Continuing after wait for external arbitration, "
408  "nodes: %s", buf);
409  break;
410  }
411  default:
412  ArbitCode::getErrText(code, errText, sizeof(errText));
413  BaseString::snprintf(m_text, m_text_len,
414  "Arbitration failure - %s [state=%u]",
415  errText, state);
416  break;
417  }
418  }
419 }
420 void getTextGlobalCheckpointStarted(QQQQ) {
421  //-----------------------------------------------------------------------
422  // This event reports that a global checkpoint has been started and this
423  // node is the master of this global checkpoint.
424  //-----------------------------------------------------------------------
425  BaseString::snprintf(m_text, m_text_len,
426  "Global checkpoint %u started",
427  theData[1]);
428 }
429 void getTextGlobalCheckpointCompleted(QQQQ) {
430  //-----------------------------------------------------------------------
431  // This event reports that a global checkpoint has been completed on this
432  // node and the node is the master of this global checkpoint.
433  //-----------------------------------------------------------------------
434  BaseString::snprintf(m_text, m_text_len,
435  "Global checkpoint %u completed",
436  theData[1]);
437 }
438 void getTextLocalCheckpointStarted(QQQQ) {
439  //-----------------------------------------------------------------------
440  // This event reports that a local checkpoint has been started and this
441  // node is the master of this local checkpoint.
442  //-----------------------------------------------------------------------
443  BaseString::snprintf(m_text, m_text_len,
444  "Local checkpoint %u started. "
445  "Keep GCI = %u oldest restorable GCI = %u",
446  theData[1],
447  theData[2],
448  theData[3]);
449 }
450 void getTextLocalCheckpointCompleted(QQQQ) {
451  //-----------------------------------------------------------------------
452  // This event reports that a local checkpoint has been completed on this
453  // node and the node is the master of this local checkpoint.
454  //-----------------------------------------------------------------------
455  BaseString::snprintf(m_text, m_text_len,
456  "Local checkpoint %u completed",
457  theData[1]);
458 }
459 void getTextTableCreated(QQQQ) {
460  //-----------------------------------------------------------------------
461  // This event reports that a table has been created.
462  //-----------------------------------------------------------------------
463  BaseString::snprintf(m_text, m_text_len,
464  "Table with ID = %u created",
465  theData[1]);
466 }
467 /* STRANGE */
468 void getTextLCPStoppedInCalcKeepGci(QQQQ) {
469  if (theData[1] == 0)
470  BaseString::snprintf(m_text, m_text_len,
471  "Local Checkpoint stopped in CALCULATED_KEEP_GCI");
472 }
473 void getTextNR_CopyDict(QQQQ) {
474  //-----------------------------------------------------------------------
475  // REPORT Node Restart completed copy of dictionary information.
476  //-----------------------------------------------------------------------
477  BaseString::snprintf(m_text, m_text_len,
478  "Node restart completed copy of dictionary information");
479 }
480 void getTextNR_CopyDistr(QQQQ) {
481  //-----------------------------------------------------------------------
482  // REPORT Node Restart completed copy of distribution information.
483  //-----------------------------------------------------------------------
484  BaseString::snprintf(m_text, m_text_len,
485  "Node restart completed copy of distribution information");
486 }
487 void getTextNR_CopyFragsStarted(QQQQ) {
488  //-----------------------------------------------------------------------
489  // REPORT Node Restart is starting to copy the fragments.
490  //-----------------------------------------------------------------------
491  BaseString::snprintf(m_text, m_text_len,
492  "Node restart starting to copy the fragments "
493  "to Node %u",
494  theData[1]);
495 }
496 void getTextNR_CopyFragDone(QQQQ) {
497  //-----------------------------------------------------------------------
498  // REPORT Node Restart copied a fragment.
499  //-----------------------------------------------------------------------
500  Uint64 rows = theData[4] + (Uint64(theData[5]) << 32);
501  Uint64 bytes = theData[6] + (Uint64(theData[7]) << 32);
502  BaseString::snprintf(m_text, m_text_len,
503  "Table ID = %u, fragment ID = %u have been synced "
504  "to Node %u rows: %llu bytes: %llu ",
505  theData[2],
506  theData[3],
507  theData[1],
508  rows, bytes);
509 }
510 void getTextNR_CopyFragsCompleted(QQQQ) {
511  BaseString::snprintf(m_text, m_text_len,
512  "Node restart completed copying the fragments "
513  "to Node %u",
514  theData[1]);
515 }
516 void getTextLCPFragmentCompleted(QQQQ) {
517  BaseString::snprintf(m_text, m_text_len,
518  "Table ID = %u, fragment ID = %u has completed LCP "
519  "on Node %u maxGciStarted: %d maxGciCompleted: %d",
520  theData[2],
521  theData[3],
522  theData[1],
523  theData[4],
524  theData[5]);
525 }
526 void getTextTransReportCounters(QQQQ) {
527  // -------------------------------------------------------------------
528  // Report information about transaction activity once per 10 seconds.
529  // -------------------------------------------------------------------
530  BaseString::snprintf(m_text, m_text_len,
531  "Trans. Count = %u, Commit Count = %u, "
532  "Read Count = %u, Simple Read Count = %u, "
533  "Write Count = %u, AttrInfo Count = %u, "
534  "Concurrent Operations = %u, Abort Count = %u"
535  " Scans = %u Range scans = %u",
536  theData[1],
537  theData[2],
538  theData[3],
539  theData[4],
540  theData[5],
541  theData[6],
542  theData[7],
543  theData[8],
544  theData[9],
545  theData[10]);
546 }
547 void getTextOperationReportCounters(QQQQ) {
548  BaseString::snprintf(m_text, m_text_len,
549  "Operations=%u",
550  theData[1]);
551 }
552 void getTextUndoLogBlocked(QQQQ) {
553  //-----------------------------------------------------------------------
554  // REPORT Undo Logging blocked due to buffer near to overflow.
555  //-----------------------------------------------------------------------
556  BaseString::snprintf(m_text, m_text_len,
557  "ACC Blocked %u and TUP Blocked %u times last second",
558  theData[1],
559  theData[2]);
560 }
561 
562 void getTextTransporterError(QQQQ) {
563  struct myTransporterError{
564  Uint32 errorNum;
565  char errorString[256];
566  };
567  int i = 0;
568  int lenth = 0;
569  static const struct myTransporterError TransporterErrorString[]=
570  {
571  //TE_NO_ERROR = 0
572  {TE_NO_ERROR,"No error"},
573  //TE_ERROR_CLOSING_SOCKET = 0x1
574  {TE_ERROR_CLOSING_SOCKET,"Error found during closing of socket"},
575  //TE_ERROR_IN_SELECT_BEFORE_ACCEPT = 0x2
576  {TE_ERROR_IN_SELECT_BEFORE_ACCEPT,"Error found before accept. The transporter will retry"},
577  //TE_INVALID_MESSAGE_LENGTH = 0x3 | TE_DO_DISCONNECT
578  {TE_INVALID_MESSAGE_LENGTH,"Error found in message (invalid message length)"},
579  //TE_INVALID_CHECKSUM = 0x4 | TE_DO_DISCONNECT
580  {TE_INVALID_CHECKSUM,"Error found in message (checksum)"},
581  //TE_COULD_NOT_CREATE_SOCKET = 0x5
582  {TE_COULD_NOT_CREATE_SOCKET,"Error found while creating socket(can't create socket)"},
583  //TE_COULD_NOT_BIND_SOCKET = 0x6
584  {TE_COULD_NOT_BIND_SOCKET,"Error found while binding server socket"},
585  //TE_LISTEN_FAILED = 0x7
586  {TE_LISTEN_FAILED,"Error found while listening to server socket"},
587  //TE_ACCEPT_RETURN_ERROR = 0x8
588  {TE_ACCEPT_RETURN_ERROR,"Error found during accept(accept return error)"},
589  //TE_SHM_DISCONNECT = 0xb | TE_DO_DISCONNECT
590  {TE_SHM_DISCONNECT,"The remote node has disconnected"},
591  //TE_SHM_IPC_STAT = 0xc | TE_DO_DISCONNECT
592  {TE_SHM_IPC_STAT,"Unable to check shm segment"},
593  //TE_SHM_UNABLE_TO_CREATE_SEGMENT = 0xd
594  {TE_SHM_UNABLE_TO_CREATE_SEGMENT,"Unable to create shm segment"},
595  //TE_SHM_UNABLE_TO_ATTACH_SEGMENT = 0xe
596  {TE_SHM_UNABLE_TO_ATTACH_SEGMENT,"Unable to attach shm segment"},
597  //TE_SHM_UNABLE_TO_REMOVE_SEGMENT = 0xf
598  {TE_SHM_UNABLE_TO_REMOVE_SEGMENT,"Unable to remove shm segment"},
599  //TE_TOO_SMALL_SIGID = 0x10
600  {TE_TOO_SMALL_SIGID,"Sig ID too small"},
601  //TE_TOO_LARGE_SIGID = 0x11
602  {TE_TOO_LARGE_SIGID,"Sig ID too large"},
603  //TE_WAIT_STACK_FULL = 0x12 | TE_DO_DISCONNECT
604  {TE_WAIT_STACK_FULL,"Wait stack was full"},
605  //TE_RECEIVE_BUFFER_FULL = 0x13 | TE_DO_DISCONNECT
606  {TE_RECEIVE_BUFFER_FULL,"Receive buffer was full"},
607  //TE_SIGNAL_LOST_SEND_BUFFER_FULL = 0x14 | TE_DO_DISCONNECT
608  {TE_SIGNAL_LOST_SEND_BUFFER_FULL,"Send buffer was full,and trying to force send fails"},
609  //TE_SIGNAL_LOST = 0x15
610  {TE_SIGNAL_LOST,"Send failed for unknown reason(signal lost)"},
611  //TE_SEND_BUFFER_FULL = 0x16
612  {TE_SEND_BUFFER_FULL,"The send buffer was full, but sleeping for a while solved"},
613  //TE_SCI_LINK_ERROR = 0x0017
614  {TE_SCI_LINK_ERROR,"There is no link from this node to the switch"},
615  //TE_SCI_UNABLE_TO_START_SEQUENCE = 0x18 | TE_DO_DISCONNECT
616  {TE_SCI_UNABLE_TO_START_SEQUENCE,"Could not start a sequence, because system resources are exumed or no sequence has been created"},
617  //TE_SCI_UNABLE_TO_REMOVE_SEQUENCE = 0x19 | TE_DO_DISCONNECT
618  {TE_SCI_UNABLE_TO_REMOVE_SEQUENCE,"Could not remove a sequence"},
619  //TE_SCI_UNABLE_TO_CREATE_SEQUENCE = 0x1a | TE_DO_DISCONNECT
620  {TE_SCI_UNABLE_TO_CREATE_SEQUENCE,"Could not create a sequence, because system resources are exempted. Must reboot"},
621  //TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR = 0x1b | TE_DO_DISCONNECT
622  {TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR,"Tried to send data on redundant link but failed"},
623  //TE_SCI_CANNOT_INIT_LOCALSEGMENT = 0x1c | TE_DO_DISCONNECT
624  {TE_SCI_CANNOT_INIT_LOCALSEGMENT,"Cannot initialize local segment"},
625  //TE_SCI_CANNOT_MAP_REMOTESEGMENT = 0x1d | TE_DO_DISCONNEC
626  {TE_SCI_CANNOT_MAP_REMOTESEGMENT,"Cannot map remote segment"},
627  //TE_SCI_UNABLE_TO_UNMAP_SEGMENT = 0x1e | TE_DO_DISCONNECT
628  {TE_SCI_UNABLE_TO_UNMAP_SEGMENT,"Cannot free the resources used by this segment (step 1)"},
629  //TE_SCI_UNABLE_TO_REMOVE_SEGMENT = 0x1f | TE_DO_DISCONNEC
630  {TE_SCI_UNABLE_TO_REMOVE_SEGMENT,"Cannot free the resources used by this segment (step 2)"},
631  //TE_SCI_UNABLE_TO_DISCONNECT_SEGMENT = 0x20 | TE_DO_DISCONNECT
632  {TE_SCI_UNABLE_TO_DISCONNECT_SEGMENT,"Cannot disconnect from a remote segment"},
633  //TE_SHM_IPC_PERMANENT = 0x21
634  {TE_SHM_IPC_PERMANENT,"Shm ipc Permanent error"},
635  //TE_SCI_UNABLE_TO_CLOSE_CHANNEL = 0x22
636  {TE_SCI_UNABLE_TO_CLOSE_CHANNEL,"Unable to close the sci channel and the resources allocated"}
637  };
638 
639  lenth = sizeof(TransporterErrorString)/sizeof(struct myTransporterError);
640  for(i=0; i<lenth; i++)
641  {
642  if(theData[2] == (Uint32) TransporterErrorString[i].errorNum)
643  {
644  BaseString::snprintf(m_text, m_text_len,
645  "Transporter to node %d reported error 0x%x: %s",
646  theData[1],
647  theData[2],
648  TransporterErrorString[i].errorString);
649  break;
650  }
651  }
652  if(i == lenth)
653  BaseString::snprintf(m_text, m_text_len,
654  "Transporter to node %d reported error 0x%x: unknown error",
655  theData[1],
656  theData[2]);
657 }
658 void getTextTransporterWarning(QQQQ) {
659  getTextTransporterError(m_text, m_text_len, theData, len);
660 }
661 void getTextMissedHeartbeat(QQQQ) {
662  BaseString::snprintf(m_text, m_text_len,
663  "Node %d missed heartbeat %d",
664  theData[1],
665  theData[2]);
666 }
667 void getTextDeadDueToHeartbeat(QQQQ) {
668  BaseString::snprintf(m_text, m_text_len,
669  "Node %d declared dead due to missed heartbeat",
670  theData[1]);
671 }
672 void getTextJobStatistic(QQQQ) {
673  BaseString::snprintf(m_text, m_text_len,
674  "Mean loop Counter in doJob last 8192 times = %u",
675  theData[1]);
676 }
677 void getTextThreadConfigLoop(QQQQ) {
678  BaseString::snprintf(m_text, m_text_len,
679  "8192 loops,tot %u usec,exec %u extra:loops = %u,time %u,const %u",
680  theData[1], theData[3], theData[4], theData[5],
681  theData[2]);
682 }
683 void getTextSendBytesStatistic(QQQQ) {
684  BaseString::snprintf(m_text, m_text_len,
685  "Mean send size to Node = %d last 4096 sends = %u bytes",
686  theData[1],
687  theData[2]);
688 }
689 void getTextReceiveBytesStatistic(QQQQ) {
690  BaseString::snprintf(m_text, m_text_len,
691  "Mean receive size to Node = %d last 4096 sends = %u bytes",
692  theData[1],
693  theData[2]);
694 }
695 void getTextSentHeartbeat(QQQQ) {
696  BaseString::snprintf(m_text, m_text_len,
697  "Node Sent Heartbeat to node = %d",
698  theData[1]);
699 }
700 void getTextCreateLogBytes(QQQQ) {
701  BaseString::snprintf(m_text, m_text_len,
702  "Log part %u, log file %u, MB %u",
703  theData[1],
704  theData[2],
705  theData[3]);
706 }
707 void getTextStartLog(QQQQ) {
708  BaseString::snprintf(m_text, m_text_len,
709  "Log part %u, start MB %u, stop MB %u, last GCI, log exec %u",
710  theData[1],
711  theData[2],
712  theData[3],
713  theData[4]);
714 }
715 void getTextStartREDOLog(QQQQ) {
716  BaseString::snprintf(m_text, m_text_len,
717  "Node: %d StartLog: [GCI Keep: %d LastCompleted: %d NewestRestorable: %d]",
718  theData[1],
719  theData[2],
720  theData[3],
721  theData[4]);
722 }
723 void getTextRedoStatus(QQQQ) {
724  Uint64 total = (Uint64(theData[6]) << 32) + theData[7];
725  Uint64 free = (Uint64(theData[8]) << 32) + theData[9];
726 
727  BaseString::snprintf(m_text, m_text_len,
728  "Logpart: %u head=[ file: %u mbyte: %u ] tail=[ file: %u mbyte: %u ] total mb: %llu free mb: %llu free%%: %u",
729  theData[1],
730  theData[2],
731  theData[3],
732  theData[4],
733  theData[5],
734  total,
735  free,
736  Uint32((100 * free) / total));
737 }
738 void getTextUNDORecordsExecuted(QQQQ) {
739  const char* line = "";
740  if (theData[1] == DBTUP){
741  line = "DBTUP";
742  }else if (theData[1] == DBACC){
743  line = "DBACC";
744  }
745 
746  BaseString::snprintf(m_text, m_text_len,
747  " UNDO %s %d [%d %d %d %d %d %d %d %d %d]",
748  line,
749  theData[2],
750  theData[3],
751  theData[4],
752  theData[5],
753  theData[6],
754  theData[7],
755  theData[8],
756  theData[9],
757  theData[10],
758  theData[11]);
759 }
760 void getTextInfoEvent(QQQQ) {
761  BaseString::snprintf(m_text, m_text_len, "%s", (char *)&theData[1]);
762 }
763 const char bytes_unit[]= "B";
764 const char kbytes_unit[]= "KB";
765 const char mbytes_unit[]= "MB";
766 static void convert_unit(unsigned &data, const char *&unit)
767 {
768  if (data < 16*1024)
769  {
770  unit= bytes_unit;
771  return;
772  }
773  if (data < 16*1024*1024)
774  {
775  data= (data+1023)/1024;
776  unit= kbytes_unit;
777  return;
778  }
779  data= (data+1024*1024-1)/(1024*1024);
780  unit= mbytes_unit;
781 }
782 
783 void getTextEventBufferStatus(QQQQ) {
784  unsigned used= theData[1], alloc= theData[2], max_= theData[3];
785  const char *used_unit, *alloc_unit, *max_unit;
786  convert_unit(used, used_unit);
787  convert_unit(alloc, alloc_unit);
788  convert_unit(max_, max_unit);
789  BaseString::snprintf(m_text, m_text_len,
790  "Event buffer status: used=%d%s(%d%%) alloc=%d%s(%d%%) "
791  "max=%d%s apply_epoch=%u/%u latest_epoch=%u/%u",
792  used, used_unit,
793  theData[2] ? (Uint32)((((Uint64)theData[1])*100)/theData[2]) : 0,
794  alloc, alloc_unit,
795  theData[3] ? (Uint32)((((Uint64)theData[2])*100)/theData[3]) : 0,
796  max_, max_unit,
797  theData[5], theData[4],
798  theData[7], theData[6]);
799 }
800 void getTextWarningEvent(QQQQ) {
801  BaseString::snprintf(m_text, m_text_len, "%s", (char *)&theData[1]);
802 }
803 void getTextGCP_TakeoverStarted(QQQQ) {
804  BaseString::snprintf(m_text, m_text_len, "GCP Take over started");
805 }
806 void getTextGCP_TakeoverCompleted(QQQQ) {
807  BaseString::snprintf(m_text, m_text_len, "GCP Take over completed");
808 }
809 void getTextLCP_TakeoverStarted(QQQQ) {
810  BaseString::snprintf(m_text, m_text_len, "LCP Take over started");
811 }
812 void getTextLCP_TakeoverCompleted(QQQQ) {
813  BaseString::snprintf(m_text, m_text_len,
814  "LCP Take over completed (state = %d)",
815  theData[1]);
816 }
817 void getTextMemoryUsage(QQQQ) {
818  const int gth = theData[1];
819  const int size = theData[2];
820  const int used = theData[3];
821  const int total = theData[4];
822  const int block = theData[5];
823  const int percent = total ? (used*100)/total : 0;
824 
825  BaseString::snprintf(m_text, m_text_len,
826  "%s usage %s %d%s(%d %dK pages of total %d)",
827  (block==DBACC ? "Index" : (block == DBTUP ?"Data":"<unknown>")),
828  (gth == 0 ? "is" : (gth > 0 ? "increased to" : "decreased to")),
829  percent, "%",
830  used, size/1024, total
831  );
832 }
833 
834 void getTextBackupStarted(QQQQ) {
835  BaseString::snprintf(m_text, m_text_len,
836  "Backup %u started from node %d",
837  theData[2], refToNode(theData[1]));
838 }
839 void getTextBackupFailedToStart(QQQQ) {
840  BaseString::snprintf(m_text, m_text_len,
841  "Backup request from %d failed to start. Error: %d",
842  refToNode(theData[1]), theData[2]);
843 }
844 void getTextBackupCompleted(QQQQ) {
845  BaseString::snprintf(m_text, m_text_len,
846  "Backup %u started from node %u completed."
847  " StartGCP: %u StopGCP: %u"
848  " #Records: %u #LogRecords: %u"
849  " Data: %u bytes Log: %u bytes",
850  theData[2], refToNode(theData[1]),
851  theData[3], theData[4], theData[6], theData[8],
852  theData[5], theData[7]);
853 }
854 void getTextBackupStatus(QQQQ) {
855  if (theData[1])
856  BaseString::snprintf(m_text, m_text_len,
857  "Local backup status: backup %u started from node %u\n"
858  " #Records: %llu #LogRecords: %llu\n"
859  " Data: %llu bytes Log: %llu bytes",
860  theData[2], refToNode(theData[1]),
861  make_uint64(theData[5], theData[6]),
862  make_uint64(theData[9], theData[10]),
863  make_uint64(theData[3], theData[4]),
864  make_uint64(theData[7], theData[8]));
865  else
866  BaseString::snprintf(m_text, m_text_len,
867  "Backup not started");
868 }
869 void getTextBackupAborted(QQQQ) {
870  BaseString::snprintf(m_text, m_text_len,
871  "Backup %u started from %d has been aborted. Error: %d",
872  theData[2],
873  refToNode(theData[1]),
874  theData[3]);
875 }
876 void getTextRestoreStarted(QQQQ)
877 {
878  BaseString::snprintf(m_text, m_text_len,
879  "Restore started: backup %u from node %u",
880  theData[1], theData[2]);
881 }
882 void getTextRestoreMetaData(QQQQ)
883 {
884  BaseString::snprintf(m_text, m_text_len,
885  "Restore meta data: backup %u from node %u "
886  "#Tables: %u\n"
887  " #Tablespaces: %u #Logfilegroups: %u "
888  "#datafiles: %u #undofiles: %u",
889  theData[1], theData[2], theData[3],
890  theData[4], theData[5], theData[6], theData[7]);
891 }
892 void getTextRestoreData(QQQQ)
893 {
894  BaseString::snprintf(m_text, m_text_len,
895  "Restore data: backup %u from node %u "
896  "#Records: %llu Data: %llu bytes",
897  theData[1], theData[2],
898  make_uint64(theData[3], theData[4]),
899  make_uint64(theData[5], theData[6]));
900 }
901 void getTextRestoreLog(QQQQ)
902 {
903  BaseString::snprintf(m_text, m_text_len,
904  "Restore log: backup %u from node %u "
905  "#Records: %llu Data: %llu bytes",
906  theData[1], theData[2],
907  make_uint64(theData[3], theData[4]),
908  make_uint64(theData[5], theData[6]));
909 }
910 void getTextRestoreCompleted(QQQQ)
911 {
912  BaseString::snprintf(m_text, m_text_len,
913  "Restore completed: backup %u from node %u",
914  theData[1], theData[2]);
915 }
916 void getTextLogFileInitStatus(QQQQ) {
917  if (theData[2])
918  BaseString::snprintf(m_text, m_text_len,
919  "Local redo log file initialization status:\n"
920  "#Total files: %u, Completed: %u\n"
921  "#Total MBytes: %u, Completed: %u",
922 // refToNode(theData[1]),
923  theData[2], theData[3],
924  theData[4], theData[5]);
925  else
926  BaseString::snprintf(m_text, m_text_len,
927  "Node %u: Log file initializtion completed",
928  refToNode(theData[1]));
929 }
930 void getTextLogFileInitCompStatus(QQQQ) {
931  BaseString::snprintf(m_text, m_text_len,
932  "Local redo log file initialization completed:\n"
933  "#Total files: %u, Completed: %u\n"
934  "#Total MBytes: %u, Completed: %u",
935 // refToNode(theData[1]),
936  theData[2], theData[3],
937  theData[4], theData[5]);
938 }
939 void getTextSingleUser(QQQQ) {
940  switch (theData[1])
941  {
942  case 0:
943  BaseString::snprintf(m_text, m_text_len, "Entering single user mode");
944  break;
945  case 1:
946  BaseString::snprintf(m_text, m_text_len,
947  "Entered single user mode "
948  "Node %d has exclusive access", theData[2]);
949  break;
950  case 2:
951  BaseString::snprintf(m_text, m_text_len,"Exiting single user mode");
952  break;
953  default:
954  BaseString::snprintf(m_text, m_text_len,
955  "Unknown single user report %d", theData[1]);
956  break;
957  }
958 }
959 
960 void getTextStartReport(QQQQ) {
961  Uint32 time = theData[2];
962  Uint32 sz = theData[3];
963  BaseString
964  bstr0 = BaseString::getPrettyText(sz, theData + 4 + (0 * sz)),
965  bstr1 = BaseString::getPrettyText(sz, theData + 4 + (1 * sz)),
966  bstr2 = BaseString::getPrettyText(sz, theData + 4 + (2 * sz)),
967  bstr3 = BaseString::getPrettyText(sz, theData + 4 + (3 * sz)),
968  bstr4 = BaseString::getPrettyText(sz, theData + 4 + (4 * sz));
969 
970  if (len < 4 + 5 * sz)
971  {
972  bstr4.assign("<unknown>");
973  }
974 
975  switch(theData[1]){
976  case 1: // Wait initial
978  (m_text, m_text_len,
979  "Initial start, waiting for %s to connect, "
980  " nodes [ all: %s connected: %s no-wait: %s ]",
981  bstr3.c_str(), bstr0.c_str(), bstr1.c_str(), bstr2.c_str());
982  break;
983  case 2: // Wait partial
985  (m_text, m_text_len,
986  "Waiting until nodes: %s connects, "
987  "nodes [ all: %s connected: %s no-wait: %s ]",
988  bstr3.c_str(), bstr0.c_str(), bstr1.c_str(), bstr2.c_str());
989  break;
990  case 3: // Wait partial timeout
992  (m_text, m_text_len,
993  "Waiting %u sec for nodes %s to connect, "
994  "nodes [ all: %s connected: %s no-wait: %s ]",
995  time, bstr3.c_str(), bstr0.c_str(), bstr1.c_str(), bstr2.c_str());
996  break;
997  case 4: // Wait partioned
999  (m_text, m_text_len,
1000  "Waiting for non partitioned start, "
1001  "nodes [ all: %s connected: %s missing: %s no-wait: %s ]",
1002  bstr0.c_str(), bstr1.c_str(), bstr3.c_str(), bstr2.c_str());
1003  break;
1004  case 5:
1006  (m_text, m_text_len,
1007  "Waiting %u sec for non partitioned start, "
1008  "nodes [ all: %s connected: %s missing: %s no-wait: %s ]",
1009  time, bstr0.c_str(), bstr1.c_str(), bstr3.c_str(), bstr2.c_str());
1010  break;
1011  case 6:
1013  (m_text, m_text_len,
1014  "Initial start, waiting %u for %s to connect, "
1015  "nodes [ all: %s connected: %s missing: %s no-wait: %s no-nodegroup: %s ]",
1016  time, bstr4.c_str(),
1017  bstr0.c_str(), bstr1.c_str(), bstr3.c_str(), bstr2.c_str(),
1018  bstr4.c_str());
1019  break;
1020  case 7: // Wait no-nodes/partial timeout
1022  (m_text, m_text_len,
1023  "Waiting %u sec for nodes %s to connect, "
1024  "nodes [ all: %s connected: %s no-wait: %s no-nodegroup: %s ]",
1025  time, bstr3.c_str(), bstr0.c_str(), bstr1.c_str(), bstr2.c_str(),
1026  bstr4.c_str());
1027  break;
1028 
1029  case 0x8000: // Do initial
1031  (m_text, m_text_len,
1032  "Initial start with nodes %s [ missing: %s no-wait: %s ]",
1033  bstr1.c_str(), bstr3.c_str(), bstr2.c_str());
1034  break;
1035  case 0x8001: // Do start
1037  (m_text, m_text_len,
1038  "Start with all nodes %s",
1039  bstr1.c_str());
1040  break;
1041  case 0x8002: // Do partial
1043  (m_text, m_text_len,
1044  "Start with nodes %s [ missing: %s no-wait: %s ]",
1045  bstr1.c_str(), bstr3.c_str(), bstr2.c_str());
1046  break;
1047  case 0x8003: // Do partioned
1049  (m_text, m_text_len,
1050  "Start potentially partitioned with nodes %s "
1051  " [ missing: %s no-wait: %s ]",
1052  bstr1.c_str(), bstr3.c_str(), bstr2.c_str());
1053  break;
1054  default:
1056  (m_text, m_text_len,
1057  "Unknown startreport: 0x%x [ %s %s %s %s ]",
1058  theData[1],
1059  bstr0.c_str(), bstr1.c_str(), bstr2.c_str(), bstr3.c_str());
1060  }
1061 }
1062 void getTextMTSignalStatistics(QQQQ) {
1063  BaseString::snprintf(m_text, m_text_len,
1064  "Signals delivered from thread %u: "
1065  "prio A %u (%u bytes) prio B %u (%u bytes)",
1066  theData[1],
1067  theData[2], theData[3], theData[4], theData[5]);
1068 }
1069 
1070 void getTextSubscriptionStatus(QQQQ)
1071 {
1072  switch(theData[1]) {
1073  case(1): // SubscriptionStatus::DISCONNECTED
1074  BaseString::snprintf(m_text, m_text_len,
1075  "Disconnecting node %u because it has "
1076  "exceeded MaxBufferedEpochs (%u > %u), epoch %u/%u",
1077  theData[2],
1078  theData[5],
1079  theData[6],
1080  theData[4], theData[3]);
1081  break;
1082  case(2): // SubscriptionStatus::INCONSISTENT
1083  BaseString::snprintf(m_text, m_text_len,
1084  "Nodefailure while out of event buffer: "
1085  "informing subscribers of possibly missing event data"
1086  ", epoch %u/%u",
1087  theData[4], theData[3]);
1088  break;
1089  }
1090 }
1091 
1092 void
1093 getTextStartReadLCP(QQQQ)
1094 {
1095  BaseString::snprintf(m_text, m_text_len,
1096  "Start reading LCP for table %u fragment: %u",
1097  theData[1],
1098  theData[2]);
1099 }
1100 
1101 void
1102 getTextReadLCPComplete(QQQQ)
1103 {
1104  BaseString::snprintf(m_text, m_text_len,
1105  "Restored LCP for table %u fragment: %u rows: %llu",
1106  theData[1],
1107  theData[2],
1108  (Uint64(theData[3]) << 32) + Uint64(theData[4]));
1109 }
1110 
1111 void
1112 getTextRunRedo(QQQQ)
1113 {
1114  const ndb_logevent_RunRedo * ev = (const ndb_logevent_RunRedo*)(theData+1);
1115  if (ev->currgci == ev->startgci)
1116  {
1117  BaseString::snprintf(m_text, m_text_len,
1118  "Log part: %u phase: %u run redo from "
1119  " gci: %u (file: %u mb: %u) to "
1120  " gci: %u (file: %u mb: %u)",
1121  ev->logpart,
1122  ev->phase,
1123  ev->startgci,
1124  ev->startfile,
1125  ev->startmb,
1126  ev->stopgci,
1127  ev->stopfile,
1128  ev->stopmb);
1129  }
1130  else if (ev->currgci == ev->stopgci)
1131  {
1132  BaseString::snprintf(m_text, m_text_len,
1133  "Log part: %u phase: %u found stop "
1134  " gci: %u (file: %u mb: %u)",
1135  ev->logpart,
1136  ev->phase,
1137  ev->currgci,
1138  ev->currfile,
1139  ev->currmb);
1140  }
1141  else
1142  {
1143  BaseString::snprintf(m_text, m_text_len,
1144  "Log part: %u phase: %u at "
1145  " gci: %u (file: %u mb: %u)",
1146  ev->logpart,
1147  ev->phase,
1148  ev->currgci,
1149  ev->currfile,
1150  ev->currmb);
1151  }
1152 }
1153 
1154 void
1155 getTextRebuildIndex(QQQQ)
1156 {
1157  BaseString::snprintf(m_text, m_text_len,
1158  "instace: %u rebuild index: %u",
1159  theData[1],
1160  theData[2]);
1161 }
1162 
1163 const
1164 char*
1165 getObjectTypeName(Uint32 type)
1166 {
1167  return "object";
1168 }
1169 
1170 void
1171 getTextCreateSchemaObject(QQQQ)
1172 {
1173  BaseString::snprintf(m_text, m_text_len,
1174  "create %s id: %u version: %u (from %u)",
1175  getObjectTypeName(theData[3]),
1176  theData[1],
1177  theData[2],
1178  theData[4]);
1179 }
1180 
1181 void
1182 getTextAlterSchemaObject(QQQQ)
1183 {
1184  BaseString::snprintf(m_text, m_text_len,
1185  "alter %s id: %u version: %u (from %u)",
1186  getObjectTypeName(theData[3]),
1187  theData[1],
1188  theData[2],
1189  theData[4]);
1190 }
1191 
1192 void
1193 getTextDropSchemaObject(QQQQ)
1194 {
1195  BaseString::snprintf(m_text, m_text_len,
1196  "drop %s id: %u version: %u (from %u)",
1197  getObjectTypeName(theData[3]),
1198  theData[1],
1199  theData[2],
1200  theData[4]);
1201 }
1202 
1203 void getTextSavedEvent(QQQQ)
1204 {
1205  abort();
1206 }
1207 
1208 void getTextConnectCheckStarted(QQQQ)
1209 {
1210  /* EventReport format :
1211  * 1 : other_node_count
1212  * 2 : reason (FailRep causes or 0)
1213  * 3 : causing_node (if from FailRep)
1214  * 4 : bitmask wordsize
1215  * 5 : bitmask[2]
1216  */
1217  Uint32 other_node_count = theData[1];
1218  Uint32 reason = theData[2];
1219  Uint32 causing_node = theData[3];
1220  Uint32 bitmaskSz = theData[4];
1221  char otherNodeMask[100];
1222  char suspectNodeMask[100];
1223  BitmaskImpl::getText(bitmaskSz, theData + 5 + (0 * bitmaskSz), otherNodeMask);
1224  BitmaskImpl::getText(bitmaskSz, theData + 5 + (1 * bitmaskSz), suspectNodeMask);
1225  Uint32 suspectCount = BitmaskImpl::count(bitmaskSz, theData + 5 + (1 * bitmaskSz));
1226 
1227  if (reason)
1228  {
1229  /* Connect check started for specific reason */
1230  const char * reasonText = NULL;
1231  switch (reason)
1232  {
1233  case FailRep::ZHEARTBEAT_FAILURE:
1234  reasonText = "Heartbeat failure";
1235  break;
1236  case FailRep::ZCONNECT_CHECK_FAILURE:
1237  reasonText = "Connectivity check request";
1238  break;
1239  default:
1240  reasonText = "UNKNOWN";
1241  break;
1242  }
1243 
1244  BaseString::snprintf(m_text, m_text_len,
1245  "Connectivity Check of %u other nodes (%s) started due to %s from node %u.",
1246  other_node_count,
1247  otherNodeMask,
1248  reasonText,
1249  causing_node);
1250  }
1251  else
1252  {
1253  /* Connect check restarted due to suspect nodes */
1254  BaseString::snprintf(m_text, m_text_len,
1255  "Connectivity Check of %u nodes (%s) restarting due to %u suspect nodes (%s).",
1256  other_node_count,
1257  otherNodeMask,
1258  suspectCount,
1259  suspectNodeMask);
1260  }
1261 }
1262 
1263 void getTextConnectCheckCompleted(QQQQ)
1264 {
1265  /* EventReport format
1266  * 1 : Nodes checked
1267  * 2 : Suspect nodes
1268  * 3 : Failed nodes
1269  */
1270 
1271  Uint32 nodes_checked = theData[1];
1272  Uint32 suspect_nodes = theData[2];
1273  Uint32 failed_nodes = theData[3];
1274 
1275  if ((failed_nodes + suspect_nodes) == 0)
1276  {
1277  /* All connectivity ok */
1278  BaseString::snprintf(m_text, m_text_len,
1279  "Connectivity Check completed on %u nodes, connectivity ok",
1280  nodes_checked);
1281  }
1282  else
1283  {
1284  if (failed_nodes > 0)
1285  {
1286  if (suspect_nodes > 0)
1287  {
1288  BaseString::snprintf(m_text, m_text_len,
1289  "Connectivity Check completed on %u nodes. %u nodes failed. "
1290  "%u nodes still suspect, repeating check.",
1291  nodes_checked,
1292  failed_nodes,
1293  suspect_nodes);
1294  }
1295  else
1296  {
1297  BaseString::snprintf(m_text, m_text_len,
1298  "Connectivity Check completed on %u nodes. %u nodes failed. "
1299  "Connectivity now OK",
1300  nodes_checked,
1301  failed_nodes);
1302  }
1303  }
1304  else
1305  {
1306  /* Just suspect nodes */
1307  BaseString::snprintf(m_text, m_text_len,
1308  "Connectivity Check completed on %u nodes. %u nodes still suspect, "
1309  "repeating check.",
1310  nodes_checked,
1311  suspect_nodes);
1312  }
1313  }
1314 }
1315 
1316 void getTextNodeFailRejected(QQQQ)
1317 {
1318  Uint32 reason = theData[1];
1319  Uint32 failed_node = theData[2];
1320  Uint32 source_node = theData[3];
1321 
1322  const char* reasonText = "Unknown";
1323  switch (reason)
1324  {
1325  case FailRep::ZCONNECT_CHECK_FAILURE:
1326  reasonText = "Connect Check Failure";
1327  break;
1328  case FailRep::ZLINK_FAILURE:
1329  reasonText = "Link Failure";
1330  break;
1331  }
1332 
1333  BaseString::snprintf(m_text, m_text_len,
1334  "Received FAIL_REP (%s (%u)) for node %u sourced by suspect node %u. "
1335  "Rejecting as failure of node %u.",
1336  reasonText,
1337  reason,
1338  failed_node,
1339  source_node,
1340  source_node);
1341 }
1342 
1343 #if 0
1344 BaseString::snprintf(m_text,
1345  m_text_len,
1346  "Unknown event: %d",
1347  theData[0]);
1348 #endif
1349 
1357 #define ROW(a,b,c,d) \
1358 { NDB_LE_ ## a, b, c, d, getText ## a}
1359 
1360 const EventLoggerBase::EventRepLogLevelMatrix EventLoggerBase::matrix[] = {
1361  // CONNECTION
1362  ROW(Connected, LogLevel::llConnection, 8, Logger::LL_INFO ),
1363  ROW(Disconnected, LogLevel::llConnection, 8, Logger::LL_ALERT ),
1364  ROW(CommunicationClosed, LogLevel::llConnection, 8, Logger::LL_INFO ),
1365  ROW(CommunicationOpened, LogLevel::llConnection, 8, Logger::LL_INFO ),
1366  ROW(ConnectedApiVersion, LogLevel::llConnection, 8, Logger::LL_INFO ),
1367  // CHECKPOINT
1368  ROW(GlobalCheckpointStarted, LogLevel::llCheckpoint, 9, Logger::LL_INFO ),
1369  ROW(GlobalCheckpointCompleted,LogLevel::llCheckpoint,10, Logger::LL_INFO ),
1370  ROW(LocalCheckpointStarted, LogLevel::llCheckpoint, 7, Logger::LL_INFO ),
1371  ROW(LocalCheckpointCompleted,LogLevel::llCheckpoint, 7, Logger::LL_INFO ),
1372  ROW(LCPStoppedInCalcKeepGci, LogLevel::llCheckpoint, 0, Logger::LL_ALERT ),
1373  ROW(LCPFragmentCompleted, LogLevel::llCheckpoint, 11, Logger::LL_INFO ),
1374  ROW(UndoLogBlocked, LogLevel::llCheckpoint, 7, Logger::LL_INFO ),
1375  ROW(RedoStatus, LogLevel::llCheckpoint, 7, Logger::LL_INFO ),
1376 
1377  // STARTUP
1378  ROW(NDBStartStarted, LogLevel::llStartUp, 1, Logger::LL_INFO ),
1379  ROW(NDBStartCompleted, LogLevel::llStartUp, 1, Logger::LL_INFO ),
1380  ROW(STTORRYRecieved, LogLevel::llStartUp, 15, Logger::LL_INFO ),
1381  ROW(StartPhaseCompleted, LogLevel::llStartUp, 4, Logger::LL_INFO ),
1382  ROW(CM_REGCONF, LogLevel::llStartUp, 3, Logger::LL_INFO ),
1383  ROW(CM_REGREF, LogLevel::llStartUp, 8, Logger::LL_INFO ),
1384  ROW(FIND_NEIGHBOURS, LogLevel::llStartUp, 8, Logger::LL_INFO ),
1385  ROW(NDBStopStarted, LogLevel::llStartUp, 1, Logger::LL_INFO ),
1386  ROW(NDBStopCompleted, LogLevel::llStartUp, 1, Logger::LL_INFO ),
1387  ROW(NDBStopForced, LogLevel::llStartUp, 1, Logger::LL_ALERT ),
1388  ROW(NDBStopAborted, LogLevel::llStartUp, 1, Logger::LL_INFO ),
1389  ROW(StartREDOLog, LogLevel::llStartUp, 4, Logger::LL_INFO ),
1390  ROW(StartLog, LogLevel::llStartUp, 10, Logger::LL_INFO ),
1391  ROW(UNDORecordsExecuted, LogLevel::llStartUp, 15, Logger::LL_INFO ),
1392  ROW(StartReport, LogLevel::llStartUp, 4, Logger::LL_INFO ),
1393  ROW(LogFileInitStatus, LogLevel::llStartUp, 7, Logger::LL_INFO),
1394  ROW(LogFileInitCompStatus, LogLevel::llStartUp, 7, Logger::LL_INFO),
1395  ROW(StartReadLCP, LogLevel::llStartUp, 10, Logger::LL_INFO),
1396  ROW(ReadLCPComplete, LogLevel::llStartUp, 10, Logger::LL_INFO),
1397  ROW(RunRedo, LogLevel::llStartUp, 8, Logger::LL_INFO),
1398  ROW(RebuildIndex, LogLevel::llStartUp, 10, Logger::LL_INFO),
1399 
1400  // NODERESTART
1401  ROW(NR_CopyDict, LogLevel::llNodeRestart, 7, Logger::LL_INFO ),
1402  ROW(NR_CopyDistr, LogLevel::llNodeRestart, 7, Logger::LL_INFO ),
1403  ROW(NR_CopyFragsStarted, LogLevel::llNodeRestart, 7, Logger::LL_INFO ),
1404  ROW(NR_CopyFragDone, LogLevel::llNodeRestart,10, Logger::LL_INFO ),
1405  ROW(NR_CopyFragsCompleted, LogLevel::llNodeRestart, 7, Logger::LL_INFO ),
1406 
1407  ROW(NodeFailCompleted, LogLevel::llNodeRestart, 8, Logger::LL_ALERT),
1408  ROW(NODE_FAILREP, LogLevel::llNodeRestart, 8, Logger::LL_ALERT),
1409  ROW(ArbitState, LogLevel::llNodeRestart, 6, Logger::LL_INFO ),
1410  ROW(ArbitResult, LogLevel::llNodeRestart, 2, Logger::LL_ALERT),
1411  ROW(GCP_TakeoverStarted, LogLevel::llNodeRestart, 7, Logger::LL_INFO ),
1412  ROW(GCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, Logger::LL_INFO ),
1413  ROW(LCP_TakeoverStarted, LogLevel::llNodeRestart, 7, Logger::LL_INFO ),
1414  ROW(LCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, Logger::LL_INFO ),
1415 
1416  ROW(ConnectCheckStarted, LogLevel::llNodeRestart, 6, Logger::LL_INFO ),
1417  ROW(ConnectCheckCompleted, LogLevel::llNodeRestart, 6, Logger::LL_INFO ),
1418  ROW(NodeFailRejected, LogLevel::llNodeRestart, 6, Logger::LL_ALERT ),
1419 
1420  // STATISTIC
1421  ROW(TransReportCounters, LogLevel::llStatistic, 8, Logger::LL_INFO ),
1422  ROW(OperationReportCounters, LogLevel::llStatistic, 8, Logger::LL_INFO ),
1423  ROW(TableCreated, LogLevel::llStatistic, 7, Logger::LL_INFO ),
1424  ROW(JobStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO ),
1425  ROW(ThreadConfigLoop, LogLevel::llStatistic, 9, Logger::LL_INFO ),
1426  ROW(SendBytesStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO ),
1427  ROW(ReceiveBytesStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO ),
1428  ROW(MemoryUsage, LogLevel::llStatistic, 5, Logger::LL_INFO ),
1429  ROW(MTSignalStatistics, LogLevel::llStatistic, 9, Logger::LL_INFO ),
1430 
1431  // Schema
1432  ROW(CreateSchemaObject, LogLevel::llSchema, 8, Logger::LL_INFO ),
1433  ROW(AlterSchemaObject, LogLevel::llSchema, 8, Logger::LL_INFO ),
1434  ROW(DropSchemaObject, LogLevel::llSchema, 8, Logger::LL_INFO ),
1435 
1436  // ERROR
1437  ROW(TransporterError, LogLevel::llError, 2, Logger::LL_ERROR ),
1438  ROW(TransporterWarning, LogLevel::llError, 8, Logger::LL_WARNING ),
1439  ROW(MissedHeartbeat, LogLevel::llError, 8, Logger::LL_WARNING ),
1440  ROW(DeadDueToHeartbeat, LogLevel::llError, 8, Logger::LL_ALERT ),
1441  ROW(WarningEvent, LogLevel::llError, 2, Logger::LL_WARNING ),
1442  ROW(SubscriptionStatus, LogLevel::llError, 4, Logger::LL_WARNING ),
1443  // INFO
1444  ROW(SentHeartbeat, LogLevel::llInfo, 12, Logger::LL_INFO ),
1445  ROW(CreateLogBytes, LogLevel::llInfo, 11, Logger::LL_INFO ),
1446  ROW(InfoEvent, LogLevel::llInfo, 2, Logger::LL_INFO ),
1447  ROW(EventBufferStatus, LogLevel::llInfo, 7, Logger::LL_INFO ),
1448 
1449  //Single User
1450  ROW(SingleUser, LogLevel::llInfo, 7, Logger::LL_INFO ),
1451 
1452  // Backup
1453  ROW(BackupStarted, LogLevel::llBackup, 7, Logger::LL_INFO ),
1454  ROW(BackupStatus, LogLevel::llBackup, 7, Logger::LL_INFO ),
1455  ROW(BackupCompleted, LogLevel::llBackup, 7, Logger::LL_INFO ),
1456  ROW(BackupFailedToStart, LogLevel::llBackup, 7, Logger::LL_ALERT),
1457  ROW(BackupAborted, LogLevel::llBackup, 7, Logger::LL_ALERT),
1458  ROW(RestoreStarted, LogLevel::llBackup, 7, Logger::LL_INFO ),
1459  ROW(RestoreMetaData, LogLevel::llBackup, 7, Logger::LL_INFO ),
1460  ROW(RestoreData, LogLevel::llBackup, 7, Logger::LL_INFO ),
1461  ROW(RestoreLog, LogLevel::llBackup, 7, Logger::LL_INFO ),
1462  ROW(RestoreCompleted, LogLevel::llBackup, 7, Logger::LL_INFO ),
1463 
1464  ROW(SavedEvent, LogLevel::llInfo, 7, Logger::LL_INFO)
1465 };
1466 
1467 const Uint32 EventLoggerBase::matrixSize=
1468 sizeof(EventLoggerBase::matrix)/sizeof(EventRepLogLevelMatrix);
1469 
1471 {
1472  setCategory("EventLogger");
1473  enable(Logger::LL_INFO, Logger::LL_ALERT);
1474 }
1475 
1477 {
1478 }
1479 
1480 void
1482 {
1484 }
1485 
1486 #ifdef NOT_USED
1487 
1488 static NdbOut&
1489 operator<<(NdbOut& out, const LogLevel & ll)
1490 {
1491  out << "[LogLevel: ";
1492  for(size_t i = 0; i<LogLevel::LOGLEVEL_CATEGORIES; i++)
1493  out << ll.getLogLevel((LogLevel::EventCategory)i) << " ";
1494  out << "]";
1495  return out;
1496 }
1497 #endif
1498 
1499 int
1500 EventLoggerBase::event_lookup(int eventType,
1501  LogLevel::EventCategory &cat,
1502  Uint32 &threshold,
1503  Logger::LoggerLevel &severity,
1504  EventTextFunction &textF)
1505 {
1506  for(unsigned i = 0; i<EventLoggerBase::matrixSize; i++){
1507  if(EventLoggerBase::matrix[i].eventType == eventType){
1508  cat = EventLoggerBase::matrix[i].eventCategory;
1509  threshold = EventLoggerBase::matrix[i].threshold;
1510  severity = EventLoggerBase::matrix[i].severity;
1511  textF= EventLoggerBase::matrix[i].textF;
1512  return 0;
1513  }
1514  }
1515  return 1;
1516 }
1517 
1518 const char*
1519 EventLogger::getText(char * dst, size_t dst_len,
1520  EventTextFunction textF,
1521  const Uint32* theData, Uint32 len, NodeId nodeId )
1522 {
1523  int pos= 0;
1524  if (nodeId != 0)
1525  {
1526  BaseString::snprintf(dst, dst_len, "Node %u: ", nodeId);
1527  pos= strlen(dst);
1528  }
1529  if (dst_len-pos > 0)
1530  textF(dst+pos, dst_len-pos, theData, len);
1531  return dst;
1532 }
1533 
1534 void
1535 EventLogger::log(int eventType, const Uint32* theData, Uint32 len,
1536  NodeId nodeId, const LogLevel* ll)
1537 {
1538  Uint32 threshold = 0;
1539  Logger::LoggerLevel severity = Logger::LL_WARNING;
1540  LogLevel::EventCategory cat= LogLevel::llInvalid;
1541  EventTextFunction textF;
1542  char log_text[MAX_TEXT_LENGTH];
1543 
1544  DBUG_ENTER("EventLogger::log");
1545  DBUG_PRINT("enter",("eventType=%d, nodeid=%d", eventType, nodeId));
1546 
1547  if (EventLoggerBase::event_lookup(eventType,cat,threshold,severity,textF))
1548  DBUG_VOID_RETURN;
1549 
1550  Uint32 set = ll?ll->getLogLevel(cat) : m_logLevel.getLogLevel(cat);
1551  DBUG_PRINT("info",("threshold=%d, set=%d", threshold, set));
1552  if (ll)
1553  DBUG_PRINT("info",("m_logLevel.getLogLevel=%d", m_logLevel.getLogLevel(cat)));
1554 
1555  if (threshold <= set){
1556  getText(log_text, sizeof(log_text), textF, theData, len, nodeId);
1557 
1558  switch (severity){
1559  case Logger::LL_ALERT:
1560  alert("%s", log_text);
1561  break;
1562  case Logger::LL_CRITICAL:
1563  critical("%s", log_text);
1564  break;
1565  case Logger::LL_WARNING:
1566  warning("%s", log_text);
1567  break;
1568  case Logger::LL_ERROR:
1569  error("%s", log_text);
1570  break;
1571  case Logger::LL_INFO:
1572  info("%s", log_text);
1573  break;
1574  case Logger::LL_DEBUG:
1575  debug("%s", log_text);
1576  break;
1577  default:
1578  info("%s", log_text);
1579  break;
1580  }
1581  } // if (..
1582  DBUG_VOID_RETURN;
1583 }
1584 
1585 EventLogger*
1586 create_event_logger()
1587 {
1588  return new EventLogger();
1589 }
1590 
1591 void
1592 destroy_event_logger(class EventLogger ** g_eventLogger)
1593 {
1594  delete *g_eventLogger;
1595  *g_eventLogger = 0;
1596 }