21 #include <ndb_limits.h>
23 #include <SimulatedBlock.hpp>
24 #include "Sysfile.hpp"
25 #include <SignalCounter.hpp>
27 #include <signaldata/MasterLCP.hpp>
28 #include <signaldata/CopyGCIReq.hpp>
29 #include <blocks/mutexes.hpp>
30 #include <signaldata/LCP.hpp>
31 #include <NdbSeqLock.hpp>
38 #define ZLIST_OF_PAIRS 0
39 #define ZLIST_OF_PAIRS_SYNCH 16
40 #define ZOPEN_READ_WRITE 2
41 #define ZCREATE_READ_WRITE 0x302
42 #define ZCLOSE_NO_DELETE 0
43 #define ZCLOSE_DELETE 1
54 #define ZVAR_NO_WORD 1
55 #define ZVAR_NO_CRESTART_INFO 20
56 #define ZVAR_NO_CRESTART_INFO_TO_FILE 21
66 #define ZUNDEFINED_FRAGMENT_ERROR 311
71 #define ZREPLERROR1 306
72 #define ZREPLERROR2 307
77 #define ZCOULD_NOT_OCCUR_ERROR 300
78 #define ZNOT_MASTER_ERROR 301
79 #define ZWRONG_FAILURE_NUMBER_ERROR 302
80 #define ZWRONG_START_NODE_ERROR 303
81 #define ZNO_REPLICA_FOUND_ERROR 304
86 #define ZNODE_FAILURE_ERROR 400
104 #define ZCREATE_REPLICA_FILE_SIZE 4
105 #define ZPROXY_MASTER_FILE_SIZE 10
106 #define ZPROXY_FILE_SIZE 10
111 typedef void (
Dbdih::* SendFunction)(
Signal*, Uint32, Uint32);
144 ALTER_TABLE_ABORT = 4,
145 ALTER_TABLE_REVERT = 5,
149 Uint32 nodes[MAX_REPLICAS];
152 Uint32 m_totalfragments;
153 Uint32 m_org_totalfragments;
154 Uint32 m_new_map_ptr_i;
160 Uint32 m_requestInfo;
163 ConnectState connectState;
167 BlockReference userblockref;
182 Uint32 logStartGci[MAX_LOG_EXEC];
183 Uint32 logStopGci[MAX_LOG_EXEC];
184 Uint16 logNodeId[MAX_LOG_EXEC];
212 OPENING_COPY_GCI = 3,
213 WRITING_COPY_GCI = 4,
214 CREATING_COPY_GCI = 5,
223 CLOSING_TABLE_CRASH = 14,
224 CLOSING_TABLE_SR = 15,
225 CLOSING_GCP_CRASH = 16,
226 TABLE_OPEN_FOR_DELETE = 17,
227 TABLE_CLOSE_DELETE = 18
231 FileStatus fileStatus;
250 Uint16 activeNodes[MAX_REPLICAS];
251 Uint32 preferredPrimary;
253 Uint32 oldStoredReplicas;
254 Uint32 storedReplicas;
255 Uint32 nextFragmentChunk;
257 Uint32 m_log_part_id;
259 Uint8 distributionKey;
261 Uint8 noOldStoredReplicas;
262 Uint8 noStoredReplicas;
272 Uint32 nodesInGroup[MAX_REPLICAS + 1];
273 Uint32 nextReplicaNode;
275 Uint32 activeTakeOver;
276 Uint32 m_next_log_part;
277 Uint32 nodegroupIndex;
286 enum NodefailHandlingStep {
287 NF_REMOVE_NODE_FROM_TABLE = 1,
288 NF_GCP_TAKE_OVER = 2,
312 NodeStatus nodeStatus;
313 bool useInTransactions;
328 Uint8 dbtcFailCompleted;
329 Uint8 dblqhFailCompleted;
330 Uint8 dbdihFailCompleted;
331 Uint8 dbdictFailCompleted;
332 Uint8 recNODE_FAILREP;
334 Uint8 noOfQueuedChkpt;
335 Uint8 noOfStartedChkpt;
337 MasterLCPConf::State lcpStateAtTakeOver;
338 Uint32 m_remove_node_from_table_lcp_id;
370 Uint32 replicaLastGci[8];
374 Uint32 lcpId[MAX_LCP_STORED];
379 Uint32 maxGciCompleted[MAX_LCP_STORED];
384 Uint32 maxGciStarted[MAX_LCP_STORED];
407 Uint32 m_restorable_gci;
418 Uint8 lcpStatus[MAX_LCP_STORED];
428 Uint8 noCrashedReplicas;
461 CS_SR_PHASE1_READ_PAGES,
462 CS_SR_PHASE2_READ_TABLE,
463 CS_SR_PHASE3_COPY_TABLE,
470 CS_INVALIDATE_NODE_LCP,
485 US_INVALIDATE_NODE_LCP,
490 TLS_WRITING_TO_FILE = 2,
513 TabLcpStatus tabLcpStatus;
523 Uint32 startFid[MAX_NDB_NODES * MAX_FRAG_PER_NODE / NO_OF_FRAGS_PER_CHUNK];
529 Uint32 m_new_map_ptr_i;
536 Uint32 schemaVersion;
537 Uint32 tabRemoveNode;
538 Uint32 totalfragments;
539 Uint32 noOfFragChunks;
540 Uint32 m_scan_count[2];
541 Uint32 m_scan_reorg_flag;
552 Uint16 primaryTableId;
555 Uint32 schemaTransId;
570 ,TO_START_FRAGMENTS = 1
573 ,TO_SELECTING_NEXT = 4
575 ,TO_UPDATE_BEFORE_STORED = 6
576 ,TO_CREATE_FRAG_STORED = 7
577 ,TO_UPDATE_AFTER_STORED = 8
580 ,TO_UPDATE_BEFORE_COMMIT = 11
581 ,TO_CREATE_FRAG_COMMIT = 12
582 ,TO_UPDATE_AFTER_COMMIT = 13
584 ,TO_START_LOGGING = 14
585 ,TO_SL_COPY_ACTIVE = 15
586 ,TO_SL_CREATE_FRAG = 16
595 ,TO_MUTEX_BEFORE_STORED = 1
596 ,TO_MUTEX_BEFORE_LOCKED = 2
598 ,TO_MUTEX_BEFORE_COMMIT = 4
599 ,TO_MUTEX_BEFORE_SWITCH_REPLICA = 5
600 ,TO_MUTEX_AFTER_SWITCH_REPLICA = 6
608 Uint32 restorableGci;
612 Uint32 toCurrentFragid;
613 Uint32 toCurrentReplica;
614 Uint32 toCurrentTabref;
616 Uint32 toStartingNode;
632 virtual bool getParam(
const char * param, Uint32 * retVal) {
633 if (param && strcmp(param,
"ActiveMutexes") == 0)
637 * retVal = 5 + MAX_NDB_NODES;
654 Uint32 totalfragments;
666 BLOCK_DEFINES(
Dbdih);
668 void execDUMP_STATE_ORD(
Signal *);
669 void execNDB_TAMPER(
Signal *);
670 void execDEBUG_SIG(
Signal *);
671 void execEMPTY_LCP_CONF(
Signal *);
672 void execEMPTY_LCP_REP(
Signal*);
673 void execMASTER_GCPREF(
Signal *);
674 void execMASTER_GCPREQ(
Signal *);
675 void execMASTER_GCPCONF(
Signal *);
676 void execMASTER_LCPREF(
Signal *);
677 void execMASTER_LCPREQ(
Signal *);
678 void execMASTER_LCPCONF(
Signal *);
679 void execNF_COMPLETEREP(
Signal *);
680 void execSTART_PERMREQ(
Signal *);
681 void execSTART_PERMCONF(
Signal *);
682 void execSTART_PERMREF(
Signal *);
683 void execINCL_NODEREQ(
Signal *);
684 void execINCL_NODECONF(
Signal *);
686 void execSTART_TOREQ(
Signal *);
687 void execSTART_TOREF(
Signal *);
688 void execSTART_TOCONF(
Signal*);
690 void execEND_TOREQ(
Signal *);
691 void execEND_TOREF(
Signal *);
692 void execEND_TOCONF(
Signal*);
694 void execUPDATE_TOREQ(
Signal* signal);
695 void execUPDATE_TOREF(
Signal* signal);
696 void execUPDATE_TOCONF(
Signal* signal);
698 void execSTART_MEREQ(
Signal *);
699 void execSTART_MECONF(
Signal *);
700 void execSTART_MEREF(
Signal *);
701 void execSTART_COPYREQ(
Signal *);
702 void execSTART_COPYCONF(
Signal *);
703 void execSTART_COPYREF(
Signal *);
704 void execCREATE_FRAGREQ(
Signal *);
705 void execCREATE_FRAGCONF(
Signal *);
706 void execDIVERIFYREQ(
Signal *);
707 void execGCP_SAVEREQ(
Signal *);
708 void execGCP_SAVECONF(
Signal *);
709 void execGCP_PREPARECONF(
Signal *);
710 void execGCP_PREPARE(
Signal *);
711 void execGCP_NODEFINISH(
Signal *);
712 void execGCP_COMMIT(
Signal *);
713 void execSUB_GCP_COMPLETE_REP(
Signal *);
714 void execSUB_GCP_COMPLETE_ACK(
Signal *);
715 void execDIHNDBTAMPER(
Signal *);
716 void execCONTINUEB(
Signal *);
717 void execCOPY_GCIREQ(
Signal *);
718 void execCOPY_GCICONF(
Signal *);
719 void execCOPY_TABREQ(
Signal *);
720 void execCOPY_TABCONF(
Signal *);
721 void execTCGETOPSIZECONF(
Signal *);
722 void execTC_CLOPSIZECONF(
Signal *);
724 void execDIH_GET_TABINFO_REQ(
Signal*);
727 void execLCP_FRAG_REP(
Signal *);
728 void execLCP_COMPLETE_REP(
Signal *);
729 void execSTART_LCP_REQ(
Signal *);
730 void execSTART_LCP_CONF(
Signal *);
732 void startLcpMutex_locked(
Signal* signal, Uint32, Uint32);
733 void startLcpMutex_unlocked(
Signal* signal, Uint32, Uint32);
734 void lcpFragmentMutex_locked(
Signal* signal, Uint32, Uint32);
735 void master_lcp_fragmentMutex_locked(
Signal* signal, Uint32, Uint32);
738 void switchPrimaryMutex_locked(
Signal* signal, Uint32, Uint32);
739 void switchPrimaryMutex_unlocked(
Signal* signal, Uint32, Uint32);
742 void switch_primary_stop_node(
Signal* signal, Uint32, Uint32);
744 void updateToReq_fragmentMutex_locked(
Signal*, Uint32, Uint32);
748 void execBLOCK_COMMIT_ORD(
Signal *);
749 void execUNBLOCK_COMMIT_ORD(
Signal *);
751 void execDIH_SWITCH_REPLICA_REQ(
Signal *);
752 void execDIH_SWITCH_REPLICA_REF(
Signal *);
753 void execDIH_SWITCH_REPLICA_CONF(
Signal *);
755 void execSTOP_PERM_REQ(
Signal *);
756 void execSTOP_PERM_REF(
Signal *);
757 void execSTOP_PERM_CONF(
Signal *);
759 void execSTOP_ME_REQ(
Signal *);
760 void execSTOP_ME_REF(
Signal *);
761 void execSTOP_ME_CONF(
Signal *);
763 void execREAD_CONFIG_REQ(
Signal *);
764 void execUNBLO_DICTCONF(
Signal *);
765 void execCOPY_ACTIVECONF(
Signal *);
766 void execTAB_COMMITREQ(
Signal *);
767 void execNODE_FAILREP(
Signal *);
768 void execCOPY_FRAGCONF(
Signal *);
769 void execCOPY_FRAGREF(
Signal *);
770 void execPREPARE_COPY_FRAG_REF(
Signal*);
771 void execPREPARE_COPY_FRAG_CONF(
Signal*);
772 void execDIADDTABREQ(
Signal *);
773 void execDIGETNODESREQ(
Signal *);
775 void execDIH_SCAN_TAB_REQ(
Signal *);
776 void execDIH_SCAN_GET_NODES_REQ(
Signal *);
777 void execDIH_SCAN_TAB_COMPLETE_REP(
Signal*);
778 void execGCP_SAVEREF(
Signal *);
779 void execGCP_TCFINISHED(
Signal *);
780 void execGCP_TCFINISHED_sync_conf(
Signal* signal, Uint32 cb, Uint32 err);
781 void execREAD_NODESCONF(
Signal *);
782 void execNDB_STTOR(
Signal *);
783 void execDICTSTARTCONF(
Signal *);
784 void execNDB_STARTREQ(
Signal *);
785 void execGETGCIREQ(
Signal *);
786 void execDIH_RESTARTREQ(
Signal *);
787 void execSTART_RECCONF(
Signal *);
788 void execSTART_FRAGREF(
Signal *);
789 void execSTART_FRAGCONF(
Signal *);
790 void execADD_FRAGCONF(
Signal *);
791 void execADD_FRAGREF(
Signal *);
792 void execDROP_FRAG_REF(
Signal *);
793 void execDROP_FRAG_CONF(
Signal *);
794 void execFSOPENCONF(
Signal *);
795 void execFSOPENREF(
Signal *);
796 void execFSCLOSECONF(
Signal *);
797 void execFSCLOSEREF(
Signal *);
798 void execFSREADCONF(
Signal *);
799 void execFSREADREF(
Signal *);
800 void execFSWRITECONF(
Signal *);
801 void execFSWRITEREF(
Signal *);
802 void execCHECKNODEGROUPSREQ(
Signal *);
803 void execSTART_INFOREQ(
Signal*);
804 void execSTART_INFOREF(
Signal*);
805 void execSTART_INFOCONF(
Signal*);
806 void execWAIT_GCP_REQ(
Signal* signal);
807 void execWAIT_GCP_REF(
Signal* signal);
808 void execWAIT_GCP_CONF(
Signal* signal);
810 void execPREP_DROP_TAB_REQ(
Signal* signal);
811 void execDROP_TAB_REQ(
Signal* signal);
813 void execALTER_TAB_REQ(
Signal* signal);
815 void execCREATE_FRAGMENTATION_REQ(
Signal*);
820 void execDICT_LOCK_CONF(
Signal* signal);
821 void execDICT_LOCK_REF(
Signal* signal);
823 void execUPGRADE_PROTOCOL_ORD(
Signal* signal);
825 void execCREATE_NODEGROUP_IMPL_REQ(
Signal*);
826 void execDROP_NODEGROUP_IMPL_REQ(
Signal*);
832 void nullRoutine(
Signal *, Uint32 nodeId, Uint32);
833 void sendCOPY_GCIREQ(
Signal *, Uint32 nodeId, Uint32);
834 void sendDIH_SWITCH_REPLICA_REQ(
Signal *, Uint32 nodeId, Uint32);
835 void sendEMPTY_LCP_REQ(
Signal *, Uint32 nodeId, Uint32);
836 void sendEND_TOREQ(
Signal *, Uint32 nodeId, Uint32);
837 void sendGCP_COMMIT(
Signal *, Uint32 nodeId, Uint32);
838 void sendGCP_PREPARE(
Signal *, Uint32 nodeId, Uint32);
839 void sendGCP_SAVEREQ(
Signal *, Uint32 nodeId, Uint32);
840 void sendSUB_GCP_COMPLETE_REP(
Signal*, Uint32 nodeId, Uint32);
841 void sendINCL_NODEREQ(
Signal *, Uint32 nodeId, Uint32);
842 void sendMASTER_GCPREQ(
Signal *, Uint32 nodeId, Uint32);
843 void sendMASTER_LCPREQ(
Signal *, Uint32 nodeId, Uint32);
844 void sendMASTER_LCPCONF(
Signal * signal);
845 void sendSTART_RECREQ(
Signal *, Uint32 nodeId, Uint32);
846 void sendSTART_INFOREQ(
Signal *, Uint32 nodeId, Uint32);
847 void sendSTART_TOREQ(
Signal *, Uint32 nodeId, Uint32);
848 void sendSTOP_ME_REQ(
Signal *, Uint32 nodeId, Uint32);
849 void sendTC_CLOPSIZEREQ(
Signal *, Uint32 nodeId, Uint32);
850 void sendTCGETOPSIZEREQ(
Signal *, Uint32 nodeId, Uint32);
851 void sendUPDATE_TOREQ(
Signal *, Uint32 nodeId, Uint32);
852 void sendSTART_LCP_REQ(
Signal *, Uint32 nodeId, Uint32);
855 void sendLastLCP_FRAG_ORD(
Signal *);
858 BlockReference ref, Uint32 reqinfo);
859 void sendCreateFragReq(
Signal *,
863 void sendDihfragreq(
Signal *,
870 void sendStartFragreq(
Signal *,
873 void sendAddFragreq(
Signal *,
880 void addTable_closeConf(
Signal* signal, Uint32 tabPtrI);
882 void resetReplicaLcp(
ReplicaRecord * replicaP, Uint32 stopGci);
889 void checkLcpStart(
Signal *, Uint32 lineNo);
890 void checkStartMoreLcp(
Signal *, Uint32 nodeId);
891 bool reportLcpCompletion(
const struct LcpFragRep *);
892 void sendLCP_COMPLETE_REP(
Signal *);
898 void openTableFileForDelete(
Signal* signal, Uint32 fileIndex);
911 void releaseFile(Uint32 fileIndex);
943 void checkEscalation();
944 void clearRestartInfoBits(
Signal *);
945 void invalidateLcpInfoAfterSr(
Signal*);
948 bool isActiveMaster();
951 void initRestartInfo(
Signal*);
952 void initRestorableGciFiles();
953 void makeNodeGroups(Uint32 nodeArray[]);
955 void inc_ng_refcount(Uint32 ng);
956 void dec_ng_refcount(Uint32 ng);
958 void makePrnList(
class ReadNodesConf * readNodes, Uint32 nodeArray[]);
959 void nodeResetStart(
Signal* signal);
960 void releaseTabPages(Uint32 tableId);
961 void replication(Uint32 noOfReplicas,
964 void sendDihRestartRef(
Signal*);
965 void selectMasterCandidateAndSend(
Signal *);
966 void setLcpActiveStatusEnd(
Signal*);
967 void setLcpActiveStatusStart(
Signal *);
968 void setNodeActiveStatus();
969 void setNodeGroups();
970 void setNodeInfo(
Signal *);
971 void setNodeLcpActiveStatus();
972 void setNodeRestartInfoBits(
Signal*);
974 void startGcpMonitor(
Signal*);
983 void writePageWord(
RWFragment* wf, Uint32 dataWord);
984 void writeReplicas(
RWFragment* wf, Uint32 replicaStartIndex);
989 void gcpcommitreqLab(
Signal *);
990 void copyGciLab(
Signal *, CopyGCIReq::CopyReason reason);
991 void storeNewLcpIdLab(
Signal *);
992 void startLcpRoundLoopLab(
Signal *, Uint32 startTableId, Uint32 startFragId);
999 void setLocalNodefailHandling(
Signal*, Uint32 failedNodeId,
1000 NodefailHandlingStep step);
1001 void checkLocalNodefailComplete(
Signal*, Uint32 failedNodeId,
1002 NodefailHandlingStep step);
1005 void sendSTTORRY(
Signal*, Uint32 senderData = 0, Uint32 retVal = 0);
1006 void ndbsttorry10Lab(
Signal *, Uint32 _line);
1007 void createMutexes(
Signal* signal, Uint32 no);
1008 void createMutex_done(
Signal* signal, Uint32 no, Uint32 retVal);
1010 void crashSystemAtGcpStop(
Signal *,
bool);
1013 void GCP_SAVEhandling(
Signal *, Uint32 nodeId);
1014 void packTableIntoPagesLab(
Signal *, Uint32 tableId);
1015 void readPagesIntoTableLab(
Signal *, Uint32 tableId);
1017 void readTabDescriptionLab(
Signal *, Uint32 tableId);
1018 void copyTableLab(
Signal *, Uint32 tableId);
1019 void breakCopyTableLab(
Signal *,
1022 void checkAddfragCompletedLab(
Signal *,
1025 void completeRestartLab(
Signal *);
1028 void checkTcCounterLab(
Signal *);
1029 void calculateKeepGciLab(
Signal *, Uint32 tableId, Uint32 fragId);
1031 void checkLcpCompletedLab(
Signal *);
1032 void initLcpLab(
Signal *, Uint32 masterRef, Uint32 tableId);
1033 void startGcpLab(
Signal *, Uint32 aWaitTime);
1034 void checkGcpStopLab(
Signal *);
1035 void MASTER_GCPhandling(
Signal *, Uint32 failedNodeId);
1036 void MASTER_LCPhandling(
Signal *, Uint32 failedNodeId);
1038 void startLcpTakeOverLab(
Signal *, Uint32 failedNodeId);
1040 void startLcpMasterTakeOver(
Signal *, Uint32 failedNodeId);
1041 void startGcpMasterTakeOver(
Signal *, Uint32 failedNodeId);
1042 void checkGcpOutstanding(
Signal*, Uint32 failedNodeId);
1044 void checkEmptyLcpComplete(
Signal *);
1045 void lcpBlockedLab(
Signal *, Uint32, Uint32);
1047 void readGciFileLab(
Signal *);
1049 void startLcpRoundLab(
Signal *);
1050 void gcpBlockedLab(
Signal *);
1051 void initialStartCompletedLab(
Signal *);
1052 void allNodesLcpCompletedLab(
Signal *);
1053 void nodeRestartPh2Lab(
Signal *);
1054 void nodeRestartPh2Lab2(
Signal *);
1055 void initGciFilesLab(
Signal *);
1056 void dictStartConfLab(
Signal *);
1057 void nodeDictStartConfLab(
Signal *);
1058 void ndbStartReqLab(
Signal *, BlockReference ref);
1059 void nodeRestartStartRecConfLab(
Signal *);
1060 void dihCopyCompletedLab(
Signal *);
1062 void copyTableNode(
Signal *,
1065 void startFragment(
Signal *, Uint32 tableId, Uint32 fragId);
1066 bool checkLcpAllTablesDoneInLqh(Uint32 from);
1068 void lcpStateAtNodeFailureLab(
Signal *, Uint32 nodeId);
1069 void copyNodeLab(
Signal *, Uint32 tableId);
1070 void copyGciReqLab(
Signal *);
1076 void removeNodeFromTables(
Signal *, Uint32 tableId, Uint32 nodeId);
1078 void removeNodeFromTablesComplete(
Signal* signal, Uint32 nodeId);
1081 void startNextChkpt(
Signal *);
1086 void initCommonData();
1087 void initialiseRecordsLab(
Signal *, Uint32 stepNo, Uint32, Uint32);
1092 bool oldStoredReplicas =
false);
1101 void handleLcpMasterTakeOver(
Signal *, Uint32 nodeId);
1110 Uint32& oldestRestorableGci);
1113 Uint32& tfstStartGci,
1117 void releaseReplicas(Uint32 * replicaPtr);
1118 void removeOldCrashedReplicas(Uint32, Uint32,
ReplicaRecordPtr rocReplicaPtr);
1119 void removeTooNewCrashedReplicas(
ReplicaRecordPtr rtnReplicaPtr, Uint32 lastCompletedGCI);
1130 Uint32 extractNodeInfo(
const Fragmentstore * fragPtr, Uint32 nodes[]);
1136 Uint32& fblStopGci);
1151 void removeNodeFromStored(Uint32 nodeId,
1168 void allocFragments(Uint32 noOfFragments,
TabRecordPtr regTabPtr);
1171 void initialiseFragstore();
1173 void wait_old_scan(
Signal*);
1181 void alter_table_writeTable_conf(
Signal* signal, Uint32 ptrI, Uint32 err);
1189 void releasePage(Uint32 pageIndex);
1198 void handleTakeOverMaster(
Signal *, Uint32 takeOverPtr);
1199 void handleTakeOverNewMaster(
Signal *, Uint32 takeOverPtr);
1206 bool anyActiveTakeOver();
1208 void checkToCopyCompleted(
Signal *);
1210 Uint32 getStartNode(Uint32 takeOverPtr);
1215 void changeNodeGroups(Uint32 startNode, Uint32 nodeTakenOver);
1216 void endTakeOver(Uint32 takeOverPtr);
1218 void systemRestartTakeOverLab(
Signal *);
1219 void startTakeOver(
Signal *,
1223 void startNextCopyFragment(
Signal *, Uint32 takeOverPtr);
1224 void toCopyFragLab(
Signal *, Uint32 takeOverPtr);
1226 void startHsAddFragConfLab(
Signal *);
1227 void prepareSendCreateFragReq(
Signal *, Uint32 takeOverPtr);
1229 void takeOverCompleted(Uint32 aNodeId);
1234 void checkStartTakeOver(
Signal *);
1240 NodeRecord::NodeStatus getNodeStatus(Uint32 nodeId);
1241 void setNodeStatus(Uint32 nodeId, NodeRecord::NodeStatus);
1244 void setNodeLcpActiveStatus(Uint32 nodeId,
bool newState);
1245 bool getNodeLcpActiveStatus(Uint32 nodeId);
1246 bool getAllowNodeStart(Uint32 nodeId);
1247 void setAllowNodeStart(Uint32 nodeId,
bool newState);
1248 bool getNodeCopyCompleted(Uint32 nodeId);
1249 void setNodeCopyCompleted(Uint32 nodeId,
bool newState);
1250 Uint32 getNodeGroup(Uint32 nodeId)
const;
1251 bool checkNodeAlive(Uint32 nodeId);
1258 void getTabInfo(
Signal*);
1260 void getTabInfo_sendComplete(
Signal*, Uint32, Uint32);
1270 Uint32 capiConnectFileSize;
1273 Uint32 cfirstconnect;
1274 Uint32 cconnectFileSize;
1277 Uint32 cnoOfCreateReplicas;
1280 Uint32 cfirstfreeFile;
1281 Uint32 cfileFileSize;
1284 Uint32 cfirstfragstore;
1285 Uint32 cfragstoreFileSize;
1286 RSS_OP_SNAPSHOT(cremainingfrags);
1288 Uint32 c_nextNodeGroup;
1290 RSS_OP_SNAPSHOT(cnghash);
1295 Uint32 cfirstfreepage;
1296 Uint32 cpageFileSize;
1299 Uint32 cfirstfreeReplica;
1300 Uint32 cnoFreeReplicaRec;
1301 Uint32 creplicaFileSize;
1302 RSS_OP_SNAPSHOT(cnoFreeReplicaRec);
1305 Uint32 ctabFileSize;
1314 struct DIVERIFY_queue
1318 cfirstVerifyQueue = clastVerifyQueue = 0;
1319 apiConnectRecord = 0;
1322 ApiConnectRecord *apiConnectRecord;
1323 Uint32 cfirstVerifyQueue;
1324 Uint32 clastVerifyQueue;
1325 Uint32 m_empty_done;
1329 bool isEmpty(
const DIVERIFY_queue&);
1330 void enqueue(DIVERIFY_queue&, Uint32 senderData, Uint64 gci);
1331 void dequeue(DIVERIFY_queue&, ApiConnectRecord &);
1332 void emptyverificbuffer(
Signal *, Uint32 q,
bool aContintueB);
1333 void emptyverificbuffer_check(
Signal*, Uint32, Uint32);
1335 DIVERIFY_queue c_diverify_queue[MAX_NDBMT_LQH_THREADS];
1336 Uint32 c_diverify_queue_cnt;
1343 Uint32 crestartInfoFile[2];
1348 Uint32 cgcpOrderBlocked;
1357 Uint32 m_master_ref;
1362 GCP_SAVE_COPY_GCI = 3
1368 Uint32 m_time_between_gcp;
1369 Uint64 m_start_time;
1380 Uint32 m_master_ref;
1388 Uint64 m_current_gci;
1394 M_GCP_COMMITTED = 3,
1400 Uint32 m_time_between_gcp;
1402 Uint64 m_start_time;
1429 MASTER_TAKE_OVER_GCP = 2
1431 MasterState cmasterState;
1432 Uint16 cmasterTakeOverNode;
1437 struct CopyGCIMaster {
1439 m_copyReason = CopyGCIReq::IDLE;
1440 for (Uint32
i = 0;
i<WAIT_CNT;
i++)
1441 m_waiting[
i] = CopyGCIReq::IDLE;
1448 CopyGCIReq::CopyReason m_copyReason;
1455 STATIC_CONST( WAIT_CNT = 2 );
1456 CopyGCIReq::CopyReason m_waiting[WAIT_CNT];
1459 struct CopyGCISlave {
1460 CopyGCISlave(){ m_copyReason = CopyGCIReq::IDLE; m_expectedNextWord = 0;}
1467 Uint32 m_senderData;
1468 BlockReference m_senderRef;
1469 CopyGCIReq::CopyReason m_copyReason;
1471 Uint32 m_expectedNextWord;
1480 LCP_STATUS_IDLE = 0,
1482 LCP_STATUS_ACTIVE = 2,
1483 LCP_CALCULATE_KEEP_GCI = 4,
1485 LCP_INIT_TABLES = 6,
1486 LCP_TC_CLOPSIZE = 7,
1487 LCP_START_LCP_ROUND = 8,
1488 LCP_TAB_COMPLETED = 9,
1495 LcpStatus lcpStatus;
1496 Uint32 lcpStatusUpdatedPlace;
1503 void setLcpStatus(LcpStatus status, Uint32 line){
1504 for (Uint32
i = 9;
i > 0;
i--)
1505 m_saveState[
i] = m_saveState[
i-1];
1506 m_saveState[0].m_status = lcpStatus;
1507 m_saveState[0].m_place = lcpStatusUpdatedPlace;
1510 lcpStatusUpdatedPlace = line;
1516 Uint32 oldestRestorableGci;
1518 Uint64 m_start_time;
1520 Uint32 m_lcp_trylock_timeout;
1527 Uint32 noOfLcpFragRepOutstanding;
1542 bool immediateLcpStart;
1543 bool m_LCP_COMPLETE_REP_From_Master_Received;
1550 Uint32 m_masterLcpDihRef;
1551 bool m_MASTER_LCPREQ_Received;
1552 Uint32 m_MASTER_LCPREQ_FailedNodeId;
1554 Uint32 m_lastLCP_COMPLETE_REP_id;
1555 Uint32 m_lastLCP_COMPLETE_REP_ref;
1563 Uint32 cnoOfActiveTables;
1565 BlockReference cdictblockref;
1571 BlockReference clocallqhblockref;
1572 BlockReference clocaltcblockref;
1573 BlockReference cmasterdihref;
1575 BlockReference cndbStartReqBlockref;
1576 BlockReference cntrlblockref;
1577 Uint32 con_lineNodes;
1578 Uint32 creceivedfrag;
1579 Uint32 cremainingfrags;
1581 Uint32 csystemnodes;
1582 Uint32 c_newest_restorable_gci;
1583 Uint32 c_set_initial_start_flag;
1584 Uint64 c_current_time;
1587 enum LcpMasterTakeOverState {
1589 LMTOS_WAIT_EMPTY_LCP = 1,
1590 LMTOS_WAIT_LCP_FRAG_REP = 2,
1593 LMTOS_ALL_ACTIVE = 5,
1594 LMTOS_LCP_CONCLUDING = 6,
1595 LMTOS_COPY_ONGOING = 7
1598 class MasterTakeOverState {
1600 MasterTakeOverState() {}
1601 void set(LcpMasterTakeOverState s, Uint32 line) {
1602 state = s; updatePlace = line;
1605 LcpMasterTakeOverState state;
1610 Uint32 failedNodeId;
1611 } c_lcpMasterTakeOverState;
1613 Uint16 cmasterNodeId;
1615 struct NodeStartMasterRecord {
1616 NodeStartMasterRecord() {}
1623 Uint32 startInfoErrorCode;
1624 Uint32 m_outstandingGsn;
1627 NodeStartMasterRecord c_nodeStartMaster;
1629 struct NodeStartSlaveRecord {
1630 NodeStartSlaveRecord() { nodeId = 0;}
1634 NodeStartSlaveRecord c_nodeStartSlave;
1636 Uint32 cfirstAliveNode;
1637 Uint32 cfirstDeadNode;
1646 Uint32 c_node_groups[MAX_NDB_NODES];
1647 Uint32 cnoOfNodeGroups;
1674 Uint32 c_blockCommitNo;
1676 bool getBlockCommit()
const {
1677 return c_blockCommit || cgckptflag;
1683 struct SwitchReplicaRecord {
1684 SwitchReplicaRecord() {}
1691 SwitchReplicaRecord c_switchReplicas;
1693 struct StopPermProxyRecord {
1694 StopPermProxyRecord() { clientRef = 0; }
1697 BlockReference clientRef;
1698 BlockReference masterRef;
1701 struct StopPermMasterRecord {
1702 StopPermMasterRecord() { clientRef = 0;}
1707 BlockReference clientRef;
1710 StopPermProxyRecord c_stopPermProxy;
1711 StopPermMasterRecord c_stopPermMaster;
1713 void checkStopPermProxy(
Signal*, NodeId failedNodeId);
1714 void checkStopPermMaster(
Signal*, NodeRecordPtr failedNodePtr);
1716 void switchReplica(
Signal*,
1721 void switchReplicaReply(
Signal*, NodeId nodeId);
1726 struct WaitGCPProxyRecord {
1727 WaitGCPProxyRecord() { clientRef = 0;}
1730 BlockReference clientRef;
1731 BlockReference masterRef;
1733 union { Uint32 nextPool; Uint32 nextList; };
1741 struct WaitGCPMasterRecord {
1742 WaitGCPMasterRecord() { clientRef = 0;}
1744 BlockReference clientRef;
1746 union { Uint32 nextPool; Uint32 nextList; };
1762 WaitGCPList c_waitGCPMasterList;
1763 WaitGCPList c_waitEpochMasterList;
1765 void checkWaitGCPProxy(
Signal*, NodeId failedNodeId);
1766 void checkWaitGCPMaster(
Signal*, NodeId failedNodeId);
1767 void emptyWaitGCPMasterQueue(
Signal*, Uint64, WaitGCPList&);
1772 struct StopMeRecord {
1773 StopMeRecord() { clientRef = 0;}
1775 BlockReference clientRef;
1778 StopMeRecord c_stopMe;
1780 void checkStopMe(
Signal *, NodeRecordPtr failedNodePtr);
1782 #define DIH_CDATA_SIZE 128
1786 Uint32 cdata[DIH_CDATA_SIZE];
1791 Uint32 sysfileData[DIH_CDATA_SIZE];
1792 Uint32 sysfileDataToFile[DIH_CDATA_SIZE];
1798 void invalidateNodeLCP(
Signal *, Uint32 nodeId, Uint32 tableId);
1799 void invalidateNodeLCP(
Signal *, Uint32 nodeId, TabRecordPtr);
1804 void startInfoReply(
Signal *, Uint32 nodeId);
1806 void dump_replica_info();
1807 void dump_replica_info(
const Fragmentstore*);
1810 void execNODE_START_REP(
Signal* signal);
1816 struct DictLockSlaveRecord {
1828 void sendDictLockReq(
Signal* signal, Uint32 lockType, Callback c);
1829 void recvDictLockConf(
Signal* signal);
1830 void sendDictUnlockOrd(
Signal* signal, Uint32 lockSlavePtrI);
1833 Uint32 c_dictLockSlavePtrI_nodeRestart;
1834 void recvDictLockConf_nodeRestart(
Signal* signal, Uint32 data, Uint32
ret);
1836 Uint32 c_error_7181_ref;
1841 Uint32
extra = RNIL,
1842 Uint32
block = 0, Uint32 gsn = 0, Uint32 len = 0,
1843 JobBufferLevel = JBB);
1846 bool check_enable_micro_gcp(
Signal* signal,
bool broadcast);
1852 void startme_copygci_conf(
Signal*);
1863 struct LocalLCPState
1875 LocalLCPState() { reset();}
1880 void lcp_complete_rep(Uint32 gci);
1885 bool check_cut_log_tail(Uint32 gci)
const;
1886 } m_local_lcp_state;
1889 Uint32 c_fragments_per_node;
1890 Uint32 dihGetInstanceKey(FragmentstorePtr tFragPtr) {
1891 ndbrequire(!tFragPtr.isNull());
1892 Uint32 log_part_id = tFragPtr.p->m_log_part_id;
1893 Uint32 instanceKey = 1 + log_part_id % MAX_NDBMT_LQH_WORKERS;
1896 Uint32 dihGetInstanceKey(Uint32 tabId, Uint32 fragId);
1901 #if (DIH_CDATA_SIZE < _SYSFILE_SIZE32)
1902 #error "cdata is to small compared to Sysfile size"