1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
20
#include <ndb_limits.h>
21
#include <SimulatedBlock.hpp>
24
#include <DLFifoList.hpp>
25
#include <DLHashTable.hpp>
27
#include <NodeBitmask.hpp>
28
#include <signaldata/LCP.hpp>
29
#include <signaldata/LqhTransConf.hpp>
30
#include <signaldata/LqhFrag.hpp>
31
#include <signaldata/FsOpenReq.hpp>
33
// primary key is stored in TUP
34
#include "../dbtup/Dbtup.hpp"
41
/* ------------------------------------------------------------------------- */
42
/* CONSTANTS USED WHEN MASTER REQUESTS STATE OF COPY FRAGMENTS. */
43
/* ------------------------------------------------------------------------- */
44
#define ZCOPY_CLOSING 0
45
#define ZCOPY_ONGOING 1
46
#define ZCOPY_ACTIVATION 2
47
/* ------------------------------------------------------------------------- */
48
/* STATES FOR THE VARIABLE GCP_LOG_PART_STATE */
49
/* ------------------------------------------------------------------------- */
54
/* ------------------------------------------------------------------------- */
55
/* STATES FOR THE VARIABLE CSR_PHASES_STARTED */
56
/* ------------------------------------------------------------------------- */
57
#define ZSR_NO_PHASE_STARTED 0
58
#define ZSR_PHASE1_COMPLETED 1
59
#define ZSR_PHASE2_COMPLETED 2
60
#define ZSR_BOTH_PHASES_STARTED 3
61
/* ------------------------------------------------------------------------- */
62
/* THE NUMBER OF PAGES IN A MBYTE, THE TWO LOGARITHM OF THIS. */
63
/* THE NUMBER OF MBYTES IN A LOG FILE. */
64
/* THE MAX NUMBER OF PAGES READ/WRITTEN FROM/TO DISK DURING */
65
/* A WRITE OR READ. */
66
/* ------------------------------------------------------------------------- */
69
#define ZREAD_AHEAD_SIZE 8
70
/* ------------------------------------------------------------------------- */
71
/* CONSTANTS OF THE LOG PAGES */
72
/* ------------------------------------------------------------------------- */
73
#define ZPAGE_HEADER_SIZE 32
74
#define ZPAGE_SIZE 8192
75
#define ZPAGES_IN_MBYTE 32
76
#define ZTWOLOG_NO_PAGES_IN_MBYTE 5
77
#define ZTWOLOG_PAGE_SIZE 13
78
#define ZMAX_MM_BUFFER_SIZE 32 // Main memory window during log execution
80
#define ZMAX_PAGES_WRITTEN 8 // Max pages before writing to disk (=> config)
81
#define ZMIN_READ_BUFFER_SIZE 2 // Minimum number of pages to execute log
82
#define ZMIN_LOG_PAGES_OPERATION 10 // Minimum no of pages before stopping
84
#define ZPOS_CHECKSUM 0
85
#define ZPOS_LOG_LAP 1
86
#define ZPOS_MAX_GCI_COMPLETED 2
87
#define ZPOS_MAX_GCI_STARTED 3
90
#define ZPOS_VERSION 6
91
#define ZPOS_NO_LOG_FILES 7
92
#define ZCURR_PAGE_INDEX 8
93
#define ZLAST_LOG_PREP_REF 10
95
/* A number of debug items written in the page header of all log files */
96
#define ZPOS_LOG_TIMER 12
97
#define ZPOS_PAGE_I 13
98
#define ZPOS_PLACE_WRITTEN_FROM 14
99
#define ZPOS_PAGE_NO 15
100
#define ZPOS_PAGE_FILE_NO 16
101
#define ZPOS_WORD_WRITTEN 17
102
#define ZPOS_IN_WRITING 18
103
#define ZPOS_PREV_PAGE_NO 19
104
#define ZPOS_IN_FREE_LIST 20
106
/* ------------------------------------------------------------------------- */
107
/* CONSTANTS FOR THE VARIOUS REPLICA AND NODE TYPES. */
108
/* ------------------------------------------------------------------------- */
109
#define ZPRIMARY_NODE 0
110
#define ZBACKUP_NODE 1
111
#define ZSTANDBY_NODE 2
114
/* ------------------------------------------------------------------------- */
115
/* VARIOUS CONSTANTS USED AS FLAGS TO THE FILE MANAGER. */
116
/* ------------------------------------------------------------------------- */
117
#define ZVAR_NO_LOG_PAGE_WORD 1
118
#define ZLIST_OF_PAIRS 0
119
#define ZLIST_OF_PAIRS_SYNCH 16
120
#define ZARRAY_OF_PAGES 1
121
#define ZLIST_OF_MEM_PAGES 2
122
#define ZLIST_OF_MEM_PAGES_SYNCH 18
123
#define ZCLOSE_NO_DELETE 0
124
#define ZCLOSE_DELETE 1
126
/* ------------------------------------------------------------------------- */
127
/* THE FOLLOWING CONSTANTS ARE USED TO DESCRIBE THE TYPES OF */
128
/* LOG RECORDS, THE SIZE OF THE VARIOUS LOG RECORD TYPES AND */
129
/* THE POSITIONS WITHIN THOSE LOG RECORDS. */
130
/* ------------------------------------------------------------------------- */
131
/* ------------------------------------------------------------------------- */
132
/* THESE CONSTANTS DESCRIBE THE SIZES OF VARIOUS TYPES OF LOG REORDS. */
133
/* NEXT_LOG_SIZE IS ACTUALLY ONE. THE REASON WE SET IT TO 2 IS TO */
134
/* SIMPLIFY THE CODE SINCE OTHERWISE HAVE TO USE A SPECIAL VERSION */
135
/* OF READ_LOGWORD WHEN READING LOG RECORD TYPE */
136
/* SINCE NEXT MBYTE TYPE COULD BE THE VERY LAST WORD IN THE MBYTE. */
137
/* BY SETTING IT TO 2 WE ENSURE IT IS NEVER THE VERY LAST WORD */
139
/* ------------------------------------------------------------------------- */
140
#define ZFD_HEADER_SIZE 3
141
#define ZFD_MBYTE_SIZE 3
142
#define ZLOG_HEAD_SIZE 8
143
#define ZNEXT_LOG_SIZE 2
144
#define ZABORT_LOG_SIZE 3
145
#define ZCOMMIT_LOG_SIZE 9
146
#define ZCOMPLETED_GCI_LOG_SIZE 2
147
/* ------------------------------------------------------------------------- */
148
/* THESE CONSTANTS DESCRIBE THE TYPE OF A LOG RECORD. */
149
/* THIS IS THE FIRST WORD OF A LOG RECORD. */
150
/* ------------------------------------------------------------------------- */
151
#define ZNEW_PREP_OP_TYPE 0
152
#define ZPREP_OP_TYPE 1
153
#define ZCOMMIT_TYPE 2
154
#define ZABORT_TYPE 3
156
#define ZFRAG_SPLIT_TYPE 5
157
#define ZNEXT_LOG_RECORD_TYPE 6
158
#define ZNEXT_MBYTE_TYPE 7
159
#define ZCOMPLETED_GCI_TYPE 8
160
#define ZINVALID_COMMIT_TYPE 9
161
/* ------------------------------------------------------------------------- */
162
/* THE POSITIONS OF LOGGED DATA IN A FILE DESCRIPTOR LOG RECORD HEADER.*/
163
/* ALSO THE MAXIMUM NUMBER OF FILE DESCRIPTORS IN A LOG RECORD. */
164
/* ------------------------------------------------------------------------- */
165
#define ZPOS_LOG_TYPE 0
167
#define ZPOS_FILE_NO 2
168
/* ------------------------------------------------------------------------- */
169
/* THE POSITIONS WITHIN A PREPARE LOG RECORD AND A NEW PREPARE */
171
/* ------------------------------------------------------------------------- */
172
#define ZPOS_HASH_VALUE 2
173
#define ZPOS_SCHEMA_VERSION 3
174
#define ZPOS_TRANS_TICKET 4
175
#define ZPOS_OP_TYPE 5
176
#define ZPOS_NO_ATTRINFO 6
177
#define ZPOS_NO_KEYINFO 7
178
/* ------------------------------------------------------------------------- */
179
/* THE POSITIONS WITHIN A COMMIT LOG RECORD. */
180
/* ------------------------------------------------------------------------- */
181
#define ZPOS_COMMIT_TRANSID1 1
182
#define ZPOS_COMMIT_TRANSID2 2
183
#define ZPOS_COMMIT_GCI 3
184
#define ZPOS_COMMIT_TABLE_REF 4
185
#define ZPOS_COMMIT_FRAGID 5
186
#define ZPOS_COMMIT_FILE_NO 6
187
#define ZPOS_COMMIT_START_PAGE_NO 7
188
#define ZPOS_COMMIT_START_PAGE_INDEX 8
189
#define ZPOS_COMMIT_STOP_PAGE_NO 9
190
/* ------------------------------------------------------------------------- */
191
/* THE POSITIONS WITHIN A ABORT LOG RECORD. */
192
/* ------------------------------------------------------------------------- */
193
#define ZPOS_ABORT_TRANSID1 1
194
#define ZPOS_ABORT_TRANSID2 2
195
/* ------------------------------------------------------------------------- */
196
/* THE POSITION WITHIN A COMPLETED GCI LOG RECORD. */
197
/* ------------------------------------------------------------------------- */
198
#define ZPOS_COMPLETED_GCI 1
199
/* ------------------------------------------------------------------------- */
200
/* THE POSITIONS WITHIN A NEW PREPARE LOG RECORD. */
201
/* ------------------------------------------------------------------------- */
202
#define ZPOS_NEW_PREP_FILE_NO 8
203
#define ZPOS_NEW_PREP_PAGE_REF 9
205
#define ZLAST_WRITE_IN_FILE 1
206
#define ZENFORCE_WRITE 2
207
/* ------------------------------------------------------------------------- */
208
/* CONSTANTS USED AS INPUT TO SUBROUTINE WRITE_LOG_PAGES AMONG OTHERS. */
209
/* ------------------------------------------------------------------------- */
212
/* ------------------------------------------------------------------------- */
213
/* CONSTANTS USED BY CONTINUEB TO DEDUCE WHICH CONTINUE SIGNAL IS TO */
214
/* BE EXECUTED AS A RESULT OF THIS CONTINUEB SIGNAL. */
215
/* ------------------------------------------------------------------------- */
216
#define ZLOG_LQHKEYREQ 0
217
#define ZPACK_LQHKEYREQ 1
218
#define ZSEND_ATTRINFO 2
219
#define ZSR_GCI_LIMITS 3
220
#define ZSR_LOG_LIMITS 4
221
#define ZSEND_EXEC_CONF 5
223
#define ZSR_FOURTH_COMP 7
224
#define ZINIT_FOURTH 8
225
#define ZTIME_SUPERVISION 9
226
#define ZSR_PHASE3_START 10
227
#define ZLQH_TRANS_NEXT 11
228
#define ZLQH_RELEASE_AT_NODE_FAILURE 12
229
#define ZSCAN_TC_CONNECT 13
230
#define ZINITIALISE_RECORDS 14
231
#define ZINIT_GCP_REC 15
232
#define ZCHECK_LCP_STOP_BLOCKED 17
233
#define ZSCAN_MARKERS 18
234
#define ZOPERATION_EVENT_REP 19
235
#define ZPREP_DROP_TABLE 20
236
#define ZENABLE_EXPAND_CHECK 21
237
#define ZRETRY_TCKEYREF 22
239
/* ------------------------------------------------------------------------- */
240
/* NODE STATE DURING SYSTEM RESTART, VARIABLES CNODES_SR_STATE */
241
/* AND CNODES_EXEC_SR_STATE. */
242
/* ------------------------------------------------------------------------- */
244
#define ZEXEC_SR_COMPLETED 2
245
/* ------------------------------------------------------------------------- */
246
/* CONSTANTS USED BY NODE STATUS TO DEDUCE THE STATUS OF A NODE. */
247
/* ------------------------------------------------------------------------- */
250
/* ------------------------------------------------------------------------- */
252
/* ------------------------------------------------------------------------- */
253
#define ZLAST_START_PHASE 255
254
#define ZSTART_PHASE1 1
255
#define ZSTART_PHASE2 2
256
#define ZSTART_PHASE3 3
257
#define ZSTART_PHASE4 4
258
#define ZSTART_PHASE6 6
259
/* ------------------------------------------------------------------------- */
260
/* CONSTANTS USED BY SCAN AND COPY FRAGMENT PROCEDURES */
261
/* ------------------------------------------------------------------------- */
262
#define ZSTORED_PROC_SCAN 0
263
#define ZSTORED_PROC_COPY 2
264
#define ZDELETE_STORED_PROC_ID 3
265
#define ZWRITE_LOCK 1
266
#define ZSCAN_FRAG_CLOSED 2
267
/* ------------------------------------------------------------------------- */
268
/* ERROR CODES ADDED IN VERSION 0.1 AND 0.2 */
269
/* ------------------------------------------------------------------------- */
270
#define ZNOT_FOUND 1 // Not an error code, a return value
271
#define ZNO_FREE_LQH_CONNECTION 414
272
#define ZGET_DATAREC_ERROR 418
273
#define ZGET_ATTRINBUF_ERROR 419
274
#define ZNO_FREE_FRAGMENTREC 460 // Insert new fragment error code
275
#define ZTAB_FILE_SIZE 464 // Insert new fragment error code + Start kernel
276
#define ZNO_ADD_FRAGREC 465 // Insert new fragment error code
277
/* ------------------------------------------------------------------------- */
278
/* ERROR CODES ADDED IN VERSION 0.3 */
279
/* ------------------------------------------------------------------------- */
280
#define ZTAIL_PROBLEM_IN_LOG_ERROR 410
281
#define ZGCI_TOO_LOW_ERROR 429 // GCP_SAVEREF error code
282
#define ZTAB_STATE_ERROR 474 // Insert new fragment error code
283
#define ZTOO_NEW_GCI_ERROR 479 // LCP Start error
284
/* ------------------------------------------------------------------------- */
285
/* ERROR CODES ADDED IN VERSION 0.4 */
286
/* ------------------------------------------------------------------------- */
288
#define ZNO_FREE_FRAG_SCAN_REC_ERROR 490 // SCAN_FRAGREF error code
289
#define ZCOPY_NO_FRAGMENT_ERROR 491 // COPY_FRAGREF error code
290
#define ZTAKE_OVER_ERROR 499
291
#define ZCOPY_NODE_ERROR 1204
292
#define ZTOO_MANY_COPY_ACTIVE_ERROR 1208 // COPY_FRAG and COPY_ACTIVEREF code
293
#define ZCOPY_ACTIVE_ERROR 1210 // COPY_ACTIVEREF error code
294
#define ZNO_TC_CONNECT_ERROR 1217 // Simple Read + SCAN
295
/* ------------------------------------------------------------------------- */
296
/* ERROR CODES ADDED IN VERSION 1.X */
297
/* ------------------------------------------------------------------------- */
298
//#define ZSCAN_BOOK_ACC_OP_ERROR 1219 // SCAN_FRAGREF error code
299
#define ZFILE_CHANGE_PROBLEM_IN_LOG_ERROR 1220
300
#define ZTEMPORARY_REDO_LOG_FAILURE 1221
301
#define ZNO_FREE_MARKER_RECORDS_ERROR 1222
302
#define ZNODE_SHUTDOWN_IN_PROGESS 1223
303
#define ZTOO_MANY_FRAGMENTS 1224
304
#define ZTABLE_NOT_DEFINED 1225
305
#define ZDROP_TABLE_IN_PROGRESS 1226
306
#define ZINVALID_SCHEMA_VERSION 1227
308
/* ------------------------------------------------------------------------- */
309
/* ERROR CODES ADDED IN VERSION 2.X */
310
/* ------------------------------------------------------------------------- */
311
#define ZNODE_FAILURE_ERROR 400
312
/* ------------------------------------------------------------------------- */
313
/* ERROR CODES FROM ACC */
314
/* ------------------------------------------------------------------------- */
315
#define ZNO_TUPLE_FOUND 626
316
#define ZTUPLE_ALREADY_EXIST 630
317
/* ------------------------------------------------------------------------- */
318
/* ERROR CODES FROM TUP */
319
/* ------------------------------------------------------------------------- */
320
#define ZSEARCH_CONDITION_FALSE 899
321
#define ZUSER_ERROR_CODE_LIMIT 6000
327
* @section secIntro Introduction
329
* Dblqh is the coordinator of the LDM. Dblqh is responsible for
330
* performing operations on tuples. It does this job with help of
331
* Dbacc block (that manages the index structures) and Dbtup
332
* (that manages the tuples).
334
* Dblqh also keeps track of the participants and acts as a coordinator of
335
* 2-phase commits. Logical redo logging is also handled by the Dblqh
338
* @section secModules Modules
340
* The code is partitioned into the following modules:
342
* - Start phase 1: Load our block reference and our processor id
343
* - Start phase 2: Initiate all records within the block
344
* Connect LQH with ACC and TUP.
345
* - Start phase 4: Connect LQH with LQH. Connect every LQH with
346
* every LQH in the database system.
347
* If initial start, then create the fragment log files.
348
* If system restart or node restart,
349
* then open the fragment log files and
350
* find the end of the log files.
351
* - ADD / DELETE FRAGMENT<br>
352
* Used by dictionary to create new fragments and delete old fragments.
354
* handles the reception of lqhkeyreq and all processing
355
* of operations on behalf of this request.
356
* This does also involve reception of various types of attrinfo
358
* It also involves communication with ACC and TUP.
360
* The log module handles the reading and writing of the log.
361
* It is also responsible for handling system restart.
362
* It controls the system restart in TUP and ACC as well.
364
* This module handles the commit and the complete phases.
365
* - MODULE TO HANDLE TC FAILURE<br>
367
* This module contains the code that handles a scan of a particular
369
* It operates under the control of TC and orders ACC to
370
* perform a scan of all tuples in the fragment.
371
* TUP performs the necessary search conditions
372
* to ensure that only valid tuples are returned to the application.
373
* - NODE RECOVERY<br>
374
* Used when a node has failed.
375
* It performs a copy of a fragment to a new replica of the fragment.
376
* It does also shut down all connections to the failed node.
377
* - LOCAL CHECKPOINT<br>
378
* Handles execution and control of LCPs
379
* It controls the LCPs in TUP and ACC.
380
* It also interacts with DIH to control which GCPs are recoverable.
381
* - GLOBAL CHECKPOINT<br>
382
* Helps DIH in discovering when GCPs are recoverable.
383
* It handles the request gcp_savereq that requests LQH to
384
* save a particular GCP to disk and respond when completed.
385
* - FILE HANDLING<br>
391
* - SYSTEM RESTART PHASE ONE
392
* - SYSTEM RESTART PHASE TWO,
393
* - SYSTEM RESTART PHASE THREE
394
* - SYSTEM RESTART PHASE FOUR
399
class Dblqh: public SimulatedBlock {
403
LCP_RUNNING = 1, // LCP is running
404
LCP_CLOSE_STARTED = 2, // Completion(closing of files) has started
405
ACC_LCP_CLOSE_COMPLETED = 3,
406
TUP_LCP_CLOSE_COMPLETED = 4
409
enum ExecUndoLogState {
415
struct AddFragRecord {
425
LqhAddAttrReq::Entry attributes[LqhAddAttrReq::MAX_ATTRIBUTES];
427
AddFragStatus addfragStatus;
428
UintR dictConnectptr;
430
UintR nextAddfragrec;
434
UintR checksumIndicator;
436
BlockReference dictBlockref;
437
Uint32 m_senderAttrPtr;
438
Uint16 addfragErrorCode;
439
Uint16 attrSentToTup;
445
Uint16 totalAttrReceived;
446
Uint16 fragCopyCreation;
451
Uint16 primaryTableId;
452
Uint32 tablespace_id;
457
Uint32 forceVarPartFlag;
459
typedef Ptr<AddFragRecord> AddFragRecordPtr;
461
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
462
/* $$$$$$$ ATTRIBUTE INFORMATION RECORD $$$$$$$ */
463
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
465
* Can contain one (1) attrinfo signal.
466
* One signal contains 24 attr. info words.
467
* But 32 elements are used to make plex happy.
468
* Some of the elements are used to the following things:
469
* - Data length in this record is stored in the
470
* element indexed by ZINBUF_DATA_LEN.
471
* - Next attrinbuf is pointed out by the element
472
* indexed by ZINBUF_NEXT.
477
typedef Ptr<Attrbuf> AttrbufPtr;
479
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
480
/* $$$$$$$ DATA BUFFER $$$$$$$ */
481
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
483
* This buffer is used as a general data storage.
489
typedef Ptr<Databuf> DatabufPtr;
495
WAIT_STORED_PROC_COPY = 1,
496
WAIT_STORED_PROC_SCAN = 2,
497
WAIT_NEXT_SCAN_COPY = 3,
499
WAIT_DELETE_STORED_PROC_ID_SCAN = 5,
500
WAIT_DELETE_STORED_PROC_ID_COPY = 6,
503
WAIT_SCAN_NEXTREQ = 10,
504
WAIT_CLOSE_SCAN = 12,
505
WAIT_CLOSE_COPY = 13,
506
WAIT_RELEASE_LOCK = 14,
507
WAIT_TUPKEY_COPY = 15,
508
WAIT_LQHKEY_COPY = 16,
517
UintR scan_acc_op_ptr[32];
518
Uint32 scan_acc_index;
519
Uint32 scan_acc_attr_recs;
523
Uint32 m_max_batch_size_rows;
524
Uint32 m_max_batch_size_bytes;
526
Uint32 m_curr_batch_size_rows;
527
Uint32 m_curr_batch_size_bytes;
529
bool check_scan_batch_completed() const;
539
bool equal(const ScanRecord & key) const {
540
return scanNumber == key.scanNumber && fragPtrI == key.fragPtrI;
542
Uint32 hashValue() const {
543
return fragPtrI ^ scanNumber;
548
UintR scanErrorCounter;
549
UintR scanSchemaVersion;
552
* This is _always_ main table, even in range scan
553
* in which case scanTcrec->fragmentptr is different
556
UintR scanStoredProcId;
560
BlockReference scanApiBlockref;
562
Uint16 scanReleaseCounter;
565
// scan source block ACC TUX TUP
566
BlockReference scanBlockref;
568
Uint8 scanCompletedStatus;
578
Uint8 scanKeyinfoFlag;
581
typedef Ptr<ScanRecord> ScanRecordPtr;
591
* Possible state transitions are:
592
* - FREE -> DEFINED Fragment record is allocated
593
* - DEFINED -> ACTIVE Add fragment is completed and
594
* fragment is ready to
595
* receive operations.
596
* - DEFINED -> ACTIVE_CREATION Add fragment is completed and
597
* fragment is ready to
598
* receive operations in parallel
599
* with a copy fragment
600
* which is performed from the
602
* - DEFINED -> CRASH_RECOVERING A fragment is ready to be
603
* recovered from a local
605
* - ACTIVE -> BLOCKED A local checkpoint is to be
606
* started. No more operations
607
* are allowed to be started until
608
* the local checkpoint
610
* - ACTIVE -> REMOVING A fragment is removed from the node
611
* - BLOCKED -> ACTIVE Operations are allowed again in
613
* - CRASH_RECOVERING -> ACTIVE A fragment has been recovered and
616
* - CRASH_RECOVERING -> REMOVING Fragment recovery failed or
618
* - ACTIVE_CREATION -> ACTIVE A fragment is now copied and now
619
* is a normal fragment
620
* - ACTIVE_CREATION -> REMOVING Copying of the fragment failed
621
* - REMOVING -> FREE Removing of the fragment is
622
* completed and the fragment
626
FREE = 0, ///< Fragment record is currently not in use
627
FSACTIVE = 1, ///< Fragment is defined and usable for operations
628
DEFINED = 2, ///< Fragment is defined but not yet usable by
630
BLOCKED = 3, ///< LQH is waiting for all active operations to
631
///< complete the current phase so that the
632
///< local checkpoint can be started.
633
ACTIVE_CREATION = 4, ///< Fragment is defined and active but is under
634
///< creation by the primary LQH.
635
CRASH_RECOVERING = 5, ///< Fragment is recovering after a crash by
636
///< executing the fragment log and so forth.
637
///< Will need further breakdown.
638
REMOVING = 6 ///< The fragment is currently removed.
639
///< Operations are not allowed.
655
* Last GCI for executing the fragment log in this phase.
657
UintR execSrLastGci[4];
659
* Start GCI for executing the fragment log in this phase.
661
UintR execSrStartGci[4];
663
* Requesting user pointer for executing the fragment log in
666
UintR execSrUserptr[4];
668
* The LCP identifier of the LCP's.
669
* =0 means that the LCP number has not been stored.
670
* The LCP identifier is supplied by DIH when starting the LCP.
672
UintR lcpId[MAX_LCP_STORED];
675
* This variable contains the maximum global checkpoint
676
* identifier that exists in a certain local checkpoint.
677
* Maximum 4 local checkpoints is possible in this release.
679
UintR maxGciCompletedInLcp;
683
* The fragment pointers in ACC
687
* The EXEC_SR variables are used to keep track of which fragments
688
* that are interested in being executed as part of executing the
690
* It is initialised for every phase of executing the
691
* fragment log (the fragment log can be executed upto four times).
693
* Each execution is capable of executing the log records on four
697
* Requesting block reference for executing the fragment log
700
BlockReference execSrBlockref[4];
702
* This variable contains references to active scan and copy
703
* fragment operations on the fragment.
704
* A maximum of four concurrently active is allowed.
706
typedef Bitmask<4> ScanNumberMask;
707
ScanNumberMask m_scanNumberMask;
708
DLList<ScanRecord>::Head m_activeScans;
709
DLFifoList<ScanRecord>::Head m_queuedScans;
711
Uint16 srLqhLognode[4];
713
* The fragment pointers in TUP and TUX
719
* This variable keeps track of how many operations that are
720
* active that have skipped writing the log but not yet committed
721
* or aborted. This is used during start of fragment.
723
UintR activeTcCounter;
726
* This status specifies whether this fragment is actively
727
* engaged in executing the fragment log.
729
ExecSrStatus execSrStatus;
732
* The fragment id of this fragment.
739
FragStatus fragStatus;
742
* 0 = undefined i.e fragStatus != ACTIVE_CREATION
747
AC_NORMAL = 0, // fragStatus != ACTIVE_CREATION
748
AC_IGNORED = 1, // Operation that got ignored during NR
749
AC_NR_COPY = 2 // Operation that got performed during NR
751
Uint8 m_copy_started_state;
754
* This flag indicates whether logging is currently activated at
756
* During a system restart it is temporarily shut off.
757
* Some fragments have it permanently shut off.
762
* This variable contains the maximum global checkpoint identifier
763
* which was completed when the local checkpoint was started.
766
* Reference to the next fragment record in a free list of fragment
776
* The newest GCI that has been committed on fragment
782
* The starting global checkpoint of this fragment.
786
* A reference to the table owning this fragment.
791
* This is the queue to put operations that have been blocked
792
* during start of a local chkp.
794
UintR firstWaitQueue;
798
* The block reference to ACC on the fragment makes it
799
* possible to have different ACC blocks for different
800
* fragments in the future.
802
BlockReference accBlockref;
805
* Ordered index block.
807
BlockReference tuxBlockref;
809
* The master block reference as sent in COPY_ACTIVEREQ.
811
BlockReference masterBlockref;
813
* These variables are used during system restart to recall
814
* from which node to execute the fragment log and which GCI's
815
* this node should start and stop from. Also to remember who
816
* to send the response to when system restart is completed.
818
BlockReference srBlockref;
820
* The block reference to TUP on the fragment makes it
821
* possible to have different TUP blocks for different
822
* fragments in the future.
824
BlockReference tupBlockref;
826
* This state indicates if the fragment will participate in a
828
* Temporary tables with Fragrecord::logFlag permanently off
829
* will also have Fragrecord::lcpFlag off.
833
* Used to ensure that updates started with old
834
* configuration do not arrive here after the copy fragment
836
* If they are allowed to arrive after they
837
* could update a record that has already been replicated to
838
* the new node. This type of arrival should be extremely
839
* rare but we must anyway ensure that no harm is done.
843
* This variable ensures that only one copy fragment is
844
* active at a time on the fragment.
848
* The number of fragment replicas that will execute the log
849
* records in this round of executing the fragment
850
* log. Maximum four is possible.
852
Uint8 execSrNoReplicas;
854
* This variable contains what type of replica this fragment
855
* is. Two types are possible:
856
* - Primary/Backup replica = 0
857
* - Stand-by replica = 1
859
* It is not possible to distinguish between primary and
860
* backup on a fragment.
861
* This can only be done per transaction.
862
* DIH can change from primary to backup without informing
863
* the various replicas about this change.
867
* This is the last fragment distribution key that we have
870
Uint8 fragDistributionKey;
872
* How many local checkpoints does the fragment contain
881
* For ordered index fragment, i-value of corresponding
882
* fragment in primary table.
889
Uint32 m_log_part_ptr_i;
891
typedef Ptr<Fragrecord> FragrecordPtr;
893
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
894
/* $$$$$$$ GLOBAL CHECKPOINT RECORD $$$$$$ */
895
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
897
* This record describes a global checkpoint that is
898
* completed. It waits for all log records belonging to this
899
* global checkpoint to be saved on disk.
903
* The file number within each log part where the log was
904
* located when gcp_savereq was received. The last record
905
* belonging to this global checkpoint is certainly before
906
* this place in the log. We could come even closer but it
907
* would cost performance and doesn't seem like a good
908
* idea. This is simple and it works.
910
Uint16 gcpFilePtr[4];
912
* The page number within the file for each log part.
916
* The word number within the last page that was written for
921
* The identity of this global checkpoint.
925
* The state of this global checkpoint, one for each log part.
927
Uint8 gcpLogPartState[4];
929
* The sync state of this global checkpoint, one for each
932
Uint8 gcpSyncReady[4];
934
* User pointer of the sender of gcp_savereq (= master DIH).
938
* Block reference of the sender of gcp_savereq
941
BlockReference gcpBlockref;
943
typedef Ptr<GcpRecord> GcpRecordPtr;
947
UintR noOfPackedWordsLqh;
948
UintR packedWordsLqh[30];
949
UintR noOfPackedWordsTc;
950
UintR packedWordsTc[29];
951
BlockReference hostLqhBlockRef;
952
BlockReference hostTcBlockRef;
954
typedef Ptr<HostRecord> HostRecordPtr;
956
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
957
/* $$$$$$ LOCAL CHECKPOINT SUPPORT RECORD $$$$$$$ */
958
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
960
* This record contains the information about an outstanding
961
* request to TUP or ACC. Used for both local checkpoints and
964
struct LcpLocRecord {
967
WAIT_TUP_PREPLCP = 1,
970
ACC_WAIT_STARTED = 4,
973
TUP_WAIT_STARTED = 7,
978
SR_ACC_COMPLETED = 12,
979
SR_TUP_COMPLETED = 13
981
LcpLocstate lcpLocstate;
984
typedef Ptr<LcpLocRecord> LcpLocRecordPtr;
986
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
987
/* $$$$$$$ LOCAL CHECKPOINT RECORD $$$$$$$ */
988
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
990
* This record contains the information about a local
991
* checkpoint that is ongoing. This record is also used as a
992
* system restart record.
995
LcpRecord() { m_EMPTY_LCP_REQ.clear(); }
1000
LCP_WAIT_FRAGID = 3,
1001
LCP_WAIT_TUP_PREPLCP = 4,
1002
LCP_WAIT_HOLDOPS = 5,
1004
LCP_BLOCKED_COMP = 8,
1005
LCP_SR_WAIT_FRAGID = 9,
1006
LCP_SR_STARTED = 10,
1007
LCP_SR_COMPLETED = 11
1011
bool firstFragmentFlag;
1012
bool lastFragmentFlag;
1016
LcpFragOrd lcpFragOrd;
1018
FragOrd currentFragment;
1021
FragOrd queuedFragment;
1024
NdbNodeBitmask m_EMPTY_LCP_REQ;
1027
Uint32 m_outstanding;
1029
typedef Ptr<LcpRecord> LcpRecordPtr;
1031
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1032
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1034
/* THE RECORDS THAT START BY LOG_ ARE A PART OF THE LOG MANAGER. */
1035
/* THESE RECORDS ARE USED TO HANDLE THE FRAGMENT LOG. */
1037
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1038
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1039
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1040
/* $$$$$$$ LOG RECORD $$$$$$$ */
1042
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1043
/* THIS RECORD IS ALIGNED TO BE 256 BYTES. */
1044
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1046
* This record describes the current state of a log.
1047
* A log consists of a number of log files.
1048
* These log files are described by the log file record.
1050
* There will be 4 sets of log files.
1051
* Different tables will use different log files dependent
1053
* This ensures that more than one outstanding request can
1054
* be sent to the file system.
1055
* The log file to use is found by performing a very simple hash
1058
struct LogPartRecord {
1060
IDLE = 0, ///< Nothing happens at the moment
1061
ACTIVE = 1, ///< An operation is active logging
1062
SR_FIRST_PHASE = 2, ///< Finding the end of the log and
1063
///< the information about global
1064
///< checkpoints in the log is ongoing.
1065
SR_FIRST_PHASE_COMPLETED = 3, ///< First phase completed
1066
SR_THIRD_PHASE_STARTED = 4, ///< Executing fragment log is in 3rd ph
1067
SR_THIRD_PHASE_COMPLETED = 5,
1068
SR_FOURTH_PHASE_STARTED = 6, ///< Finding the log tail and head
1069
///< is the fourth phase.
1070
SR_FOURTH_PHASE_COMPLETED = 7,
1071
FILE_CHANGE_PROBLEM = 8, ///< For some reason the write to
1072
///< page zero in file zero have not
1073
///< finished after 15 mbyte of
1074
///< log data have been written
1075
TAIL_PROBLEM = 9 ///< Only 1 mbyte of log left.
1076
///< No operations allowed to enter the
1077
///< log. Only special log records
1080
enum WaitWriteGciLog {
1086
LES_SEARCH_STOP = 1,
1087
LES_SEARCH_START = 2,
1089
LES_EXEC_LOG_NEW_MBYTE = 4,
1090
LES_EXEC_LOG_NEW_FILE = 5,
1091
LES_EXEC_LOGREC_FROM_FILE = 6,
1092
LES_EXEC_LOG_COMPLETED = 7,
1093
LES_WAIT_READ_EXEC_SR_NEW_MBYTE = 8,
1094
LES_WAIT_READ_EXEC_SR = 9,
1095
LES_EXEC_LOG_INVALIDATE = 10
1099
* Is a CONTINUEB(ZLOG_LQHKEYREQ) signal sent and
1100
* outstanding. We do not want several instances of this
1101
* signal out in the air since that would create multiple
1102
* writers of the list.
1104
UintR LogLqhKeyReqSent;
1106
* Contains the current log file where log records are
1107
* written. During system restart it is used to indicate the
1110
UintR currentLogfile;
1112
* The log file used to execute log records from far behind.
1114
UintR execSrExecLogFile;
1116
* The currently executing prepare record starts in this log
1117
* page. This variable is used to enable that a log record is
1118
* executed multiple times in execution of the log.
1120
UintR execSrLogPage;
1122
* This variable keeps track of the lfo record where the
1123
* pages that were read from disk when an operations log
1124
* record were not found in the main memory buffer for log
1129
* The starting page number when reading log from far behind.
1131
UintR execSrStartPageNo;
1133
* The last page number when reading log from far behind.
1135
UintR execSrStopPageNo;
1137
* Contains a reference to the first log file, file number 0.
1141
* The head of the operations queued for logging.
1143
UintR firstLogQueue;
1145
* This variable contains the oldest operation in this log
1146
* part which have not been committed yet.
1148
UintR firstLogTcrec;
1150
* The first reference to a set of 8 pages. These are used
1151
* during execution of the log to keep track of which pages
1152
* are in memory and which are not.
1156
* This variable contains the global checkpoint record
1157
* waiting for disk writes to complete.
1161
* The last reference to a set of 8 pages. These are used
1162
* during execution of the log to keep track of which pages
1163
* are in memory and which are not.
1167
* The tail of the operations queued for logging.
1171
* This variable contains the newest operation in this log
1172
* part which have not been committed yet.
1176
* This variable indicates which was the last mbyte that was
1177
* written before the system crashed. Discovered during
1182
* This variable is used to keep track of the state during
1183
* the third phase of the system restart, i.e. when
1184
* LogPartRecord::logPartState ==
1185
* LogPartRecord::SR_THIRD_PHASE_STARTED.
1187
LogExecState logExecState;
1189
* This variable contains the lap number of this log part.
1193
* This variable contains the place to stop executing the log
1198
* This variable contains the place to start executing the
1199
* log in this phase.
1203
* The latest GCI completed in this log part.
1205
UintR logPartNewestCompletedGCI;
1207
* The current state of this log part.
1209
LogPartState logPartState;
1211
* A timer that is set every time a log page is sent to disk.
1212
* Ensures that log pages are not kept in main memory for
1213
* more than a certain time.
1217
* The current timer which is set by the periodic signal
1222
* Contains the number of the log tail file and the mbyte
1223
* reference within that file. This information ensures that
1224
* the tail is not overwritten when writing new log records.
1226
UintR logTailFileNo;
1228
* The TcConnectionrec used during execution of this log part.
1232
* The number of pages that currently resides in the main
1233
* memory buffer. It does not refer pages that are currently
1234
* read from the log files. Only to pages already read
1235
* from the log file.
1239
* Contains the current number of log files in this log part.
1243
* This variable is used only during execution of a log
1244
* record. It keeps track of in which page record a log
1245
* record was started. It is used then to deduce which
1246
* pages that are dirty after that the log records on the
1247
* page have been executed.
1249
* It is also used to find out where to write the invalidate
1250
* command when that is needed.
1254
* The number of files remaining to gather GCI information
1255
* for during system restart. Only used if number of files
1256
* is larger than 60.
1258
UintR srRemainingFiles;
1260
* The log file where to start executing the log during
1265
* The last log file in which to execute the log during system
1270
* This variable keeps track of when we want to write a complete
1271
* gci log record but have been blocked by an ongoing log operation.
1273
WaitWriteGciLog waitWriteGciLog;
1275
* The currently executing prepare record starts in this index
1278
Uint16 execSrLogPageIndex;
1280
* Which of the four exec_sr's in the fragment is currently executing
1282
Uint16 execSrExecuteIndex;
1284
* The number of pages executed in the current mbyte.
1286
Uint16 execSrPagesExecuted;
1288
* The number of pages read from disk that have arrived and are
1289
* currently awaiting execution of the log.
1291
Uint16 execSrPagesRead;
1293
* The number of pages read from disk and currently not arrived
1296
Uint16 execSrPagesReading;
1298
* This variable refers to the new header file where we will
1299
* start writing the log after a system restart have been completed.
1303
* This variable refers to the page number within the header file.
1307
* This variable refers to the index within the new header
1310
Uint16 headPageIndex;
1312
* This variables indicates which was the last mbyte in the last
1313
* logfile before a system crash. Discovered during system restart.
1317
* This variable is used only during execution of a log
1318
* record. It keeps track of in which file page a log
1319
* record was started. It is used if it is needed to write a
1320
* dirty page to disk during log execution (this happens when
1321
* commit records are invalidated).
1323
Uint16 prevFilepage;
1325
* This is used to save where we were in the execution of log
1326
* records when we find a commit record that needs to be
1329
* This variable is also used to remember the index where the
1330
* log type was in the log record. It is only used in this
1331
* role when finding a commit record that needs to be
1334
Uint16 savePageIndex;
1337
* The mbyte within the starting log file where to start
1338
* executing the log.
1342
* The last mbyte in which to execute the log during system
1347
* This variable refers to the file where invalidation is
1348
* occuring during system/node restart.
1350
Uint16 invalidateFileNo;
1352
* This variable refers to the page where invalidation is
1353
* occuring during system/node restart.
1355
Uint16 invalidatePageNo;
1356
}; // Size 164 Bytes
1357
typedef Ptr<LogPartRecord> LogPartRecordPtr;
1359
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1360
/* $$$$$$$ LOG FILE RECORD $$$$$$$ */
1361
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1362
/* THIS RECORD IS ALIGNED TO BE 288 (256 + 32) BYTES. */
1363
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1365
* This record contains information about a log file.
1366
* A log file contains log records from several tables and
1367
* fragments of a table. LQH can contain more than
1368
* one log file to ensure faster log processing.
1370
* The number of pages to write to disk at a time is
1373
struct LogFileRecord {
1374
enum FileChangeState {
1376
BOTH_WRITES_ONGOING = 1,
1377
LAST_WRITE_ONGOING = 2,
1378
FIRST_WRITE_ONGOING = 3,
1379
WRITE_PAGE_ZERO_ONGOING = 4
1381
enum LogFileStatus {
1382
LFS_IDLE = 0, ///< Log file record not in use
1383
CLOSED = 1, ///< Log file closed
1385
OPEN_SR_FRONTPAGE = 3, ///< Log file opened as part of system
1386
///< restart. Open file 0 to find
1387
///< the front page of the log part.
1388
OPEN_SR_LAST_FILE = 4, ///< Open last log file that was written
1389
///< before the system restart.
1390
OPEN_SR_NEXT_FILE = 5, ///< Open a log file which is 16 files
1391
///< backwards to find the next
1392
///< information about GCPs.
1393
OPEN_EXEC_SR_START = 6, ///< Log file opened as part of
1395
///< log during system restart.
1396
OPEN_EXEC_SR_NEW_MBYTE = 7,
1397
OPEN_SR_FOURTH_PHASE = 8,
1398
OPEN_SR_FOURTH_NEXT = 9,
1399
OPEN_SR_FOURTH_ZERO = 10,
1400
OPENING_WRITE_LOG = 11, ///< Log file opened as part of writing
1401
///< log during normal operation.
1404
CLOSING_SR = 14, ///< Log file closed as part of system
1405
///< restart. Currently trying to
1406
///< find where to start executing the
1408
CLOSING_EXEC_SR = 15, ///< Log file closed as part of
1409
///< executing log during system restart
1410
CLOSING_EXEC_SR_COMPLETED = 16,
1411
CLOSING_WRITE_LOG = 17, ///< Log file closed as part of writing
1412
///< log during normal operation.
1413
CLOSING_EXEC_LOG = 18,
1415
OPEN = 20, ///< Log file open
1416
OPEN_SR_INVALIDATE_PAGES = 21,
1417
CLOSE_SR_INVALIDATE_PAGES = 22
1421
* When a new mbyte is started in the log we have to find out
1422
* how far back in the log we still have prepared operations
1423
* which have been neither committed or aborted. This variable
1424
* keeps track of this value for each of the mbytes in this
1425
* log file. This is used in writing down these values in the
1426
* header of each log file. That information is used during
1427
* system restart to find the tail of the log.
1429
UintR *logLastPrepRef;
1431
* The max global checkpoint completed before the mbyte in the
1432
* log file was started. One variable per mbyte.
1434
UintR *logMaxGciCompleted;
1436
* The max global checkpoint started before the mbyte in the log
1437
* file was started. One variable per mbyte.
1439
UintR *logMaxGciStarted;
1441
* This variable contains the file name as needed by the file
1442
* system when opening the file.
1446
* This variable has a reference to the log page which is
1447
* currently in use by the log.
1449
UintR currentLogpage;
1451
* The number of the current mbyte in the log file.
1455
* This variable is used when changing files. It is to find
1456
* out when both the last write in the previous file and the
1457
* first write in this file has been completed. After these
1458
* writes have completed the variable keeps track of when the
1459
* write to page zero in file zero is completed.
1461
FileChangeState fileChangeState;
1463
* The number of the file within this log part.
1467
* This variable shows where to read/write the next pages into
1468
* the log. Used when writing the log during normal operation
1469
* and when reading the log during system restart. It
1470
* specifies the page position where each page is 8 kbyte.
1474
* This contains the file pointer needed by the file system
1475
* when reading/writing/closing and synching.
1479
* The head of the pages waiting for shipment to disk.
1480
* They are filled with log info.
1482
UintR firstFilledPage;
1484
* A list of active read/write operations on the log file.
1485
* Operations are always put in last and the first should
1486
* always complete first.
1491
* The tail of the pages waiting for shipment to disk.
1492
* They are filled with log info.
1494
UintR lastFilledPage;
1496
* This variable keeps track of the last written page in the
1497
* file while writing page zero in file zero when changing log
1500
UintR lastPageWritten;
1502
* This variable keeps track of the last written word in the
1503
* last page written in the file while writing page zero in
1504
* file zero when changing log file.
1506
UintR lastWordWritten;
1508
* This variable contains the last word written in the last page.
1510
LogFileStatus logFileStatus;
1512
* A reference to page zero in this file.
1513
* This page is written before the file is closed.
1517
* This variable contains a reference to the record describing
1518
* this log part. One of four records (0,1,2 or 3).
1522
* Next free log file record or next log file in this log.
1526
* The previous log file.
1530
* The number of remaining words in this mbyte of the log file.
1532
UintR remainingWordsInMbyte;
1534
* The current file page within the current log file. This is
1535
* a reference within the file and not a reference to a log
1536
* page record. It is used to deduce where log records are
1537
* written. Particularly completed gcp records and prepare log
1540
Uint16 currentFilepage;
1542
* The number of pages in the list referenced by
1545
Uint16 noLogpagesInBuffer;
1546
}; // Size 288 bytes
1547
typedef Ptr<LogFileRecord> LogFileRecordPtr;
1549
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1550
/* $$$$$$$ LOG OPERATION RECORD $$$$$$$ */
1551
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1553
* This record contains a currently active file operation
1554
* that has started by the log module.
1556
struct LogFileOperationRecord {
1558
IDLE = 0, ///< Operation is not used at the moment
1559
INIT_WRITE_AT_END = 1, ///< Write in file so that it grows to
1561
INIT_FIRST_PAGE = 2, ///< Initialise the first page in a file
1563
WRITE_INIT_MBYTE = 4,
1565
READ_SR_FRONTPAGE = 6, ///< Read page zero in file zero during
1567
READ_SR_LAST_FILE = 7, ///< Read page zero in last file open
1568
///< before system crash
1569
READ_SR_NEXT_FILE = 8, ///< Read 60 files backwards to find
1570
///< further information GCPs in page
1572
READ_SR_LAST_MBYTE = 9,
1575
READ_SR_FOURTH_PHASE = 12,
1576
READ_SR_FOURTH_ZERO = 13,
1577
FIRST_PAGE_WRITE_IN_LOGFILE = 14,
1578
LAST_WRITE_IN_FILE = 15,
1579
WRITE_PAGE_ZERO = 16,
1580
ACTIVE_WRITE_LOG = 17, ///< A write operation during
1582
READ_SR_INVALIDATE_PAGES = 18,
1583
WRITE_SR_INVALIDATE_PAGES = 19,
1584
WRITE_SR_INVALIDATE_PAGES_UPDATE_PAGE0 = 20
1587
* We have to remember the log pages read.
1588
* Otherwise we cannot build the linked list after the pages have
1589
* arrived to main memory.
1591
UintR logPageArray[16];
1593
* A list of the pages that are part of this active operation.
1597
* A timer to ensure that records are not lost.
1601
* The word number of the last written word in the last during
1604
UintR lfoWordWritten;
1606
* This variable contains the state of the log file operation.
1610
* The log file that the file operation affects.
1614
* The log file operations on a file are kept in a linked list.
1618
* The page number of the first read/written page during a file
1623
* The number of pages written or read during an operation to
1628
typedef Ptr<LogFileOperationRecord> LogFileOperationRecordPtr;
1630
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1631
/* $$$$$$$ LOG PAGE RECORD $$$$$$$ */
1632
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
1634
* These are the 8 k pages used to store log records before storing
1635
* them in the file system.
1636
* Since 64 kbyte is sent to disk at a time it is necessary to have
1637
* at least 4*64 kbytes of log pages.
1638
* To handle multiple outstanding requests we need some additional pages.
1639
* Thus we allocate 1 mbyte to ensure that we do not get problems with
1640
* insufficient number of pages.
1642
struct LogPageRecord {
1644
* This variable contains the pages that are sent to disk.
1646
* All pages contain a header of 12 words:
1647
* - WORD 0: CHECKSUM Calculated before storing on disk and
1648
* checked when read from disk.
1649
* - WORD 1: LAP How many wraparounds have the log
1650
* experienced since initial start of the
1652
* - WORD 2: MAX_GCI_COMPLETED Which is the maximum gci which have
1653
* completed before this page. This
1654
* gci will not be found in this
1655
* page and hereafter in the log.
1656
* - WORD 3: MAX_GCI_STARTED The maximum gci which have started
1658
* - WORD 4: NEXT_PAGE Pointer to the next page.
1659
* Only used in main memory
1660
* - WORD 5: PREVIOUS_PAGE Pointer to the previous page.
1661
* Currently not used.
1662
* - WORD 6: VERSION NDB version that wrote the page.
1663
* - WORD 7: NO_LOG_FILES Number of log files in this log part.
1664
* - WORD 8: CURRENT PAGE INDEX This keeps track of where we are in the
1666
* This is only used when pages is in
1668
* - WORD 9: OLD PREPARE FILE NO This keeps track of the oldest prepare
1669
* operation still alive (not committed
1670
* or aborted) when this mbyte started.
1671
* - WORD 10: OLD PREPARE PAGE REF File page reference within this file
1673
* Page no + Page index.
1674
* If no prepare was alive then these
1675
* values points this mbyte.
1676
* - WORD 11: DIRTY FLAG = 0 means not dirty and
1677
* = 1 means the page is dirty.
1678
* Is used when executing log when
1679
* a need to write invalid commit
1682
* The remaining 2036 words are used for log information, i.e.
1685
* A log record on this page has the following layout:
1686
* - WORD 0: LOG RECORD TYPE
1687
* The following types are supported:
1688
* - PREPARE OPERATION An operation not yet committed.
1689
* - NEW PREPARE OPERATION A prepared operation already
1690
* logged is inserted
1691
* into the log again so that the
1692
* log tail can be advanced.
1693
* This can happen when a transaction is
1694
* committed for a long time.
1695
* - ABORT TRANSACTION A previously prepared transaction
1697
* - COMMIT TRANSACTION A previously prepared transaction
1699
* - INVALID COMMIT A previous commit record was
1701
* subsequent system restart.
1702
* A log record must be invalidated
1703
* in a system restart if it belongs
1704
* to a global checkpoint id which
1705
* is not included in the system
1707
* Otherwise it will be included in
1708
* a subsequent system restart since
1709
* it will then most likely belong
1710
* to a global checkpoint id which
1711
* is part of that system
1713
* This is not a correct behaviour
1714
* since this operation is lost in a
1715
* system restart and should not
1716
* reappear at a later system
1718
* - COMPLETED GCI A GCI has now been completed.
1719
* - FRAGMENT SPLIT A fragment has been split
1720
* (not implemented yet)
1721
* - FILE DESCRIPTOR This is always the first log record
1723
* It is always placed on page 0 after
1725
* It is written when the file is
1726
* opened and when the file is closed.
1727
* - NEXT LOG RECORD This log record only records where
1728
* the next log record starts.
1729
* - NEXT MBYTE RECORD This log record specifies that there
1730
* are no more log records in this mbyte.
1733
* A FILE DESCRIPTOR log record continues as follows:
1734
* - WORD 1: NO_LOG_DESCRIPTORS This defines the number of
1735
* descriptors of log files that
1736
* will follow hereafter (max 32).
1737
* the log descriptor will describe
1739
* max_gci_completed,
1740
* max_gci_started and log_lap at
1741
* every 1 mbyte of the log file
1742
* since a log file is 16 mbyte
1743
* always, i need 16 entries in the
1744
* array with max_gci_completed,
1745
* max_gci_started and log_lap. thus
1746
* 32 entries per log file
1747
* descriptor (max 32*48 = 1536,
1748
* always fits in page 0).
1749
* - WORD 2: LAST LOG FILE The number of the log file currently
1750
* open. This is only valid in file 0.
1751
* - WORD 3 - WORD 18: MAX_GCI_COMPLETED for every 1 mbyte
1753
* - WORD 19 - WORD 34: MAX_GCI_STARTED for every 1 mbyte
1756
* Then it continues for NO_LOG_DESCRIPTORS until all subsequent
1757
* log files (max 32) have been properly described.
1760
* A PREPARE OPERATION log record continues as follows:
1761
* - WORD 1: LOG RECORD SIZE
1762
* - WORD 2: HASH VALUE
1763
* - WORD 3: SCHEMA VERSION
1764
* - WORD 4: OPERATION TYPE
1769
* - WORD 5: NUMBER OF WORDS IN ATTRINFO PART
1770
* - WORD 6: KEY LENGTH IN WORDS
1771
* - WORD 7 - (WORD 7 + KEY_LENGTH - 1) The tuple key
1772
* - (WORD 7 + KEY_LENGTH) -
1773
* (WORD 7 + KEY_LENGTH + ATTRINFO_LENGTH - 1) The attrinfo
1775
* A log record can be spread in several pages in some cases.
1776
* The next log record always starts immediately after this log record.
1777
* A log record does however never traverse a 1 mbyte boundary.
1778
* This is used to ensure that we can always come back if something
1779
* strange occurs in the log file.
1780
* To ensure this we also have log records which only records
1781
* the next log record.
1784
* A COMMIT TRANSACTION log record continues as follows:
1785
* - WORD 1: TRANSACTION ID PART 1
1786
* - WORD 2: TRANSACTION ID PART 2
1787
* - WORD 3: FRAGMENT ID OF THE OPERATION
1788
* - WORD 4: TABLE ID OF THE OPERATION
1789
* - WORD 5: THE FILE NUMBER OF THE PREPARE RECORD
1790
* - WORD 6: THE STARTING PAGE NUMBER OF THE PREPARE RECORD
1791
* - WORD 7: THE STARTING PAGE INDEX OF THE PREPARE RECORD
1792
* - WORD 8: THE STOP PAGE NUMBER OF THE PREPARE RECORD
1793
* - WORD 9: GLOBAL CHECKPOINT OF THE TRANSACTION
1796
* An ABORT TRANSACTION log record continues as follows:
1797
* - WORD 1: TRANSACTION ID PART 1
1798
* - WORD 2: TRANSACTION ID PART 2
1801
* A COMPLETED CGI log record continues as follows:
1802
* - WORD 1: THE COMPLETED GCI
1805
* A NEXT LOG RECORD log record continues as follows:
1806
* - There is no more information needed.
1807
* The next log record will always refer to the start of the next page.
1809
* A NEXT MBYTE RECORD log record continues as follows:
1810
* - There is no more information needed.
1811
* The next mbyte will always refer to the start of the next mbyte.
1813
UintR logPageWord[8192]; // Size 32 kbytes
1815
typedef Ptr<LogPageRecord> LogPageRecordPtr;
1817
struct PageRefRecord {
1824
typedef Ptr<PageRefRecord> PageRefRecordPtr;
1830
ADD_TABLE_ONGOING = 2,
1831
PREP_DROP_TABLE_ONGOING = 3,
1832
PREP_DROP_TABLE_DONE = 4
1835
UintR fragrec[MAX_FRAG_PER_NODE];
1836
Uint16 fragid[MAX_FRAG_PER_NODE];
1838
* Status of the table
1840
TableStatus tableStatus;
1842
* Table type and target table of index.
1845
Uint16 primaryTableId;
1846
Uint32 schemaVersion;
1850
NdbNodeBitmask waitingTC;
1851
NdbNodeBitmask waitingDIH;
1852
}; // Size 100 bytes
1853
typedef Ptr<Tablerec> TablerecPtr;
1855
struct TcConnectionrec {
1860
enum LogWriteState {
1863
NOT_WRITTEN_WAIT = 2,
1874
enum TransactionState {
1877
/* -------------------------------------------------------------------- */
1878
// Transaction in progress states
1879
/* -------------------------------------------------------------------- */
1881
WAIT_TUPKEYINFO = 2,
1887
LOG_COMMIT_WRITTEN_WAIT_SIGNAL = 8,
1888
LOG_COMMIT_QUEUED_WAIT_SIGNAL = 9,
1890
/* -------------------------------------------------------------------- */
1891
// Commit in progress states
1892
/* -------------------------------------------------------------------- */
1893
COMMIT_STOPPED = 10,
1894
LOG_COMMIT_QUEUED = 11,
1897
WAIT_TUP_COMMIT= 35,
1899
/* -------------------------------------------------------------------- */
1900
// Abort in progress states
1901
/* -------------------------------------------------------------------- */
1902
WAIT_ACC_ABORT = 14,
1905
WAIT_AI_AFTER_ABORT = 17,
1906
LOG_ABORT_QUEUED = 18,
1907
WAIT_TUP_TO_ABORT = 19,
1909
/* -------------------------------------------------------------------- */
1910
// Scan in progress states
1911
/* -------------------------------------------------------------------- */
1913
SCAN_STATE_USED = 21,
1914
SCAN_FIRST_STOPPED = 22,
1915
SCAN_CHECK_STOPPED = 23,
1917
SCAN_RELEASE_STOPPED = 25,
1918
SCAN_CLOSE_STOPPED = 26,
1919
COPY_CLOSE_STOPPED = 27,
1920
COPY_FIRST_STOPPED = 28,
1925
TC_NOT_CONNECTED = 32,
1926
PREPARED_RECEIVED_COMMIT = 33, // Temporary state in write commit log
1927
LOG_COMMIT_WRITTEN = 34 // Temporary state in write commit log
1935
ConnectState connectState;
1936
UintR copyCountWords;
1937
UintR firstAttrinfo[5];
1938
UintR tupkeyData[4];
1940
AbortState abortState;
1941
UintR accConnectrec;
1943
UintR clientConnectrec;
1947
UintR firstAttrinbuf;
1948
UintR firstTupkeybuf;
1953
UintR lastTupkeybuf;
1954
UintR lastAttrinbuf;
1956
* Each operation (TcConnectrec) can be stored in max one out of many
1958
* This variable keeps track of which list it is in.
1960
ListState listState;
1962
UintR logStartFileNo;
1963
LogWriteState logWriteState;
1966
UintR nextTcLogQueue;
1968
UintR nextTcConnectrec;
1975
UintR schemaVersion;
1977
UintR simpleTcConnect;
1984
UintR tupConnectrec;
1986
TransactionState transactionState;
1987
BlockReference applRef;
1988
BlockReference clientBlockref;
1990
BlockReference reqBlockref;
1991
BlockReference tcBlockref;
1992
BlockReference tcAccBlockref;
1993
BlockReference tcTuxBlockref;
1994
BlockReference tcTupBlockref;
1995
Uint32 commitAckMarker;
1997
Uint32 m_scan_curr_range_no;
1998
UintR noFiredTriggers;
2001
Uint16 logStartPageIndex;
2002
Uint16 logStartPageNo;
2003
Uint16 logStopPageNo;
2007
Uint16 nodeAfterNext[3];
2013
Uint8 lastReplicaNo;
2015
Uint8 nextSeqNoReplica;
2019
Uint8 reclenAiLqhkey;
2020
Uint8 m_offset_current_keybuf;
2023
Uint8 tcNodeFailrec;
2027
Uint32 m_log_part_ptr_i;
2032
Uint32 m_page_id[2];
2033
Local_key m_disk_ref[2];
2035
}; /* p2c: size = 280 bytes */
2037
typedef Ptr<TcConnectionrec> TcConnectionrecPtr;
2039
struct TcNodeFailRecord {
2047
TcFailStatus tcFailStatus;
2049
BlockReference lastNewTcBlockref;
2050
BlockReference newTcBlockref;
2053
typedef Ptr<TcNodeFailRecord> TcNodeFailRecordPtr;
2055
struct CommitLogRecord {
2057
Uint32 startPageIndex;
2063
Dblqh(Block_context& ctx);
2066
void receive_keyinfo(Signal*, Uint32 * data, Uint32 len);
2067
void receive_attrinfo(Signal*, Uint32 * data, Uint32 len);
2070
BLOCK_DEFINES(Dblqh);
2072
void execPACKED_SIGNAL(Signal* signal);
2073
void execDEBUG_SIG(Signal* signal);
2074
void execATTRINFO(Signal* signal);
2075
void execKEYINFO(Signal* signal);
2076
void execLQHKEYREQ(Signal* signal);
2077
void execLQHKEYREF(Signal* signal);
2078
void execCOMMIT(Signal* signal);
2079
void execCOMPLETE(Signal* signal);
2080
void execLQHKEYCONF(Signal* signal);
2081
void execTESTSIG(Signal* signal);
2082
void execLQH_RESTART_OP(Signal* signal);
2083
void execCONTINUEB(Signal* signal);
2084
void execSTART_RECREQ(Signal* signal);
2085
void execSTART_RECCONF(Signal* signal);
2086
void execEXEC_FRAGREQ(Signal* signal);
2087
void execEXEC_FRAGCONF(Signal* signal);
2088
void execEXEC_FRAGREF(Signal* signal);
2089
void execSTART_EXEC_SR(Signal* signal);
2090
void execEXEC_SRREQ(Signal* signal);
2091
void execEXEC_SRCONF(Signal* signal);
2092
void execREAD_PSEUDO_REQ(Signal* signal);
2094
void execDUMP_STATE_ORD(Signal* signal);
2095
void execACC_ABORTCONF(Signal* signal);
2096
void execNODE_FAILREP(Signal* signal);
2097
void execCHECK_LCP_STOP(Signal* signal);
2098
void execSEND_PACKED(Signal* signal);
2099
void execTUP_ATTRINFO(Signal* signal);
2100
void execREAD_CONFIG_REQ(Signal* signal);
2101
void execLQHFRAGREQ(Signal* signal);
2102
void execLQHADDATTREQ(Signal* signal);
2103
void execTUP_ADD_ATTCONF(Signal* signal);
2104
void execTUP_ADD_ATTRREF(Signal* signal);
2105
void execACCFRAGCONF(Signal* signal);
2106
void execACCFRAGREF(Signal* signal);
2107
void execTUPFRAGCONF(Signal* signal);
2108
void execTUPFRAGREF(Signal* signal);
2109
void execTAB_COMMITREQ(Signal* signal);
2110
void execACCSEIZECONF(Signal* signal);
2111
void execACCSEIZEREF(Signal* signal);
2112
void execREAD_NODESCONF(Signal* signal);
2113
void execREAD_NODESREF(Signal* signal);
2114
void execSTTOR(Signal* signal);
2115
void execNDB_STTOR(Signal* signal);
2116
void execTUPSEIZECONF(Signal* signal);
2117
void execTUPSEIZEREF(Signal* signal);
2118
void execACCKEYCONF(Signal* signal);
2119
void execACCKEYREF(Signal* signal);
2120
void execTUPKEYCONF(Signal* signal);
2121
void execTUPKEYREF(Signal* signal);
2122
void execABORT(Signal* signal);
2123
void execABORTREQ(Signal* signal);
2124
void execCOMMITREQ(Signal* signal);
2125
void execCOMPLETEREQ(Signal* signal);
2126
void execMEMCHECKREQ(Signal* signal);
2127
void execSCAN_FRAGREQ(Signal* signal);
2128
void execSCAN_NEXTREQ(Signal* signal);
2129
void execACC_SCANCONF(Signal* signal);
2130
void execACC_SCANREF(Signal* signal);
2131
void execNEXT_SCANCONF(Signal* signal);
2132
void execNEXT_SCANREF(Signal* signal);
2133
void execACC_TO_REF(Signal* signal);
2134
void execSTORED_PROCCONF(Signal* signal);
2135
void execSTORED_PROCREF(Signal* signal);
2136
void execCOPY_FRAGREQ(Signal* signal);
2137
void execPREPARE_COPY_FRAG_REQ(Signal* signal);
2138
void execUPDATE_FRAG_DIST_KEY_ORD(Signal*);
2139
void execCOPY_ACTIVEREQ(Signal* signal);
2140
void execCOPY_STATEREQ(Signal* signal);
2141
void execLQH_TRANSREQ(Signal* signal);
2142
void execTRANSID_AI(Signal* signal);
2143
void execINCL_NODEREQ(Signal* signal);
2145
void execLCP_FRAG_ORD(Signal* signal);
2146
void execEMPTY_LCP_REQ(Signal* signal);
2148
void execSTART_FRAGREQ(Signal* signal);
2149
void execSTART_RECREF(Signal* signal);
2151
void execGCP_SAVEREQ(Signal* signal);
2152
void execFSOPENREF(Signal* signal);
2153
void execFSOPENCONF(Signal* signal);
2154
void execFSCLOSECONF(Signal* signal);
2155
void execFSWRITECONF(Signal* signal);
2156
void execFSWRITEREF(Signal* signal);
2157
void execFSREADCONF(Signal* signal);
2158
void execFSREADREF(Signal* signal);
2159
void execSCAN_HBREP(Signal* signal);
2160
void execTIME_SIGNAL(Signal* signal);
2161
void execFSSYNCCONF(Signal* signal);
2163
void execALTER_TAB_REQ(Signal* signal);
2164
void execALTER_TAB_CONF(Signal* signal);
2166
void execCREATE_TRIG_CONF(Signal* signal);
2167
void execCREATE_TRIG_REF(Signal* signal);
2168
void execCREATE_TRIG_REQ(Signal* signal);
2170
void execDROP_TRIG_CONF(Signal* signal);
2171
void execDROP_TRIG_REF(Signal* signal);
2172
void execDROP_TRIG_REQ(Signal* signal);
2174
void execPREP_DROP_TAB_REQ(Signal* signal);
2175
void execWAIT_DROP_TAB_REQ(Signal* signal);
2176
void execDROP_TAB_REQ(Signal* signal);
2178
void execLQH_ALLOCREQ(Signal* signal);
2179
void execTUP_DEALLOCREQ(Signal* signal);
2180
void execLQH_WRITELOG_REQ(Signal* signal);
2182
void execTUXFRAGCONF(Signal* signal);
2183
void execTUXFRAGREF(Signal* signal);
2184
void execTUX_ADD_ATTRCONF(Signal* signal);
2185
void execTUX_ADD_ATTRREF(Signal* signal);
2189
void init_acc_ptr_list(ScanRecord*);
2190
bool seize_acc_ptr_list(ScanRecord*, Uint32);
2191
void release_acc_ptr_list(ScanRecord*);
2192
Uint32 get_acc_ptr_from_scan_record(ScanRecord*, Uint32, bool);
2193
void set_acc_ptr_in_scan_record(ScanRecord*, Uint32, Uint32);
2194
void i_get_acc_ptr(ScanRecord*, Uint32*&, Uint32);
2196
void removeTable(Uint32 tableId);
2197
void sendLCP_COMPLETE_REP(Signal* signal, Uint32 lcpId);
2198
void sendEMPTY_LCP_CONF(Signal* signal, bool idle);
2199
void sendLCP_FRAGIDREQ(Signal* signal);
2200
void sendLCP_FRAG_REP(Signal * signal, const LcpRecord::FragOrd &) const;
2202
void updatePackedList(Signal* signal, HostRecord * ahostptr, Uint16 hostId);
2203
void LQHKEY_abort(Signal* signal, int errortype);
2204
void LQHKEY_error(Signal* signal, int errortype);
2205
void nextRecordCopy(Signal* signal);
2206
Uint32 calculateHash(Uint32 tableId, const Uint32* src);
2207
void continueAfterCheckLcpStopBlocked(Signal* signal);
2208
void checkLcpStopBlockedLab(Signal* signal);
2209
void sendCommittedTc(Signal* signal, BlockReference atcBlockref);
2210
void sendCompletedTc(Signal* signal, BlockReference atcBlockref);
2211
void sendLqhkeyconfTc(Signal* signal, BlockReference atcBlockref);
2212
void sendCommitLqh(Signal* signal, BlockReference alqhBlockref);
2213
void sendCompleteLqh(Signal* signal, BlockReference alqhBlockref);
2214
void sendPackedSignalLqh(Signal* signal, HostRecord * ahostptr);
2215
void sendPackedSignalTc(Signal* signal, HostRecord * ahostptr);
2216
void cleanUp(Signal* signal);
2217
void sendAttrinfoLoop(Signal* signal);
2218
void sendAttrinfoSignal(Signal* signal);
2219
void sendLqhAttrinfoSignal(Signal* signal);
2220
void sendKeyinfoAcc(Signal* signal, Uint32 pos);
2221
Uint32 initScanrec(const class ScanFragReq *);
2222
void initScanTc(const class ScanFragReq *,
2227
void finishScanrec(Signal* signal);
2228
void releaseScanrec(Signal* signal);
2229
void seizeScanrec(Signal* signal);
2230
Uint32 sendKeyinfo20(Signal* signal, ScanRecord *, TcConnectionrec *);
2231
void sendTCKEYREF(Signal*, Uint32 dst, Uint32 route, Uint32 cnt);
2232
void sendScanFragConf(Signal* signal, Uint32 scanCompleted);
2233
void initCopyrec(Signal* signal);
2234
void initCopyTc(Signal* signal, Operation_t);
2235
void sendCopyActiveConf(Signal* signal,Uint32 tableId);
2236
void checkLcpCompleted(Signal* signal);
2237
void checkLcpHoldop(Signal* signal);
2238
bool checkLcpStarted(Signal* signal);
2239
void checkLcpTupprep(Signal* signal);
2240
void getNextFragForLcp(Signal* signal);
2241
void sendAccContOp(Signal* signal);
2242
void sendStartLcp(Signal* signal);
2243
void setLogTail(Signal* signal, Uint32 keepGci);
2244
Uint32 remainingLogSize(const LogFileRecordPtr &sltCurrLogFilePtr,
2245
const LogPartRecordPtr &sltLogPartPtr);
2246
void checkGcpCompleted(Signal* signal, Uint32 pageWritten, Uint32 wordWritten);
2247
void initFsopenconf(Signal* signal);
2248
void initFsrwconf(Signal* signal, bool write);
2249
void initLfo(Signal* signal);
2250
void initLogfile(Signal* signal, Uint32 fileNo);
2251
void initLogpage(Signal* signal);
2252
void openFileRw(Signal* signal, LogFileRecordPtr olfLogFilePtr);
2253
void openLogfileInit(Signal* signal);
2254
void openNextLogfile(Signal* signal);
2255
void releaseLfo(Signal* signal);
2256
void releaseLfoPages(Signal* signal);
2257
void releaseLogpage(Signal* signal);
2258
void seizeLfo(Signal* signal);
2259
void seizeLogfile(Signal* signal);
2260
void seizeLogpage(Signal* signal);
2261
void writeFileDescriptor(Signal* signal);
2262
void writeFileHeaderOpen(Signal* signal, Uint32 type);
2263
void writeInitMbyte(Signal* signal);
2264
void writeSinglePage(Signal* signal, Uint32 pageNo,
2265
Uint32 wordWritten, Uint32 place);
2266
void buildLinkedLogPageList(Signal* signal);
2267
void changeMbyte(Signal* signal);
2268
Uint32 checkIfExecLog(Signal* signal);
2269
void checkNewMbyte(Signal* signal);
2270
void checkReadExecSr(Signal* signal);
2271
void checkScanTcCompleted(Signal* signal);
2272
void closeFile(Signal* signal, LogFileRecordPtr logFilePtr, Uint32 place);
2273
void completedLogPage(Signal* signal, Uint32 clpType, Uint32 place);
2274
void deleteFragrec(Uint32 fragId);
2275
void deleteTransidHash(Signal* signal);
2276
void findLogfile(Signal* signal,
2278
LogPartRecordPtr flfLogPartPtr,
2279
LogFileRecordPtr* parLogFilePtr);
2280
void findPageRef(Signal* signal, CommitLogRecord* commitLogRecord);
2281
int findTransaction(UintR Transid1, UintR Transid2, UintR TcOprec);
2282
void getFirstInLogQueue(Signal* signal);
2283
bool getFragmentrec(Signal* signal, Uint32 fragId);
2284
void initialiseAddfragrec(Signal* signal);
2285
void initialiseAttrbuf(Signal* signal);
2286
void initialiseDatabuf(Signal* signal);
2287
void initialiseFragrec(Signal* signal);
2288
void initialiseGcprec(Signal* signal);
2289
void initialiseLcpRec(Signal* signal);
2290
void initialiseLfo(Signal* signal);
2291
void initialiseLogFile(Signal* signal);
2292
void initialiseLogPage(Signal* signal);
2293
void initialiseLogPart(Signal* signal);
2294
void initialisePageRef(Signal* signal);
2295
void initialiseScanrec(Signal* signal);
2296
void initialiseTabrec(Signal* signal);
2297
void initialiseTcrec(Signal* signal);
2298
void initialiseTcNodeFailRec(Signal* signal);
2299
void initFragrec(Signal* signal,
2303
void initFragrecSr(Signal* signal);
2304
void initGciInLogFileRec(Signal* signal, Uint32 noFdDesc);
2305
void initLcpSr(Signal* signal,
2311
void initLogpart(Signal* signal);
2312
void initLogPointers(Signal* signal);
2313
void initReqinfoExecSr(Signal* signal);
2314
bool insertFragrec(Signal* signal, Uint32 fragId);
2315
void linkFragQueue(Signal* signal);
2316
void linkWaitLog(Signal* signal, LogPartRecordPtr regLogPartPtr);
2317
void logNextStart(Signal* signal);
2318
void moveToPageRef(Signal* signal);
2319
void readAttrinfo(Signal* signal);
2320
void readCommitLog(Signal* signal, CommitLogRecord* commitLogRecord);
2321
void readExecLog(Signal* signal);
2322
void readExecSrNewMbyte(Signal* signal);
2323
void readExecSr(Signal* signal);
2324
void readKey(Signal* signal);
2325
void readLogData(Signal* signal, Uint32 noOfWords, Uint32* dataPtr);
2326
void readLogHeader(Signal* signal);
2327
Uint32 readLogword(Signal* signal);
2328
Uint32 readLogwordExec(Signal* signal);
2329
void readSinglePage(Signal* signal, Uint32 pageNo);
2330
void releaseActiveCopy(Signal* signal);
2331
void releaseAddfragrec(Signal* signal);
2332
void releaseFragrec();
2333
void releaseOprec(Signal* signal);
2334
void releasePageRef(Signal* signal);
2335
void releaseMmPages(Signal* signal);
2336
void releasePrPages(Signal* signal);
2337
void releaseTcrec(Signal* signal, TcConnectionrecPtr tcConnectptr);
2338
void releaseTcrecLog(Signal* signal, TcConnectionrecPtr tcConnectptr);
2339
void releaseWaitQueue(Signal* signal);
2340
void removeLogTcrec(Signal* signal);
2341
void removePageRef(Signal* signal);
2342
Uint32 returnExecLog(Signal* signal);
2343
int saveTupattrbuf(Signal* signal, Uint32* dataPtr, Uint32 length);
2344
void seizeAddfragrec(Signal* signal);
2345
void seizeAttrinbuf(Signal* signal);
2346
Uint32 seize_attrinbuf();
2347
Uint32 release_attrinbuf(Uint32);
2348
Uint32 copy_bounds(Uint32 * dst, TcConnectionrec*);
2350
void seizeFragmentrec(Signal* signal);
2351
void seizePageRef(Signal* signal);
2353
void seizeTupkeybuf(Signal* signal);
2354
void sendAborted(Signal* signal);
2355
void sendLqhTransconf(Signal* signal, LqhTransConf::OperationStatus);
2356
void sendTupkey(Signal* signal);
2357
void startExecSr(Signal* signal);
2358
void startNextExecSr(Signal* signal);
2359
void startTimeSupervision(Signal* signal);
2360
void stepAhead(Signal* signal, Uint32 stepAheadWords);
2361
void systemError(Signal* signal, int line);
2362
void writeAbortLog(Signal* signal);
2363
void writeCommitLog(Signal* signal, LogPartRecordPtr regLogPartPtr);
2364
void writeCompletedGciLog(Signal* signal);
2365
void writeDbgInfoPageHeader(LogPageRecordPtr logPagePtr, Uint32 place,
2366
Uint32 pageNo, Uint32 wordWritten);
2367
void writeDirty(Signal* signal, Uint32 place);
2368
void writeKey(Signal* signal);
2369
void writeLogHeader(Signal* signal);
2370
void writeLogWord(Signal* signal, Uint32 data);
2371
void writeNextLog(Signal* signal);
2372
void errorReport(Signal* signal, int place);
2373
void warningReport(Signal* signal, int place);
2374
void invalidateLogAfterLastGCI(Signal *signal);
2375
void readFileInInvalidate(Signal *signal, bool stepNext);
2376
void exitFromInvalidate(Signal* signal);
2377
Uint32 calcPageCheckSum(LogPageRecordPtr logP);
2378
Uint32 handleLongTupKey(Signal* signal, Uint32* dataPtr, Uint32 len);
2380
// Generated statement blocks
2381
void systemErrorLab(Signal* signal, int line);
2382
void initFourth(Signal* signal);
2383
void packLqhkeyreqLab(Signal* signal);
2384
void sendNdbSttorryLab(Signal* signal);
2385
void execSrCompletedLab(Signal* signal);
2386
void execLogRecord(Signal* signal);
2387
void srPhase3Comp(Signal* signal);
2388
void srLogLimits(Signal* signal);
2389
void srGciLimits(Signal* signal);
2390
void srPhase3Start(Signal* signal);
2391
void checkStartCompletedLab(Signal* signal);
2392
void continueAbortLab(Signal* signal);
2393
void abortContinueAfterBlockedLab(Signal* signal, bool canBlock);
2394
void abortCommonLab(Signal* signal);
2395
void localCommitLab(Signal* signal);
2396
void abortErrorLab(Signal* signal);
2397
void continueAfterReceivingAllAiLab(Signal* signal);
2398
void abortStateHandlerLab(Signal* signal);
2399
void writeAttrinfoLab(Signal* signal);
2400
void scanAttrinfoLab(Signal* signal, Uint32* dataPtr, Uint32 length);
2401
void abort_scan(Signal* signal, Uint32 scan_ptr_i, Uint32 errcode);
2402
void localAbortStateHandlerLab(Signal* signal);
2403
void logLqhkeyreqLab(Signal* signal);
2404
void lqhAttrinfoLab(Signal* signal, Uint32* dataPtr, Uint32 length);
2405
void rwConcludedAiLab(Signal* signal);
2406
void aiStateErrorCheckLab(Signal* signal, Uint32* dataPtr, Uint32 length);
2407
void takeOverErrorLab(Signal* signal);
2408
void endgettupkeyLab(Signal* signal);
2409
void noFreeRecordLab(Signal* signal,
2410
const class LqhKeyReq * lqhKeyReq,
2412
void logLqhkeyrefLab(Signal* signal);
2413
void closeCopyLab(Signal* signal);
2414
void commitReplyLab(Signal* signal);
2415
void completeUnusualLab(Signal* signal);
2416
void completeTransNotLastLab(Signal* signal);
2417
void completedLab(Signal* signal);
2418
void copyCompletedLab(Signal* signal);
2419
void completeLcpRoundLab(Signal* signal, Uint32 lcpId);
2420
void continueAfterLogAbortWriteLab(Signal* signal);
2421
void sendAttrinfoLab(Signal* signal);
2422
void sendExecConf(Signal* signal);
2423
void execSr(Signal* signal);
2424
void srFourthComp(Signal* signal);
2425
void timeSup(Signal* signal);
2426
void closeCopyRequestLab(Signal* signal);
2427
void closeScanRequestLab(Signal* signal);
2428
void scanTcConnectLab(Signal* signal, Uint32 startTcCon, Uint32 fragId);
2429
void initGcpRecLab(Signal* signal);
2430
void prepareContinueAfterBlockedLab(Signal* signal);
2431
void commitContinueAfterBlockedLab(Signal* signal);
2432
void continueCopyAfterBlockedLab(Signal* signal);
2433
void continueFirstCopyAfterBlockedLab(Signal* signal);
2434
void continueFirstScanAfterBlockedLab(Signal* signal);
2435
void continueScanAfterBlockedLab(Signal* signal);
2436
void continueScanReleaseAfterBlockedLab(Signal* signal);
2437
void continueCloseScanAfterBlockedLab(Signal* signal);
2438
void continueCloseCopyAfterBlockedLab(Signal* signal);
2439
void sendExecFragRefLab(Signal* signal);
2440
void fragrefLab(Signal* signal, BlockReference retRef,
2441
Uint32 retPtr, Uint32 errorCode);
2442
void abortAddFragOps(Signal* signal);
2443
void rwConcludedLab(Signal* signal);
2444
void sendsttorryLab(Signal* signal);
2445
void initialiseRecordsLab(Signal* signal, Uint32 data, Uint32, Uint32);
2446
void startphase2Lab(Signal* signal, Uint32 config);
2447
void startphase3Lab(Signal* signal);
2448
void startphase4Lab(Signal* signal);
2449
void startphase6Lab(Signal* signal);
2450
void moreconnectionsLab(Signal* signal);
2451
void scanReleaseLocksLab(Signal* signal);
2452
void closeScanLab(Signal* signal);
2453
void nextScanConfLoopLab(Signal* signal);
2454
void scanNextLoopLab(Signal* signal);
2455
void commitReqLab(Signal* signal, Uint32 gci);
2456
void completeTransLastLab(Signal* signal);
2457
void tupScanCloseConfLab(Signal* signal);
2458
void tupCopyCloseConfLab(Signal* signal);
2459
void accScanCloseConfLab(Signal* signal);
2460
void accCopyCloseConfLab(Signal* signal);
2461
void nextScanConfScanLab(Signal* signal);
2462
void nextScanConfCopyLab(Signal* signal);
2463
void continueScanNextReqLab(Signal* signal);
2464
void keyinfoLab(const Uint32 * src, const Uint32 * end);
2465
void copySendTupkeyReqLab(Signal* signal);
2466
void storedProcConfScanLab(Signal* signal);
2467
void storedProcConfCopyLab(Signal* signal);
2468
void copyStateFinishedLab(Signal* signal);
2469
void lcpCompletedLab(Signal* signal);
2470
void lcpStartedLab(Signal* signal);
2471
void contChkpNextFragLab(Signal* signal);
2472
void startLcpRoundLab(Signal* signal);
2473
void startFragRefLab(Signal* signal);
2474
void srCompletedLab(Signal* signal);
2475
void openFileInitLab(Signal* signal);
2476
void openSrFrontpageLab(Signal* signal);
2477
void openSrLastFileLab(Signal* signal);
2478
void openSrNextFileLab(Signal* signal);
2479
void openExecSrStartLab(Signal* signal);
2480
void openExecSrNewMbyteLab(Signal* signal);
2481
void openSrFourthPhaseLab(Signal* signal);
2482
void openSrFourthZeroSkipInitLab(Signal* signal);
2483
void openSrFourthZeroLab(Signal* signal);
2484
void openExecLogLab(Signal* signal);
2485
void checkInitCompletedLab(Signal* signal);
2486
void closingSrLab(Signal* signal);
2487
void closeExecSrLab(Signal* signal);
2488
void execLogComp(Signal* signal);
2489
void closeWriteLogLab(Signal* signal);
2490
void closeExecLogLab(Signal* signal);
2491
void writePageZeroLab(Signal* signal);
2492
void lastWriteInFileLab(Signal* signal);
2493
void initWriteEndLab(Signal* signal);
2494
void initFirstPageLab(Signal* signal);
2495
void writeGciZeroLab(Signal* signal);
2496
void writeDirtyLab(Signal* signal);
2497
void writeInitMbyteLab(Signal* signal);
2498
void writeLogfileLab(Signal* signal);
2499
void firstPageWriteLab(Signal* signal);
2500
void readSrLastMbyteLab(Signal* signal);
2501
void readSrLastFileLab(Signal* signal);
2502
void readSrNextFileLab(Signal* signal);
2503
void readExecSrLab(Signal* signal);
2504
void readExecLogLab(Signal* signal);
2505
void readSrFourthPhaseLab(Signal* signal);
2506
void readSrFourthZeroLab(Signal* signal);
2507
void copyLqhKeyRefLab(Signal* signal);
2508
void restartOperationsLab(Signal* signal);
2509
void lqhTransNextLab(Signal* signal);
2510
void restartOperationsAfterStopLab(Signal* signal);
2511
void startphase1Lab(Signal* signal, Uint32 config, Uint32 nodeId);
2512
void tupkeyConfLab(Signal* signal);
2513
void copyTupkeyConfLab(Signal* signal);
2514
void scanTupkeyConfLab(Signal* signal);
2515
void scanTupkeyRefLab(Signal* signal);
2516
void accScanConfScanLab(Signal* signal);
2517
void accScanConfCopyLab(Signal* signal);
2518
void scanLockReleasedLab(Signal* signal);
2519
void openSrFourthNextLab(Signal* signal);
2520
void closingInitLab(Signal* signal);
2521
void closeExecSrCompletedLab(Signal* signal);
2522
void readSrFrontpageLab(Signal* signal);
2524
void sendAddFragReq(Signal* signal);
2525
void sendAddAttrReq(Signal* signal);
2526
void checkDropTab(Signal*);
2527
Uint32 checkDropTabState(Tablerec::TableStatus, Uint32) const;
2533
void define_backup(Signal*);
2534
void execDEFINE_BACKUP_REF(Signal*);
2535
void execDEFINE_BACKUP_CONF(Signal*);
2536
void execBACKUP_FRAGMENT_REF(Signal* signal);
2537
void execBACKUP_FRAGMENT_CONF(Signal* signal);
2538
void execLCP_PREPARE_REF(Signal* signal);
2539
void execLCP_PREPARE_CONF(Signal* signal);
2540
void execEND_LCPREF(Signal* signal);
2541
void execEND_LCPCONF(Signal* signal);
2542
Uint32 m_backup_ptr;
2544
void send_restore_lcp(Signal * signal);
2545
void execRESTORE_LCP_REF(Signal* signal);
2546
void execRESTORE_LCP_CONF(Signal* signal);
2552
* Read primary key from tup
2554
Uint32 readPrimaryKeys(ScanRecord*, TcConnectionrec*, Uint32 * dst);
2557
* Read primary key from operation
2560
Uint32 readPrimaryKeys(Uint32 opPtrI, Uint32 * dst, bool xfrm);
2563
void acckeyconf_tupkeyreq(Signal*, TcConnectionrec*, Fragrecord*, Uint32, Uint32);
2564
void acckeyconf_load_diskpage(Signal*,TcConnectionrecPtr,Fragrecord*,Uint32);
2566
void handle_nr_copy(Signal*, Ptr<TcConnectionrec>);
2567
void exec_acckeyreq(Signal*, Ptr<TcConnectionrec>);
2568
int compare_key(const TcConnectionrec*, const Uint32 * ptr, Uint32 len);
2569
void nr_copy_delete_row(Signal*, Ptr<TcConnectionrec>, Local_key*, Uint32);
2574
Uint32 m_tup_frag_ptr_i;
2577
Local_key m_disk_ref;
2579
void get_nr_op_info(Nr_op_info*, Uint32 page_id = RNIL);
2580
void nr_delete_complete(Signal*, Nr_op_info*);
2583
void acckeyconf_load_diskpage_callback(Signal*, Uint32, Uint32);
2586
void next_scanconf_load_diskpage(Signal* signal,
2587
ScanRecordPtr scanPtr,
2588
Ptr<TcConnectionrec> regTcPtr,
2589
Fragrecord* fragPtrP);
2591
void next_scanconf_tupkeyreq(Signal* signal, ScanRecordPtr,
2592
TcConnectionrec * regTcPtr,
2593
Fragrecord* fragPtrP,
2597
void next_scanconf_load_diskpage_callback(Signal* signal, Uint32, Uint32);
2599
void tupcommit_conf_callback(Signal* signal, Uint32 tcPtrI);
2601
void tupcommit_conf(Signal* signal, TcConnectionrec *,Fragrecord *);
2603
// ----------------------------------------------------------------
2604
// These are variables handling the records. For most records one
2605
// pointer to the array of structs, one pointer-struct, a file size
2606
// and a first free record variable. The pointer struct are temporary
2607
// variables that are kept on the class object since there are often a
2608
// great deal of those variables that exist simultaneously and
2609
// thus no perfect solution of handling them is currently available.
2610
// ----------------------------------------------------------------
2611
/* ------------------------------------------------------------------------- */
2612
/* POSITIONS WITHIN THE ATTRINBUF AND THE MAX SIZE OF DATA WITHIN AN */
2614
/* ------------------------------------------------------------------------- */
2617
#define ZADDFRAGREC_FILE_SIZE 1
2618
AddFragRecord *addFragRecord;
2619
AddFragRecordPtr addfragptr;
2620
UintR cfirstfreeAddfragrec;
2621
UintR caddfragrecFileSize;
2623
#define ZATTRINBUF_FILE_SIZE 12288 // 1.5 MByte
2624
#define ZINBUF_DATA_LEN 24 /* POSITION OF 'DATA LENGHT'-VARIABLE. */
2625
#define ZINBUF_NEXT 25 /* POSITION OF 'NEXT'-VARIABLE. */
2627
AttrbufPtr attrinbufptr;
2628
UintR cfirstfreeAttrinbuf;
2629
UintR cattrinbufFileSize;
2630
Uint32 c_no_attrinbuf_recs;
2632
#define ZDATABUF_FILE_SIZE 10000 // 200 kByte
2634
DatabufPtr databufptr;
2635
UintR cfirstfreeDatabuf;
2636
UintR cdatabufFileSize;
2639
FragrecordPtr fragptr;
2640
ArrayPool<Fragrecord> c_fragment_pool;
2642
#define ZGCPREC_FILE_SIZE 1
2643
GcpRecord *gcpRecord;
2644
GcpRecordPtr gcpPtr;
2645
UintR cgcprecFileSize;
2647
// MAX_NDB_NODES is the size of this array
2648
HostRecord *hostRecord;
2649
UintR chostFileSize;
2651
#define ZNO_CONCURRENT_LCP 1
2652
LcpRecord *lcpRecord;
2653
LcpRecordPtr lcpPtr;
2654
UintR cfirstfreeLcpLoc;
2657
#define ZLOG_PART_FILE_SIZE 4
2658
LogPartRecord *logPartRecord;
2659
LogPartRecordPtr logPartPtr;
2660
UintR clogPartFileSize;
2661
Uint32 clogFileSize; // In MBYTE
2662
Uint32 cmaxLogFilesInPageZero; //
2665
LogFileRecord *logFileRecord;
2666
LogFileRecordPtr logFilePtr;
2667
UintR cfirstfreeLogFile;
2668
UintR clogFileFileSize;
2670
#define ZLFO_MIN_FILE_SIZE 256
2671
// RedoBuffer/32K minimum ZLFO_MIN_FILE_SIZE
2672
LogFileOperationRecord *logFileOperationRecord;
2673
LogFileOperationRecordPtr lfoPtr;
2674
UintR cfirstfreeLfo;
2677
LogPageRecord *logPageRecord;
2678
void *logPageRecordUnaligned;
2679
LogPageRecordPtr logPagePtr;
2680
UintR cfirstfreeLogPage;
2681
UintR clogPageFileSize;
2683
#define ZPAGE_REF_FILE_SIZE 20
2684
PageRefRecord *pageRefRecord;
2685
PageRefRecordPtr pageRefPtr;
2686
UintR cfirstfreePageRef;
2687
UintR cpageRefFileSize;
2690
ArrayPool<ScanRecord> c_scanRecordPool;
2691
ScanRecordPtr scanptr;
2692
UintR cscanNoFreeRec;
2693
Uint32 cscanrecFileSize;
2698
UintR ctabrecFileSize;
2701
TcConnectionrec *tcConnectionrec;
2702
TcConnectionrecPtr tcConnectptr;
2703
UintR cfirstfreeTcConrec;
2704
UintR ctcConnectrecFileSize;
2706
// MAX_NDB_NODES is the size of this array
2707
TcNodeFailRecord *tcNodeFailRecord;
2708
TcNodeFailRecordPtr tcNodeFailptr;
2709
UintR ctcNodeFailrecFileSize;
2713
Uint32 c_firstInNodeGroup;
2715
// ------------------------------------------------------------------------
2716
// These variables are used to store block state which do not need arrays
2718
// ------------------------------------------------------------------------
2720
Uint32 cnoOfFragsCheckpointed;
2722
/* ------------------------------------------------------------------------- */
2723
// cmaxWordsAtNodeRec keeps track of how many words that currently are
2724
// outstanding in a node recovery situation.
2725
// cbookedAccOps keeps track of how many operation records that have been
2726
// booked in ACC for the scan processes.
2727
// cmaxAccOps contains the maximum number of operation records which can be
2728
// allocated for scan purposes in ACC.
2729
/* ------------------------------------------------------------------------- */
2730
UintR cmaxWordsAtNodeRec;
2731
UintR cbookedAccOps;
2733
/* ------------------------------------------------------------------------- */
2734
/*THIS STATE VARIABLE IS ZTRUE IF AN ADD NODE IS ONGOING. ADD NODE MEANS */
2735
/*THAT CONNECTIONS ARE SET-UP TO THE NEW NODE. */
2736
/* ------------------------------------------------------------------------- */
2737
Uint8 caddNodeState;
2738
/* ------------------------------------------------------------------------- */
2739
/*THIS VARIABLE SPECIFIES WHICH TYPE OF RESTART THAT IS ONGOING */
2740
/* ------------------------------------------------------------------------- */
2742
/* ------------------------------------------------------------------------- */
2743
/*THIS VARIABLE INDICATES WHETHER AN INITIAL RESTART IS ONGOING OR NOT. */
2744
/* ------------------------------------------------------------------------- */
2745
Uint8 cinitialStartOngoing;
2746
/* ------------------------------------------------------------------------- */
2747
/*THIS VARIABLE KEEPS TRACK OF WHEN TUP AND ACC HAVE COMPLETED EXECUTING */
2748
/*THEIR UNDO LOG. */
2749
/* ------------------------------------------------------------------------- */
2750
ExecUndoLogState csrExecUndoLogState;
2751
/* ------------------------------------------------------------------------- */
2752
/*THIS VARIABLE KEEPS TRACK OF WHEN TUP AND ACC HAVE CONFIRMED COMPLETION */
2753
/*OF A LOCAL CHECKPOINT ROUND. */
2754
/* ------------------------------------------------------------------------- */
2755
LcpCloseState clcpCompletedState;
2756
/* ------------------------------------------------------------------------- */
2757
/*DURING CONNECTION PROCESSES IN SYSTEM RESTART THESE VARIABLES KEEP TRACK */
2758
/*OF HOW MANY CONNECTIONS AND RELEASES THAT ARE TO BE PERFORMED. */
2759
/* ------------------------------------------------------------------------- */
2760
/***************************************************************************>*/
2761
/*THESE VARIABLES CONTAIN INFORMATION USED DURING SYSTEM RESTART. */
2762
/***************************************************************************>*/
2763
/* ------------------------------------------------------------------------- */
2764
/*THIS VARIABLE IS ZTRUE IF THE SIGNAL START_REC_REQ HAVE BEEN RECEIVED. */
2765
/*RECEPTION OF THIS SIGNAL INDICATES THAT ALL FRAGMENTS THAT THIS NODE */
2766
/*SHOULD START HAVE BEEN RECEIVED. */
2767
/* ------------------------------------------------------------------------- */
2769
/* ------------------------------------------------------------------------- */
2770
/*THIS VARIABLE KEEPS TRACK OF HOW MANY FRAGMENTS THAT PARTICIPATE IN */
2771
/*EXECUTING THE LOG. IF ZERO WE DON'T NEED TO EXECUTE THE LOG AT ALL. */
2772
/* ------------------------------------------------------------------------- */
2773
Uint32 cnoFragmentsExecSr;
2776
* This is no of sent GSN_EXEC_FRAGREQ during this log phase
2778
Uint32 cnoOutstandingExecFragReq;
2780
/* ------------------------------------------------------------------------- */
2781
/*THIS VARIABLE KEEPS TRACK OF WHICH OF THE FIRST TWO RESTART PHASES THAT */
2782
/*HAVE COMPLETED. */
2783
/* ------------------------------------------------------------------------- */
2784
Uint8 csrPhaseStarted;
2785
/* ------------------------------------------------------------------------- */
2786
/*NUMBER OF PHASES COMPLETED OF EXECUTING THE FRAGMENT LOG. */
2787
/* ------------------------------------------------------------------------- */
2788
Uint8 csrPhasesCompleted;
2789
/* ------------------------------------------------------------------------- */
2790
/*THE BLOCK REFERENCE OF THE MASTER DIH DURING SYSTEM RESTART. */
2791
/* ------------------------------------------------------------------------- */
2792
BlockReference cmasterDihBlockref;
2793
/* ------------------------------------------------------------------------- */
2794
/*THIS VARIABLE IS THE HEAD OF A LINKED LIST OF FRAGMENTS WAITING TO BE */
2795
/*RESTORED FROM DISK. */
2796
/* ------------------------------------------------------------------------- */
2797
DLFifoList<Fragrecord> c_lcp_waiting_fragments; // StartFragReq'ed
2798
DLFifoList<Fragrecord> c_lcp_restoring_fragments; // Restoring as we speek
2799
DLFifoList<Fragrecord> c_lcp_complete_fragments; // Restored
2801
/* ------------------------------------------------------------------------- */
2802
/*USED DURING SYSTEM RESTART, INDICATES THE OLDEST GCI THAT CAN BE RESTARTED */
2803
/*FROM AFTER THIS SYSTEM RESTART. USED TO FIND THE LOG TAIL. */
2804
/* ------------------------------------------------------------------------- */
2805
UintR crestartOldestGci;
2806
/* ------------------------------------------------------------------------- */
2807
/*USED DURING SYSTEM RESTART, INDICATES THE NEWEST GCI THAT CAN BE RESTARTED */
2808
/*AFTER THIS SYSTEM RESTART. USED TO FIND THE LOG HEAD. */
2809
/* ------------------------------------------------------------------------- */
2810
UintR crestartNewestGci;
2811
/* ------------------------------------------------------------------------- */
2812
/*THE NUMBER OF LOG FILES. SET AS A PARAMETER WHEN NDB IS STARTED. */
2813
/* ------------------------------------------------------------------------- */
2815
/* ------------------------------------------------------------------------- */
2816
/*THESE TWO VARIABLES CONTAIN THE NEWEST GCI RECEIVED IN THE BLOCK AND THE */
2817
/*NEWEST COMPLETED GCI IN THE BLOCK. */
2818
/* ------------------------------------------------------------------------- */
2820
UintR cnewestCompletedGci;
2821
/* ------------------------------------------------------------------------- */
2822
/*THIS VARIABLE ONLY PASSES INFORMATION FROM STTOR TO STTORRY = TEMPORARY */
2823
/* ------------------------------------------------------------------------- */
2825
/* ------------------------------------------------------------------------- */
2826
/*THIS VARIABLE CONTAINS THE CURRENT START PHASE IN THE BLOCK. IS ZNIL IF */
2827
/*NO SYSTEM RESTART IS ONGOING. */
2828
/* ------------------------------------------------------------------------- */
2830
/* ------------------------------------------------------------------------- */
2831
/*THIS VARIABLE CONTAIN THE CURRENT GLOBAL CHECKPOINT RECORD. IT'S RNIL IF */
2832
/*NOT A GCP SAVE IS ONGOING. */
2833
/* ------------------------------------------------------------------------- */
2834
UintR ccurrentGcprec;
2835
/* ------------------------------------------------------------------------- */
2836
/*THESE VARIABLES ARE USED TO KEEP TRACK OF ALL ACTIVE COPY FRAGMENTS IN LQH.*/
2837
/* ------------------------------------------------------------------------- */
2838
Uint8 cnoActiveCopy;
2839
UintR cactiveCopy[4];
2841
/* ------------------------------------------------------------------------- */
2842
/*THESE VARIABLES CONTAIN THE BLOCK REFERENCES OF THE OTHER NDB BLOCKS. */
2843
/*ALSO THE BLOCK REFERENCE OF MY OWN BLOCK = LQH */
2844
/* ------------------------------------------------------------------------- */
2845
BlockReference caccBlockref;
2846
BlockReference ctupBlockref;
2847
BlockReference ctuxBlockref;
2848
BlockReference cownref;
2849
UintR cLqhTimeOutCount;
2850
UintR cLqhTimeOutCheckCount;
2851
UintR cnoOfLogPages;
2852
/* ------------------------------------------------------------------------- */
2853
/*THIS VARIABLE CONTAINS MY OWN PROCESSOR ID. */
2854
/* ------------------------------------------------------------------------- */
2857
/* ------------------------------------------------------------------------- */
2858
/*THESE VARIABLES CONTAIN INFORMATION ABOUT THE OTHER NODES IN THE SYSTEM */
2859
/*THESE VARIABLES ARE MOSTLY USED AT SYSTEM RESTART AND ADD NODE TO SET-UP */
2860
/*AND RELEASE CONNECTIONS TO OTHER NODES IN THE CLUSTER. */
2861
/* ------------------------------------------------------------------------- */
2862
/* ------------------------------------------------------------------------- */
2863
/*THIS ARRAY CONTAINS THE PROCESSOR ID'S OF THE NODES THAT ARE ALIVE. */
2864
/*CNO_OF_NODES SPECIFIES HOW MANY NODES THAT ARE CURRENTLY ALIVE. */
2865
/*CNODE_VERSION SPECIFIES THE NDB VERSION EXECUTING ON THE NODE. */
2866
/* ------------------------------------------------------------------------- */
2867
UintR cpackedListIndex;
2868
Uint16 cpackedList[MAX_NDB_NODES];
2869
UintR cnodeData[MAX_NDB_NODES];
2870
UintR cnodeStatus[MAX_NDB_NODES];
2873
NdbNodeBitmask m_sr_nodes;
2874
NdbNodeBitmask m_sr_exec_sr_req;
2875
NdbNodeBitmask m_sr_exec_sr_conf;
2877
/* ------------------------------------------------------------------------- */
2878
/* THIS VARIABLE CONTAINS THE DIRECTORY OF A HASH TABLE OF ALL ACTIVE */
2879
/* OPERATION IN THE BLOCK. IT IS USED TO BE ABLE TO QUICKLY ABORT AN */
2880
/* OPERATION WHERE THE CONNECTION WAS LOST DUE TO NODE FAILURES. IT IS */
2881
/* ACTUALLY USED FOR ALL ABORTS COMMANDED BY TC. */
2882
/* ------------------------------------------------------------------------- */
2883
UintR preComputedRequestInfoMask;
2884
UintR ctransidHash[1024];
2888
Uint32 c_error_insert_table_id;
2891
bool is_same_trans(Uint32 opId, Uint32 trid1, Uint32 trid2);
2892
void get_op_info(Uint32 opId, Uint32 *hash, Uint32* gci);
2893
void accminupdate(Signal*, Uint32 opPtrI, const Local_key*);
2898
struct CommitAckMarker {
2899
CommitAckMarker() {}
2903
Uint32 apiRef; // Api block ref
2904
Uint32 apiOprec; // Connection Object in NDB API
2906
union { Uint32 nextPool; Uint32 nextHash; };
2909
inline bool equal(const CommitAckMarker & p) const {
2910
return ((p.transid1 == transid1) && (p.transid2 == transid2));
2913
inline Uint32 hashValue() const {
2918
typedef Ptr<CommitAckMarker> CommitAckMarkerPtr;
2919
ArrayPool<CommitAckMarker> m_commitAckMarkerPool;
2920
DLHashTable<CommitAckMarker> m_commitAckMarkerHash;
2921
typedef DLHashTable<CommitAckMarker>::Iterator CommitAckMarkerIterator;
2922
void execREMOVE_MARKER_ORD(Signal* signal);
2923
void scanMarkers(Signal* signal, Uint32 tcNodeFail, Uint32 bucket, Uint32 i);
2929
inline void clear(){
2934
Counters c_Counters;
2936
inline bool getAllowRead() const {
2937
return getNodeState().startLevel < NodeState::SL_STOPPING_3;
2940
DLHashTable<ScanRecord> c_scanTakeOverHash;
2942
inline bool TRACE_OP_CHECK(const TcConnectionrec* regTcPtr);
2944
void TRACE_OP_DUMP(const TcConnectionrec* regTcPtr, const char * pos);
2950
Dblqh::ScanRecord::check_scan_batch_completed() const
2952
Uint32 max_rows = m_max_batch_size_rows;
2953
Uint32 max_bytes = m_max_batch_size_bytes;
2955
return (max_rows > 0 && (m_curr_batch_size_rows >= max_rows)) ||
2956
(max_bytes > 0 && (m_curr_batch_size_bytes >= max_bytes));
2961
Dblqh::i_get_acc_ptr(ScanRecord* scanP, Uint32* &acc_ptr, Uint32 index)
2964
acc_ptr= (Uint32*)&scanP->scan_acc_op_ptr[0];
2966
Uint32 attr_buf_index, attr_buf_rec;
2968
AttrbufPtr regAttrPtr;
2970
attr_buf_rec= (index + 31) / 32;
2971
attr_buf_index= (index - 1) & 31;
2972
regAttrPtr.i= scanP->scan_acc_op_ptr[attr_buf_rec];
2973
ptrCheckGuard(regAttrPtr, cattrinbufFileSize, attrbuf);
2974
acc_ptr= (Uint32*)®AttrPtr.p->attrbuf[attr_buf_index];
2980
Dblqh::is_same_trans(Uint32 opId, Uint32 trid1, Uint32 trid2)
2982
TcConnectionrecPtr regTcPtr;
2984
ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
2985
return ((regTcPtr.p->transid[0] == trid1) &&
2986
(regTcPtr.p->transid[1] == trid2));
2991
Dblqh::get_op_info(Uint32 opId, Uint32 *hash, Uint32* gci)
2993
TcConnectionrecPtr regTcPtr;
2995
ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
2996
*hash= regTcPtr.p->hashValue;
2997
*gci= regTcPtr.p->gci;
3000
#include "../dbacc/Dbacc.hpp"
3004
Dblqh::accminupdate(Signal* signal, Uint32 opId, const Local_key* key)
3006
TcConnectionrecPtr regTcPtr;
3008
ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
3009
signal->theData[0] = regTcPtr.p->accConnectrec;
3010
signal->theData[1] = key->m_page_no << MAX_TUPLES_BITS | key->m_page_idx;
3011
c_acc->execACCMINUPDATE(signal);
3013
if (ERROR_INSERTED(5712) || ERROR_INSERTED(5713))
3014
ndbout << " LK: " << *key;
3015
regTcPtr.p->m_row_id = *key;
3020
Dblqh::TRACE_OP_CHECK(const TcConnectionrec* regTcPtr)
3022
return (ERROR_INSERTED(5712) &&
3023
(regTcPtr->operation == ZINSERT ||
3024
regTcPtr->operation == ZDELETE)) ||
3025
ERROR_INSERTED(5713);