MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Dblqh.hpp
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 #ifndef DBLQH_H
19 #define DBLQH_H
20 
21 #include <pc.hpp>
22 #include <ndb_limits.h>
23 #include <SimulatedBlock.hpp>
24 #include <SectionReader.hpp>
25 #include <SLList.hpp>
26 #include <DLList.hpp>
27 #include <DLFifoList.hpp>
28 #include <DLHashTable.hpp>
29 
30 #include <NodeBitmask.hpp>
31 #include <signaldata/LCP.hpp>
32 #include <signaldata/LqhTransConf.hpp>
33 #include <signaldata/CreateTab.hpp>
34 #include <signaldata/LqhFrag.hpp>
35 #include <signaldata/FsOpenReq.hpp>
36 #include <signaldata/DropTab.hpp>
37 
38 // primary key is stored in TUP
39 #include "../dbtup/Dbtup.hpp"
40 
41 class Dbacc;
42 class Dbtup;
43 class Lgman;
44 
45 #ifdef DBLQH_C
46 // Constants
47 /* ------------------------------------------------------------------------- */
48 /* CONSTANTS USED WHEN MASTER REQUESTS STATE OF COPY FRAGMENTS. */
49 /* ------------------------------------------------------------------------- */
50 #define ZCOPY_CLOSING 0
51 #define ZCOPY_ONGOING 1
52 #define ZCOPY_ACTIVATION 2
53 /* ------------------------------------------------------------------------- */
54 /* STATES FOR THE VARIABLE GCP_LOG_PART_STATE */
55 /* ------------------------------------------------------------------------- */
56 #define ZIDLE 0
57 #define ZWAIT_DISK 1
58 #define ZON_DISK 2
59 #define ZACTIVE 1
60 /* ------------------------------------------------------------------------- */
61 /* STATES FOR THE VARIABLE CSR_PHASES_STARTED */
62 /* ------------------------------------------------------------------------- */
63 #define ZSR_NO_PHASE_STARTED 0
64 #define ZSR_PHASE1_COMPLETED 1
65 #define ZSR_PHASE2_COMPLETED 2
66 #define ZSR_BOTH_PHASES_STARTED 3
67 /* ------------------------------------------------------------------------- */
68 /* THE NUMBER OF PAGES IN A MBYTE, THE TWO LOGARITHM OF THIS. */
69 /* THE NUMBER OF MBYTES IN A LOG FILE. */
70 /* THE MAX NUMBER OF PAGES READ/WRITTEN FROM/TO DISK DURING */
71 /* A WRITE OR READ. */
72 /* ------------------------------------------------------------------------- */
73 #define ZNOT_DIRTY 0
74 #define ZDIRTY 1
75 #define ZREAD_AHEAD_SIZE 8
76 /* ------------------------------------------------------------------------- */
77 /* CONSTANTS OF THE LOG PAGES */
78 /* ------------------------------------------------------------------------- */
79 #define ZPAGE_HEADER_SIZE 32
80 #define ZPAGE_SIZE 8192
81 #define ZPAGES_IN_MBYTE 32
82 #define ZTWOLOG_NO_PAGES_IN_MBYTE 5
83 #define ZTWOLOG_PAGE_SIZE 13
84 #define ZMAX_MM_BUFFER_SIZE 32 // Main memory window during log execution
85 
86 #define ZMAX_PAGES_WRITTEN 8 // Max pages before writing to disk (=> config)
87 #define ZMIN_READ_BUFFER_SIZE 2 // Minimum number of pages to execute log
88 #define ZMIN_LOG_PAGES_OPERATION 10 // Minimum no of pages before stopping
89 
90 #define ZPOS_CHECKSUM 0
91 #define ZPOS_LOG_LAP 1
92 #define ZPOS_MAX_GCI_COMPLETED 2
93 #define ZPOS_MAX_GCI_STARTED 3
94 #define ZNEXT_PAGE 4
95 #define ZPREV_PAGE 5
96 #define ZPOS_VERSION 6
97 #define ZPOS_NO_LOG_FILES 7
98 #define ZCURR_PAGE_INDEX 8
99 #define ZLAST_LOG_PREP_REF 10
100 #define ZPOS_DIRTY 11
101 /* A number of debug items written in the page header of all log files */
102 #define ZPOS_LOG_TIMER 12
103 #define ZPOS_PAGE_I 13
104 #define ZPOS_PLACE_WRITTEN_FROM 14
105 #define ZPOS_PAGE_NO 15
106 #define ZPOS_PAGE_FILE_NO 16
107 #define ZPOS_WORD_WRITTEN 17
108 #define ZPOS_IN_WRITING 18
109 #define ZPOS_PREV_PAGE_NO 19
110 #define ZPOS_IN_FREE_LIST 20
111 
112 /* ------------------------------------------------------------------------- */
113 /* CONSTANTS FOR THE VARIOUS REPLICA AND NODE TYPES. */
114 /* ------------------------------------------------------------------------- */
115 #define ZPRIMARY_NODE 0
116 #define ZBACKUP_NODE 1
117 #define ZSTANDBY_NODE 2
118 #define ZTC_NODE 3
119 #define ZLOG_NODE 3
120 /* ------------------------------------------------------------------------- */
121 /* VARIOUS CONSTANTS USED AS FLAGS TO THE FILE MANAGER. */
122 /* ------------------------------------------------------------------------- */
123 #define ZVAR_NO_LOG_PAGE_WORD 1
124 #define ZLIST_OF_PAIRS 0
125 #define ZLIST_OF_PAIRS_SYNCH 16
126 #define ZARRAY_OF_PAGES 1
127 #define ZLIST_OF_MEM_PAGES 2
128 #define ZLIST_OF_MEM_PAGES_SYNCH 18
129 #define ZCLOSE_NO_DELETE 0
130 #define ZCLOSE_DELETE 1
131 #define ZPAGE_ZERO 0
132 /* ------------------------------------------------------------------------- */
133 /* THE FOLLOWING CONSTANTS ARE USED TO DESCRIBE THE TYPES OF */
134 /* LOG RECORDS, THE SIZE OF THE VARIOUS LOG RECORD TYPES AND */
135 /* THE POSITIONS WITHIN THOSE LOG RECORDS. */
136 /* ------------------------------------------------------------------------- */
137 /* ------------------------------------------------------------------------- */
138 /* THESE CONSTANTS DESCRIBE THE SIZES OF VARIOUS TYPES OF LOG REORDS. */
139 /* NEXT_LOG_SIZE IS ACTUALLY ONE. THE REASON WE SET IT TO 2 IS TO */
140 /* SIMPLIFY THE CODE SINCE OTHERWISE HAVE TO USE A SPECIAL VERSION */
141 /* OF READ_LOGWORD WHEN READING LOG RECORD TYPE */
142 /* SINCE NEXT MBYTE TYPE COULD BE THE VERY LAST WORD IN THE MBYTE. */
143 /* BY SETTING IT TO 2 WE ENSURE IT IS NEVER THE VERY LAST WORD */
144 /* IN THE MBYTE. */
145 /* ------------------------------------------------------------------------- */
146 #define ZFD_HEADER_SIZE 3
147 #define ZFD_MBYTE_SIZE 3
148 #define ZLOG_HEAD_SIZE 8
149 #define ZNEXT_LOG_SIZE 2
150 #define ZABORT_LOG_SIZE 3
151 #define ZCOMMIT_LOG_SIZE 9
152 #define ZCOMPLETED_GCI_LOG_SIZE 2
153 /* ------------------------------------------------------------------------- */
154 /* THESE CONSTANTS DESCRIBE THE TYPE OF A LOG RECORD. */
155 /* THIS IS THE FIRST WORD OF A LOG RECORD. */
156 /* ------------------------------------------------------------------------- */
157 #define ZNEW_PREP_OP_TYPE 0
158 #define ZPREP_OP_TYPE 1
159 #define ZCOMMIT_TYPE 2
160 #define ZABORT_TYPE 3
161 #define ZFD_TYPE 4
162 #define ZFRAG_SPLIT_TYPE 5
163 #define ZNEXT_LOG_RECORD_TYPE 6
164 #define ZNEXT_MBYTE_TYPE 7
165 #define ZCOMPLETED_GCI_TYPE 8
166 #define ZINVALID_COMMIT_TYPE 9
167 /* ------------------------------------------------------------------------- */
168 /* THE POSITIONS OF LOGGED DATA IN A FILE DESCRIPTOR LOG RECORD HEADER.*/
169 /* ALSO THE MAXIMUM NUMBER OF FILE DESCRIPTORS IN A LOG RECORD. */
170 /* ------------------------------------------------------------------------- */
171 #define ZPOS_LOG_TYPE 0
172 #define ZPOS_NO_FD 1
173 #define ZPOS_FILE_NO 2
174 /* ------------------------------------------------------------------------- */
175 /* THE POSITIONS WITHIN A PREPARE LOG RECORD AND A NEW PREPARE */
176 /* LOG RECORD. */
177 /* ------------------------------------------------------------------------- */
178 #define ZPOS_HASH_VALUE 2
179 #define ZPOS_SCHEMA_VERSION 3
180 #define ZPOS_TRANS_TICKET 4
181 #define ZPOS_OP_TYPE 5
182 #define ZPOS_NO_ATTRINFO 6
183 #define ZPOS_NO_KEYINFO 7
184 /* ------------------------------------------------------------------------- */
185 /* THE POSITIONS WITHIN A COMMIT LOG RECORD. */
186 /* ------------------------------------------------------------------------- */
187 #define ZPOS_COMMIT_TRANSID1 1
188 #define ZPOS_COMMIT_TRANSID2 2
189 #define ZPOS_COMMIT_GCI 3
190 #define ZPOS_COMMIT_TABLE_REF 4
191 #define ZPOS_COMMIT_FRAGID 5
192 #define ZPOS_COMMIT_FILE_NO 6
193 #define ZPOS_COMMIT_START_PAGE_NO 7
194 #define ZPOS_COMMIT_START_PAGE_INDEX 8
195 #define ZPOS_COMMIT_STOP_PAGE_NO 9
196 /* ------------------------------------------------------------------------- */
197 /* THE POSITIONS WITHIN A ABORT LOG RECORD. */
198 /* ------------------------------------------------------------------------- */
199 #define ZPOS_ABORT_TRANSID1 1
200 #define ZPOS_ABORT_TRANSID2 2
201 /* ------------------------------------------------------------------------- */
202 /* THE POSITION WITHIN A COMPLETED GCI LOG RECORD. */
203 /* ------------------------------------------------------------------------- */
204 #define ZPOS_COMPLETED_GCI 1
205 /* ------------------------------------------------------------------------- */
206 /* THE POSITIONS WITHIN A NEW PREPARE LOG RECORD. */
207 /* ------------------------------------------------------------------------- */
208 #define ZPOS_NEW_PREP_FILE_NO 8
209 #define ZPOS_NEW_PREP_PAGE_REF 9
210 
211 #define ZLAST_WRITE_IN_FILE 1
212 #define ZENFORCE_WRITE 2
213 /* ------------------------------------------------------------------------- */
214 /* CONSTANTS USED AS INPUT TO SUBROUTINE WRITE_LOG_PAGES AMONG OTHERS. */
215 /* ------------------------------------------------------------------------- */
216 #define ZNORMAL 0
217 #define ZINIT 1
218 /* ------------------------------------------------------------------------- */
219 /* CONSTANTS USED BY CONTINUEB TO DEDUCE WHICH CONTINUE SIGNAL IS TO */
220 /* BE EXECUTED AS A RESULT OF THIS CONTINUEB SIGNAL. */
221 /* ------------------------------------------------------------------------- */
222 #define ZLOG_LQHKEYREQ 0
223 #define ZPACK_LQHKEYREQ 1
224 #define ZSEND_ATTRINFO 2
225 #define ZSR_GCI_LIMITS 3
226 #define ZSR_LOG_LIMITS 4
227 #define ZSEND_EXEC_CONF 5
228 #define ZEXEC_SR 6
229 #define ZSR_FOURTH_COMP 7
230 #define ZINIT_FOURTH 8
231 #define ZTIME_SUPERVISION 9
232 #define ZSR_PHASE3_START 10
233 #define ZLQH_TRANS_NEXT 11
234 #define ZLQH_RELEASE_AT_NODE_FAILURE 12
235 #define ZSCAN_TC_CONNECT 13
236 #define ZINITIALISE_RECORDS 14
237 #define ZINIT_GCP_REC 15
238 #define ZCHECK_LCP_STOP_BLOCKED 17
239 #define ZSCAN_MARKERS 18
240 #define ZOPERATION_EVENT_REP 19
241 #define ZDROP_TABLE_WAIT_USAGE 20
242 #define ZENABLE_EXPAND_CHECK 21
243 #define ZRETRY_TCKEYREF 22
244 #define ZWAIT_REORG_SUMA_FILTER_ENABLED 23
245 #define ZREBUILD_ORDERED_INDEXES 24
246 #define ZWAIT_READONLY 25
247 
248 /* ------------------------------------------------------------------------- */
249 /* NODE STATE DURING SYSTEM RESTART, VARIABLES CNODES_SR_STATE */
250 /* AND CNODES_EXEC_SR_STATE. */
251 /* ------------------------------------------------------------------------- */
252 #define ZSTART_SR 1
253 #define ZEXEC_SR_COMPLETED 2
254 /* ------------------------------------------------------------------------- */
255 /* CONSTANTS USED BY NODE STATUS TO DEDUCE THE STATUS OF A NODE. */
256 /* ------------------------------------------------------------------------- */
257 #define ZNODE_UP 0
258 #define ZNODE_DOWN 1
259 /* ------------------------------------------------------------------------- */
260 /* START PHASES */
261 /* ------------------------------------------------------------------------- */
262 #define ZLAST_START_PHASE 255
263 #define ZSTART_PHASE1 1
264 #define ZSTART_PHASE2 2
265 #define ZSTART_PHASE3 3
266 #define ZSTART_PHASE4 4
267 #define ZSTART_PHASE6 6
268 /* ------------------------------------------------------------------------- */
269 /* CONSTANTS USED BY SCAN AND COPY FRAGMENT PROCEDURES */
270 /* ------------------------------------------------------------------------- */
271 #define ZSTORED_PROC_SCAN 0
272 #define ZSTORED_PROC_COPY 2
273 #define ZDELETE_STORED_PROC_ID 3
274 #define ZWRITE_LOCK 1
275 #define ZSCAN_FRAG_CLOSED 2
276 /* ------------------------------------------------------------------------- */
277 /* ERROR CODES ADDED IN VERSION 0.1 AND 0.2 */
278 /* ------------------------------------------------------------------------- */
279 #define ZNOT_FOUND 1 // Not an error code, a return value
280 #define ZNO_FREE_LQH_CONNECTION 414
281 #define ZGET_DATAREC_ERROR 418
282 #define ZGET_ATTRINBUF_ERROR 419
283 #define ZNO_FREE_FRAGMENTREC 460 // Insert new fragment error code
284 #define ZTAB_FILE_SIZE 464 // Insert new fragment error code + Start kernel
285 #define ZNO_ADD_FRAGREC 465 // Insert new fragment error code
286 /* ------------------------------------------------------------------------- */
287 /* ERROR CODES ADDED IN VERSION 0.3 */
288 /* ------------------------------------------------------------------------- */
289 #define ZTAIL_PROBLEM_IN_LOG_ERROR 410
290 #define ZGCI_TOO_LOW_ERROR 429 // GCP_SAVEREF error code
291 #define ZTAB_STATE_ERROR 474 // Insert new fragment error code
292 #define ZTOO_NEW_GCI_ERROR 479 // LCP Start error
293 /* ------------------------------------------------------------------------- */
294 /* ERROR CODES ADDED IN VERSION 0.4 */
295 /* ------------------------------------------------------------------------- */
296 
297 #define ZNO_FREE_FRAG_SCAN_REC_ERROR 490 // SCAN_FRAGREF error code
298 #define ZCOPY_NO_FRAGMENT_ERROR 491 // COPY_FRAGREF error code
299 #define ZTAKE_OVER_ERROR 499
300 #define ZCOPY_NODE_ERROR 1204
301 #define ZTOO_MANY_COPY_ACTIVE_ERROR 1208 // COPY_FRAG and COPY_ACTIVEREF code
302 #define ZCOPY_ACTIVE_ERROR 1210 // COPY_ACTIVEREF error code
303 #define ZNO_TC_CONNECT_ERROR 1217 // Simple Read + SCAN
304 #define ZTRANSPORTER_OVERLOADED_ERROR 1218
305 /* ------------------------------------------------------------------------- */
306 /* ERROR CODES ADDED IN VERSION 1.X */
307 /* ------------------------------------------------------------------------- */
308 //#define ZSCAN_BOOK_ACC_OP_ERROR 1219 // SCAN_FRAGREF error code
309 #define ZFILE_CHANGE_PROBLEM_IN_LOG_ERROR 1220
310 #define ZTEMPORARY_REDO_LOG_FAILURE 1221
311 #define ZNO_FREE_MARKER_RECORDS_ERROR 1222
312 #define ZNODE_SHUTDOWN_IN_PROGESS 1223
313 #define ZTOO_MANY_FRAGMENTS 1224
314 #define ZTABLE_NOT_DEFINED 1225
315 #define ZDROP_TABLE_IN_PROGRESS 1226
316 #define ZINVALID_SCHEMA_VERSION 1227
317 #define ZTABLE_READ_ONLY 1233
318 #define ZREDO_IO_PROBLEM 1234
319 
320 /* ------------------------------------------------------------------------- */
321 /* ERROR CODES ADDED IN VERSION 2.X */
322 /* ------------------------------------------------------------------------- */
323 #define ZNODE_FAILURE_ERROR 400
324 #define ZBAD_UNLOCK_STATE 416
325 #define ZBAD_OP_REF 417
326 /* ------------------------------------------------------------------------- */
327 /* ERROR CODES FROM ACC */
328 /* ------------------------------------------------------------------------- */
329 #define ZNO_TUPLE_FOUND 626
330 #define ZTUPLE_ALREADY_EXIST 630
331 /* ------------------------------------------------------------------------- */
332 /* ERROR CODES FROM TUP */
333 /* ------------------------------------------------------------------------- */
334 #define ZSEARCH_CONDITION_FALSE 899
335 #define ZUSER_ERROR_CODE_LIMIT 6000
336 #endif
337 
413 class Dblqh: public SimulatedBlock {
414  friend class DblqhProxy;
415 
416 public:
417  enum LcpCloseState {
418  LCP_IDLE = 0,
419  LCP_RUNNING = 1, // LCP is running
420  LCP_CLOSE_STARTED = 2, // Completion(closing of files) has started
421  ACC_LCP_CLOSE_COMPLETED = 3,
422  TUP_LCP_CLOSE_COMPLETED = 4
423  };
424 
425  enum ExecUndoLogState {
426  EULS_IDLE = 0,
427  EULS_STARTED = 1,
428  EULS_COMPLETED = 2
429  };
430 
431  struct AddFragRecord {
432  enum AddFragStatus {
433  FREE = 0,
434  ACC_ADDFRAG = 1,
435  WAIT_TUP = 3,
436  WAIT_TUX = 5,
437  WAIT_ADD_ATTR = 6,
438  TUP_ATTR_WAIT = 7,
439  TUX_ATTR_WAIT = 9
440  };
441  AddFragStatus addfragStatus;
442  UintR fragmentPtr;
443  UintR nextAddfragrec;
444  UintR accConnectptr;
445  UintR tupConnectptr;
446  UintR tuxConnectptr;
447 
448  CreateTabReq m_createTabReq;
449  LqhFragReq m_lqhFragReq;
450  LqhAddAttrReq m_addAttrReq;
451  DropFragReq m_dropFragReq;
452  DropTabReq m_dropTabReq;
453 
454  Uint16 addfragErrorCode;
455  Uint16 attrSentToTup;
456  Uint16 attrReceived;
457  Uint16 totalAttrReceived;
458  Uint16 fragCopyCreation;
459  Uint16 defValNextPos;
460  Uint32 defValSectionI;
461  };
463 
464  struct ScanRecord {
465  ScanRecord() {}
466  enum ScanState {
467  SCAN_FREE = 0,
468  WAIT_STORED_PROC_COPY = 1,
469  WAIT_STORED_PROC_SCAN = 2,
470  WAIT_NEXT_SCAN_COPY = 3,
471  WAIT_NEXT_SCAN = 4,
472  WAIT_DELETE_STORED_PROC_ID_SCAN = 5,
473  WAIT_DELETE_STORED_PROC_ID_COPY = 6,
474  WAIT_ACC_COPY = 7,
475  WAIT_ACC_SCAN = 8,
476  WAIT_SCAN_NEXTREQ = 10,
477  WAIT_CLOSE_SCAN = 12,
478  WAIT_CLOSE_COPY = 13,
479  WAIT_RELEASE_LOCK = 14,
480  WAIT_TUPKEY_COPY = 15,
481  WAIT_LQHKEY_COPY = 16,
482  IN_QUEUE = 17
483  };
484  enum ScanType {
485  ST_IDLE = 0,
486  SCAN = 1,
487  COPY = 2
488  };
489 
490  /* A single scan of each fragment can have MAX_PARALLEL_OP_PER_SCAN
491  * read operations in progress at one time
492  * We must store ACC ptrs for each read operation. They are stored
493  * in SegmentedSections linked in the array below.
494  * The main oddity is that the first element of scan_acc_op_ptr is
495  * an ACC ptr, but all others are refs to SectionSegments containing
496  * ACC ptrs.
497  */
498  STATIC_CONST( MaxScanAccSegments= (
499  (MAX_PARALLEL_OP_PER_SCAN + SectionSegment::DataLength - 1) /
500  SectionSegment::DataLength) + 1);
501 
502  UintR scan_acc_op_ptr[ MaxScanAccSegments ];
503  Uint32 scan_acc_index;
504  Uint32 scan_acc_segments;
505  UintR scanApiOpPtr;
506  Local_key m_row_id;
507 
508  Uint32 m_max_batch_size_rows;
509  Uint32 m_max_batch_size_bytes;
510 
511  Uint32 m_curr_batch_size_rows;
512  Uint32 m_curr_batch_size_bytes;
513 
514  bool check_scan_batch_completed() const;
515 
516  UintR copyPtr;
517  union {
518  Uint32 nextPool;
519  Uint32 nextList;
520  };
521  Uint32 prevList;
522  Uint32 nextHash;
523  Uint32 prevHash;
524  bool equal(const ScanRecord & key) const {
525  return scanNumber == key.scanNumber && fragPtrI == key.fragPtrI;
526  }
527  Uint32 hashValue() const {
528  return fragPtrI ^ scanNumber;
529  }
530 
531  UintR scanAccPtr;
532  UintR scanAiLength;
533  UintR scanErrorCounter;
534  UintR scanSchemaVersion;
535  Uint32 scanTcWaiting; // When the request came from TC, 0 is no request
536 
541  Uint32 fragPtrI;
542  UintR scanStoredProcId;
543  ScanState scanState;
544  UintR scanTcrec;
545  ScanType scanType;
546  BlockReference scanApiBlockref;
547  NodeId scanNodeId;
548  Uint16 scanReleaseCounter;
549  Uint16 scanNumber;
550 
551  // scan source block ACC TUX TUP
552  BlockReference scanBlockref;
553 
554  Uint8 scanCompletedStatus;
555  Uint8 scanFlag;
556  Uint8 scanLockHold;
557  Uint8 scanLockMode;
558  Uint8 readCommitted;
559  Uint8 rangeScan;
560  Uint8 descending;
561  Uint8 tupScan;
562  Uint8 lcpScan;
563  Uint8 scanKeyinfoFlag;
564  Uint8 m_last_row;
565  Uint8 m_reserved;
566  Uint8 statScan;
567  Uint8 dummy[3]; // align?
568  }; // Size 272 bytes
570 
571  struct Fragrecord {
572  Fragrecord() {}
573 
574  enum ExecSrStatus {
575  IDLE = 0,
576  ACTIVE = 2
577  };
613  enum FragStatus {
614  FREE = 0,
615  FSACTIVE = 1,
616  DEFINED = 2,
617 
618  BLOCKED = 3,
619 
620 
622 
624 
625 
626  REMOVING = 6
627 
628  };
629  enum LogFlag {
630  STATE_TRUE = 0,
631  STATE_FALSE = 1
632  };
633  enum SrStatus {
634  SS_IDLE = 0,
635  SS_STARTED = 1,
636  SS_COMPLETED = 2
637  };
638  enum LcpFlag {
639  LCP_STATE_TRUE = 0,
640  LCP_STATE_FALSE = 1
641  };
645  UintR execSrLastGci[4];
649  UintR execSrStartGci[4];
654  UintR execSrUserptr[4];
660  UintR lcpId[MAX_LCP_STORED];
661  UintR maxGciInLcp;
668  UintR srLastGci[4];
669  UintR srStartGci[4];
673  UintR accFragptr;
688  BlockReference execSrBlockref[4];
695  typedef Bitmask<8> ScanNumberMask; // Max 255 KeyInfo20::ScanNo
696  ScanNumberMask m_scanNumberMask;
697  DLList<ScanRecord>::Head m_activeScans;
698  DLFifoList<ScanRecord>::Head m_queuedScans;
699  DLFifoList<ScanRecord>::Head m_queuedTupScans;
700 
701  Uint16 srLqhLognode[4];
705  UintR tupFragptr;
706  UintR tuxFragptr;
707 
714 
719  ExecSrStatus execSrStatus;
720 
724  UintR fragId;
725 
730 
736  enum ActiveCreat {
737  AC_NORMAL = 0, // fragStatus != ACTIVE_CREATION
738  AC_IGNORED = 1, // Operation that got ignored during NR
739  AC_NR_COPY = 2 // Operation that got performed during NR
740  };
741  Uint8 m_copy_started_state;
742 
749  LogFlag logFlag;
750  UintR masterPtr;
759  union {
760  Uint32 nextPool;
761  Uint32 nextList;
762  };
763  Uint32 prevList;
764 
768  UintR newestGci;
769  SrStatus srStatus;
770  UintR srUserptr;
774  UintR startGci;
778  UintR tabRef;
779 
785  UintR lastWaitQueue;
786 
792  BlockReference accBlockref;
793 
797  BlockReference tuxBlockref;
801  BlockReference masterBlockref;
808  BlockReference srBlockref;
814  BlockReference tupBlockref;
821  LcpFlag lcpFlag;
831  Uint16 copyNode;
855  Uint8 fragCopy;
864  Uint8 srChkpnr;
865  Uint8 srNoLognodes;
869  Uint8 tableType;
875 
880 
885  };
887 
888  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
889  /* $$$$$$$ GLOBAL CHECKPOINT RECORD $$$$$$ */
890  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
896  struct GcpRecord {
905  Uint16 gcpFilePtr[4];
909  Uint16 gcpPageNo[4];
914  Uint16 gcpWordNo[4];
918  UintR gcpId;
922  Uint8 gcpLogPartState[4];
927  Uint8 gcpSyncReady[4];
931  UintR gcpUserptr;
936  BlockReference gcpBlockref;
937  }; // Size 44 bytes
939 
940  struct HostRecord {
941  Uint8 inPackedList;
942  Uint8 nodestatus;
943  Uint8 _unused[2];
944  UintR noOfPackedWordsLqh;
945  UintR packedWordsLqh[30];
946  UintR noOfPackedWordsTc;
947  UintR packedWordsTc[29];
948  BlockReference hostLqhBlockRef;
949  BlockReference hostTcBlockRef;
950  };// Size 128 bytes
952 
953  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
954  /* $$$$$$ LOCAL CHECKPOINT SUPPORT RECORD $$$$$$$ */
955  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
961  struct LcpLocRecord {
962  enum LcpLocstate {
963  IDLE = 0,
964  WAIT_TUP_PREPLCP = 1,
965  WAIT_LCPHOLDOP = 2,
966  HOLDOP_READY = 3,
967  ACC_WAIT_STARTED = 4,
968  ACC_STARTED = 5,
969  ACC_COMPLETED = 6,
970  TUP_WAIT_STARTED = 7,
971  TUP_STARTED = 8,
972  TUP_COMPLETED = 9,
973  SR_ACC_STARTED = 10,
974  SR_TUP_STARTED = 11,
975  SR_ACC_COMPLETED = 12,
976  SR_TUP_COMPLETED = 13
977  };
978  LcpLocstate lcpLocstate;
979  Uint32 lcpRef;
980  }; // 28 bytes
982 
983  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
984  /* $$$$$$$ LOCAL CHECKPOINT RECORD $$$$$$$ */
985  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
991  struct LcpRecord {
992  LcpRecord() { m_EMPTY_LCP_REQ.clear(); }
993 
994  enum LcpState {
995  LCP_IDLE = 0,
996  LCP_COMPLETED = 2,
997  LCP_WAIT_FRAGID = 3,
998  LCP_WAIT_TUP_PREPLCP = 4,
999  LCP_WAIT_HOLDOPS = 5,
1000  LCP_START_CHKP = 7,
1001  LCP_BLOCKED_COMP = 8,
1002  LCP_SR_WAIT_FRAGID = 9,
1003  LCP_SR_STARTED = 10,
1004  LCP_SR_COMPLETED = 11
1005  };
1006 
1007  LcpState lcpState;
1008  bool firstFragmentFlag;
1009  bool lastFragmentFlag;
1010 
1011  struct FragOrd {
1012  Uint32 fragPtrI;
1013  LcpFragOrd lcpFragOrd;
1014  };
1015  FragOrd currentFragment;
1016 
1017  bool lcpQueued;
1018  FragOrd queuedFragment;
1019 
1020  bool reportEmpty;
1021  NdbNodeBitmask m_EMPTY_LCP_REQ;
1022 
1023  Uint32 m_error;
1024  Uint32 m_outstanding;
1025  }; // Size 76 bytes
1026  typedef Ptr<LcpRecord> LcpRecordPtr;
1027 
1028  struct IOTracker
1029  {
1030  STATIC_CONST( SAMPLE_TIME = 128 ); // millis
1031  STATIC_CONST( SLIDING_WINDOW_LEN = 1024 ); // millis
1032  STATIC_CONST( SLIDING_WINDOW_HISTORY_LEN = 8 );
1033 
1034  void init(Uint32 partNo);
1035  Uint32 m_log_part_no;
1036  Uint32 m_current_time;
1037 
1041  Uint32 m_save_pos; // current pos in array
1042  Uint32 m_save_written_bytes[SLIDING_WINDOW_HISTORY_LEN];
1043  Uint32 m_save_elapsed_millis[SLIDING_WINDOW_HISTORY_LEN];
1044 
1049  Uint32 m_curr_elapsed_millis;
1050 
1055 
1059  Uint32 m_lag_cnt;
1060 
1065 
1070 
1071  int tick(Uint32 now, Uint32 maxlag, Uint32 maxlag_cnt);
1072  void send_io(Uint32 bytes);
1073  void complete_io(Uint32 bytes);
1074  };
1075 
1076  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1077  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1078  /* */
1079  /* THE RECORDS THAT START BY LOG_ ARE A PART OF THE LOG MANAGER. */
1080  /* THESE RECORDS ARE USED TO HANDLE THE FRAGMENT LOG. */
1081  /* */
1082  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1083  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1084  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1085  /* $$$$$$$ LOG RECORD $$$$$$$ */
1086  /* */
1087  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1088  /* THIS RECORD IS ALIGNED TO BE 256 BYTES. */
1089  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1103  struct LogPartRecord {
1105  IDLE = 0,
1106  ACTIVE = 1,
1108 
1109 
1112  SR_THIRD_PHASE_COMPLETED = 5,
1114 
1115  SR_FOURTH_PHASE_COMPLETED = 7
1116  };
1117  enum WaitWriteGciLog {
1118  WWGL_TRUE = 0,
1119  WWGL_FALSE = 1
1120  };
1121  enum LogExecState {
1122  LES_IDLE = 0,
1123  LES_SEARCH_STOP = 1,
1124  LES_SEARCH_START = 2,
1125  LES_EXEC_LOG = 3,
1126  LES_EXEC_LOG_NEW_MBYTE = 4,
1127  LES_EXEC_LOG_NEW_FILE = 5,
1128  LES_EXEC_LOGREC_FROM_FILE = 6,
1129  LES_EXEC_LOG_COMPLETED = 7,
1130  LES_WAIT_READ_EXEC_SR_NEW_MBYTE = 8,
1131  LES_WAIT_READ_EXEC_SR = 9,
1132  LES_EXEC_LOG_INVALIDATE = 10
1133  };
1134 
1192  UintR gcprec;
1199 
1201  {
1202  void init() { firstElement = lastElement = RNIL;}
1203  bool isEmpty() const { return firstElement == RNIL; }
1204  Uint32 firstElement;
1205  Uint32 lastElement;
1206  };
1207 
1212 
1217 
1235  LogExecState logExecState;
1239  UintR logLap;
1244  UintR logLastGci;
1258 
1262  enum {
1263  P_TAIL_PROBLEM = 0x1,// 410
1264  P_REDO_IO_PROBLEM = 0x2,// 1234
1265  P_FILE_CHANGE_PROBLEM = 0x4 // 1220
1266  };
1267  Uint32 m_log_problems;
1268 
1279  UintR logTimer;
1300  UintR noLogFiles;
1332  WaitWriteGciLog waitWriteGciLog;
1360  Uint16 headFileNo;
1364  Uint16 headPageNo;
1374  Uint16 lastMbyte;
1394  Uint16 logTailMbyte;
1399  Uint16 startMbyte;
1404  Uint16 stopMbyte;
1418  Uint16 logPartNo;
1419 
1424  }; // Size 164 Bytes
1426 
1427  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1428  /* $$$$$$$ LOG FILE RECORD $$$$$$$ */
1429  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1430  /* THIS RECORD IS ALIGNED TO BE 288 (256 + 32) BYTES. */
1431  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1441  struct LogFileRecord {
1442  LogFileRecord() {}
1443 
1444  enum FileChangeState {
1445  NOT_ONGOING = 0,
1446  BOTH_WRITES_ONGOING = 1,
1447  LAST_WRITE_ONGOING = 2,
1448  FIRST_WRITE_ONGOING = 3,
1449  WRITE_PAGE_ZERO_ONGOING = 4
1450  };
1452  LFS_IDLE = 0,
1453  CLOSED = 1,
1454  OPENING_INIT = 2,
1456 
1457 
1459 
1461 
1462 
1464 
1465 
1466  OPEN_EXEC_SR_NEW_MBYTE = 7,
1467  OPEN_SR_FOURTH_PHASE = 8,
1468  OPEN_SR_FOURTH_NEXT = 9,
1469  OPEN_SR_FOURTH_ZERO = 10,
1471 
1472  OPEN_EXEC_LOG = 12,
1473  CLOSING_INIT = 13,
1474  CLOSING_SR = 14,
1475 
1476 
1477 
1479 
1480  CLOSING_EXEC_SR_COMPLETED = 16,
1482 
1483  CLOSING_EXEC_LOG = 18,
1484  OPEN_INIT = 19,
1485  OPEN = 20,
1486  OPEN_SR_READ_INVALIDATE_PAGES = 21,
1487  CLOSE_SR_READ_INVALIDATE_PAGES = 22,
1488  OPEN_SR_WRITE_INVALIDATE_PAGES = 23,
1489  CLOSE_SR_WRITE_INVALIDATE_PAGES = 24,
1490  OPEN_SR_READ_INVALIDATE_SEARCH_FILES = 25,
1491  CLOSE_SR_READ_INVALIDATE_SEARCH_FILES = 26,
1492  CLOSE_SR_READ_INVALIDATE_SEARCH_LAST_FILE = 27
1493 #ifndef NO_REDO_OPEN_FILE_CACHE
1494  ,OPEN_EXEC_LOG_CACHED = 28
1495  ,CLOSING_EXEC_LOG_CACHED = 29
1496 #endif
1497  };
1498 
1523  UintR fileName[4];
1540  FileChangeState fileChangeState;
1544  UintR fileNo;
1556  UintR fileRef;
1567  UintR firstLfo;
1568  UintR lastLfo;
1599  UintR logPartRec;
1625 
1626 #ifndef NO_REDO_OPEN_FILE_CACHE
1627  Uint32 nextList;
1628  Uint32 prevList;
1629 #endif
1630  }; // Size 288 bytes
1632 
1633  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1634  /* $$$$$$$ LOG OPERATION RECORD $$$$$$$ */
1635  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1641  enum LfoState {
1642  IDLE = 0,
1644 
1646  WRITE_GCI_ZERO = 3,
1647  WRITE_INIT_MBYTE = 4,
1648  WRITE_DIRTY = 5,
1650 
1652 
1654 
1655 
1656  READ_SR_LAST_MBYTE = 9,
1657  READ_EXEC_SR = 10,
1658  READ_EXEC_LOG = 11,
1659  READ_SR_FOURTH_PHASE = 12,
1660  READ_SR_FOURTH_ZERO = 13,
1661  FIRST_PAGE_WRITE_IN_LOGFILE = 14,
1662  LAST_WRITE_IN_FILE = 15,
1663  WRITE_PAGE_ZERO = 16,
1665 
1666  READ_SR_INVALIDATE_PAGES = 18,
1667  WRITE_SR_INVALIDATE_PAGES = 19,
1668  WRITE_SR_INVALIDATE_PAGES_UPDATE_PAGE0 = 20
1669  ,READ_SR_INVALIDATE_SEARCH_FILES = 21
1670  };
1676  UintR logPageArray[16];
1684  UintR lfoTimer;
1697  UintR logFileRec;
1701  UintR nextLfo;
1706  Uint16 lfoPageNo;
1711  Uint16 noPagesRw;
1712  }; // 92 bytes
1714 
1715  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1716  /* $$$$$$$ LOG PAGE RECORD $$$$$$$ */
1717  /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1727  struct LogPageRecord {
1898  UintR logPageWord[8192]; // Size 32 kbytes
1899  };
1901 
1902  struct PageRefRecord {
1903  UintR pageRef[8];
1904  UintR prNext;
1905  UintR prPrev;
1906  Uint16 prFileNo;
1907  Uint16 prPageNo;
1908  }; // size 44 bytes
1910 
1911  struct Tablerec {
1912  enum TableStatus {
1913  TABLE_DEFINED = 0,
1914  NOT_DEFINED = 1,
1915  ADD_TABLE_ONGOING = 2,
1916  PREP_DROP_TABLE_DONE = 3,
1917  DROP_TABLE_WAIT_USAGE = 4,
1918  DROP_TABLE_WAIT_DONE = 5,
1919  DROP_TABLE_ACC = 6,
1920  DROP_TABLE_TUP = 7,
1921  DROP_TABLE_TUX = 8
1922  ,TABLE_READ_ONLY = 9
1923  };
1924 
1925  UintR fragrec[MAX_FRAG_PER_NODE];
1926  Uint16 fragid[MAX_FRAG_PER_NODE];
1930  TableStatus tableStatus;
1934  Uint16 tableType;
1935  Uint16 primaryTableId;
1936  Uint32 schemaVersion;
1937  Uint8 m_disk_table;
1938 
1939  Uint32 usageCountR; // readers
1940  Uint32 usageCountW; // writers
1941  }; // Size 100 bytes
1942  typedef Ptr<Tablerec> TablerecPtr;
1943 
1945  enum ListState {
1946  NOT_IN_LIST = 0,
1947  WAIT_QUEUE_LIST = 3
1948  };
1949  enum LogWriteState {
1950  NOT_STARTED = 0,
1951  NOT_WRITTEN = 1,
1952  NOT_WRITTEN_WAIT = 2,
1953  WRITTEN = 3
1954  };
1955  enum AbortState {
1956  ABORT_IDLE = 0,
1957  ABORT_ACTIVE = 1,
1958  NEW_FROM_TC = 2,
1959  REQ_FROM_TC = 3,
1960  ABORT_FROM_TC = 4,
1961  ABORT_FROM_LQH = 5
1962  };
1963  enum TransactionState {
1964  IDLE = 0,
1965 
1966  /* -------------------------------------------------------------------- */
1967  // Transaction in progress states
1968  /* -------------------------------------------------------------------- */
1969  WAIT_ACC = 1,
1970  WAIT_TUPKEYINFO = 2,
1971  WAIT_ATTR = 3,
1972  WAIT_TUP = 4,
1973  STOPPED = 5,
1974  LOG_QUEUED = 6,
1975  PREPARED = 7,
1976  LOG_COMMIT_WRITTEN_WAIT_SIGNAL = 8,
1977  LOG_COMMIT_QUEUED_WAIT_SIGNAL = 9,
1978 
1979  /* -------------------------------------------------------------------- */
1980  // Commit in progress states
1981  /* -------------------------------------------------------------------- */
1982  COMMIT_STOPPED = 10,
1983  LOG_COMMIT_QUEUED = 11,
1984  COMMIT_QUEUED = 12,
1985  COMMITTED = 13,
1986  WAIT_TUP_COMMIT= 35,
1987 
1988  /* -------------------------------------------------------------------- */
1989  // Abort in progress states
1990  /* -------------------------------------------------------------------- */
1991  WAIT_ACC_ABORT = 14,
1992  ABORT_QUEUED = 15,
1993  ABORT_STOPPED = 16,
1994  WAIT_AI_AFTER_ABORT = 17,
1995  LOG_ABORT_QUEUED = 18,
1996  WAIT_TUP_TO_ABORT = 19,
1997 
1998  /* -------------------------------------------------------------------- */
1999  // Scan in progress states
2000  /* -------------------------------------------------------------------- */
2001  WAIT_SCAN_AI = 20,
2002  SCAN_STATE_USED = 21,
2003  SCAN_FIRST_STOPPED = 22,
2004  SCAN_CHECK_STOPPED = 23,
2005  SCAN_STOPPED = 24,
2006  SCAN_RELEASE_STOPPED = 25,
2007  SCAN_CLOSE_STOPPED = 26,
2008  COPY_CLOSE_STOPPED = 27,
2009  COPY_FIRST_STOPPED = 28,
2010  COPY_STOPPED = 29,
2011  SCAN_TUPKEY = 30,
2012  COPY_TUPKEY = 31,
2013 
2014  TC_NOT_CONNECTED = 32,
2015  PREPARED_RECEIVED_COMMIT = 33, // Temporary state in write commit log
2016  LOG_COMMIT_WRITTEN = 34 // Temporary state in write commit log
2017  };
2018  enum ConnectState {
2019  DISCONNECTED = 0,
2020  CONNECTED = 1,
2021  COPY_CONNECTED = 2,
2022  LOG_CONNECTED = 3
2023  };
2024  ConnectState connectState;
2025  UintR copyCountWords;
2026  Uint32 keyInfoIVal;
2027  Uint32 attrInfoIVal;
2028  UintR transid[2];
2029  AbortState abortState;
2030  UintR accConnectrec;
2031  UintR applOprec;
2032  UintR clientConnectrec;
2033  UintR tcTimer;
2034  UintR currReclenAi;
2035  UintR currTupAiLen;
2036  UintR fragmentid;
2037  UintR fragmentptr;
2038  UintR gci_hi;
2039  UintR gci_lo;
2040  UintR hashValue;
2046  ListState listState;
2047 
2048  UintR logStartFileNo;
2049  LogWriteState logWriteState;
2050  UintR nextHashRec;
2051  UintR nextLogTcrec;
2052  UintR nextTcLogQueue;
2053  UintR nextTc;
2054  UintR nextTcConnectrec;
2055  UintR prevHashRec;
2056  UintR prevLogTcrec;
2057  UintR prevTc;
2058  UintR readlenAi;
2059  UintR reqRef;
2060  UintR reqinfo;
2061  UintR schemaVersion;
2062  UintR storedProcId;
2063  UintR simpleTcConnect;
2064  UintR tableref;
2065  UintR tcOprec;
2066  Uint32 tcHashKeyHi;
2067  UintR tcScanInfo;
2068  UintR tcScanRec;
2069  UintR totReclenAi;
2070  UintR totSendlenAi;
2071  UintR tupConnectrec;
2072  UintR savePointId;
2073  TransactionState transactionState;
2074  BlockReference applRef;
2075  BlockReference clientBlockref;
2076 
2077  BlockReference reqBlockref;
2078  BlockReference tcBlockref;
2079  BlockReference tcAccBlockref;
2080  BlockReference tcTuxBlockref;
2081  BlockReference tcTupBlockref;
2082  Uint32 commitAckMarker;
2083  union {
2084  Uint32 m_scan_curr_range_no;
2085  UintR noFiredTriggers;
2086  };
2087  Uint32 m_corrFactorLo; // For result correlation for linked operations.
2088  Uint32 m_corrFactorHi;
2089  Uint64 lqhKeyReqId;
2090  Uint16 errorCode;
2091  Uint16 logStartPageIndex;
2092  Uint16 logStartPageNo;
2093  Uint16 logStopPageNo;
2094  Uint16 nextReplica;
2095  Uint16 primKeyLen;
2096  Uint16 save1;
2097  Uint16 nodeAfterNext[3];
2098 
2099  Uint8 activeCreat;
2100  Uint8 apiVersionNo;
2101  Uint8 dirtyOp;
2102  Uint8 indTakeOver;
2103  Uint8 lastReplicaNo;
2104  Uint8 lockType;
2105  Uint8 nextSeqNoReplica;
2106  Uint8 opSimple;
2107  Uint8 opExec;
2108  Uint8 operation;
2109  Uint8 m_reorg;
2110  Uint8 reclenAiLqhkey;
2111  Uint8 replicaType;
2112  Uint8 seqNoReplica;
2113  Uint8 tcNodeFailrec;
2114  Uint8 m_disk_table;
2115  Uint8 m_use_rowid;
2116  Uint8 m_dealloc;
2117  Uint8 m_fire_trig_pass;
2118  enum op_flags {
2119  OP_ISLONGREQ = 0x1,
2120  OP_SAVEATTRINFO = 0x2,
2121  OP_SCANKEYINFOPOSSAVED = 0x4,
2122  OP_DEFERRED_CONSTRAINTS = 0x8
2123  };
2124  Uint32 m_flags;
2125  Uint32 m_log_part_ptr_i;
2126  SectionReader::PosInfo scanKeyInfoPos;
2127  Local_key m_row_id;
2128 
2129  struct {
2130  Uint32 m_cnt;
2131  Uint32 m_page_id[2];
2132  Local_key m_disk_ref[2];
2133  } m_nr_delete;
2134  }; /* p2c: size = 280 bytes */
2135 
2136  typedef Ptr<TcConnectionrec> TcConnectionrecPtr;
2137 
2139  enum TcFailStatus {
2140  TC_STATE_TRUE = 0,
2141  TC_STATE_FALSE = 1,
2142  TC_STATE_BREAK = 2
2143  };
2144  UintR lastNewTcRef;
2145  UintR newTcRef;
2146  TcFailStatus tcFailStatus;
2147  UintR tcRecNow;
2148  BlockReference lastNewTcBlockref;
2149  BlockReference newTcBlockref;
2150  Uint16 oldNodeId;
2151  }; // Size 28 bytes
2153 
2155  Uint32 startPageNo;
2156  Uint32 startPageIndex;
2157  Uint32 stopPageNo;
2158  Uint32 fileNo;
2159  };
2160  //for statistic information about redo log initialization
2161  Uint32 totalLogFiles;
2162  Uint32 logFileInitDone;
2163  Uint32 totallogMBytes;
2164  Uint32 logMBytesInitDone;
2165 
2166  Uint32 m_startup_report_frequency;
2167  NDB_TICKS m_next_report_time;
2168 
2169 public:
2170  Dblqh(Block_context& ctx, Uint32 instanceNumber = 0);
2171  virtual ~Dblqh();
2172 
2173  void receive_keyinfo(Signal*, Uint32 * data, Uint32 len);
2174  void receive_attrinfo(Signal*, Uint32 * data, Uint32 len);
2175 
2176 private:
2177  BLOCK_DEFINES(Dblqh);
2178 
2179  void execPACKED_SIGNAL(Signal* signal);
2180  void execDEBUG_SIG(Signal* signal);
2181  void execATTRINFO(Signal* signal);
2182  void execKEYINFO(Signal* signal);
2183  void execLQHKEYREQ(Signal* signal);
2184  void execLQHKEYREF(Signal* signal);
2185  void execCOMMIT(Signal* signal);
2186  void execCOMPLETE(Signal* signal);
2187  void execLQHKEYCONF(Signal* signal);
2188  void execTESTSIG(Signal* signal);
2189  void execLQH_RESTART_OP(Signal* signal);
2190  void execCONTINUEB(Signal* signal);
2191  void execSTART_RECREQ(Signal* signal);
2192  void execSTART_RECCONF(Signal* signal);
2193  void execEXEC_FRAGREQ(Signal* signal);
2194  void execEXEC_FRAGCONF(Signal* signal);
2195  void execEXEC_FRAGREF(Signal* signal);
2196  void execSTART_EXEC_SR(Signal* signal);
2197  void execEXEC_SRREQ(Signal* signal);
2198  void execEXEC_SRCONF(Signal* signal);
2199  void execREAD_PSEUDO_REQ(Signal* signal);
2200  void execSIGNAL_DROPPED_REP(Signal* signal);
2201 
2202  void execDBINFO_SCANREQ(Signal* signal);
2203  void execDUMP_STATE_ORD(Signal* signal);
2204  void execACC_ABORTCONF(Signal* signal);
2205  void execNODE_FAILREP(Signal* signal);
2206  void execCHECK_LCP_STOP(Signal* signal);
2207  void execSEND_PACKED(Signal* signal);
2208  void execTUP_ATTRINFO(Signal* signal);
2209  void execREAD_CONFIG_REQ(Signal* signal);
2210 
2211  void execCREATE_TAB_REQ(Signal* signal);
2212  void execCREATE_TAB_REF(Signal* signal);
2213  void execCREATE_TAB_CONF(Signal* signal);
2214  void execLQHADDATTREQ(Signal* signal);
2215  void execTUP_ADD_ATTCONF(Signal* signal);
2216  void execTUP_ADD_ATTRREF(Signal* signal);
2217 
2218  void execLQHFRAGREQ(Signal* signal);
2219  void execACCFRAGCONF(Signal* signal);
2220  void execACCFRAGREF(Signal* signal);
2221  void execTUPFRAGCONF(Signal* signal);
2222  void execTUPFRAGREF(Signal* signal);
2223 
2224  void execDROP_FRAG_REQ(Signal*);
2225  void execDROP_FRAG_REF(Signal*);
2226  void execDROP_FRAG_CONF(Signal*);
2227 
2228  void execTAB_COMMITREQ(Signal* signal);
2229  void execACCSEIZECONF(Signal* signal);
2230  void execACCSEIZEREF(Signal* signal);
2231  void execREAD_NODESCONF(Signal* signal);
2232  void execREAD_NODESREF(Signal* signal);
2233  void execSTTOR(Signal* signal);
2234  void execNDB_STTOR(Signal* signal);
2235  void execTUPSEIZECONF(Signal* signal);
2236  void execTUPSEIZEREF(Signal* signal);
2237  void execACCKEYCONF(Signal* signal);
2238  void execACCKEYREF(Signal* signal);
2239  void execTUPKEYCONF(Signal* signal);
2240  void execTUPKEYREF(Signal* signal);
2241  void execABORT(Signal* signal);
2242  void execABORTREQ(Signal* signal);
2243  void execCOMMITREQ(Signal* signal);
2244  void execCOMPLETEREQ(Signal* signal);
2245  void execMEMCHECKREQ(Signal* signal);
2246  void execSCAN_FRAGREQ(Signal* signal);
2247  void execSCAN_NEXTREQ(Signal* signal);
2248  void execACC_SCANCONF(Signal* signal);
2249  void execACC_SCANREF(Signal* signal);
2250  void execNEXT_SCANCONF(Signal* signal);
2251  void execNEXT_SCANREF(Signal* signal);
2252  void execACC_TO_REF(Signal* signal);
2253  void execSTORED_PROCCONF(Signal* signal);
2254  void execSTORED_PROCREF(Signal* signal);
2255  void execCOPY_FRAGREQ(Signal* signal);
2256  void execCOPY_FRAGREF(Signal* signal);
2257  void execCOPY_FRAGCONF(Signal* signal);
2258  void execPREPARE_COPY_FRAG_REQ(Signal* signal);
2259  void execUPDATE_FRAG_DIST_KEY_ORD(Signal*);
2260  void execCOPY_ACTIVEREQ(Signal* signal);
2261  void execCOPY_STATEREQ(Signal* signal);
2262  void execLQH_TRANSREQ(Signal* signal);
2263  void execTRANSID_AI(Signal* signal);
2264  void execINCL_NODEREQ(Signal* signal);
2265 
2266  void force_lcp(Signal* signal);
2267  void execLCP_FRAG_ORD(Signal* signal);
2268  void execEMPTY_LCP_REQ(Signal* signal);
2269 
2270  void execSTART_FRAGREQ(Signal* signal);
2271  void execSTART_RECREF(Signal* signal);
2272 
2273  void execGCP_SAVEREQ(Signal* signal);
2274  void execSUB_GCP_COMPLETE_REP(Signal* signal);
2275  void execFSOPENREF(Signal* signal);
2276  void execFSOPENCONF(Signal* signal);
2277  void execFSCLOSECONF(Signal* signal);
2278  void execFSWRITECONF(Signal* signal);
2279  void execFSWRITEREF(Signal* signal);
2280  void execFSREADCONF(Signal* signal);
2281  void execFSREADREF(Signal* signal);
2282  void execFSWRITEREQ(Signal*);
2283  void execTIME_SIGNAL(Signal* signal);
2284  void execFSSYNCCONF(Signal* signal);
2285 
2286  void execALTER_TAB_REQ(Signal* signal);
2287  void execALTER_TAB_CONF(Signal* signal);
2288 
2289  void execCREATE_TRIG_IMPL_CONF(Signal* signal);
2290  void execCREATE_TRIG_IMPL_REF(Signal* signal);
2291  void execCREATE_TRIG_IMPL_REQ(Signal* signal);
2292 
2293  void execDROP_TRIG_IMPL_CONF(Signal* signal);
2294  void execDROP_TRIG_IMPL_REF(Signal* signal);
2295  void execDROP_TRIG_IMPL_REQ(Signal* signal);
2296 
2297  void execPREP_DROP_TAB_REQ(Signal* signal);
2298  void execDROP_TAB_REQ(Signal* signal);
2299  void execDROP_TAB_REF(Signal*);
2300  void execDROP_TAB_CONF(Signal*);
2301  void dropTable_nextStep(Signal*, AddFragRecordPtr);
2302 
2303  void execLQH_ALLOCREQ(Signal* signal);
2304  void execTUP_DEALLOCREQ(Signal* signal);
2305  void execLQH_WRITELOG_REQ(Signal* signal);
2306 
2307  void execTUXFRAGCONF(Signal* signal);
2308  void execTUXFRAGREF(Signal* signal);
2309  void execTUX_ADD_ATTRCONF(Signal* signal);
2310  void execTUX_ADD_ATTRREF(Signal* signal);
2311 
2312  void execBUILD_INDX_IMPL_REF(Signal* signal);
2313  void execBUILD_INDX_IMPL_CONF(Signal* signal);
2314 
2315  void execFIRE_TRIG_REQ(Signal*);
2316 
2317  // Statement blocks
2318 
2319  void init_acc_ptr_list(ScanRecord*);
2320  bool seize_acc_ptr_list(ScanRecord*, Uint32, Uint32);
2321  void release_acc_ptr_list(ScanRecord*);
2322  Uint32 get_acc_ptr_from_scan_record(ScanRecord*, Uint32, bool);
2323  void set_acc_ptr_in_scan_record(ScanRecord*, Uint32, Uint32);
2324  void i_get_acc_ptr(ScanRecord*, Uint32*&, Uint32);
2325 
2326  void removeTable(Uint32 tableId);
2327  void sendLCP_COMPLETE_REP(Signal* signal, Uint32 lcpId);
2328  void sendEMPTY_LCP_CONF(Signal* signal, bool idle);
2329  void sendLCP_FRAGIDREQ(Signal* signal);
2330  void sendLCP_FRAG_REP(Signal * signal, const LcpRecord::FragOrd &,
2331  const Fragrecord*) const;
2332 
2333  void updatePackedList(Signal* signal, HostRecord * ahostptr, Uint16 hostId);
2334  void LQHKEY_abort(Signal* signal, int errortype);
2335  void LQHKEY_error(Signal* signal, int errortype);
2336  void nextRecordCopy(Signal* signal);
2337  Uint32 calculateHash(Uint32 tableId, const Uint32* src);
2338  void continueAfterCheckLcpStopBlocked(Signal* signal);
2339  void checkLcpStopBlockedLab(Signal* signal);
2340  void sendCommittedTc(Signal* signal, BlockReference atcBlockref);
2341  void sendCompletedTc(Signal* signal, BlockReference atcBlockref);
2342  void sendLqhkeyconfTc(Signal* signal, BlockReference atcBlockref);
2343  void sendCommitLqh(Signal* signal, BlockReference alqhBlockref);
2344  void sendCompleteLqh(Signal* signal, BlockReference alqhBlockref);
2345  void sendPackedSignalLqh(Signal* signal, HostRecord * ahostptr);
2346  void sendPackedSignalTc(Signal* signal, HostRecord * ahostptr);
2347  void cleanUp(Signal* signal);
2348  void sendAttrinfoLoop(Signal* signal);
2349  void sendAttrinfoSignal(Signal* signal);
2350  void sendLqhAttrinfoSignal(Signal* signal);
2351  void sendKeyinfoAcc(Signal* signal, Uint32 pos);
2352  Uint32 initScanrec(const class ScanFragReq *,
2353  Uint32 aiLen);
2354  void initScanTc(const class ScanFragReq *,
2355  Uint32 transid1,
2356  Uint32 transid2,
2357  Uint32 fragId,
2358  Uint32 nodeId,
2359  Uint32 hashHi);
2360  void finishScanrec(Signal* signal);
2361  void releaseScanrec(Signal* signal);
2362  void seizeScanrec(Signal* signal);
2363  Uint32 sendKeyinfo20(Signal* signal, ScanRecord *, TcConnectionrec *);
2364  void sendTCKEYREF(Signal*, Uint32 dst, Uint32 route, Uint32 cnt);
2365  void sendScanFragConf(Signal* signal, Uint32 scanCompleted);
2366  void initCopyrec(Signal* signal);
2367  void initCopyTc(Signal* signal, Operation_t);
2368  void sendCopyActiveConf(Signal* signal,Uint32 tableId);
2369  void checkLcpCompleted(Signal* signal);
2370  void checkLcpHoldop(Signal* signal);
2371  bool checkLcpStarted(Signal* signal);
2372  void checkLcpTupprep(Signal* signal);
2373  void getNextFragForLcp(Signal* signal);
2374  void sendAccContOp(Signal* signal);
2375  void sendStartLcp(Signal* signal);
2376  void setLogTail(Signal* signal, Uint32 keepGci);
2377  Uint32 remainingLogSize(const LogFileRecordPtr &sltCurrLogFilePtr,
2378  const LogPartRecordPtr &sltLogPartPtr);
2379  bool checkGcpCompleted(Signal* signal, Uint32 pageWritten, Uint32 wordWritten);
2380  void initFsopenconf(Signal* signal);
2381  void initFsrwconf(Signal* signal, bool write);
2382  void initLfo(Signal* signal);
2383  void initLogfile(Signal* signal, Uint32 fileNo);
2384  void initLogpage(Signal* signal);
2385  void openFileRw(Signal* signal, LogFileRecordPtr olfLogFilePtr, bool writeBuffer = true);
2386  void openLogfileInit(Signal* signal);
2387  void openNextLogfile(Signal* signal);
2388  void releaseLfo(Signal* signal);
2389  void releaseLfoPages(Signal* signal);
2390  void releaseLogpage(Signal* signal);
2391  void seizeLfo(Signal* signal);
2392  void seizeLogfile(Signal* signal);
2393  void seizeLogpage(Signal* signal);
2394  void writeFileDescriptor(Signal* signal);
2395  void writeFileHeaderOpen(Signal* signal, Uint32 type);
2396  void writeInitMbyte(Signal* signal);
2397  void writeSinglePage(Signal* signal, Uint32 pageNo,
2398  Uint32 wordWritten, Uint32 place,
2399  bool sync = true);
2400  void buildLinkedLogPageList(Signal* signal);
2401  void changeMbyte(Signal* signal);
2402  Uint32 checkIfExecLog(Signal* signal);
2403  void checkNewMbyte(Signal* signal);
2404  void checkReadExecSr(Signal* signal);
2405  void checkScanTcCompleted(Signal* signal);
2406  void closeFile(Signal* signal, LogFileRecordPtr logFilePtr, Uint32 place);
2407  void completedLogPage(Signal* signal, Uint32 clpType, Uint32 place);
2408 
2409  void commit_reorg(TablerecPtr tablePtr);
2410  void wait_reorg_suma_filter_enabled(Signal*);
2411 
2412  void deleteFragrec(Uint32 fragId);
2413  void deleteTransidHash(Signal* signal);
2414  void findLogfile(Signal* signal,
2415  Uint32 fileNo,
2416  LogPartRecordPtr flfLogPartPtr,
2417  LogFileRecordPtr* parLogFilePtr);
2418  void findPageRef(Signal* signal, CommitLogRecord* commitLogRecord);
2419  int findTransaction(UintR Transid1, UintR Transid2, UintR TcOprec, UintR hi);
2420  void getFirstInLogQueue(Signal* signal, Ptr<TcConnectionrec>&dst);
2421  bool getFragmentrec(Signal* signal, Uint32 fragId);
2422  void initialiseAddfragrec(Signal* signal);
2423  void initialiseFragrec(Signal* signal);
2424  void initialiseGcprec(Signal* signal);
2425  void initialiseLcpRec(Signal* signal);
2426  void initialiseLfo(Signal* signal);
2427  void initialiseLogFile(Signal* signal);
2428  void initialiseLogPage(Signal* signal);
2429  void initialiseLogPart(Signal* signal);
2430  void initialisePageRef(Signal* signal);
2431  void initialiseScanrec(Signal* signal);
2432  void initialiseTabrec(Signal* signal);
2433  void initialiseTcrec(Signal* signal);
2434  void initialiseTcNodeFailRec(Signal* signal);
2435  void initFragrec(Signal* signal,
2436  Uint32 tableId,
2437  Uint32 fragId,
2438  Uint32 copyType);
2439  void initFragrecSr(Signal* signal);
2440  void initGciInLogFileRec(Signal* signal, Uint32 noFdDesc);
2441  void initLcpSr(Signal* signal,
2442  Uint32 lcpNo,
2443  Uint32 lcpId,
2444  Uint32 tableId,
2445  Uint32 fragId,
2446  Uint32 fragPtr);
2447  void initLogpart(Signal* signal);
2448  void initLogPointers(Signal* signal);
2449  void initReqinfoExecSr(Signal* signal);
2450  bool insertFragrec(Signal* signal, Uint32 fragId);
2451  void linkFragQueue(Signal* signal);
2452  void linkWaitLog(Signal*, LogPartRecordPtr, LogPartRecord::OperationQueue &);
2453  void logNextStart(Signal* signal);
2454  void moveToPageRef(Signal* signal);
2455  void readAttrinfo(Signal* signal);
2456  void readCommitLog(Signal* signal, CommitLogRecord* commitLogRecord);
2457  void readExecLog(Signal* signal);
2458  void readExecSrNewMbyte(Signal* signal);
2459  void readExecSr(Signal* signal);
2460  void readKey(Signal* signal);
2461  void readLogData(Signal* signal, Uint32 noOfWords, Uint32& sectionIVal);
2462  void readLogHeader(Signal* signal);
2463  Uint32 readLogword(Signal* signal);
2464  Uint32 readLogwordExec(Signal* signal);
2465  void readSinglePage(Signal* signal, Uint32 pageNo);
2466  void releaseActiveCopy(Signal* signal);
2467  void releaseAddfragrec(Signal* signal);
2468  void releaseFragrec();
2469  void releaseOprec(Signal* signal);
2470  void releasePageRef(Signal* signal);
2471  void releaseMmPages(Signal* signal);
2472  void releasePrPages(Signal* signal);
2473  void releaseTcrec(Signal* signal, TcConnectionrecPtr tcConnectptr);
2474  void releaseTcrecLog(Signal* signal, TcConnectionrecPtr tcConnectptr);
2475  void releaseWaitQueue(Signal* signal);
2476  void removeLogTcrec(Signal* signal);
2477  void removePageRef(Signal* signal);
2478  Uint32 returnExecLog(Signal* signal);
2479  int saveAttrInfoInSection(const Uint32* dataPtr, Uint32 len);
2480  void seizeAddfragrec(Signal* signal);
2481  Uint32 seizeSegment();
2482  Uint32 copyNextRange(Uint32 * dst, TcConnectionrec*);
2483 
2484  void seizeFragmentrec(Signal* signal);
2485  void seizePageRef(Signal* signal);
2486  void seizeTcrec();
2487  void sendAborted(Signal* signal);
2488  void sendLqhTransconf(Signal* signal, LqhTransConf::OperationStatus);
2489  void sendTupkey(Signal* signal);
2490  void startExecSr(Signal* signal);
2491  void startNextExecSr(Signal* signal);
2492  void startTimeSupervision(Signal* signal);
2493  void stepAhead(Signal* signal, Uint32 stepAheadWords);
2494  void systemError(Signal* signal, int line);
2495  void writeAbortLog(Signal* signal);
2496  void writeCommitLog(Signal* signal, LogPartRecordPtr regLogPartPtr);
2497  void writeCompletedGciLog(Signal* signal);
2498  void writeDbgInfoPageHeader(LogPageRecordPtr logPagePtr, Uint32 place,
2499  Uint32 pageNo, Uint32 wordWritten);
2500  void writeDirty(Signal* signal, Uint32 place);
2501  void writeKey(Signal* signal);
2502  void writeLogHeader(Signal* signal);
2503  void writeLogWord(Signal* signal, Uint32 data);
2504  void writeLogWords(Signal* signal, const Uint32* data, Uint32 len);
2505  void writeNextLog(Signal* signal);
2506  void errorReport(Signal* signal, int place);
2507  void warningReport(Signal* signal, int place);
2508  void invalidateLogAfterLastGCI(Signal *signal);
2509  Uint32 nextLogFilePtr(Uint32 logFilePtrI);
2510  void readFileInInvalidate(Signal *signal, int stepNext);
2511  void writeFileInInvalidate(Signal *signal, int stepPrev);
2512  bool invalidateCloseFile(Signal*, Ptr<LogPartRecord>, Ptr<LogFileRecord>,
2514  void exitFromInvalidate(Signal* signal);
2515  Uint32 calcPageCheckSum(LogPageRecordPtr logP);
2516  Uint32 handleLongTupKey(Signal* signal, Uint32* dataPtr, Uint32 len);
2517 
2518  void rebuildOrderedIndexes(Signal* signal, Uint32 tableId);
2519 
2520  // Generated statement blocks
2521  void systemErrorLab(Signal* signal, int line);
2522  void initFourth(Signal* signal);
2523  void packLqhkeyreqLab(Signal* signal);
2524  void sendNdbSttorryLab(Signal* signal);
2525  void execSrCompletedLab(Signal* signal);
2526  void execLogRecord(Signal* signal);
2527  void srPhase3Comp(Signal* signal);
2528  void srLogLimits(Signal* signal);
2529  void srGciLimits(Signal* signal);
2530  void srPhase3Start(Signal* signal);
2531  void checkStartCompletedLab(Signal* signal);
2532  void continueAbortLab(Signal* signal);
2533  void abortContinueAfterBlockedLab(Signal* signal);
2534  void abortCommonLab(Signal* signal);
2535  void localCommitLab(Signal* signal);
2536  void abortErrorLab(Signal* signal);
2537  void continueAfterReceivingAllAiLab(Signal* signal);
2538  void abortStateHandlerLab(Signal* signal);
2539  void writeAttrinfoLab(Signal* signal);
2540  void scanAttrinfoLab(Signal* signal, Uint32* dataPtr, Uint32 length);
2541  void abort_scan(Signal* signal, Uint32 scan_ptr_i, Uint32 errcode);
2542  void localAbortStateHandlerLab(Signal* signal);
2543  void logLqhkeyreqLab(Signal* signal);
2544  void logLqhkeyreqLab_problems(Signal* signal);
2545  void update_log_problem(Signal*, LogPartRecordPtr, Uint32 problem, bool);
2546  void lqhAttrinfoLab(Signal* signal, Uint32* dataPtr, Uint32 length);
2547  void rwConcludedAiLab(Signal* signal);
2548  void aiStateErrorCheckLab(Signal* signal, Uint32* dataPtr, Uint32 length);
2549  void takeOverErrorLab(Signal* signal);
2550  void endgettupkeyLab(Signal* signal);
2551  bool checkTransporterOverloaded(Signal* signal,
2552  const NodeBitmask& all,
2553  const class LqhKeyReq* req);
2554  void noFreeRecordLab(Signal* signal,
2555  const class LqhKeyReq * lqhKeyReq,
2556  Uint32 errorCode);
2557  void logLqhkeyrefLab(Signal* signal);
2558  void closeCopyLab(Signal* signal);
2559  void commitReplyLab(Signal* signal);
2560  void completeUnusualLab(Signal* signal);
2561  void completeTransNotLastLab(Signal* signal);
2562  void completedLab(Signal* signal);
2563  void copyCompletedLab(Signal* signal);
2564  void completeLcpRoundLab(Signal* signal, Uint32 lcpId);
2565  void continueAfterLogAbortWriteLab(Signal* signal);
2566  void sendAttrinfoLab(Signal* signal);
2567  void sendExecConf(Signal* signal);
2568  void execSr(Signal* signal);
2569  void srFourthComp(Signal* signal);
2570  void timeSup(Signal* signal);
2571  void closeCopyRequestLab(Signal* signal);
2572  void closeScanRequestLab(Signal* signal);
2573  void scanTcConnectLab(Signal* signal, Uint32 startTcCon, Uint32 fragId);
2574  void initGcpRecLab(Signal* signal);
2575  void prepareContinueAfterBlockedLab(Signal* signal);
2576  void commitContinueAfterBlockedLab(Signal* signal);
2577  void continueCopyAfterBlockedLab(Signal* signal);
2578  void continueFirstCopyAfterBlockedLab(Signal* signal);
2579  void continueFirstScanAfterBlockedLab(Signal* signal);
2580  void continueScanAfterBlockedLab(Signal* signal);
2581  void continueScanReleaseAfterBlockedLab(Signal* signal);
2582  void continueCloseScanAfterBlockedLab(Signal* signal);
2583  void continueCloseCopyAfterBlockedLab(Signal* signal);
2584  void sendExecFragRefLab(Signal* signal);
2585  void fragrefLab(Signal* signal, Uint32 errorCode, const LqhFragReq* req);
2586  void abortAddFragOps(Signal* signal);
2587  void rwConcludedLab(Signal* signal);
2588  void sendsttorryLab(Signal* signal);
2589  void initialiseRecordsLab(Signal* signal, Uint32 data, Uint32, Uint32);
2590  void startphase2Lab(Signal* signal, Uint32 config);
2591  void startphase3Lab(Signal* signal);
2592  void startphase4Lab(Signal* signal);
2593  void startphase6Lab(Signal* signal);
2594  void moreconnectionsLab(Signal* signal);
2595  void scanReleaseLocksLab(Signal* signal);
2596  void closeScanLab(Signal* signal);
2597  void nextScanConfLoopLab(Signal* signal);
2598  void scanNextLoopLab(Signal* signal);
2599  void commitReqLab(Signal* signal, Uint32 gci_hi, Uint32 gci_lo);
2600  void completeTransLastLab(Signal* signal);
2601  void tupScanCloseConfLab(Signal* signal);
2602  void tupCopyCloseConfLab(Signal* signal);
2603  void accScanCloseConfLab(Signal* signal);
2604  void accCopyCloseConfLab(Signal* signal);
2605  void nextScanConfScanLab(Signal* signal);
2606  void nextScanConfCopyLab(Signal* signal);
2607  void continueScanNextReqLab(Signal* signal);
2608  bool keyinfoLab(const Uint32 * src, Uint32 len);
2609  void copySendTupkeyReqLab(Signal* signal);
2610  void storedProcConfScanLab(Signal* signal);
2611  void storedProcConfCopyLab(Signal* signal);
2612  void copyStateFinishedLab(Signal* signal);
2613  void lcpCompletedLab(Signal* signal);
2614  void lcpStartedLab(Signal* signal);
2615  void contChkpNextFragLab(Signal* signal);
2616  void startLcpRoundLab(Signal* signal);
2617  void startFragRefLab(Signal* signal);
2618  void srCompletedLab(Signal* signal);
2619  void openFileInitLab(Signal* signal);
2620  void openSrFrontpageLab(Signal* signal);
2621  void openSrLastFileLab(Signal* signal);
2622  void openSrNextFileLab(Signal* signal);
2623  void openExecSrStartLab(Signal* signal);
2624  void openExecSrNewMbyteLab(Signal* signal);
2625  void openSrFourthPhaseLab(Signal* signal);
2626  void openSrFourthZeroSkipInitLab(Signal* signal);
2627  void openSrFourthZeroLab(Signal* signal);
2628  void openExecLogLab(Signal* signal);
2629  void checkInitCompletedLab(Signal* signal);
2630  void closingSrLab(Signal* signal);
2631  void closeExecSrLab(Signal* signal);
2632  void execLogComp(Signal* signal);
2633  void execLogComp_extra_files_closed(Signal* signal);
2634  void closeWriteLogLab(Signal* signal);
2635  void closeExecLogLab(Signal* signal);
2636  void writePageZeroLab(Signal* signal, Uint32 from);
2637  void lastWriteInFileLab(Signal* signal);
2638  void initWriteEndLab(Signal* signal);
2639  void initFirstPageLab(Signal* signal);
2640  void writeGciZeroLab(Signal* signal);
2641  void writeDirtyLab(Signal* signal);
2642  void writeInitMbyteLab(Signal* signal);
2643  void writeLogfileLab(Signal* signal);
2644  void firstPageWriteLab(Signal* signal);
2645  void readSrLastMbyteLab(Signal* signal);
2646  void readSrLastFileLab(Signal* signal);
2647  void readSrNextFileLab(Signal* signal);
2648  void readExecSrLab(Signal* signal);
2649  void readExecLogLab(Signal* signal);
2650  void readSrFourthPhaseLab(Signal* signal);
2651  void readSrFourthZeroLab(Signal* signal);
2652  void copyLqhKeyRefLab(Signal* signal);
2653  void restartOperationsLab(Signal* signal);
2654  void lqhTransNextLab(Signal* signal);
2655  void restartOperationsAfterStopLab(Signal* signal);
2656  void startphase1Lab(Signal* signal, Uint32 config, Uint32 nodeId);
2657  void tupkeyConfLab(Signal* signal);
2658  void copyTupkeyRefLab(Signal* signal);
2659  void copyTupkeyConfLab(Signal* signal);
2660  void scanTupkeyConfLab(Signal* signal);
2661  void scanTupkeyRefLab(Signal* signal);
2662  void accScanConfScanLab(Signal* signal);
2663  void accScanConfCopyLab(Signal* signal);
2664  void scanLockReleasedLab(Signal* signal);
2665  void openSrFourthNextLab(Signal* signal);
2666  void closingInitLab(Signal* signal);
2667  void closeExecSrCompletedLab(Signal* signal);
2668  void readSrFrontpageLab(Signal* signal);
2669 
2670  void sendCreateTabReq(Signal*, AddFragRecordPtr);
2671  void sendAddAttrReq(Signal* signal);
2672  void sendAddFragReq(Signal* signal);
2673  void dropTab_wait_usage(Signal*);
2674  Uint32 get_table_state_error(Ptr<Tablerec> tabPtr) const;
2675  void wait_readonly(Signal*);
2676  int check_tabstate(Signal * signal, const Tablerec * tablePtrP, Uint32 op);
2677 
2678  void remove_commit_marker(TcConnectionrec * const regTcPtr);
2679  // Initialisation
2680  void initData();
2681  void initRecords();
2682 protected:
2683  virtual bool getParam(const char* name, Uint32* count);
2684 
2685 private:
2686 
2687 
2688  bool validate_filter(Signal*);
2689  bool match_and_print(Signal*, Ptr<TcConnectionrec>);
2690 
2691  void define_backup(Signal*);
2692  void execDEFINE_BACKUP_REF(Signal*);
2693  void execDEFINE_BACKUP_CONF(Signal*);
2694  void execBACKUP_FRAGMENT_REF(Signal* signal);
2695  void execBACKUP_FRAGMENT_CONF(Signal* signal);
2696  void execLCP_PREPARE_REF(Signal* signal);
2697  void execLCP_PREPARE_CONF(Signal* signal);
2698  void execEND_LCPREF(Signal* signal);
2699  void execEND_LCPCONF(Signal* signal);
2700  Uint32 m_backup_ptr;
2701 
2702  void send_restore_lcp(Signal * signal);
2703  void execRESTORE_LCP_REF(Signal* signal);
2704  void execRESTORE_LCP_CONF(Signal* signal);
2705 
2710  /* Init at start of redo log file initialization, timers etc... */
2711  void initReportStatus(Signal* signal);
2712  /* Check timers for reporting at certain points */
2713  void checkReportStatus(Signal* signal);
2714  /* Send redo log file initialization status, invoked either periodically, or explicitly */
2715  void reportStatus(Signal* signal);
2716  /* redo log file initialization completed report*/
2717  void logfileInitCompleteReport(Signal* signal);
2718 
2719  void check_send_scan_hb_rep(Signal* signal, ScanRecord*, TcConnectionrec*);
2720 
2721  void unlockError(Signal* signal, Uint32 error);
2722  void handleUserUnlockRequest(Signal* signal);
2723 
2724  Dbtup* c_tup;
2725  Dbacc* c_acc;
2726  Lgman* c_lgman;
2727 
2731  Uint32 readPrimaryKeys(ScanRecord*, TcConnectionrec*, Uint32 * dst);
2732 
2736 public:
2737  Uint32 readPrimaryKeys(Uint32 opPtrI, Uint32 * dst, bool xfrm);
2738 private:
2739 
2740  void acckeyconf_tupkeyreq(Signal*, TcConnectionrec*, Fragrecord*,
2741  Uint32, Uint32, Uint32);
2742  void acckeyconf_load_diskpage(Signal*,TcConnectionrecPtr,Fragrecord*,
2743  Uint32, Uint32);
2744 
2745  void handle_nr_copy(Signal*, Ptr<TcConnectionrec>);
2746  void exec_acckeyreq(Signal*, Ptr<TcConnectionrec>);
2747  int compare_key(const TcConnectionrec*, const Uint32 * ptr, Uint32 len);
2748  void nr_copy_delete_row(Signal*, Ptr<TcConnectionrec>, Local_key*, Uint32);
2749  Uint32 getKeyInfoWordOrZero(const TcConnectionrec* regTcPtr,
2750  Uint32 offset);
2751 public:
2752  struct Nr_op_info
2753  {
2754  Uint32 m_ptr_i;
2755  Uint32 m_tup_frag_ptr_i;
2756  Uint32 m_gci_hi;
2757  Uint32 m_gci_lo;
2758  Uint32 m_page_id;
2759  Local_key m_disk_ref;
2760  };
2761  void get_nr_op_info(Nr_op_info*, Uint32 page_id = RNIL);
2763 
2764 public:
2765  void acckeyconf_load_diskpage_callback(Signal*, Uint32, Uint32);
2766 
2767 private:
2768  void next_scanconf_load_diskpage(Signal* signal,
2769  ScanRecordPtr scanPtr,
2770  Ptr<TcConnectionrec> regTcPtr,
2771  Fragrecord* fragPtrP);
2772 
2773  void next_scanconf_tupkeyreq(Signal* signal, ScanRecordPtr,
2774  TcConnectionrec * regTcPtr,
2775  Fragrecord* fragPtrP,
2776  Uint32 disk_page);
2777 
2778 public:
2779  void next_scanconf_load_diskpage_callback(Signal* signal, Uint32, Uint32);
2780 
2781  void tupcommit_conf_callback(Signal* signal, Uint32 tcPtrI);
2782 private:
2783  void tupcommit_conf(Signal* signal, TcConnectionrec *,Fragrecord *);
2784 
2785 // ----------------------------------------------------------------
2786 // These are variables handling the records. For most records one
2787 // pointer to the array of structs, one pointer-struct, a file size
2788 // and a first free record variable. The pointer struct are temporary
2789 // variables that are kept on the class object since there are often a
2790 // great deal of those variables that exist simultaneously and
2791 // thus no perfect solution of handling them is currently available.
2792 // ----------------------------------------------------------------
2793 /* ------------------------------------------------------------------------- */
2794 /* POSITIONS WITHIN THE ATTRINBUF AND THE MAX SIZE OF DATA WITHIN AN */
2795 /* ATTRINBUF. */
2796 /* ------------------------------------------------------------------------- */
2797 
2798 
2799 #define ZADDFRAGREC_FILE_SIZE 1
2800  AddFragRecord *addFragRecord;
2801  AddFragRecordPtr addfragptr;
2802  UintR cfirstfreeAddfragrec;
2803  UintR caddfragrecFileSize;
2804  Uint32 c_active_add_frag_ptr_i;
2805 
2806 // Configurable
2807  FragrecordPtr fragptr;
2808  ArrayPool<Fragrecord> c_fragment_pool;
2809  RSS_AP_SNAPSHOT(c_fragment_pool);
2810 
2811 #define ZGCPREC_FILE_SIZE 1
2812  GcpRecord *gcpRecord;
2813  GcpRecordPtr gcpPtr;
2814  UintR cgcprecFileSize;
2815 
2816 // MAX_NDB_NODES is the size of this array
2817  HostRecord *hostRecord;
2818  UintR chostFileSize;
2819 
2820 #define ZNO_CONCURRENT_LCP 1
2821  LcpRecord *lcpRecord;
2822  LcpRecordPtr lcpPtr;
2823  UintR cfirstfreeLcpLoc;
2824  UintR clcpFileSize;
2825 
2826 #define ZLOG_PART_FILE_SIZE 4
2827  LogPartRecord *logPartRecord;
2828  LogPartRecordPtr logPartPtr;
2829  UintR clogPartFileSize;
2830  Uint32 clogFileSize; // In MBYTE
2831  Uint32 cmaxLogFilesInPageZero; //
2832 
2833 // Configurable
2834  LogFileRecord *logFileRecord;
2835  LogFileRecordPtr logFilePtr;
2836  UintR cfirstfreeLogFile;
2837  UintR clogFileFileSize;
2838 
2839 #define ZLFO_MIN_FILE_SIZE 256
2840 // RedoBuffer/32K minimum ZLFO_MIN_FILE_SIZE
2841  LogFileOperationRecord *logFileOperationRecord;
2843  UintR cfirstfreeLfo;
2844  UintR clfoFileSize;
2845 
2846  LogPageRecord *logPageRecord;
2847  LogPageRecordPtr logPagePtr;
2848  UintR cfirstfreeLogPage;
2849  UintR clogPageFileSize;
2850  Uint32 clogPageCount;
2851 
2852 #define ZPAGE_REF_FILE_SIZE 20
2853  PageRefRecord *pageRefRecord;
2854  PageRefRecordPtr pageRefPtr;
2855  UintR cfirstfreePageRef;
2856  UintR cpageRefFileSize;
2857 
2858 // Configurable
2859  ArrayPool<ScanRecord> c_scanRecordPool;
2860  ScanRecordPtr scanptr;
2861  Uint32 cscanrecFileSize;
2862  DLList<ScanRecord> m_reserved_scans; // LCP + NR
2863 
2864 // Configurable
2865  Tablerec *tablerec;
2866  TablerecPtr tabptr;
2867  UintR ctabrecFileSize;
2868 
2869 // Configurable
2870  TcConnectionrec *tcConnectionrec;
2871  TcConnectionrecPtr tcConnectptr;
2872  UintR cfirstfreeTcConrec;
2873  UintR ctcConnectrecFileSize;
2874 
2875 // MAX_NDB_NODES is the size of this array
2876  TcNodeFailRecord *tcNodeFailRecord;
2877  TcNodeFailRecordPtr tcNodeFailptr;
2878  UintR ctcNodeFailrecFileSize;
2879 
2880  Uint16 terrorCode;
2881 
2882  Uint32 c_firstInNodeGroup;
2883 
2884 // ------------------------------------------------------------------------
2885 // These variables are used to store block state which do not need arrays
2886 // of struct's.
2887 // ------------------------------------------------------------------------
2888  Uint32 c_lcpId;
2889  Uint32 cnoOfFragsCheckpointed;
2890  Uint32 c_last_force_lcp_time;
2891  Uint32 c_free_mb_force_lcp_limit; // Force lcp when less than this free mb
2892  Uint32 c_free_mb_tail_problem_limit; // Set TAIL_PROBLEM when less than this..
2893 
2894 /* ------------------------------------------------------------------------- */
2895 // cmaxWordsAtNodeRec keeps track of how many words that currently are
2896 // outstanding in a node recovery situation.
2897 // cbookedAccOps keeps track of how many operation records that have been
2898 // booked in ACC for the scan processes.
2899 // cmaxAccOps contains the maximum number of operation records which can be
2900 // allocated for scan purposes in ACC.
2901 /* ------------------------------------------------------------------------- */
2902  UintR cmaxWordsAtNodeRec;
2903  UintR cbookedAccOps;
2904  UintR cmaxAccOps;
2905 /* ------------------------------------------------------------------------- */
2906 /*THIS STATE VARIABLE IS ZTRUE IF AN ADD NODE IS ONGOING. ADD NODE MEANS */
2907 /*THAT CONNECTIONS ARE SET-UP TO THE NEW NODE. */
2908 /* ------------------------------------------------------------------------- */
2909  Uint8 caddNodeState;
2910 /* ------------------------------------------------------------------------- */
2911 /*THIS VARIABLE SPECIFIES WHICH TYPE OF RESTART THAT IS ONGOING */
2912 /* ------------------------------------------------------------------------- */
2913  Uint16 cstartType;
2914 /* ------------------------------------------------------------------------- */
2915 /*THIS VARIABLE INDICATES WHETHER AN INITIAL RESTART IS ONGOING OR NOT. */
2916 /* ------------------------------------------------------------------------- */
2917  Uint8 cinitialStartOngoing;
2918 /* ------------------------------------------------------------------------- */
2919 /*THIS VARIABLE KEEPS TRACK OF WHEN TUP AND ACC HAVE COMPLETED EXECUTING */
2920 /*THEIR UNDO LOG. */
2921 /* ------------------------------------------------------------------------- */
2922  ExecUndoLogState csrExecUndoLogState;
2923 /* ------------------------------------------------------------------------- */
2924 /*THIS VARIABLE KEEPS TRACK OF WHEN TUP AND ACC HAVE CONFIRMED COMPLETION */
2925 /*OF A LOCAL CHECKPOINT ROUND. */
2926 /* ------------------------------------------------------------------------- */
2927  LcpCloseState clcpCompletedState;
2928 /* ------------------------------------------------------------------------- */
2929 /*DURING CONNECTION PROCESSES IN SYSTEM RESTART THESE VARIABLES KEEP TRACK */
2930 /*OF HOW MANY CONNECTIONS AND RELEASES THAT ARE TO BE PERFORMED. */
2931 /* ------------------------------------------------------------------------- */
2932 /***************************************************************************>*/
2933 /*THESE VARIABLES CONTAIN INFORMATION USED DURING SYSTEM RESTART. */
2934 /***************************************************************************>*/
2935 /* ------------------------------------------------------------------------- */
2936 /*THIS VARIABLE IS ZTRUE IF THE SIGNAL START_REC_REQ HAVE BEEN RECEIVED. */
2937 /*RECEPTION OF THIS SIGNAL INDICATES THAT ALL FRAGMENTS THAT THIS NODE */
2938 /*SHOULD START HAVE BEEN RECEIVED. */
2939 /* ------------------------------------------------------------------------- */
2940  enum {
2941  SRR_INITIAL = 0
2942  ,SRR_START_REC_REQ_ARRIVED = 1
2943  ,SRR_REDO_COMPLETE = 2
2944  ,SRR_FIRST_LCP_DONE = 3
2945  } cstartRecReq;
2946  Uint32 cstartRecReqData;
2947 
2948 /* ------------------------------------------------------------------------- */
2949 /*THIS VARIABLE KEEPS TRACK OF HOW MANY FRAGMENTS THAT PARTICIPATE IN */
2950 /*EXECUTING THE LOG. IF ZERO WE DON'T NEED TO EXECUTE THE LOG AT ALL. */
2951 /* ------------------------------------------------------------------------- */
2952  Uint32 cnoFragmentsExecSr;
2953 
2957  Uint32 cnoOutstandingExecFragReq;
2958 
2959 /* ------------------------------------------------------------------------- */
2960 /*THIS VARIABLE KEEPS TRACK OF WHICH OF THE FIRST TWO RESTART PHASES THAT */
2961 /*HAVE COMPLETED. */
2962 /* ------------------------------------------------------------------------- */
2963  Uint8 csrPhaseStarted;
2964 /* ------------------------------------------------------------------------- */
2965 /*NUMBER OF PHASES COMPLETED OF EXECUTING THE FRAGMENT LOG. */
2966 /* ------------------------------------------------------------------------- */
2967  Uint8 csrPhasesCompleted;
2968 /* ------------------------------------------------------------------------- */
2969 /*THE BLOCK REFERENCE OF THE MASTER DIH DURING SYSTEM RESTART. */
2970 /* ------------------------------------------------------------------------- */
2971  BlockReference cmasterDihBlockref;
2972 /* ------------------------------------------------------------------------- */
2973 /*THIS VARIABLE IS THE HEAD OF A LINKED LIST OF FRAGMENTS WAITING TO BE */
2974 /*RESTORED FROM DISK. */
2975 /* ------------------------------------------------------------------------- */
2976  DLFifoList<Fragrecord> c_lcp_waiting_fragments; // StartFragReq'ed
2977  DLFifoList<Fragrecord> c_lcp_restoring_fragments; // Restoring as we speek
2978  DLFifoList<Fragrecord> c_lcp_complete_fragments; // Restored
2979 
2980 /* ------------------------------------------------------------------------- */
2981 /*USED DURING SYSTEM RESTART, INDICATES THE OLDEST GCI THAT CAN BE RESTARTED */
2982 /*FROM AFTER THIS SYSTEM RESTART. USED TO FIND THE LOG TAIL. */
2983 /* ------------------------------------------------------------------------- */
2984  UintR crestartOldestGci;
2985 /* ------------------------------------------------------------------------- */
2986 /*USED DURING SYSTEM RESTART, INDICATES THE NEWEST GCI THAT CAN BE RESTARTED */
2987 /*AFTER THIS SYSTEM RESTART. USED TO FIND THE LOG HEAD. */
2988 /* ------------------------------------------------------------------------- */
2989  UintR crestartNewestGci;
2990 /* ------------------------------------------------------------------------- */
2991 /*THE NUMBER OF LOG FILES. SET AS A PARAMETER WHEN NDB IS STARTED. */
2992 /* ------------------------------------------------------------------------- */
2993  UintR cnoLogFiles;
2994 /* ------------------------------------------------------------------------- */
2995 /*THESE TWO VARIABLES CONTAIN THE NEWEST GCI RECEIVED IN THE BLOCK AND THE */
2996 /*NEWEST COMPLETED GCI IN THE BLOCK. */
2997 /* ------------------------------------------------------------------------- */
2998  UintR cnewestGci;
2999  UintR cnewestCompletedGci;
3000 /* ------------------------------------------------------------------------- */
3001 /*THIS VARIABLE ONLY PASSES INFORMATION FROM STTOR TO STTORRY = TEMPORARY */
3002 /* ------------------------------------------------------------------------- */
3003  Uint16 csignalKey;
3004 /* ------------------------------------------------------------------------- */
3005 /*THIS VARIABLE CONTAINS THE CURRENT START PHASE IN THE BLOCK. IS ZNIL IF */
3006 /*NO SYSTEM RESTART IS ONGOING. */
3007 /* ------------------------------------------------------------------------- */
3008  Uint16 cstartPhase;
3009 /* ------------------------------------------------------------------------- */
3010 /*THIS VARIABLE CONTAIN THE CURRENT GLOBAL CHECKPOINT RECORD. IT'S RNIL IF */
3011 /*NOT A GCP SAVE IS ONGOING. */
3012 /* ------------------------------------------------------------------------- */
3013  UintR ccurrentGcprec;
3014 /* ------------------------------------------------------------------------- */
3015 /*THESE VARIABLES ARE USED TO KEEP TRACK OF ALL ACTIVE COPY FRAGMENTS IN LQH.*/
3016 /* ------------------------------------------------------------------------- */
3017  Uint8 cnoActiveCopy;
3018  UintR cactiveCopy[4];
3019 
3020 /* ------------------------------------------------------------------------- */
3021 /*THESE VARIABLES CONTAIN THE BLOCK REFERENCES OF THE OTHER NDB BLOCKS. */
3022 /*ALSO THE BLOCK REFERENCE OF MY OWN BLOCK = LQH */
3023 /* ------------------------------------------------------------------------- */
3024  BlockReference caccBlockref;
3025  BlockReference ctupBlockref;
3026  BlockReference ctuxBlockref;
3027  BlockReference cownref;
3028  Uint32 cTransactionDeadlockDetectionTimeout;
3029  UintR cLqhTimeOutCount;
3030  UintR cLqhTimeOutCheckCount;
3031  UintR cnoOfLogPages;
3032 /* ------------------------------------------------------------------------- */
3033 /*THIS VARIABLE CONTAINS MY OWN PROCESSOR ID. */
3034 /* ------------------------------------------------------------------------- */
3035  NodeId cownNodeid;
3036 
3037 /* ------------------------------------------------------------------------- */
3038 /*THESE VARIABLES CONTAIN INFORMATION ABOUT THE OTHER NODES IN THE SYSTEM */
3039 /*THESE VARIABLES ARE MOSTLY USED AT SYSTEM RESTART AND ADD NODE TO SET-UP */
3040 /*AND RELEASE CONNECTIONS TO OTHER NODES IN THE CLUSTER. */
3041 /* ------------------------------------------------------------------------- */
3042 /* ------------------------------------------------------------------------- */
3043 /*THIS ARRAY CONTAINS THE PROCESSOR ID'S OF THE NODES THAT ARE ALIVE. */
3044 /*CNO_OF_NODES SPECIFIES HOW MANY NODES THAT ARE CURRENTLY ALIVE. */
3045 /*CNODE_VERSION SPECIFIES THE NDB VERSION EXECUTING ON THE NODE. */
3046 /* ------------------------------------------------------------------------- */
3047  UintR cpackedListIndex;
3048  Uint16 cpackedList[MAX_NDB_NODES];
3049  UintR cnodeData[MAX_NDB_NODES];
3050  UintR cnodeStatus[MAX_NDB_NODES];
3051  UintR cnoOfNodes;
3052 
3053  NdbNodeBitmask m_sr_nodes;
3054  NdbNodeBitmask m_sr_exec_sr_req;
3055  NdbNodeBitmask m_sr_exec_sr_conf;
3056 
3057 /* ------------------------------------------------------------------------- */
3058 /* THIS VARIABLE CONTAINS THE DIRECTORY OF A HASH TABLE OF ALL ACTIVE */
3059 /* OPERATION IN THE BLOCK. IT IS USED TO BE ABLE TO QUICKLY ABORT AN */
3060 /* OPERATION WHERE THE CONNECTION WAS LOST DUE TO NODE FAILURES. IT IS */
3061 /* ACTUALLY USED FOR ALL ABORTS COMMANDED BY TC. */
3062 /* ------------------------------------------------------------------------- */
3063  UintR preComputedRequestInfoMask;
3064  UintR ctransidHash[1024];
3065 
3066  Uint32 c_diskless;
3067  Uint32 c_o_direct;
3068  Uint32 m_use_om_init;
3069  Uint32 c_error_insert_table_id;
3070 
3071 #ifndef NO_REDO_PAGE_CACHE
3072  /***********************************************************
3073  * MODULE: Redo Page Cache
3074  *
3075  * When running redo, current codes scan log until finding a commit
3076  * record (for an operation). The commit record contains a back-pointer
3077  * to a prepare-record.
3078  *
3079  * If the prepare record is inside the 512k window that is being read
3080  * from redo-log, the access is quick.
3081  *
3082  * But it's not, then the following sequence is performed
3083  * [file-open]?[page-read][execute-log-record][file-close]?[release-page]
3084  *
3085  * For big (or long running) transactions this becomes very inefficient
3086  *
3087  * The RedoPageCache changes this so that the pages that are not released
3088  * in sequence above, but rather put into a LRU (using RedoBuffer)
3089  */
3090 
3095  struct RedoCacheLogPageRecord
3096  {
3097  RedoCacheLogPageRecord() {}
3101  Uint32 header0[15];
3102  Uint32 m_page_no;
3103  Uint32 m_file_no;
3104  Uint32 header1[5];
3105  Uint32 m_part_no;
3106  Uint32 nextList;
3107  Uint32 nextHash;
3108  Uint32 prevList;
3109  Uint32 prevHash;
3110  Uint32 rest[8192-27];
3111 
3112  inline bool equal(const RedoCacheLogPageRecord & p) const {
3113  return
3114  (p.m_part_no == m_part_no) &&
3115  (p.m_page_no == m_page_no) &&
3116  (p.m_file_no == m_file_no);
3117  }
3118 
3119  inline Uint32 hashValue() const {
3120  return (m_part_no << 24) + (m_file_no << 16) + m_page_no;
3121  }
3122  };
3123  struct RedoPageCache
3124  {
3125  RedoPageCache() : m_hash(m_pool), m_lru(m_pool),
3126  m_hits(0),m_multi_page(0), m_multi_miss(0) {}
3130  Uint32 m_hits;
3131  Uint32 m_multi_page;
3132  Uint32 m_multi_miss;
3133  } m_redo_page_cache;
3134 
3135  void evict(RedoPageCache&, Uint32 cnt);
3136  void do_evict(RedoPageCache&, Ptr<RedoCacheLogPageRecord>);
3137  void addCachePages(RedoPageCache&,
3138  Uint32 partNo,
3139  Uint32 startPageNo,
3140  LogFileOperationRecord*);
3141  void release(RedoPageCache&);
3142 #endif
3143 
3144 #ifndef NO_REDO_OPEN_FILE_CACHE
3145  struct RedoOpenFileCache
3146  {
3147  RedoOpenFileCache() : m_lru(m_pool), m_hits(0), m_close_cnt(0) {}
3148 
3150  ArrayPool<LogFileRecord> m_pool;
3151  Uint32 m_hits;
3152  Uint32 m_close_cnt;
3153  } m_redo_open_file_cache;
3154 
3155  void openFileRw_cache(Signal* signal, LogFileRecordPtr olfLogFilePtr);
3156  void closeFile_cache(Signal* signal, LogFileRecordPtr logFilePtr, Uint32);
3157  void release(Signal*, RedoOpenFileCache&);
3158 #endif
3159 
3160 public:
3161  bool is_same_trans(Uint32 opId, Uint32 trid1, Uint32 trid2);
3162  void get_op_info(Uint32 opId, Uint32 *hash, Uint32* gci_hi, Uint32* gci_lo,
3163  Uint32* transId1, Uint32* transId2);
3164  void accminupdate(Signal*, Uint32 opPtrI, const Local_key*);
3165  void accremoverow(Signal*, Uint32 opPtrI, const Local_key*);
3166 
3171  CommitAckMarker() {}
3172  Uint32 transid1;
3173  Uint32 transid2;
3174 
3175  Uint32 apiRef; // Api block ref
3176  Uint32 apiOprec; // Connection Object in NDB API
3177  Uint32 tcNodeId;
3178  union { Uint32 nextPool; Uint32 nextHash; };
3179  Uint32 prevHash;
3180  Uint32 reference_count;
3181 
3182  inline bool equal(const CommitAckMarker & p) const {
3183  return ((p.transid1 == transid1) && (p.transid2 == transid2));
3184  }
3185 
3186  inline Uint32 hashValue() const {
3187  return transid1;
3188  }
3189  };
3190 
3192  ArrayPool<CommitAckMarker> m_commitAckMarkerPool;
3193  DLHashTable<CommitAckMarker> m_commitAckMarkerHash;
3194  typedef DLHashTable<CommitAckMarker>::Iterator CommitAckMarkerIterator;
3195  void execREMOVE_MARKER_ORD(Signal* signal);
3196  void scanMarkers(Signal* signal, Uint32 tcNodeFail, Uint32 bucket, Uint32 i);
3197 
3198  void ndbdFailBlockCleanupCallback(Signal* signal, Uint32 failedNodeID, Uint32 ignoredRc);
3199 
3201  MonotonicCounters() :
3202  operations(0) {}
3203 
3204  Uint64 operations;
3205 
3206  Uint32 build_event_rep(Signal* signal) const
3207  {
3208  /*
3209  Read saved value from CONTINUEB, subtract from
3210  counter and write to EVENT_REP
3211  */
3212  struct { const Uint64* ptr; Uint64 old; } vars[] = {
3213  { &operations, 0 }
3214  };
3215  const size_t num = sizeof(vars)/sizeof(vars[0]);
3216 
3217  signal->theData[0] = NDB_LE_OperationReportCounters;
3218 
3219  // Read old values from signal
3220  for (size_t i = 0; i < num ; i++)
3221  {
3222  vars[i].old =
3223  (signal->theData[1+(2*i)+1] |(Uint64(signal->theData[1+(2*i)])<< 32));
3224  }
3225 
3226  // Write difference back to signal
3227  for (size_t i = 0; i < num ; i++)
3228  {
3229  signal->theData[1 + i] = (Uint32)(*vars[i].ptr - vars[i].old);
3230  }
3231  return 1 + num;
3232  }
3233 
3234  Uint32 build_continueB(Signal* signal) const
3235  {
3236  /* Save current value of counters to CONTINUEB */
3237  const Uint64* vars[] = { &operations };
3238  const size_t num = sizeof(vars)/sizeof(vars[0]);
3239 
3240  for (size_t i = 0; i < num ; i++)
3241  {
3242  signal->theData[1+i*2] = Uint32(*vars[i] >> 32);
3243  signal->theData[1+i*2+1] = Uint32(*vars[i]);
3244  }
3245  return 1 + num * 2;
3246  }
3247 
3248  } c_Counters;
3249 
3250  Uint32 c_max_redo_lag;
3251  Uint32 c_max_redo_lag_counter;
3252  Uint64 cTotalLqhKeyReqCount;
3253  Uint32 c_max_parallel_scans_per_frag;
3254 
3255  inline bool getAllowRead() const {
3257  }
3258 
3259  DLHashTable<ScanRecord> c_scanTakeOverHash;
3260 
3261  inline bool TRACE_OP_CHECK(const TcConnectionrec* regTcPtr);
3262 #ifdef ERROR_INSERT
3263  void TRACE_OP_DUMP(const TcConnectionrec* regTcPtr, const char * pos);
3264 #endif
3265 
3266 #ifdef ERROR_INSERT
3267  Uint32 c_master_node_id;
3268 #endif
3269 
3270  Uint32 get_node_status(Uint32 nodeId) const;
3271  bool check_ndb_versions() const;
3272 
3273  void suspendFile(Signal* signal, Uint32 filePtrI, Uint32 millis);
3274  void suspendFile(Signal* signal, Ptr<LogFileRecord> logFile, Uint32 millis);
3275 
3276  void send_runredo_event(Signal*, LogPartRecord *, Uint32 currgci);
3277 
3278  void sendFireTrigConfTc(Signal* signal, BlockReference ref, Uint32 Tdata[]);
3279  bool check_fire_trig_pass(Uint32 op, Uint32 pass);
3280 };
3281 
3282 inline
3283 bool
3284 Dblqh::ScanRecord::check_scan_batch_completed() const
3285 {
3286  Uint32 max_rows = m_max_batch_size_rows;
3287  Uint32 max_bytes = m_max_batch_size_bytes;
3288 
3289  return (max_rows > 0 && (m_curr_batch_size_rows >= max_rows)) ||
3290  (max_bytes > 0 && (m_curr_batch_size_bytes >= max_bytes));
3291 }
3292 
3293 inline
3294 void
3295 Dblqh::i_get_acc_ptr(ScanRecord* scanP, Uint32* &acc_ptr, Uint32 index)
3296 {
3297  /* Return ptr to place where acc ptr for operation with given
3298  * index is stored.
3299  * If index == 0, it's stored in the ScanRecord, otherwise it's
3300  * stored in a segment linked from the ScanRecord.
3301  */
3302  if (index == 0) {
3303  acc_ptr= (Uint32*)&scanP->scan_acc_op_ptr[0];
3304  } else {
3305  jam();
3306 
3307  Uint32 segmentIVal, segment, segmentOffset;
3308  SegmentedSectionPtr segPtr;
3309 
3310  segment= (index + SectionSegment::DataLength -1) /
3311  SectionSegment::DataLength;
3312  segmentOffset= (index - 1) % SectionSegment::DataLength;
3313 
3314  ndbassert( segment < ScanRecord::MaxScanAccSegments );
3315 
3316  segmentIVal= scanP->scan_acc_op_ptr[ segment ];
3317  getSection(segPtr, segmentIVal);
3318 
3319  acc_ptr= &segPtr.p->theData[ segmentOffset ];
3320  }
3321 }
3322 
3323 inline
3324 bool
3325 Dblqh::is_same_trans(Uint32 opId, Uint32 trid1, Uint32 trid2)
3326 {
3327  TcConnectionrecPtr regTcPtr;
3328  regTcPtr.i= opId;
3329  ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
3330  return ((regTcPtr.p->transid[0] == trid1) &&
3331  (regTcPtr.p->transid[1] == trid2));
3332 }
3333 
3334 inline
3335 void
3336 Dblqh::get_op_info(Uint32 opId, Uint32 *hash, Uint32* gci_hi, Uint32* gci_lo,
3337  Uint32* transId1, Uint32* transId2)
3338 {
3339  TcConnectionrecPtr regTcPtr;
3340  regTcPtr.i= opId;
3341  ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
3342  *hash = regTcPtr.p->hashValue;
3343  *gci_hi = regTcPtr.p->gci_hi;
3344  *gci_lo = regTcPtr.p->gci_lo;
3345  *transId1 = regTcPtr.p->transid[0];
3346  *transId2 = regTcPtr.p->transid[1];
3347 }
3348 
3349 #include "../dbacc/Dbacc.hpp"
3350 
3351 inline
3352 void
3353 Dblqh::accminupdate(Signal* signal, Uint32 opId, const Local_key* key)
3354 {
3355  TcConnectionrecPtr regTcPtr;
3356  regTcPtr.i= opId;
3357  ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
3358  signal->theData[0] = regTcPtr.p->accConnectrec;
3359  signal->theData[1] = key->m_page_no;
3360  signal->theData[2] = key->m_page_idx;
3361  c_acc->execACCMINUPDATE(signal);
3362 
3363  if (ERROR_INSERTED(5714))
3364  {
3365  FragrecordPtr regFragptr;
3366  regFragptr.i = regTcPtr.p->fragmentptr;
3367  c_fragment_pool.getPtr(regFragptr);
3368  if (regFragptr.p->m_copy_started_state == Fragrecord::AC_NR_COPY)
3369  ndbout << " LK: " << *key;
3370  }
3371 
3372  if (ERROR_INSERTED(5712) || ERROR_INSERTED(5713))
3373  ndbout << " LK: " << *key;
3374  regTcPtr.p->m_row_id = *key;
3375 }
3376 
3377 inline
3378 void
3379 Dblqh::accremoverow(Signal* signal, Uint32 opId, const Local_key* key)
3380 {
3381  TcConnectionrecPtr regTcPtr;
3382  regTcPtr.i= opId;
3383  ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
3384  c_acc->removerow(regTcPtr.p->accConnectrec, key);
3385 }
3386 
3387 inline
3388 bool
3389 Dblqh::TRACE_OP_CHECK(const TcConnectionrec* regTcPtr)
3390 {
3391  if (ERROR_INSERTED(5714))
3392  {
3393  FragrecordPtr regFragptr;
3394  regFragptr.i = regTcPtr->fragmentptr;
3395  c_fragment_pool.getPtr(regFragptr);
3396  return regFragptr.p->m_copy_started_state == Fragrecord::AC_NR_COPY;
3397  }
3398 
3399  return (ERROR_INSERTED(5712) &&
3400  (regTcPtr->operation == ZINSERT ||
3401  regTcPtr->operation == ZDELETE)) ||
3402  ERROR_INSERTED(5713);
3403 }
3404 
3405 #endif