1 /*
2    Copyright (c) 2005, 2021, Oracle and/or its affiliates.
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 #ifndef NDB_LOGEVENT_H
26 #define NDB_LOGEVENT_H
27 
28 /** @addtogroup MGM_C_API
29  *  @{
30  */
31 
32 #include "mgmapi_config_parameters.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38   /**
39    * Available log events grouped by @ref ndb_mgm_event_category
40    */
41 
42   enum Ndb_logevent_type {
43 
44     NDB_LE_ILLEGAL_TYPE = -1,
45 
46     /** NDB_MGM_EVENT_CATEGORY_CONNECTION */
47     NDB_LE_Connected = 0,
48     /** NDB_MGM_EVENT_CATEGORY_CONNECTION */
49     NDB_LE_Disconnected = 1,
50     /** NDB_MGM_EVENT_CATEGORY_CONNECTION */
51     NDB_LE_CommunicationClosed = 2,
52     /** NDB_MGM_EVENT_CATEGORY_CONNECTION */
53     NDB_LE_CommunicationOpened = 3,
54     /** NDB_MGM_EVENT_CATEGORY_CONNECTION */
55     NDB_LE_ConnectedApiVersion = 51,
56 
57     /** NDB_MGM_EVENT_CATEGORY_CHECKPOINT */
58     NDB_LE_GlobalCheckpointStarted = 4,
59     /** NDB_MGM_EVENT_CATEGORY_CHECKPOINT */
60     NDB_LE_GlobalCheckpointCompleted = 5,
61     /** NDB_MGM_EVENT_CATEGORY_CHECKPOINT */
62     NDB_LE_LocalCheckpointStarted = 6,
63     /** NDB_MGM_EVENT_CATEGORY_CHECKPOINT */
64     NDB_LE_LocalCheckpointCompleted = 7,
65     /** NDB_MGM_EVENT_CATEGORY_CHECKPOINT */
66     NDB_LE_LCPStoppedInCalcKeepGci = 8,
67     /** NDB_MGM_EVENT_CATEGORY_CHECKPOINT */
68     NDB_LE_LCPFragmentCompleted = 9,
69 
70     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
71     NDB_LE_NDBStartStarted = 10,
72     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
73     NDB_LE_NDBStartCompleted = 11,
74     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
75     NDB_LE_STTORRYRecieved = 12,
76     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
77     NDB_LE_StartPhaseCompleted = 13,
78     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
79     NDB_LE_CM_REGCONF = 14,
80     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
81     NDB_LE_CM_REGREF = 15,
82     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
83     NDB_LE_FIND_NEIGHBOURS = 16,
84     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
85     NDB_LE_NDBStopStarted = 17,
86     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
87     NDB_LE_NDBStopCompleted = 53,
88     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
89     NDB_LE_NDBStopForced = 59,
90     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
91     NDB_LE_NDBStopAborted = 18,
92     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
93     NDB_LE_StartREDOLog = 19,
94     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
95     NDB_LE_StartLog = 20,
96     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
97     NDB_LE_UNDORecordsExecuted = 21,
98 
99     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
100     NDB_LE_NR_CopyDict = 22,
101     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
102     NDB_LE_NR_CopyDistr = 23,
103     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
104     NDB_LE_NR_CopyFragsStarted = 24,
105     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
106     NDB_LE_NR_CopyFragDone = 25,
107     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
108     NDB_LE_NR_CopyFragsCompleted = 26,
109 
110     /* NODEFAIL */
111     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
112     NDB_LE_NodeFailCompleted = 27,
113     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
114     NDB_LE_NODE_FAILREP = 28,
115     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
116     NDB_LE_ArbitState = 29,
117     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
118     NDB_LE_ArbitResult = 30,
119     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
120     NDB_LE_GCP_TakeoverStarted = 31,
121     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
122     NDB_LE_GCP_TakeoverCompleted = 32,
123     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
124     NDB_LE_LCP_TakeoverStarted = 33,
125     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
126     NDB_LE_LCP_TakeoverCompleted = 34,
127     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
128     NDB_LE_ConnectCheckStarted = 82,
129     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
130     NDB_LE_ConnectCheckCompleted = 83,
131     /** NDB_MGM_EVENT_CATEGORY_NODE_RESTART */
132     NDB_LE_NodeFailRejected = 84,
133 
134     /** NDB_MGM_EVENT_CATEGORY_STATISTIC */
135     NDB_LE_TransReportCounters = 35,
136     /** NDB_MGM_EVENT_CATEGORY_STATISTIC */
137     NDB_LE_OperationReportCounters = 36,
138     /** NDB_MGM_EVENT_CATEGORY_STATISTIC */
139     NDB_LE_TableCreated = 37,
140     /** NDB_MGM_EVENT_CATEGORY_STATISTIC */
141     NDB_LE_UndoLogBlocked = 38,
142     /** NDB_MGM_EVENT_CATEGORY_STATISTIC */
143     NDB_LE_JobStatistic = 39,
144     /** NDB_MGM_EVENT_CATEGORY_STATISTIC */
145     NDB_LE_SendBytesStatistic = 40,
146     /** NDB_MGM_EVENT_CATEGORY_STATISTIC */
147     NDB_LE_ReceiveBytesStatistic = 41,
148     /** NDB_MGM_EVENT_CATEGORY_STATISTIC */
149     NDB_LE_MemoryUsage = 50,
150     /** NDB_MGM_EVENT_CATEGORY_STATISTIC */
151     NDB_LE_ThreadConfigLoop = 68,
152 
153     /** NDB_MGM_EVENT_CATEGORY_ERROR */
154     NDB_LE_TransporterError = 42,
155     /** NDB_MGM_EVENT_CATEGORY_ERROR */
156     NDB_LE_TransporterWarning = 43,
157     /** NDB_MGM_EVENT_CATEGORY_ERROR */
158     NDB_LE_MissedHeartbeat = 44,
159     /** NDB_MGM_EVENT_CATEGORY_ERROR */
160     NDB_LE_DeadDueToHeartbeat = 45,
161     /** NDB_MGM_EVENT_CATEGORY_ERROR */
162     NDB_LE_WarningEvent = 46,
163 
164     /** NDB_MGM_EVENT_CATEGORY_INFO */
165     NDB_LE_SentHeartbeat = 47,
166     /** NDB_MGM_EVENT_CATEGORY_INFO */
167     NDB_LE_CreateLogBytes = 48,
168     /** NDB_MGM_EVENT_CATEGORY_INFO */
169     NDB_LE_InfoEvent = 49,
170 
171     /* 50 used */
172     /* 51 used */
173 
174     /* SINGLE USER */
175     NDB_LE_SingleUser = 52,
176     /* 53 used */
177 
178     /** NDB_MGM_EVENT_CATEGORY_BACKUP */
179     NDB_LE_BackupStarted = 54,
180     /** NDB_MGM_EVENT_CATEGORY_BACKUP */
181     NDB_LE_BackupFailedToStart = 55,
182     /** NDB_MGM_EVENT_CATEGORY_BACKUP */
183     NDB_LE_BackupStatus = 62,
184     /** NDB_MGM_EVENT_CATEGORY_BACKUP */
185     NDB_LE_BackupCompleted = 56,
186     /** NDB_MGM_EVENT_CATEGORY_BACKUP */
187     NDB_LE_BackupAborted = 57,
188     /** NDB_MGM_EVENT_CATEGORY_BACKUP */
189     NDB_LE_RestoreMetaData = 63,
190     /** NDB_MGM_EVENT_CATEGORY_BACKUP */
191     NDB_LE_RestoreData = 64,
192     /** NDB_MGM_EVENT_CATEGORY_BACKUP */
193     NDB_LE_RestoreLog = 65,
194     /** NDB_MGM_EVENT_CATEGORY_BACKUP */
195     NDB_LE_RestoreStarted = 66,
196     /** NDB_MGM_EVENT_CATEGORY_BACKUP */
197     NDB_LE_RestoreCompleted = 67,
198 
199     /** NDB_MGM_EVENT_CATEGORY_INFO */
200     NDB_LE_EventBufferStatus = 58,
201 
202     /* 59 used */
203 
204     /** NDB_MGM_EVENT_CATEGORY_STARTUP */
205     NDB_LE_StartReport = 60,
206 
207     /* 61 (used in upcoming patch) */
208     /* 62-72 used */
209     /** NDB_MGM_EVENT_SEVERITY_WARNING */
210     NDB_LE_SubscriptionStatus = 69,
211 
212     NDB_LE_MTSignalStatistics = 70,
213 
214     /** NDB_MGM_EVENT_CATEGORY_FRAGLOGFILE */
215     NDB_LE_LogFileInitStatus = 71,
216     /** NDB_MGM_EVENT_CATEGORY_FRAGLOGFILE */
217     NDB_LE_LogFileInitCompStatus = 72
218 
219     ,NDB_LE_RedoStatus = 73
220     ,NDB_LE_CreateSchemaObject = 74
221     ,NDB_LE_AlterSchemaObject = 75
222     ,NDB_LE_DropSchemaObject = 76
223     ,NDB_LE_StartReadLCP = 77
224     ,NDB_LE_ReadLCPComplete = 78
225     ,NDB_LE_RunRedo = 79
226     ,NDB_LE_RebuildIndex = 80
227     ,NDB_LE_SavedEvent = 81
228   };
229 
230   /**
231    *   Log event severities (used to filter the cluster log,
232    *   ndb_mgm_set_clusterlog_severity_filter(), and filter listening to events
233    *   ndb_mgm_listen_event())
234    */
235   enum ndb_mgm_event_severity {
236     NDB_MGM_ILLEGAL_EVENT_SEVERITY = -1,
237     /*  Must be a nonnegative integer (used for array indexing) */
238     /** Cluster log on */
239     NDB_MGM_EVENT_SEVERITY_ON    = 0,
240     /** Used in NDB Cluster developement */
241     NDB_MGM_EVENT_SEVERITY_DEBUG = 1,
242     /** Informational messages*/
243     NDB_MGM_EVENT_SEVERITY_INFO = 2,
244     /** Conditions that are not error condition, but might require handling.
245      */
246     NDB_MGM_EVENT_SEVERITY_WARNING = 3,
247     /** Conditions that, while not fatal, should be corrected. */
248     NDB_MGM_EVENT_SEVERITY_ERROR = 4,
249     /** Critical conditions, like device errors or out of resources */
250     NDB_MGM_EVENT_SEVERITY_CRITICAL = 5,
251     /** A condition that should be corrected immediately,
252      *  such as a corrupted system
253      */
254     NDB_MGM_EVENT_SEVERITY_ALERT = 6,
255     /* must be next number, works as bound in loop */
256     /** All severities */
257     NDB_MGM_EVENT_SEVERITY_ALL = 7
258   };
259 
260   /**
261    *  Log event categories, used to set filter level on the log events using
262    *  ndb_mgm_set_clusterlog_loglevel() and ndb_mgm_listen_event()
263    */
264   enum ndb_mgm_event_category {
265     /**
266      * Invalid log event category
267      */
268     NDB_MGM_ILLEGAL_EVENT_CATEGORY = -1,
269     /**
270      * Log events during all kinds of startups
271      */
272     NDB_MGM_EVENT_CATEGORY_STARTUP = CFG_LOGLEVEL_STARTUP,
273     /**
274      * Log events during shutdown
275      */
276     NDB_MGM_EVENT_CATEGORY_SHUTDOWN = CFG_LOGLEVEL_SHUTDOWN,
277     /**
278      * Statistics log events
279      */
280     NDB_MGM_EVENT_CATEGORY_STATISTIC = CFG_LOGLEVEL_STATISTICS,
281     /**
282      * Log events related to checkpoints
283      */
284     NDB_MGM_EVENT_CATEGORY_CHECKPOINT = CFG_LOGLEVEL_CHECKPOINT,
285     /**
286      * Log events during node restart
287      */
288     NDB_MGM_EVENT_CATEGORY_NODE_RESTART = CFG_LOGLEVEL_NODERESTART,
289     /**
290      * Log events related to connections between cluster nodes
291      */
292     NDB_MGM_EVENT_CATEGORY_CONNECTION = CFG_LOGLEVEL_CONNECTION,
293     /**
294      * Backup related log events
295      */
296     NDB_MGM_EVENT_CATEGORY_BACKUP = CFG_LOGLEVEL_BACKUP,
297     /**
298      * Congestion related log events
299      */
300     NDB_MGM_EVENT_CATEGORY_CONGESTION = CFG_LOGLEVEL_CONGESTION,
301 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
302     /**
303      * Loglevel debug
304      */
305     NDB_MGM_EVENT_CATEGORY_DEBUG = CFG_LOGLEVEL_DEBUG,
306 #endif
307     /**
308      * Uncategorized log events (severity info)
309      */
310     NDB_MGM_EVENT_CATEGORY_INFO = CFG_LOGLEVEL_INFO,
311     /**
312      * Uncategorized log events (severity warning or higher)
313      */
314     NDB_MGM_EVENT_CATEGORY_ERROR = CFG_LOGLEVEL_ERROR,
315 
316     NDB_MGM_EVENT_CATEGORY_SCHEMA = CFG_LOGLEVEL_SCHEMA,
317 
318 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
319     NDB_MGM_MIN_EVENT_CATEGORY = CFG_MIN_LOGLEVEL,
320     NDB_MGM_MAX_EVENT_CATEGORY = CFG_MAX_LOGLEVEL
321 #endif
322   };
323 
324   struct ndb_logevent_Connected {
325     unsigned node;
326   };
327 
328   struct ndb_logevent_Disconnected {
329     unsigned node;
330   };
331 
332   struct ndb_logevent_CommunicationClosed {
333     unsigned node;
334   };
335 
336   struct ndb_logevent_CommunicationOpened {
337     unsigned node;
338   };
339 
340   struct ndb_logevent_ConnectedApiVersion {
341     unsigned node;
342     unsigned version;
343   };
344 
345   /* CHECKPOINT */
346   struct ndb_logevent_GlobalCheckpointStarted {
347     unsigned gci;
348   };
349   struct ndb_logevent_GlobalCheckpointCompleted {
350     unsigned gci;
351   };
352   struct ndb_logevent_LocalCheckpointStarted {
353     unsigned lci;
354     unsigned keep_gci;
355     unsigned restore_gci;
356   };
357   struct ndb_logevent_LocalCheckpointCompleted {
358     unsigned lci;
359   };
360   struct ndb_logevent_LCPStoppedInCalcKeepGci {
361     unsigned data;
362   };
363   struct ndb_logevent_LCPFragmentCompleted {
364     unsigned node;
365     unsigned table_id;
366     unsigned fragment_id;
367   };
368   struct ndb_logevent_UndoLogBlocked {
369     unsigned acc_count;
370     unsigned tup_count;
371   };
372 
373   /* STARTUP */
374   struct ndb_logevent_NDBStartStarted {
375     unsigned version;
376   };
377   struct ndb_logevent_NDBStartCompleted {
378     unsigned version;
379   };
380   struct ndb_logevent_STTORRYRecieved {
381     unsigned unused;
382   };
383   struct ndb_logevent_StartPhaseCompleted {
384     unsigned phase;
385     unsigned starttype;
386   };
387   struct ndb_logevent_CM_REGCONF {
388     unsigned own_id;
389     unsigned president_id;
390     unsigned dynamic_id;
391   };
392   struct ndb_logevent_CM_REGREF {
393     unsigned own_id;
394     unsigned other_id;
395     unsigned cause;
396   };
397   struct ndb_logevent_FIND_NEIGHBOURS {
398     unsigned own_id;
399     unsigned left_id;
400     unsigned right_id;
401     unsigned dynamic_id;
402   };
403   struct ndb_logevent_NDBStopStarted {
404     unsigned stoptype;
405   };
406   struct ndb_logevent_NDBStopCompleted {
407     unsigned action;
408     unsigned signum;
409   };
410   struct ndb_logevent_NDBStopForced {
411     unsigned action;
412     unsigned signum;
413     unsigned error;
414     unsigned sphase;
415     unsigned extra;
416   };
417   struct ndb_logevent_NDBStopAborted {
418     unsigned _unused;
419   };
420   struct ndb_logevent_StartREDOLog {
421     unsigned node;
422     unsigned keep_gci;
423     unsigned completed_gci;
424     unsigned restorable_gci;
425   };
426   struct ndb_logevent_StartLog {
427     unsigned log_part;
428     unsigned start_mb;
429     unsigned stop_mb;
430     unsigned gci;
431   };
432   struct ndb_logevent_UNDORecordsExecuted {
433     unsigned block;
434     unsigned data1;
435     unsigned data2;
436     unsigned data3;
437     unsigned data4;
438     unsigned data5;
439     unsigned data6;
440     unsigned data7;
441     unsigned data8;
442     unsigned data9;
443     unsigned data10;
444   };
445 
446   /* NODERESTART */
447   struct ndb_logevent_NR_CopyDict {
448     unsigned _unused;
449   };
450   struct ndb_logevent_NR_CopyDistr {
451     unsigned _unused;
452   };
453   struct ndb_logevent_NR_CopyFragsStarted {
454     unsigned dest_node;
455   };
456   struct ndb_logevent_NR_CopyFragDone {
457     unsigned dest_node;
458     unsigned table_id;
459     unsigned fragment_id;
460   };
461   struct ndb_logevent_NR_CopyFragsCompleted {
462     unsigned dest_node;
463   };
464 
465   struct ndb_logevent_NodeFailCompleted {
466     unsigned block; /* 0 = all */
467     unsigned failed_node;
468     unsigned completing_node; /* 0 = all */
469   };
470   struct ndb_logevent_NODE_FAILREP {
471     unsigned failed_node;
472     unsigned failure_state;
473   };
474   struct ndb_logevent_ArbitState {
475     unsigned code;                /* code & state << 16 */
476     unsigned arbit_node;
477     unsigned ticket_0;
478     unsigned ticket_1;
479     /* TODO */
480   };
481   struct ndb_logevent_ArbitResult {
482     unsigned code;                /* code & state << 16 */
483     unsigned arbit_node;
484     unsigned ticket_0;
485     unsigned ticket_1;
486     /* TODO */
487   };
488   struct ndb_logevent_GCP_TakeoverStarted {
489     unsigned _unused;
490   };
491   struct ndb_logevent_GCP_TakeoverCompleted {
492     unsigned _unused;
493   };
494   struct ndb_logevent_LCP_TakeoverStarted {
495     unsigned _unused;
496   };
497   struct ndb_logevent_LCP_TakeoverCompleted {
498     unsigned state;
499   };
500   struct ndb_logevent_ConnectCheckStarted {
501     unsigned other_node_count;
502     unsigned reason;
503     unsigned causing_node;
504   };
505   struct ndb_logevent_ConnectCheckCompleted {
506     unsigned nodes_checked;
507     unsigned nodes_suspect;
508     unsigned nodes_failed;
509   };
510   struct ndb_logevent_NodeFailRejected {
511     unsigned reason;
512     unsigned failed_node;
513     unsigned source_node;
514   };
515 
516   /* STATISTIC */
517   struct ndb_logevent_TransReportCounters {
518     unsigned trans_count;
519     unsigned commit_count;
520     unsigned read_count;
521     unsigned simple_read_count;
522     unsigned write_count;
523     unsigned attrinfo_count;
524     unsigned conc_op_count;
525     unsigned abort_count;
526     unsigned scan_count;
527     unsigned range_scan_count;
528   };
529   struct ndb_logevent_OperationReportCounters {
530     unsigned ops;
531   };
532   struct ndb_logevent_TableCreated {
533     unsigned table_id;
534   };
535   struct ndb_logevent_JobStatistic {
536     unsigned mean_loop_count;
537   };
538   struct ndb_logevent_SendBytesStatistic {
539     unsigned to_node;
540     unsigned mean_sent_bytes;
541   };
542   struct ndb_logevent_ReceiveBytesStatistic {
543     unsigned from_node;
544     unsigned mean_received_bytes;
545   };
546   struct ndb_logevent_MemoryUsage {
547     int      gth;
548     /* union is for compatibility backward.
549      * page_size_kb member variable should be removed in the future
550      */
551     union {
552       unsigned page_size_kb;
553       unsigned page_size_bytes;
554     };
555     unsigned pages_used;
556     unsigned pages_total;
557     unsigned block;
558   };
559 
560   /* ERROR */
561   struct ndb_logevent_TransporterError {
562     unsigned to_node;
563     unsigned code;
564   };
565   struct ndb_logevent_TransporterWarning {
566     unsigned to_node;
567     unsigned code;
568   };
569   struct ndb_logevent_MissedHeartbeat {
570     unsigned node;
571     unsigned count;
572   };
573   struct ndb_logevent_DeadDueToHeartbeat {
574     unsigned node;
575   };
576   struct ndb_logevent_WarningEvent {
577     /* TODO */
578     unsigned _unused;
579   };
580 
581   /* INFO */
582   struct ndb_logevent_SentHeartbeat {
583     unsigned node;
584   };
585   struct ndb_logevent_CreateLogBytes {
586     unsigned node;
587   };
588   struct ndb_logevent_InfoEvent {
589     /* TODO */
590     unsigned _unused;
591   };
592   struct ndb_logevent_EventBufferStatus {
593     unsigned usage;
594     unsigned alloc;
595     unsigned max;
596     unsigned apply_gci_l;
597     unsigned apply_gci_h;
598     unsigned latest_gci_l;
599     unsigned latest_gci_h;
600   };
601 
602   /** Log event data for @ref NDB_LE_BackupStarted */
603   struct ndb_logevent_BackupStarted {
604     unsigned starting_node;
605     unsigned backup_id;
606   };
607   /** Log event data @ref NDB_LE_BackupFailedToStart */
608   struct ndb_logevent_BackupFailedToStart {
609     unsigned starting_node;
610     unsigned error;
611   };
612   /** Log event data @ref NDB_LE_BackupCompleted */
613   struct ndb_logevent_BackupCompleted {
614     unsigned starting_node;
615     unsigned backup_id;
616     unsigned start_gci;
617     unsigned stop_gci;
618     unsigned n_records;
619     unsigned n_log_records;
620     unsigned n_bytes;
621     unsigned n_log_bytes;
622     unsigned n_records_hi;
623     unsigned n_log_records_hi;
624     unsigned n_bytes_hi;
625     unsigned n_log_bytes_hi;
626   };
627   /** Log event data @ref NDB_LE_BackupStatus */
628   struct ndb_logevent_BackupStatus {
629     unsigned starting_node;
630     unsigned backup_id;
631     unsigned n_records_lo;
632     unsigned n_records_hi;
633     unsigned n_log_records_lo;
634     unsigned n_log_records_hi;
635     unsigned n_bytes_lo;
636     unsigned n_bytes_hi;
637     unsigned n_log_bytes_lo;
638     unsigned n_log_bytes_hi;
639   };
640 
641   /** Log event data @ref NDB_LE_BackupAborted */
642   struct ndb_logevent_BackupAborted {
643     unsigned starting_node;
644     unsigned backup_id;
645     unsigned error;
646   };
647 
648   /** Log event data @ref NDB_LE_RestoreStarted */
649   struct ndb_logevent_RestoreStarted {
650     unsigned backup_id;
651     unsigned node_id;
652   };
653   /** Log event data @ref NDB_LE_RestoreMetaData */
654   struct ndb_logevent_RestoreMetaData {
655     unsigned backup_id;
656     unsigned node_id;
657     unsigned n_tables;
658     unsigned n_tablespaces;
659     unsigned n_logfilegroups;
660     unsigned n_datafiles;
661     unsigned n_undofiles;
662   };
663   /** Log event data @ref NDB_LE_RestoreData */
664   struct ndb_logevent_RestoreData {
665     unsigned backup_id;
666     unsigned node_id;
667     unsigned n_records_lo;
668     unsigned n_records_hi;
669     unsigned n_bytes_lo;
670     unsigned n_bytes_hi;
671   };
672   /** Log event data @ref NDB_LE_RestoreLog */
673   struct ndb_logevent_RestoreLog {
674     unsigned backup_id;
675     unsigned node_id;
676     unsigned n_records_lo;
677     unsigned n_records_hi;
678     unsigned n_bytes_lo;
679     unsigned n_bytes_hi;
680   };
681   /** Log event data @ref NDB_LE_RestoreCompleted */
682   struct ndb_logevent_RestoreCompleted {
683     unsigned backup_id;
684     unsigned node_id;
685   };
686 
687   /** Log event data @ref NDB_LE_SingleUser */
688   struct ndb_logevent_SingleUser {
689     unsigned type;
690     unsigned node_id;
691   };
692   /** Log even data @ref NDB_LE_StartReport */
693   struct ndb_logevent_StartReport {
694     unsigned report_type;
695     unsigned remaining_time;
696     unsigned bitmask_size;
697     unsigned bitmask_data[1];
698   };
699 
700   /** Log event data @ref NDB_LE_SubscriptionStatus */
701   struct ndb_logevent_SubscriptionStatus {
702     unsigned report_type;
703     unsigned node_id;
704   };
705 
706   /** Log event data @ref NDB_LE_RedoStatus */
707   struct ndb_logevent_RedoStatus {
708     unsigned log_part;
709     unsigned head_file_no;
710     unsigned head_mbyte;
711     unsigned tail_file_no;
712     unsigned tail_mbyte;
713     unsigned total_hi;
714     unsigned total_lo;
715     unsigned free_hi;
716     unsigned free_lo;
717     unsigned no_logfiles;
718     unsigned logfilesize;
719   };
720 
721   /** Log event data @ref NDB_LE_LogFileInitStatus */
722   struct ndb_logevent_LogFileInitStatus {
723     unsigned node_id;
724     unsigned total_files;
725     unsigned file_done;
726     unsigned total_mbytes;
727     unsigned mbytes_done;
728   };
729 
730   /** Log event data @ref NDB_LE_MTSignalStatistic */
731   struct ndb_logevent_MTSignalStatistics {
732     unsigned thr_no;
733     unsigned prioa_count;
734     unsigned prioa_size;
735     unsigned priob_count;
736     unsigned priob_size;
737   };
738 
739   struct ndb_logevent_CreateSchemaObject {
740     unsigned objectid;
741     unsigned version;
742     unsigned type;
743     unsigned node; /* Node create object */
744   };
745 
746   struct ndb_logevent_AlterSchemaObject {
747     unsigned objectid;
748     unsigned version;
749     unsigned type;
750     unsigned node; /* Node create object */
751   };
752 
753   struct ndb_logevent_DropSchemaObject {
754     unsigned objectid;
755     unsigned version;
756     unsigned type;
757     unsigned node; /* Node create object */
758   };
759 
760   struct ndb_logevent_StartReadLCP {
761     unsigned tableid;
762     unsigned fragmentid;
763   };
764 
765   struct ndb_logevent_ReadLCPComplete {
766     unsigned tableid;
767     unsigned fragmentid;
768     unsigned rows_hi;
769     unsigned rows_lo;
770   };
771 
772   struct ndb_logevent_RunRedo {
773     unsigned logpart;
774     unsigned phase;
775     unsigned startgci;
776     unsigned currgci;
777     unsigned stopgci;
778     unsigned startfile;
779     unsigned startmb;
780     unsigned currfile;
781     unsigned currmb;
782     unsigned stopfile;
783     unsigned stopmb;
784   };
785 
786   struct ndb_logevent_RebuildIndex {
787     unsigned instance;
788     unsigned indexid;
789   };
790 
791   struct ndb_logevent_SavedEvent {
792     unsigned len;
793     unsigned seq;
794     unsigned time;
795     unsigned data[1];
796   };
797 
798   /**
799    * Structure to store and retrieve log event information.
800    * @see @ref secSLogEvents
801    */
802   struct ndb_logevent {
803     /** NdbLogEventHandle (to be used for comparing only)
804      *  set in ndb_logevent_get_next()
805      */
806     void *handle;
807 
808     /** Which event */
809     enum Ndb_logevent_type type;
810 
811     /** Time when log event was registred at the management server */
812     unsigned time;
813 
814     /** Category of log event */
815     enum ndb_mgm_event_category category;
816 
817     /** Severity of log event */
818     enum ndb_mgm_event_severity severity;
819 
820     /** Level (0-15) of log event */
821     unsigned level;
822 
823     /** Node ID of the node that reported the log event */
824     unsigned source_nodeid;
825 
826     /** Union of log event specific data. Use @ref type to decide
827      *  which struct to use
828      */
829     union {
830       /* CONNECT */
831       struct ndb_logevent_Connected Connected;
832       struct ndb_logevent_Disconnected Disconnected;
833       struct ndb_logevent_CommunicationClosed CommunicationClosed;
834       struct ndb_logevent_CommunicationOpened CommunicationOpened;
835       struct ndb_logevent_ConnectedApiVersion ConnectedApiVersion;
836 
837       /* CHECKPOINT */
838       struct ndb_logevent_GlobalCheckpointStarted GlobalCheckpointStarted;
839       struct ndb_logevent_GlobalCheckpointCompleted GlobalCheckpointCompleted;
840       struct ndb_logevent_LocalCheckpointStarted LocalCheckpointStarted;
841       struct ndb_logevent_LocalCheckpointCompleted LocalCheckpointCompleted;
842       struct ndb_logevent_LCPStoppedInCalcKeepGci LCPStoppedInCalcKeepGci;
843       struct ndb_logevent_LCPFragmentCompleted LCPFragmentCompleted;
844       struct ndb_logevent_UndoLogBlocked UndoLogBlocked;
845 
846       /* STARTUP */
847       struct ndb_logevent_NDBStartStarted NDBStartStarted;
848       struct ndb_logevent_NDBStartCompleted NDBStartCompleted;
849       struct ndb_logevent_STTORRYRecieved STTORRYRecieved;
850       struct ndb_logevent_StartPhaseCompleted StartPhaseCompleted;
851       struct ndb_logevent_CM_REGCONF CM_REGCONF;
852       struct ndb_logevent_CM_REGREF CM_REGREF;
853       struct ndb_logevent_FIND_NEIGHBOURS FIND_NEIGHBOURS;
854       struct ndb_logevent_NDBStopStarted NDBStopStarted;
855       struct ndb_logevent_NDBStopCompleted NDBStopCompleted;
856       struct ndb_logevent_NDBStopForced NDBStopForced;
857       struct ndb_logevent_NDBStopAborted NDBStopAborted;
858       struct ndb_logevent_StartREDOLog StartREDOLog;
859       struct ndb_logevent_StartLog StartLog;
860       struct ndb_logevent_UNDORecordsExecuted UNDORecordsExecuted;
861       /* NODERESTART */
862       struct ndb_logevent_NR_CopyDict NR_CopyDict;
863       struct ndb_logevent_NR_CopyDistr NR_CopyDistr;
864       struct ndb_logevent_NR_CopyFragsStarted NR_CopyFragsStarted;
865       struct ndb_logevent_NR_CopyFragDone NR_CopyFragDone;
866       struct ndb_logevent_NR_CopyFragsCompleted NR_CopyFragsCompleted;
867       struct ndb_logevent_NodeFailCompleted NodeFailCompleted;
868       struct ndb_logevent_NODE_FAILREP NODE_FAILREP;
869       struct ndb_logevent_ArbitState ArbitState;
870       struct ndb_logevent_ArbitResult ArbitResult;
871       struct ndb_logevent_GCP_TakeoverStarted GCP_TakeoverStarted;
872       struct ndb_logevent_GCP_TakeoverCompleted GCP_TakeoverCompleted;
873       struct ndb_logevent_LCP_TakeoverStarted LCP_TakeoverStarted;
874       struct ndb_logevent_LCP_TakeoverCompleted LCP_TakeoverCompleted;
875       struct ndb_logevent_ConnectCheckStarted ConnectCheckStarted;
876       struct ndb_logevent_ConnectCheckCompleted ConnectCheckCompleted;
877       struct ndb_logevent_NodeFailRejected NodeFailRejected;
878 
879       /* STATISTIC */
880       struct ndb_logevent_TransReportCounters TransReportCounters;
881       struct ndb_logevent_OperationReportCounters OperationReportCounters;
882       struct ndb_logevent_TableCreated TableCreated;
883       struct ndb_logevent_JobStatistic JobStatistic;
884       struct ndb_logevent_SendBytesStatistic SendBytesStatistic;
885       struct ndb_logevent_ReceiveBytesStatistic ReceiveBytesStatistic;
886       struct ndb_logevent_MemoryUsage MemoryUsage;
887 
888       /* ERROR */
889       struct ndb_logevent_TransporterError TransporterError;
890       struct ndb_logevent_TransporterWarning TransporterWarning;
891       struct ndb_logevent_MissedHeartbeat MissedHeartbeat;
892       struct ndb_logevent_DeadDueToHeartbeat DeadDueToHeartbeat;
893       struct ndb_logevent_WarningEvent WarningEvent;
894 
895       /* INFO */
896       struct ndb_logevent_SentHeartbeat SentHeartbeat;
897       struct ndb_logevent_CreateLogBytes CreateLogBytes;
898       struct ndb_logevent_InfoEvent InfoEvent;
899       struct ndb_logevent_EventBufferStatus EventBufferStatus;
900       struct ndb_logevent_SavedEvent SavedEvent;
901 
902       /** Log event data for @ref NDB_LE_BackupStarted */
903       struct ndb_logevent_BackupStarted BackupStarted;
904       /** Log event data @ref NDB_LE_BackupFailedToStart */
905       struct ndb_logevent_BackupFailedToStart BackupFailedToStart;
906       /** Log event data @ref NDB_LE_BackupCompleted */
907       struct ndb_logevent_BackupCompleted BackupCompleted;
908       /** Log event data @ref NDB_LE_BackupStatus */
909       struct ndb_logevent_BackupStatus BackupStatus;
910       /** Log event data @ref NDB_LE_BackupAborted */
911       struct ndb_logevent_BackupAborted BackupAborted;
912       /** Log event data @ref NDB_LE_RestoreStarted */
913       struct ndb_logevent_RestoreStarted RestoreStarted;
914       /** Log event data @ref NDB_LE_RestoreMetaData */
915       struct ndb_logevent_RestoreMetaData RestoreMetaData;
916       /** Log event data @ref NDB_LE_RestoreData */
917       struct ndb_logevent_RestoreData RestoreData;
918       /** Log event data @ref NDB_LE_RestoreLog */
919       struct ndb_logevent_RestoreLog RestoreLog;
920       /** Log event data @ref NDB_LE_RestoreCompleted */
921       struct ndb_logevent_RestoreCompleted RestoreCompleted;
922       /** Log event data @ref NDB_LE_LogFileInitStatus */
923       struct ndb_logevent_LogFileInitStatus LogFileInitStatus;
924       /** Log event data @ref NDB_LE_SingleUser */
925       struct ndb_logevent_SingleUser SingleUser;
926       /** Log event data @ref NDB_LE_MTSignalStatistic */
927       struct ndb_logevent_MTSignalStatistics MTSignalStatistics;
928       /** Log event data @ref NDB_LE_StartReport */
929       struct ndb_logevent_StartReport StartReport;
930       /** Log event data @ref NDB_LE_SubscriptionStatus */
931       struct ndb_logevent_SubscriptionStatus SubscriptionStatus;
932       /** Log event data @ref NDB_LE_RedoStatus */
933       struct ndb_logevent_RedoStatus RedoStatus;
934 
935       struct ndb_logevent_CreateSchemaObject CreateSchemaObject;
936       struct ndb_logevent_AlterSchemaObject AlterSchemaObject;
937       struct ndb_logevent_DropSchemaObject DropSchemaObject;
938       struct ndb_logevent_StartReadLCP StartReadLCP;
939       struct ndb_logevent_ReadLCPComplete ReadLCPComplete;
940       struct ndb_logevent_RunRedo RunRedo;
941       struct ndb_logevent_RebuildIndex RebuildIndex;
942 
943       /** Raw data */
944       unsigned Data[29];
945 #ifndef DOXYGEN_FIX
946     };
947 #else
948     } <union>;
949 #endif
950   };
951 
952 enum ndb_logevent_handle_error {
953   NDB_LEH_NO_ERROR,
954   NDB_LEH_READ_ERROR,
955   NDB_LEH_MISSING_EVENT_SPECIFIER,
956   NDB_LEH_UNKNOWN_EVENT_TYPE,
957   NDB_LEH_UNKNOWN_EVENT_VARIABLE,
958   NDB_LEH_INTERNAL_ERROR
959 };
960 
961 #ifdef __cplusplus
962 }
963 #endif
964 
965 /** @} */
966 
967 #endif
968