20 #include <ndb_limits.h>
21 #include <md5_hash.hpp>
23 #include <ndb_version.h>
24 #include <signaldata/TuxBound.hpp>
25 #include <signaldata/AccScan.hpp>
26 #include <signaldata/CopyActive.hpp>
27 #include <signaldata/CopyFrag.hpp>
28 #include <signaldata/CreateTrigImpl.hpp>
29 #include <signaldata/DropTrigImpl.hpp>
30 #include <signaldata/EmptyLcp.hpp>
31 #include <signaldata/EventReport.hpp>
32 #include <signaldata/ExecFragReq.hpp>
33 #include <signaldata/GCP.hpp>
34 #include <signaldata/TcKeyRef.hpp>
35 #include <signaldata/LqhKey.hpp>
36 #include <signaldata/NextScan.hpp>
37 #include <signaldata/NFCompleteRep.hpp>
38 #include <signaldata/NodeFailRep.hpp>
39 #include <signaldata/ReadNodesConf.hpp>
40 #include <signaldata/RelTabMem.hpp>
41 #include <signaldata/ScanFrag.hpp>
42 #include <signaldata/SrFragidConf.hpp>
43 #include <signaldata/StartFragReq.hpp>
44 #include <signaldata/StartRec.hpp>
45 #include <signaldata/TupKey.hpp>
46 #include <signaldata/TupCommit.hpp>
47 #include <signaldata/LqhFrag.hpp>
48 #include <signaldata/AccFrag.hpp>
49 #include <signaldata/TupFrag.hpp>
50 #include <signaldata/DumpStateOrd.hpp>
51 #include <signaldata/PackedSignal.hpp>
53 #include <signaldata/CreateTab.hpp>
54 #include <signaldata/CreateTable.hpp>
55 #include <signaldata/PrepDropTab.hpp>
56 #include <signaldata/DropTab.hpp>
58 #include <signaldata/AlterTab.hpp>
59 #include <signaldata/AlterTable.hpp>
60 #include <signaldata/DictTabInfo.hpp>
62 #include <signaldata/LCP.hpp>
63 #include <DebuggerNames.hpp>
64 #include <signaldata/BackupImpl.hpp>
65 #include <signaldata/RestoreImpl.hpp>
66 #include <signaldata/KeyInfo.hpp>
67 #include <signaldata/AttrInfo.hpp>
68 #include <signaldata/TransIdAI.hpp>
69 #include <KeyDescriptor.hpp>
70 #include <signaldata/RouteOrd.hpp>
71 #include <signaldata/FsRef.hpp>
72 #include <SectionReader.hpp>
73 #include <signaldata/SignalDroppedRep.hpp>
74 #include <signaldata/FsReadWriteReq.hpp>
75 #include <signaldata/DbinfoScan.hpp>
76 #include <signaldata/SystemError.hpp>
77 #include <signaldata/FireTrigOrd.hpp>
80 #include "../suma/Suma.hpp"
81 #include "DblqhCommon.hpp"
83 #include <EventLogger.hpp>
89 #define DEBUG(x) ndbout << "DBLQH: "<< x << endl;
92 operator<<(NdbOut& out, Dblqh::TcConnectionrec::TransactionState state){
99 operator<<(NdbOut& out, Dblqh::TcConnectionrec::LogWriteState state){
106 operator<<(NdbOut& out, Dblqh::TcConnectionrec::ListState state){
113 operator<<(NdbOut& out, Dblqh::TcConnectionrec::AbortState state){
120 operator<<(NdbOut& out, Dblqh::ScanRecord::ScanState state){
134 operator<<(NdbOut& out, Dblqh::ScanRecord::ScanType state){
141 operator<<(NdbOut& out, Operation_t op)
144 case ZREAD: out <<
"READ";
break;
145 case ZREAD_EX: out <<
"READ-EX";
break;
146 case ZINSERT: out <<
"INSERT";
break;
147 case ZUPDATE: out <<
"UPDATE";
break;
148 case ZDELETE: out <<
"DELETE";
break;
149 case ZWRITE: out <<
"WRITE";
break;
150 case ZUNLOCK: out <<
"UNLOCK";
break;
151 case ZREFRESH: out <<
"REFRESH";
break;
164 #ifndef NDB_DEBUG_REDO
165 #define NDB_DEBUG_REDO
169 #ifdef NDB_DEBUG_REDO
170 static int DEBUG_REDO = 0;
175 const Uint32 NR_ScanNo = 0;
184 #include <NdbConfig.h>
185 static NdbOut * tracenrout = 0;
186 static int TRACENR_FLAG = 0;
187 #define TRACENR(x) (* tracenrout) << x
188 #define SET_TRACENR_FLAG TRACENR_FLAG = 1
189 #define CLEAR_TRACENR_FLAG TRACENR_FLAG = 0
191 #define TRACENR_FLAG 0
192 #define TRACENR(x) do { } while(0)
193 #define SET_TRACENR_FLAG
194 #define CLEAR_TRACENR_FLAG
198 static NdbOut * traceopout = 0;
199 #define TRACE_OP(regTcPtr, place) do { if (TRACE_OP_CHECK(regTcPtr)) TRACE_OP_DUMP(regTcPtr, place); } while(0)
201 #define TRACE_OP(x, y) { (void)x;}
213 if (pos1.m_file_no > pos2.m_file_no)
215 if (pos1.m_file_no < pos2.m_file_no)
217 if (pos1.m_mbyte > pos2.m_mbyte)
219 if (pos1.m_mbyte < pos2.m_mbyte)
231 Uint32 cnt, Uint32
size)
233 Uint64 headmb = head.m_file_no*Uint64(size) + head.m_mbyte;
234 Uint64 tailmb = tail.m_file_no*Uint64(size) + tail.m_mbyte;
235 if (headmb >= tailmb)
237 return (cnt * Uint64(size)) - headmb + tailmb;
241 return tailmb - headmb;
249 void Dblqh::systemError(
Signal* signal,
int line)
251 signal->theData[0] = 2304;
252 execDUMP_STATE_ORD(signal);
259 void Dblqh::execACCSEIZEREF(
Signal* signal)
272 void Dblqh::execCONTINUEB(
Signal* signal)
275 Uint32 tcase = signal->theData[0];
276 Uint32 data0 = signal->theData[1];
277 Uint32 data1 = signal->theData[2];
278 Uint32 data2 = signal->theData[3];
281 tcConnectptr.i = data0;
282 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
283 ndbout <<
"State = " << tcConnectptr.p->transactionState;
284 ndbout <<
" seqNoReplica = " << tcConnectptr.p->seqNoReplica;
285 ndbout <<
" tcNodeFailrec = " << tcConnectptr.p->tcNodeFailrec;
286 ndbout <<
" activeCreat = " << tcConnectptr.p->activeCreat;
288 ndbout <<
"abortState = " << tcConnectptr.p->abortState;
289 ndbout <<
"listState = " << tcConnectptr.p->
listState;
294 LogPartRecordPtr save;
297 if (cnoOfLogPages == 0) {
300 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 10, 2);
303 logPartPtr.i = data0;
304 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
320 if (logPartPtr.p->m_log_problems != 0)
329 if (cnoOfLogPages < ZMIN_LOG_PAGES_OPERATION)
338 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
340 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
342 getFirstInLogQueue(signal, tcConnectptr);
343 fragptr.i = tcConnectptr.p->fragmentptr;
344 c_fragment_pool.
getPtr(fragptr);
349 switch (tcConnectptr.p->transactionState) {
350 case TcConnectionrec::LOG_QUEUED:
351 if (tcConnectptr.p->abortState != TcConnectionrec::ABORT_IDLE)
354 abortCommonLab(signal);
359 logLqhkeyreqLab(signal);
362 case TcConnectionrec::LOG_ABORT_QUEUED:
364 writeAbortLog(signal);
365 removeLogTcrec(signal);
366 continueAfterLogAbortWriteLab(signal);
368 case TcConnectionrec::LOG_COMMIT_QUEUED:
369 case TcConnectionrec::LOG_COMMIT_QUEUED_WAIT_SIGNAL:
371 writeCommitLog(signal, logPartPtr);
372 if (tcConnectptr.p->transactionState == TcConnectionrec::LOG_COMMIT_QUEUED) {
373 if (tcConnectptr.p->seqNoReplica == 0 ||
374 tcConnectptr.p->activeCreat == Fragrecord::AC_NR_COPY)
377 localCommitLab(signal);
382 commitReplyLab(signal);
388 tcConnectptr.p->transactionState = TcConnectionrec::LOG_COMMIT_WRITTEN_WAIT_SIGNAL;
391 case TcConnectionrec::COMMIT_QUEUED:
393 localCommitLab(signal);
395 case TcConnectionrec::ABORT_QUEUED:
397 abortCommonLab(signal);
410 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
412 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
413 logNextStart(signal);
418 signal->theData[0] = data0;
424 signal->theData[0] = data0;
425 signal->theData[1] = data1;
426 signal->theData[2] = data2;
430 case ZSEND_EXEC_CONF:
432 signal->theData[0] = data0;
433 sendExecConf(signal);
438 signal->theData[0] = data0;
442 case ZSR_FOURTH_COMP:
444 signal->theData[0] = data0;
445 srFourthComp(signal);
450 signal->theData[0] = data0;
454 case ZTIME_SUPERVISION:
456 signal->theData[0] = data0;
460 case ZSR_PHASE3_START:
462 srPhase3Start(signal);
465 case ZLQH_TRANS_NEXT:
467 tcNodeFailptr.i = data0;
468 ptrCheckGuard(tcNodeFailptr, ctcNodeFailrecFileSize, tcNodeFailRecord);
469 lqhTransNextLab(signal);
472 case ZSCAN_TC_CONNECT:
475 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
476 scanTcConnectLab(signal, data0, data2);
479 case ZINITIALISE_RECORDS:
481 initialiseRecordsLab(signal, data0, data2, signal->theData[4]);
487 ptrAss(gcpPtr, gcpRecord);
488 initGcpRecLab(signal);
489 startTimeSupervision(signal);
492 case ZCHECK_LCP_STOP_BLOCKED:
494 c_scanRecordPool.
getPtr(scanptr, data0);
495 tcConnectptr.i = scanptr.p->scanTcrec;
496 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
497 fragptr.i = tcConnectptr.p->fragmentptr;
498 c_fragment_pool.
getPtr(fragptr);
499 checkLcpStopBlockedLab(signal);
507 case ZOPERATION_EVENT_REP:
511 const Uint32 len = c_Counters.build_event_rep(signal);
512 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, len, JBB);
516 const Uint32 report_interval = 5000;
517 const Uint32 len = c_Counters.build_continueB(signal);
518 signal->theData[0] = ZOPERATION_EVENT_REP;
519 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal,
520 report_interval, len);
523 case ZDROP_TABLE_WAIT_USAGE:
525 dropTab_wait_usage(signal);
528 case ZENABLE_EXPAND_CHECK:
531 fragptr.i = signal->theData[1];
532 if (fragptr.i != RNIL)
535 c_lcp_complete_fragments.
getPtr(fragptr);
536 signal->theData[0] = fragptr.p->
tabRef;
537 signal->theData[1] = fragptr.p->
fragId;
538 BlockReference accRef = calcInstanceBlockRef(DBACC);
539 sendSignal(accRef, GSN_EXPANDCHECK2, signal, 2, JBB);
542 c_lcp_complete_fragments.
next(fragptr);
543 signal->theData[0] = ZENABLE_EXPAND_CHECK;
544 signal->theData[1] = fragptr.i;
545 sendSignal(reference(), GSN_CONTINUEB, signal, 2, JBB);
547 c_lcp_complete_fragments.remove(save);
553 cstartRecReq = SRR_REDO_COMPLETE;
554 ndbrequire(c_lcp_complete_fragments.isEmpty());
556 rebuildOrderedIndexes(signal, 0);
560 case ZRETRY_TCKEYREF:
563 Uint32 cnt = signal->theData[1];
564 Uint32 ref = signal->theData[2];
565 if (cnt < (10 * 60 * 5))
571 memmove(signal->theData, signal->theData+3, 4*TcKeyRef::SignalLength);
572 sendTCKEYREF(signal, ref, 0, cnt);
576 case ZWAIT_REORG_SUMA_FILTER_ENABLED:
578 wait_reorg_suma_filter_enabled(signal);
580 case ZREBUILD_ORDERED_INDEXES:
582 Uint32 tableId = signal->theData[1];
583 rebuildOrderedIndexes(signal, tableId);
589 wait_readonly(signal);
602 void Dblqh::execINCL_NODEREQ(
Signal* signal)
605 BlockReference retRef = signal->theData[0];
606 Uint32 nodeId = signal->theData[1];
607 cnewestGci = signal->theData[2];
608 cnewestCompletedGci = signal->theData[2] - 1;
609 ndbrequire(cnoOfNodes < MAX_NDB_NODES);
610 for (Uint32
i = 0;
i < cnoOfNodes;
i++) {
612 if (cnodeData[
i] == nodeId) {
614 cnodeStatus[
i] = ZNODE_UP;
619 HostRecordPtr Thostptr;
621 ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
622 Thostptr.p->nodestatus = ZNODE_UP;
625 signal->theData[0] = nodeId;
626 signal->theData[1] = cownref;
627 sendSignal(retRef, GSN_INCL_NODECONF, signal, 2, JBB);
631 void Dblqh::execTUPSEIZEREF(
Signal* signal)
643 void Dblqh::execSTTOR(
Signal* signal)
649 tstartPhase = signal->theData[1];
651 csignalKey = signal->theData[6];
652 #if defined VM_TRACE || defined ERROR_INSERT || defined NDBD_TRACENR
656 switch (tstartPhase) {
659 cstartPhase = tstartPhase;
660 c_tup = (
Dbtup*)globalData.getBlock(DBTUP, instance());
661 c_acc = (
Dbacc*)globalData.getBlock(DBACC, instance());
662 c_lgman = (
Lgman*)globalData.getBlock(LGMAN);
663 ndbrequire(c_tup != 0 && c_acc != 0 && c_lgman != 0);
664 sendsttorryLab(signal);
668 out = globalSignalLoggers.getOutputStream();
671 name = NdbConfig_SignalLogFileName(getOwnNodeId());
672 out = fopen(name,
"a");
678 traceopout = &ndbout;
681 #ifdef NDB_DEBUG_REDO
684 if (NdbEnv_GetEnv(
"NDB_DEBUG_REDO", buf,
sizeof(buf)))
694 define_backup(signal);
699 sendsttorryLab(signal);
706 Dblqh::define_backup(
Signal* signal)
712 req->senderRef = reference();
714 req->backupKey[0] = 0;
715 req->backupKey[1] = 0;
717 req->nodes.
set(getOwnNodeId());
718 req->backupDataLen = ~0;
720 BlockReference backupRef = calcInstanceBlockRef(BACKUP);
721 sendSignal(backupRef, GSN_DEFINE_BACKUP_REQ, signal,
722 DefineBackupReq::SignalLength, JBB);
726 Dblqh::execDEFINE_BACKUP_REF(
Signal* signal)
732 char * extra_msg = NULL;
734 switch(ref->errorCode){
735 case DefineBackupRef::Undefined:
736 case DefineBackupRef::FailedToSetupFsBuffers:
737 case DefineBackupRef::FailedToAllocateBuffers:
738 case DefineBackupRef::FailedToAllocateTables:
739 case DefineBackupRef::FailedAllocateTableMem:
740 case DefineBackupRef::FailedToAllocateFileRecord:
741 case DefineBackupRef::FailedToAllocateAttributeRecord:
742 case DefineBackupRef::FailedInsertFileHeader:
743 case DefineBackupRef::FailedInsertTableList:
745 err_code = NDBD_EXIT_INVALID_CONFIG;
746 extra_msg = (
char*)
"Probably Backup parameters configuration error, Please consult the manual";
747 progError(__LINE__, err_code, extra_msg);
750 sendsttorryLab(signal);
754 Dblqh::execDEFINE_BACKUP_CONF(
Signal* signal)
758 m_backup_ptr = conf->backupPtr;
759 sendsttorryLab(signal);
765 void Dblqh::execNDB_STTOR(
Signal* signal)
768 Uint32 ownNodeId = signal->theData[1];
769 cstartPhase = signal->theData[2];
770 cstartType = signal->theData[3];
772 switch (cstartPhase) {
775 preComputedRequestInfoMask = 0;
776 LqhKeyReq::setKeyLen(preComputedRequestInfoMask, RI_KEYLEN_MASK);
777 LqhKeyReq::setLastReplicaNo(preComputedRequestInfoMask, RI_LAST_REPL_MASK);
779 LqhKeyReq::setDirtyFlag(preComputedRequestInfoMask, 1);
781 LqhKeyReq::setSimpleFlag(preComputedRequestInfoMask, 1);
782 LqhKeyReq::setOperation(preComputedRequestInfoMask, RI_OPERATION_MASK);
783 LqhKeyReq::setGCIFlag(preComputedRequestInfoMask, 1);
784 LqhKeyReq::setNrCopyFlag(preComputedRequestInfoMask, 1);
790 LqhKeyReq::setMarkerFlag(preComputedRequestInfoMask, 1);
791 LqhKeyReq::setQueueOnRedoProblemFlag(preComputedRequestInfoMask, 1);
793 startphase1Lab(signal, ~0, ownNodeId);
797 const Uint32 len = c_Counters.build_continueB(signal);
798 signal->theData[0] = ZOPERATION_EVENT_REP;
799 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 10, len);
805 startphase2Lab(signal, ~0);
810 startphase3Lab(signal);
815 startphase4Lab(signal);
820 startphase6Lab(signal);
826 sendNdbSttorryLab(signal);
837 void Dblqh::startphase1Lab(
Signal* signal, Uint32 _dummy, Uint32 ownNodeId)
840 HostRecordPtr ThostPtr;
843 cownNodeid = ownNodeId;
844 caccBlockref = calcInstanceBlockRef(DBACC);
845 ctupBlockref = calcInstanceBlockRef(DBTUP);
846 ctuxBlockref = calcInstanceBlockRef(DBTUX);
847 cownref = calcInstanceBlockRef(DBLQH);
848 ndbassert(cownref == reference());
849 for (Ti = 0; Ti < chostFileSize; Ti++) {
851 ptrCheckGuard(ThostPtr, chostFileSize, hostRecord);
856 ThostPtr.p->hostLqhBlockRef = calcInstanceBlockRef(DBLQH, ThostPtr.i);
857 ThostPtr.p->hostTcBlockRef = calcTcBlockRef(ThostPtr.i);
858 ThostPtr.p->inPackedList =
false;
859 ThostPtr.p->noOfPackedWordsLqh = 0;
860 ThostPtr.p->noOfPackedWordsTc = 0;
861 ThostPtr.p->nodestatus = ZNODE_DOWN;
863 cpackedListIndex = 0;
866 (cstartType == NodeState::ST_INITIAL_START) ||
867 (cstartType == NodeState::ST_INITIAL_NODE_RESTART);
869 LogFileRecordPtr prevLogFilePtr;
870 LogFileRecordPtr zeroLogFilePtr;
872 ndbrequire(cnoLogFiles != 0);
873 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++)
876 ptrAss(logPartPtr, logPartRecord);
878 for (Uint32 fileNo = 0; fileNo < cnoLogFiles; fileNo++)
880 seizeLogfile(signal);
884 prevLogFilePtr.p->nextLogFile = logFilePtr.i;
892 zeroLogFilePtr.i = logFilePtr.i;
893 zeroLogFilePtr.p = logFilePtr.p;
895 prevLogFilePtr.i = logFilePtr.i;
896 prevLogFilePtr.p = logFilePtr.p;
897 initLogfile(signal, fileNo);
901 if (logFilePtr.i == zeroLogFilePtr.i)
910 if (m_use_om_init == 0 || logPartPtr.i == 0)
925 disable_global_variables();
928 openLogfileInit(signal);
933 zeroLogFilePtr.p->prevLogFile = logFilePtr.i;
937 initReportStatus(signal);
941 sendNdbSttorryLab(signal);
945 reportStatus(signal);
958 void Dblqh::startphase2Lab(
Signal* signal, Uint32 _dummy)
960 cmaxWordsAtNodeRec = MAX_NO_WORDS_OUTSTANDING_COPY_FRAGMENT;
963 ptrAss(tcConnectptr, tcConnectionrec);
964 moreconnectionsLab(signal);
968 void Dblqh::moreconnectionsLab(
Signal* signal)
970 tcConnectptr.p->tcAccBlockref = caccBlockref;
972 tcConnectptr.p->tcTuxBlockref = ctuxBlockref;
977 signal->theData[0] = tcConnectptr.i;
978 signal->theData[1] = cownref;
979 sendSignal(caccBlockref, GSN_ACCSEIZEREQ, signal, 2, JBB);
986 void Dblqh::execACCSEIZECONF(
Signal* signal)
989 tcConnectptr.i = signal->theData[0];
990 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
991 tcConnectptr.p->accConnectrec = signal->theData[1];
995 tcConnectptr.p->tcTupBlockref = ctupBlockref;
996 signal->theData[0] = tcConnectptr.i;
997 signal->theData[1] = cownref;
998 sendSignal(ctupBlockref, GSN_TUPSEIZEREQ, signal, 2, JBB);
1005 void Dblqh::execTUPSEIZECONF(
Signal* signal)
1008 tcConnectptr.i = signal->theData[0];
1009 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
1010 tcConnectptr.p->tupConnectrec = signal->theData[1];
1012 tcConnectptr.i = tcConnectptr.p->nextTcConnectrec;
1013 if (tcConnectptr.i != RNIL) {
1015 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
1016 moreconnectionsLab(signal);
1020 sendNdbSttorryLab(signal);
1038 void Dblqh::startphase3Lab(
Signal* signal)
1040 caddNodeState = ZTRUE;
1044 cinitialStartOngoing = ZTRUE;
1047 case NodeState::ST_NODE_RESTART:
1048 case NodeState::ST_SYSTEM_RESTART:
1050 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++)
1053 LogFileRecordPtr locLogFilePtr;
1054 ptrAss(logPartPtr, logPartRecord);
1056 ptrCheckGuard(locLogFilePtr, clogFileFileSize, logFileRecord);
1058 openFileRw(signal, locLogFilePtr);
1061 case NodeState::ST_INITIAL_START:
1062 case NodeState::ST_INITIAL_NODE_RESTART:
1064 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++)
1067 signal->theData[0] = ZINIT_FOURTH;
1068 signal->theData[1] = logPartPtr.i;
1069 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
1074 signal->theData[0] = cownref;
1075 sendSignal(NDBCNTR_REF, GSN_READ_NODESREQ, signal, 1, JBB);
1082 void Dblqh::execREAD_NODESCONF(
Signal* signal)
1087 cnoOfNodes = readNodes->noOfNodes;
1091 for (
i = 1;
i < MAX_NDB_NODES;
i++) {
1099 HostRecordPtr Thostptr;
1101 ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
1102 Thostptr.p->nodestatus = cnodeStatus[ind];
1114 ndbrequire(ind == cnoOfNodes);
1115 ndbrequire(cnoOfNodes >= 1 && cnoOfNodes < MAX_NDB_NODES);
1116 ndbrequire(!(cnoOfNodes == 1 && cstartType == NodeState::ST_NODE_RESTART));
1119 c_master_node_id = readNodes->masterNodeId;
1122 caddNodeState = ZFALSE;
1123 if (cstartType == NodeState::ST_SYSTEM_RESTART)
1126 sendNdbSttorryLab(signal);
1129 else if (cstartType == NodeState::ST_NODE_RESTART)
1134 m_sr_nodes.
set(getOwnNodeId());
1135 sendNdbSttorryLab(signal);
1140 checkStartCompletedLab(signal);
1144 void Dblqh::checkStartCompletedLab(
Signal* signal)
1146 if (caddNodeState == ZFALSE) {
1147 if (cinitialStartOngoing == ZFALSE) {
1149 sendNdbSttorryLab(signal);
1156 void Dblqh::startphase4Lab(
Signal* signal)
1158 sendNdbSttorryLab(signal);
1165 void Dblqh::startphase6Lab(
Signal* signal)
1170 sendNdbSttorryLab(signal);
1174 void Dblqh::sendNdbSttorryLab(
Signal* signal)
1176 signal->theData[0] = cownref;
1177 BlockReference cntrRef = !isNdbMtLqh() ? NDBCNTR_REF : DBLQH_REF;
1178 sendSignal(cntrRef, GSN_NDB_STTORRY, signal, 1, JBB);
1182 void Dblqh::sendsttorryLab(
Signal* signal)
1187 signal->theData[0] = csignalKey;
1188 signal->theData[1] = 3;
1189 signal->theData[2] = 2;
1190 signal->theData[3] = ZSTART_PHASE1;
1191 signal->theData[4] = 4;
1192 signal->theData[5] = 255;
1193 BlockReference cntrRef = !isNdbMtLqh() ? NDBCNTR_REF : DBLQH_REF;
1194 sendSignal(cntrRef, GSN_STTORRY, signal, 6, JBB);
1201 void Dblqh::execREAD_NODESREF(
Signal* signal)
1210 void Dblqh::execREAD_CONFIG_REQ(
Signal* signal)
1213 Uint32 ref = req->senderRef;
1214 Uint32 senderData = req->senderData;
1215 ndbrequire(req->noOfParameters == 0);
1220 m_ctx.m_config.getOwnConfigIterator();
1224 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_REDOLOG_FILES,
1226 ndbrequire(cnoLogFiles > 0);
1228 Uint32 log_page_size= 0;
1229 ndb_mgm_get_int_parameter(p, CFG_DB_REDO_BUFFER,
1235 clogPageFileSize= (log_page_size /
sizeof(LogPageRecord));
1236 Uint32 mega_byte_part= clogPageFileSize & 15;
1237 if (mega_byte_part != 0) {
1239 clogPageFileSize+= (16 - mega_byte_part);
1243 clfoFileSize = clogPageFileSize;
1244 if (clfoFileSize < ZLFO_MIN_FILE_SIZE)
1245 clfoFileSize = ZLFO_MIN_FILE_SIZE;
1247 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_TABLE, &ctabrecFileSize));
1248 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_TC_CONNECT,
1249 &ctcConnectrecFileSize));
1250 clogFileFileSize = 4 * cnoLogFiles;
1251 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_SCAN, &cscanrecFileSize));
1252 cmaxAccOps = cscanrecFileSize * MAX_PARALLEL_OP_PER_SCAN;
1254 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_DISCLESS, &c_diskless));
1256 ndb_mgm_get_int_parameter(p, CFG_DB_O_DIRECT, &c_o_direct);
1260 const char * conf = 0;
1261 if (!ndb_mgm_get_string_parameter(p, CFG_DB_INIT_REDO, &conf) && conf)
1264 if (strcasecmp(conf,
"sparse") == 0)
1269 else if (strcasecmp(conf,
"full") == 0)
1278 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_FRAG, &tmp));
1281 if (!ndb_mgm_get_int_parameter(p, CFG_DB_REDOLOG_FILE_SIZE,
1285 clogFileSize = (clogFileSize + 1024*1024 - 1) / (1024 * 1024);
1286 ndbrequire(clogFileSize >= 4 && clogFileSize <= 1024);
1289 m_startup_report_frequency = 0;
1290 ndb_mgm_get_int_parameter(p,CFG_DB_STARTUP_REPORT_FREQUENCY,
1291 &m_startup_report_frequency);
1292 totalLogFiles = 4 * cnoLogFiles;
1293 totallogMBytes = totalLogFiles * clogFileSize;
1295 cmaxLogFilesInPageZero = (ZPAGE_SIZE - ZPAGE_HEADER_SIZE - 128) /
1296 (ZFD_MBYTE_SIZE * clogFileSize);
1305 if (cmaxLogFilesInPageZero > 40)
1308 cmaxLogFilesInPageZero = 40;
1312 ndbrequire(cmaxLogFilesInPageZero);
1316 Uint32 config_val = 20;
1317 ndb_mgm_get_int_parameter(p, CFG_DB_LCP_INTERVAL, &config_val);
1318 config_val = config_val > 31 ? 31 : config_val;
1320 const Uint32 mb = 1024 * 1024;
1323 const Uint64 config_mbytes = ((Uint64(4) << config_val) + mb - 1) / mb;
1324 const Uint64 totalmb = Uint64(cnoLogFiles) * Uint64(clogFileSize);
1325 if (totalmb > config_mbytes)
1327 c_free_mb_force_lcp_limit = Uint32(totalmb - config_mbytes);
1331 c_free_mb_force_lcp_limit = 0;
1335 Uint32
limit = Uint32(totalmb / 3);
1336 if (c_free_mb_force_lcp_limit < limit)
1338 c_free_mb_force_lcp_limit =
limit;
1341 c_free_mb_tail_problem_limit = 4;
1343 ndb_mgm_get_int_parameter(p, CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT,
1344 &cTransactionDeadlockDetectionTimeout);
1347 initialiseRecordsLab(signal, 0, ref, senderData);
1349 c_max_redo_lag = 30;
1350 ndb_mgm_get_int_parameter(p, CFG_DB_REDO_OVERCOMMIT_LIMIT,
1353 c_max_redo_lag_counter = 3;
1354 ndb_mgm_get_int_parameter(p, CFG_DB_REDO_OVERCOMMIT_COUNTER,
1355 &c_max_redo_lag_counter);
1357 c_max_parallel_scans_per_frag = 32;
1358 ndb_mgm_get_int_parameter(p, CFG_DB_PARALLEL_SCANS_PER_FRAG,
1359 &c_max_parallel_scans_per_frag);
1361 if (c_max_parallel_scans_per_frag > (256 - MAX_PARALLEL_SCANS_PER_FRAG) / 2)
1364 c_max_parallel_scans_per_frag = (256 - MAX_PARALLEL_SCANS_PER_FRAG) / 2;
1385 Dblqh::execCREATE_TAB_REQ(
Signal* signal)
1388 tabptr.i = req->tableId;
1389 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
1391 Uint32 senderRef = req->senderRef;
1392 Uint32 senderData = req->senderData;
1394 if (tabptr.p->
tableStatus != Tablerec::NOT_DEFINED)
1398 ref->senderData = senderData;
1399 ref->senderRef = reference();
1400 ref->errorCode = CreateTableRef::TableAlreadyExist;
1401 sendSignal(senderRef, GSN_CREATE_TAB_REF, signal,
1402 CreateTabRef::SignalLength, JBB);
1406 seizeAddfragrec(signal);
1407 addfragptr.p->m_createTabReq = *req;
1408 req = &addfragptr.p->m_createTabReq;
1410 tabptr.p->
tableStatus = Tablerec::ADD_TABLE_ONGOING;
1412 tabptr.p->primaryTableId = (req->primaryTableId == RNIL ? tabptr.i :
1413 req->primaryTableId);
1414 tabptr.p->schemaVersion = req->tableVersion;
1415 tabptr.p->m_disk_table= 0;
1417 addfragptr.p->addfragStatus = AddFragRecord::WAIT_TUP;
1418 sendCreateTabReq(signal, addfragptr);
1422 Dblqh::sendCreateTabReq(
Signal* signal, AddFragRecordPtr addfragptr)
1425 tabPtr.i = addfragptr.p->m_createTabReq.tableId;
1426 ptrCheckGuard(tabPtr, ctabrecFileSize, tablerec);
1429 * req = addfragptr.p->m_createTabReq;
1431 req->senderRef = reference();
1432 req->senderData = addfragptr.i;
1434 Uint32 ref = calcInstanceBlockRef(DBTUP);
1435 switch(addfragptr.p->addfragStatus){
1436 case AddFragRecord::WAIT_TUP:
1437 if (DictTabInfo::isOrderedIndex(tabPtr.p->tableType))
1440 req->noOfAttributes = 1;
1441 req->noOfKeyAttr = 1;
1442 req->noOfNullAttributes = 0;
1445 case AddFragRecord::WAIT_TUX:
1447 ndbrequire(req->noOfAttributes >= 2);
1448 req->noOfAttributes--;
1449 ref = calcInstanceBlockRef(DBTUX);
1452 jamLine(addfragptr.p->addfragStatus);
1456 sendSignal(ref, GSN_CREATE_TAB_REQ, signal,
1457 CreateTabReq::SignalLengthLDM, JBB);
1461 Dblqh::execCREATE_TAB_REF(
Signal* signal)
1466 addfragptr.i = ref->senderData;
1467 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
1469 abortAddFragOps(signal);
1471 ref->senderRef = reference();
1472 ref->senderData = addfragptr.p->m_createTabReq.senderData;
1473 sendSignal(addfragptr.p->m_createTabReq.senderRef,
1474 GSN_CREATE_TAB_REF, signal, CreateTabConf::SignalLength, JBB);
1476 releaseAddfragrec(signal);
1480 Dblqh::execCREATE_TAB_CONF(
Signal* signal)
1484 addfragptr.i = conf->senderData;
1485 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
1488 tabPtr.i = addfragptr.p->m_createTabReq.tableId;
1489 ptrCheckGuard(tabPtr, ctabrecFileSize, tablerec);
1491 switch(addfragptr.p->addfragStatus){
1492 case AddFragRecord::WAIT_TUP:
1494 addfragptr.p->tupConnectptr = conf->tupConnectPtr;
1495 if (DictTabInfo::isOrderedIndex(tabPtr.p->tableType))
1498 addfragptr.p->addfragStatus = AddFragRecord::WAIT_TUX;
1499 sendCreateTabReq(signal, addfragptr);
1503 case AddFragRecord::WAIT_TUX:
1505 addfragptr.p->tuxConnectptr = conf->tuxConnectPtr;
1508 jamLine(addfragptr.p->addfragStatus);
1512 addfragptr.p->addfragStatus = AddFragRecord::WAIT_ADD_ATTR;
1514 conf->senderRef = reference();
1515 conf->senderData = addfragptr.p->m_createTabReq.senderData;
1516 conf->lqhConnectPtr = addfragptr.i;
1517 sendSignal(addfragptr.p->m_createTabReq.senderRef,
1518 GSN_CREATE_TAB_CONF, signal, CreateTabConf::SignalLength, JBB);
1524 void Dblqh::execLQHADDATTREQ(
Signal* signal)
1529 addfragptr.i = req->lqhFragPtr;
1530 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
1532 addfragptr.p->m_addAttrReq = * req;
1534 const Uint32 tnoOfAttr = req->noOfAttributes;
1535 const Uint32 numSections = signal->getNoOfSections();
1536 bool isLongReq= ( numSections != 0 );
1537 addfragptr.p->defValSectionI = RNIL;
1538 addfragptr.p->defValNextPos = 0;
1544 handle.getSection(defValSection, LqhAddAttrReq::DEFAULT_VALUE_SECTION_NUM);
1545 addfragptr.p->defValSectionI = defValSection.i;
1546 addfragptr.p->defValNextPos = 0;
1551 ndbrequire(addfragptr.p->addfragStatus == AddFragRecord::WAIT_ADD_ATTR);
1552 ndbrequire((tnoOfAttr != 0) && (tnoOfAttr <= LqhAddAttrReq::MAX_ATTRIBUTES));
1553 addfragptr.p->totalAttrReceived += tnoOfAttr;
1554 ndbrequire(addfragptr.p->totalAttrReceived <=
1555 addfragptr.p->m_createTabReq.noOfAttributes);
1557 addfragptr.p->attrReceived = tnoOfAttr;
1560 tabPtr.i = addfragptr.p->m_createTabReq.tableId;
1561 ptrCheckGuard(tabPtr, ctabrecFileSize, tablerec);
1563 for (Uint32
i = 0;
i < tnoOfAttr;
i++)
1565 if(AttributeDescriptor::getDiskBased(req->attributes[
i].attrDescriptor))
1568 tabPtr.p->m_disk_table = 1;
1572 addfragptr.p->attrSentToTup = 0;
1573 addfragptr.p->addfragStatus = AddFragRecord::TUP_ATTR_WAIT;
1574 sendAddAttrReq(signal);
1580 void Dblqh::execTUP_ADD_ATTCONF(
Signal* signal)
1583 addfragptr.i = signal->theData[0];
1585 const bool lastAttr = signal->theData[1];
1586 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
1588 tabptr.i = addfragptr.p->m_createTabReq.tableId;
1589 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
1591 Uint32 noOfAttr = addfragptr.p->m_createTabReq.noOfAttributes;
1593 switch (addfragptr.p->addfragStatus) {
1594 case AddFragRecord::TUP_ATTR_WAIT:
1595 if (DictTabInfo::isOrderedIndex(tabptr.p->
tableType))
1597 addfragptr.p->addfragStatus = AddFragRecord::TUX_ATTR_WAIT;
1598 sendAddAttrReq(signal);
1601 goto done_with_attr;
1603 case AddFragRecord::TUX_ATTR_WAIT:
1606 addfragptr.p->tuxConnectptr = RNIL;
1607 goto done_with_attr;
1610 addfragptr.p->attrSentToTup = addfragptr.p->attrSentToTup + 1;
1611 ndbrequire(addfragptr.p->attrSentToTup <= addfragptr.p->attrReceived);
1612 ndbrequire(addfragptr.p->totalAttrReceived <= noOfAttr);
1613 if (addfragptr.p->attrSentToTup < addfragptr.p->attrReceived)
1617 addfragptr.p->addfragStatus = AddFragRecord::TUP_ATTR_WAIT;
1618 sendAddAttrReq(signal);
1622 if (addfragptr.p->defValSectionI != RNIL)
1624 releaseSection(addfragptr.p->defValSectionI);
1625 addfragptr.p->defValNextPos = 0;
1626 addfragptr.p->defValSectionI = RNIL;
1631 conf->senderData = addfragptr.p->m_addAttrReq.senderData;
1632 conf->senderAttrPtr = addfragptr.p->m_addAttrReq.senderAttrPtr;
1633 sendSignal(addfragptr.p->m_createTabReq.senderRef,
1634 GSN_LQHADDATTCONF, signal, LqhAddAttrConf::SignalLength, JBB);
1636 if (addfragptr.p->totalAttrReceived < noOfAttr)
1639 addfragptr.p->addfragStatus = AddFragRecord::WAIT_ADD_ATTR;
1644 releaseAddfragrec(signal);
1656 void Dblqh::execTUX_ADD_ATTRCONF(
Signal* signal)
1659 execTUP_ADD_ATTCONF(signal);
1665 void Dblqh::execTUP_ADD_ATTRREF(
Signal* signal)
1668 addfragptr.i = signal->theData[0];
1669 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
1670 Uint32 errorCode = terrorCode = signal->theData[1];
1672 abortAddFragOps(signal);
1675 switch (addfragptr.p->addfragStatus) {
1676 case AddFragRecord::TUP_ATTR_WAIT:
1679 case AddFragRecord::TUX_ATTR_WAIT:
1687 if (addfragptr.p->defValSectionI != RNIL)
1689 releaseSection(addfragptr.p->defValSectionI);
1690 addfragptr.p->defValNextPos = 0;
1691 addfragptr.p->defValSectionI = RNIL;
1694 const Uint32 Ref = addfragptr.p->m_createTabReq.senderRef;
1695 const Uint32 senderData = addfragptr.p->m_addAttrReq.senderData;
1697 releaseAddfragrec(signal);
1700 ref->senderData = senderData;
1701 ref->errorCode = errorCode;
1702 sendSignal(Ref, GSN_LQHADDATTREF, signal,
1703 LqhAddAttrRef::SignalLength, JBB);
1709 void Dblqh::execTUX_ADD_ATTRREF(
Signal* signal)
1712 execTUP_ADD_ATTRREF(signal);
1719 Dblqh::sendAddAttrReq(
Signal* signal)
1721 arrGuard(addfragptr.p->attrSentToTup, LqhAddAttrReq::MAX_ATTRIBUTES);
1723 addfragptr.p->m_addAttrReq.attributes[addfragptr.p->attrSentToTup];
1725 const Uint32 attrId = entry.attrId & 0xffff;
1726 const Uint32 primaryAttrId = entry.attrId >> 16;
1728 tabptr.i = addfragptr.p->m_createTabReq.tableId;
1729 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
1731 if (addfragptr.p->addfragStatus == AddFragRecord::TUP_ATTR_WAIT)
1733 if (DictTabInfo::isTable(tabptr.p->
tableType) ||
1734 DictTabInfo::isHashIndex(tabptr.p->
tableType) ||
1735 (DictTabInfo::isOrderedIndex(tabptr.p->
tableType) &&
1736 primaryAttrId == ZNIL)) {
1739 tupreq->tupConnectPtr = addfragptr.p->tupConnectptr;
1740 tupreq->attrId = attrId;
1741 tupreq->attrDescriptor = entry.attrDescriptor;
1742 tupreq->extTypeInfo = entry.extTypeInfo;
1743 BlockReference tupRef = calcInstanceBlockRef(DBTUP);
1745 Uint32 sectionLen = 0;
1746 Uint32 startIndex = TupAddAttrReq::SignalLength;
1747 if (addfragptr.p->defValSectionI != RNIL)
1750 getSection(defValSection, addfragptr.p->defValSectionI);
1752 SectionReader defValueReader(defValSection, getSectionSegmentPool());
1753 Uint32 defSectionWords = defValueReader.getSize();
1755 ndbrequire(defValueReader.step(addfragptr.p->defValNextPos));
1757 Uint32 defValueHeader;
1758 ndbrequire(defValueReader.peekWord(&defValueHeader));
1761 Uint32 defValueLen = ah.getByteSize();
1762 Uint32 defValueWords = ((defValueLen +3)/4) + 1;
1763 Uint32 *dst = &signal->theData[startIndex];
1764 ndbassert(defSectionWords >= (addfragptr.p->defValNextPos + defValueWords));
1765 ndbrequire(defValueReader.getWords(dst, defValueWords));
1766 addfragptr.p->defValNextPos += defValueWords;
1767 sectionLen = defValueWords;
1771 if (sectionLen != 0)
1774 ptr[0].p= &signal->theData[startIndex];
1775 ptr[0].sz= sectionLen;
1776 sendSignal(tupRef, GSN_TUP_ADD_ATTRREQ,
1777 signal, TupAddAttrReq::SignalLength, JBB, ptr, 1);
1780 sendSignal(tupRef, GSN_TUP_ADD_ATTRREQ,
1781 signal, TupAddAttrReq::SignalLength, JBB);
1785 if (DictTabInfo::isOrderedIndex(tabptr.p->
tableType) &&
1786 primaryAttrId != ZNIL) {
1790 tupconf->userPtr = addfragptr.i;
1791 tupconf->lastAttr =
false;
1792 sendSignal(reference(), GSN_TUP_ADD_ATTCONF,
1793 signal, TupAddAttrConf::SignalLength, JBB);
1798 if (addfragptr.p->addfragStatus == AddFragRecord::TUX_ATTR_WAIT)
1801 if (DictTabInfo::isOrderedIndex(tabptr.p->
tableType) &&
1802 primaryAttrId != ZNIL) {
1805 tuxreq->tuxConnectPtr = addfragptr.p->tuxConnectptr;
1806 tuxreq->notused1 = 0;
1807 tuxreq->attrId = attrId;
1808 tuxreq->attrDescriptor = entry.attrDescriptor;
1809 tuxreq->extTypeInfo = entry.extTypeInfo;
1810 tuxreq->primaryAttrId = primaryAttrId;
1811 BlockReference tuxRef = calcInstanceBlockRef(DBTUX);
1812 sendSignal(tuxRef, GSN_TUX_ADD_ATTRREQ,
1813 signal, TuxAddAttrReq::SignalLength, JBB);
1816 if (DictTabInfo::isOrderedIndex(tabptr.p->
tableType) &&
1817 primaryAttrId == ZNIL) {
1821 tuxconf->userPtr = addfragptr.i;
1822 tuxconf->lastAttr =
false;
1823 sendSignal(reference(), GSN_TUX_ADD_ATTRCONF,
1824 signal, TuxAddAttrConf::SignalLength, JBB);
1831 void Dblqh::execLQHFRAGREQ(
Signal* signal)
1837 tabptr.i = req->tableId;
1838 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
1840 if (tabptr.p->
tableStatus != Tablerec::ADD_TABLE_ONGOING &&
1841 (AlterTableReq::getAddFragFlag(req->changeMask) == 0))
1844 fragrefLab(signal, ZTAB_STATE_ERROR, req);
1848 if (getFragmentrec(signal, req->fragId))
1851 fragrefLab(signal, terrorCode, req);
1855 if (!insertFragrec(signal, req->fragId))
1858 fragrefLab(signal, terrorCode, req);
1862 Uint32 copyType = req->requestInfo & 3;
1863 bool tempTable = ((req->requestInfo & LqhFragReq::TemporaryTable) != 0);
1864 initFragrec(signal, tabptr.i, req->fragId, copyType);
1865 fragptr.p->
startGci = req->startGci;
1872 Uint32 logPartNo = lpinfo.partNoFromId(req->logPartId);
1873 ndbrequire(lpinfo.partNoOwner(logPartNo));
1875 LogPartRecordPtr ptr;
1876 ptr.i = lpinfo.partNoIndex(logPartNo);
1877 ptrCheckGuard(ptr, clogPartFileSize, logPartRecord);
1878 ndbrequire(ptr.p->logPartNo == logPartNo);
1884 if (DictTabInfo::isOrderedIndex(tabptr.p->tableType)) {
1887 TablerecPtr tTablePtr;
1888 tTablePtr.i = tabptr.p->primaryTableId;
1889 ptrCheckGuard(tTablePtr, ctabrecFileSize, tablerec);
1890 FragrecordPtr tFragPtr;
1892 for (Uint32
i = 0;
i < MAX_FRAG_PER_NODE;
i++) {
1893 if (tTablePtr.p->fragid[
i] == fragptr.p->fragId) {
1895 tFragPtr.i = tTablePtr.p->fragrec[
i];
1899 ndbrequire(tFragPtr.i != RNIL);
1901 fragptr.p->tableFragptr = tFragPtr.i;
1906 fragptr.p->tableFragptr = fragptr.i;
1916 fragptr.p->logFlag = Fragrecord::STATE_FALSE;
1917 fragptr.p->lcpFlag = Fragrecord::LCP_STATE_FALSE;
1920 seizeAddfragrec(signal);
1921 addfragptr.p->m_lqhFragReq = * req;
1922 addfragptr.p->fragmentPtr = fragptr.i;
1924 if (DictTabInfo::isTable(tabptr.p->tableType) ||
1925 DictTabInfo::isHashIndex(tabptr.p->tableType)) {
1928 accreq->userPtr = addfragptr.i;
1929 accreq->userRef = cownref;
1930 accreq->tableId = tabptr.i;
1931 accreq->reqInfo = 0;
1932 accreq->fragId = req->fragId;
1933 accreq->localKeyLen = addfragptr.p->m_lqhFragReq.localKeyLength;
1934 accreq->maxLoadFactor = addfragptr.p->m_lqhFragReq.maxLoadFactor;
1935 accreq->minLoadFactor = addfragptr.p->m_lqhFragReq.minLoadFactor;
1936 accreq->kValue = addfragptr.p->m_lqhFragReq.kValue;
1937 accreq->lhFragBits = addfragptr.p->m_lqhFragReq.lh3DistrBits;
1938 accreq->lhDirBits = addfragptr.p->m_lqhFragReq.lh3PageBits;
1939 accreq->keyLength = addfragptr.p->m_lqhFragReq.keyLength;
1944 addfragptr.p->addfragStatus = AddFragRecord::ACC_ADDFRAG;
1945 sendSignal(fragptr.p->accBlockref, GSN_ACCFRAGREQ,
1946 signal, AccFragReq::SignalLength, JBB);
1949 if (DictTabInfo::isOrderedIndex(tabptr.p->tableType)) {
1951 addfragptr.p->addfragStatus = AddFragRecord::WAIT_TUP;
1952 sendAddFragReq(signal);
1961 void Dblqh::execACCFRAGCONF(
Signal* signal)
1964 addfragptr.i = signal->theData[0];
1965 Uint32 taccConnectptr = signal->theData[1];
1967 Uint32 accFragPtr1 = signal->theData[4];
1968 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
1969 ndbrequire(addfragptr.p->addfragStatus == AddFragRecord::ACC_ADDFRAG);
1971 addfragptr.p->accConnectptr = taccConnectptr;
1972 fragptr.i = addfragptr.p->fragmentPtr;
1973 c_fragment_pool.
getPtr(fragptr);
1976 addfragptr.p->addfragStatus = AddFragRecord::WAIT_TUP;
1977 sendAddFragReq(signal);
1983 void Dblqh::execTUPFRAGCONF(
Signal* signal)
1986 addfragptr.i = signal->theData[0];
1987 Uint32 tupConnectptr = signal->theData[1];
1988 Uint32 tupFragPtr = signal->theData[2];
1990 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
1991 fragptr.i = addfragptr.p->fragmentPtr;
1992 c_fragment_pool.
getPtr(fragptr);
1993 tabptr.i = fragptr.p->
tabRef;
1994 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
1996 switch (addfragptr.p->addfragStatus) {
1997 case AddFragRecord::WAIT_TUP:
2000 addfragptr.p->tupConnectptr = tupConnectptr;
2001 if (DictTabInfo::isOrderedIndex(tabptr.p->
tableType))
2003 addfragptr.p->addfragStatus = AddFragRecord::WAIT_TUX;
2004 sendAddFragReq(signal);
2007 goto done_with_frag;
2009 case AddFragRecord::WAIT_TUX:
2011 fragptr.p->tuxFragptr = tupFragPtr;
2012 addfragptr.p->tuxConnectptr = tupConnectptr;
2013 goto done_with_frag;
2022 conf->senderData = addfragptr.p->m_lqhFragReq.senderData;
2023 conf->lqhFragPtr = RNIL;
2024 conf->tableId = addfragptr.p->m_lqhFragReq.tableId;
2025 conf->fragId = fragptr.p->
fragId;
2026 conf->changeMask = addfragptr.p->m_lqhFragReq.changeMask;
2027 sendSignal(addfragptr.p->m_lqhFragReq.senderRef, GSN_LQHFRAGCONF,
2028 signal, LqhFragConf::SignalLength, JBB);
2030 releaseAddfragrec(signal);
2041 void Dblqh::execTUXFRAGCONF(
Signal* signal)
2044 execTUPFRAGCONF(signal);
2051 Dblqh::sendAddFragReq(
Signal* signal)
2053 fragptr.i = addfragptr.p->fragmentPtr;
2054 c_fragment_pool.
getPtr(fragptr);
2055 tabptr.i = fragptr.p->
tabRef;
2056 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
2057 if (addfragptr.p->addfragStatus == AddFragRecord::WAIT_TUP)
2060 tupFragReq->userPtr = addfragptr.i;
2061 tupFragReq->userRef = cownref;
2062 tupFragReq->reqInfo = 0;
2063 tupFragReq->tableId = tabptr.i;
2064 tupFragReq->fragId = addfragptr.p->m_lqhFragReq.fragId;
2065 tupFragReq->tablespaceid = addfragptr.p->m_lqhFragReq.tablespace_id;
2066 tupFragReq->maxRowsHigh = addfragptr.p->m_lqhFragReq.maxRowsHigh;
2067 tupFragReq->maxRowsLow = addfragptr.p->m_lqhFragReq.maxRowsLow;
2068 tupFragReq->minRowsHigh = addfragptr.p->m_lqhFragReq.minRowsHigh;
2069 tupFragReq->minRowsLow = addfragptr.p->m_lqhFragReq.minRowsLow;
2070 tupFragReq->changeMask = addfragptr.p->m_lqhFragReq.changeMask;
2071 sendSignal(fragptr.p->
tupBlockref, GSN_TUPFRAGREQ,
2072 signal, TupFragReq::SignalLength, JBB);
2075 if (addfragptr.p->addfragStatus == AddFragRecord::WAIT_TUX)
2078 ndbrequire(DictTabInfo::isOrderedIndex(tabptr.p->
tableType));
2080 tuxreq->userPtr = addfragptr.i;
2081 tuxreq->userRef = cownref;
2082 tuxreq->reqInfo = 0;
2083 tuxreq->tableId = tabptr.i;
2084 tuxreq->fragId = addfragptr.p->m_lqhFragReq.fragId;
2085 tuxreq->primaryTableId = tabptr.p->primaryTableId;
2087 tuxreq->tupIndexFragPtrI = fragptr.p->
tupFragptr;
2089 FragrecordPtr tFragPtr;
2091 c_fragment_pool.
getPtr(tFragPtr);
2092 tuxreq->tupTableFragPtrI = tFragPtr.p->tupFragptr;
2093 tuxreq->accTableFragPtrI = tFragPtr.p->accFragptr;
2094 sendSignal(fragptr.p->
tuxBlockref, GSN_TUXFRAGREQ,
2095 signal, TuxFragReq::SignalLength, JBB);
2104 void Dblqh::execTAB_COMMITREQ(
Signal* signal)
2107 Uint32 dihPtr = signal->theData[0];
2108 BlockReference dihBlockref = signal->theData[1];
2109 tabptr.i = signal->theData[2];
2111 if (tabptr.i >= ctabrecFileSize) {
2113 terrorCode = ZTAB_FILE_SIZE;
2114 signal->theData[0] = dihPtr;
2115 signal->theData[1] = cownNodeid;
2116 signal->theData[2] = tabptr.i;
2117 signal->theData[3] = terrorCode;
2118 sendSignal(dihBlockref, GSN_TAB_COMMITREF, signal, 4, JBB);
2121 ptrAss(tabptr, tablerec);
2122 if (tabptr.p->
tableStatus != Tablerec::ADD_TABLE_ONGOING) {
2124 terrorCode = ZTAB_STATE_ERROR;
2125 signal->theData[0] = dihPtr;
2126 signal->theData[1] = cownNodeid;
2127 signal->theData[2] = tabptr.i;
2128 signal->theData[3] = terrorCode;
2130 sendSignal(dihBlockref, GSN_TAB_COMMITREF, signal, 5, JBB);
2134 tabptr.p->usageCountR = 0;
2135 tabptr.p->usageCountW = 0;
2137 signal->theData[0] = dihPtr;
2138 signal->theData[1] = cownNodeid;
2139 signal->theData[2] = tabptr.i;
2140 sendSignal(dihBlockref, GSN_TAB_COMMITCONF, signal, 3, JBB);
2146 void Dblqh::fragrefLab(
Signal* signal,
2151 ref->senderData = req->senderData;
2152 ref->errorCode = errorCode;
2153 ref->requestInfo = req->requestInfo;
2154 ref->tableId = req->tableId;
2155 ref->fragId = req->fragId;
2156 ref->changeMask = req->changeMask;
2157 sendSignal(req->senderRef, GSN_LQHFRAGREF, signal,
2158 LqhFragRef::SignalLength, JBB);
2165 void Dblqh::abortAddFragOps(
Signal* signal)
2167 if (addfragptr.p->tupConnectptr != RNIL) {
2170 tupFragReq->userPtr = (Uint32)-1;
2171 tupFragReq->userRef = addfragptr.p->tupConnectptr;
2172 sendSignal(ctupBlockref, GSN_TUPFRAGREQ, signal, 2, JBB);
2173 addfragptr.p->tupConnectptr = RNIL;
2175 if (addfragptr.p->tuxConnectptr != RNIL) {
2178 tuxFragReq->userPtr = (Uint32)-1;
2179 tuxFragReq->userRef = addfragptr.p->tuxConnectptr;
2180 sendSignal(ctuxBlockref, GSN_TUXFRAGREQ, signal, 2, JBB);
2181 addfragptr.p->tuxConnectptr = RNIL;
2188 void Dblqh::execACCFRAGREF(
Signal* signal)
2191 addfragptr.i = signal->theData[0];
2192 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
2193 Uint32 errorCode = terrorCode = signal->theData[1];
2194 ndbrequire(addfragptr.p->addfragStatus == AddFragRecord::ACC_ADDFRAG);
2196 fragrefLab(signal, errorCode, &addfragptr.p->m_lqhFragReq);
2197 releaseAddfragrec(signal);
2205 void Dblqh::execTUPFRAGREF(
Signal* signal)
2208 addfragptr.i = signal->theData[0];
2209 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
2210 Uint32 errorCode = terrorCode = signal->theData[1];
2211 fragptr.i = addfragptr.p->fragmentPtr;
2212 c_fragment_pool.
getPtr(fragptr);
2215 switch (addfragptr.p->addfragStatus) {
2216 case AddFragRecord::WAIT_TUP:
2219 case AddFragRecord::WAIT_TUX:
2227 fragrefLab(signal, errorCode, &addfragptr.p->m_lqhFragReq);
2228 releaseAddfragrec(signal);
2233 Dblqh::execDROP_FRAG_REQ(
Signal* signal)
2236 seizeAddfragrec(signal);
2237 addfragptr.p->m_dropFragReq = *req;
2245 tabptr.i = req->tableId;
2246 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
2248 deleteFragrec(req->fragId);
2250 Uint32 ref = calcInstanceBlockRef(DBACC);
2251 if (DictTabInfo::isOrderedIndex(tabptr.p->
tableType))
2254 ref = calcInstanceBlockRef(DBTUP);
2257 req->senderRef = reference();
2258 req->senderData = addfragptr.i;
2259 sendSignal(ref, GSN_DROP_FRAG_REQ, signal, DropFragReq::SignalLength, JBB);
2263 Dblqh::execDROP_FRAG_REF(
Signal* signal)
2269 Dblqh::execDROP_FRAG_CONF(
Signal* signal)
2272 addfragptr.i = conf->senderData;
2273 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
2276 switch(refToMain(conf->senderRef)){
2279 ref = calcInstanceBlockRef(DBTUP);
2283 tabptr.i = addfragptr.p->m_dropFragReq.tableId;
2284 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
2285 if (DictTabInfo::isOrderedIndex(tabptr.p->
tableType))
2288 ref = calcInstanceBlockRef(DBTUX);
2301 * req = addfragptr.p->m_dropFragReq;
2302 req->senderRef = reference();
2303 req->senderData = addfragptr.i;
2304 sendSignal(ref, GSN_DROP_FRAG_REQ, signal, DropFragReq::SignalLength,
2309 conf->senderRef = reference();
2310 conf->senderData = addfragptr.p->m_dropFragReq.senderData;
2311 conf->tableId = addfragptr.p->m_dropFragReq.tableId;
2312 conf->fragId = addfragptr.p->m_dropFragReq.fragId;
2313 sendSignal(addfragptr.p->m_dropFragReq.senderRef, GSN_DROP_FRAG_CONF,
2314 signal, DropFragConf::SignalLength, JBB);
2316 releaseAddfragrec(signal);
2322 void Dblqh::execTUXFRAGREF(
Signal* signal)
2325 execTUPFRAGREF(signal);
2329 Dblqh::execPREP_DROP_TAB_REQ(
Signal* signal){
2334 Uint32 senderRef = req->senderRef;
2335 Uint32 senderData = req->senderData;
2338 tabPtr.i = req->tableId;
2339 ptrCheckGuard(tabPtr, ctabrecFileSize, tablerec);
2342 switch(tabPtr.p->tableStatus) {
2343 case Tablerec::TABLE_DEFINED:
2346 case Tablerec::NOT_DEFINED:
2349 case Tablerec::ADD_TABLE_ONGOING:
2351 errCode = PrepDropTabRef::NoSuchTable;
2353 case Tablerec::PREP_DROP_TABLE_DONE:
2355 errCode = PrepDropTabRef::DropInProgress;
2357 case Tablerec::DROP_TABLE_WAIT_USAGE:
2358 case Tablerec::DROP_TABLE_WAIT_DONE:
2359 case Tablerec::DROP_TABLE_ACC:
2360 case Tablerec::DROP_TABLE_TUP:
2361 case Tablerec::DROP_TABLE_TUX:
2363 errCode = PrepDropTabRef::DropInProgress;
2364 case Tablerec::TABLE_READ_ONLY:
2366 errCode = PrepDropTabRef::InvalidTableState;
2375 ref->senderRef = reference();
2376 ref->senderData = senderData;
2377 ref->tableId = tabPtr.i;
2378 ref->errorCode = errCode;
2379 sendSignal(senderRef, GSN_PREP_DROP_TAB_REF, signal,
2380 PrepDropTabRef::SignalLength, JBB);
2384 tabPtr.p->tableStatus = Tablerec::PREP_DROP_TABLE_DONE;
2387 conf->tableId = tabPtr.i;
2388 conf->senderRef = reference();
2389 conf->senderData = senderData;
2390 sendSignal(senderRef, GSN_PREP_DROP_TAB_CONF, signal,
2391 PrepDropTabConf::SignalLength, JBB);
2395 Dblqh::dropTab_wait_usage(
Signal* signal){
2398 tabPtr.i = signal->theData[1];
2399 ptrCheckGuard(tabPtr, ctabrecFileSize, tablerec);
2401 Uint32 senderRef = signal->theData[2];
2402 Uint32 senderData = signal->theData[3];
2404 ndbrequire(tabPtr.p->tableStatus == Tablerec::DROP_TABLE_WAIT_USAGE);
2406 if (tabPtr.p->usageCountR > 0 || tabPtr.p->usageCountW > 0)
2409 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 4);
2413 bool lcpDone =
true;
2415 ptrAss(lcpPtr, lcpRecord);
2416 if(lcpPtr.p->lcpState != LcpRecord::LCP_IDLE)
2420 if(lcpPtr.p->currentFragment.lcpFragOrd.tableId == tabPtr.i)
2426 if(lcpPtr.p->lcpQueued &&
2427 lcpPtr.p->queuedFragment.lcpFragOrd.tableId == tabPtr.i)
2437 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 4);
2441 tabPtr.p->tableStatus = Tablerec::DROP_TABLE_WAIT_DONE;
2444 conf->tableId = tabPtr.i;
2445 conf->senderRef = reference();
2446 conf->senderData = senderData;
2447 sendSignal(senderRef, GSN_DROP_TAB_CONF, signal,
2448 DropTabConf::SignalLength, JBB);
2452 Dblqh::execDROP_TAB_REQ(
Signal* signal){
2459 tabPtr.i = req->tableId;
2460 ptrCheckGuard(tabPtr, ctabrecFileSize, tablerec);
2463 switch((DropTabReq::RequestType)req->requestType) {
2464 case DropTabReq::RestartDropTab:
2466 tabPtr.p->tableStatus = Tablerec::DROP_TABLE_WAIT_DONE;
2468 case DropTabReq::CreateTabDrop:
2470 tabPtr.p->tableStatus = Tablerec::DROP_TABLE_WAIT_DONE;
2472 case DropTabReq::OnlineDropTab:
2474 switch(tabPtr.p->tableStatus) {
2475 case Tablerec::TABLE_DEFINED:
2477 errCode = DropTabRef::DropWoPrep;
2479 case Tablerec::NOT_DEFINED:
2481 errCode = DropTabRef::NoSuchTable;
2483 case Tablerec::ADD_TABLE_ONGOING:
2486 case Tablerec::PREP_DROP_TABLE_DONE:
2488 tabPtr.p->tableStatus = Tablerec::DROP_TABLE_WAIT_USAGE;
2489 signal->theData[0] = ZDROP_TABLE_WAIT_USAGE;
2490 signal->theData[1] = tabPtr.i;
2491 signal->theData[2] = req->senderRef;
2492 signal->theData[3] = req->senderData;
2493 dropTab_wait_usage(signal);
2496 case Tablerec::DROP_TABLE_WAIT_USAGE:
2497 case Tablerec::DROP_TABLE_ACC:
2498 case Tablerec::DROP_TABLE_TUP:
2499 case Tablerec::DROP_TABLE_TUX:
2501 case Tablerec::DROP_TABLE_WAIT_DONE:
2504 case Tablerec::TABLE_READ_ONLY:
2506 errCode = DropTabRef::InvalidTableState;
2515 ref->tableId = tabPtr.i;
2516 ref->senderRef = reference();
2517 ref->senderData = req->senderData;
2518 ref->errorCode = errCode;
2519 sendSignal(req->senderRef, GSN_DROP_TAB_REF, signal,
2520 DropTabRef::SignalLength, JBB);
2524 ndbrequire(tabPtr.p->usageCountR == 0 && tabPtr.p->usageCountW == 0);
2525 seizeAddfragrec(signal);
2526 addfragptr.p->m_dropTabReq = * req;
2527 dropTable_nextStep(signal, addfragptr);
2531 Dblqh::execDROP_TAB_REF(
Signal* signal)
2536 #if defined ERROR_INSERT || defined VM_TRACE
2537 jamLine(ref->errorCode);
2542 addFragPtr.i = ref->senderData;
2543 ptrCheckGuard(addFragPtr, caddfragrecFileSize, addFragRecord);
2544 dropTable_nextStep(signal, addFragPtr);
2548 Dblqh::execDROP_TAB_CONF(
Signal* signal)
2554 addFragPtr.i = conf->senderData;
2555 ptrCheckGuard(addFragPtr, caddfragrecFileSize, addFragRecord);
2556 dropTable_nextStep(signal, addFragPtr);
2565 tabPtr.i = addFragPtr.p->m_dropTabReq.tableId;
2566 ptrCheckGuard(tabPtr, ctabrecFileSize, tablerec);
2569 if (tabPtr.p->tableStatus == Tablerec::DROP_TABLE_WAIT_DONE)
2572 if (DictTabInfo::isTable(tabPtr.p->tableType) ||
2573 DictTabInfo::isHashIndex(tabPtr.p->tableType))
2576 ref = calcInstanceBlockRef(DBACC);
2577 tabPtr.p->tableStatus = Tablerec::DROP_TABLE_ACC;
2582 ref = calcInstanceBlockRef(DBTUP);
2583 tabPtr.p->tableStatus = Tablerec::DROP_TABLE_TUP;
2586 else if (tabPtr.p->tableStatus == Tablerec::DROP_TABLE_ACC)
2589 ref = calcInstanceBlockRef(DBTUP);
2590 tabPtr.p->tableStatus = Tablerec::DROP_TABLE_TUP;
2592 else if (tabPtr.p->tableStatus == Tablerec::DROP_TABLE_TUP)
2595 if (DictTabInfo::isOrderedIndex(tabPtr.p->tableType))
2598 ref = calcInstanceBlockRef(DBTUX);
2599 tabPtr.p->tableStatus = Tablerec::DROP_TABLE_TUX;
2607 req->senderData = addFragPtr.i;
2608 req->senderRef = reference();
2609 req->tableId = tabPtr.i;
2610 req->tableVersion = tabPtr.p->schemaVersion;
2611 req->requestType = addFragPtr.p->m_dropTabReq.requestType;
2612 sendSignal(ref, GSN_DROP_TAB_REQ, signal,
2613 DropTabReq::SignalLength, JBB);
2617 removeTable(tabPtr.i);
2618 tabPtr.p->tableStatus = Tablerec::NOT_DEFINED;
2621 conf->senderRef = reference();
2622 conf->senderData = addFragPtr.p->m_dropTabReq.senderData;
2623 conf->tableId = tabPtr.i;
2624 sendSignal(addFragPtr.p->m_dropTabReq.senderRef, GSN_DROP_TAB_CONF, signal,
2625 DropTabConf::SignalLength, JBB);
2627 addfragptr = addFragPtr;
2628 releaseAddfragrec(signal);
2631 void Dblqh::removeTable(Uint32 tableId)
2634 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
2636 for (Uint32
i = 0;
i < MAX_FRAG_PER_NODE;
i++) {
2638 if (tabptr.p->fragid[
i] != ZNIL) {
2640 deleteFragrec(tabptr.p->fragid[
i]);
2646 Dblqh::execALTER_TAB_REQ(
Signal* signal)
2655 const Uint32 senderRef = req->senderRef;
2656 const Uint32 senderData = req->senderData;
2657 const Uint32 tableId = req->tableId;
2658 const Uint32 tableVersion = req->tableVersion;
2659 const Uint32 newTableVersion = req->newTableVersion;
2660 AlterTabReq::RequestType requestType =
2661 (AlterTabReq::RequestType) req->requestType;
2663 TablerecPtr tablePtr;
2664 tablePtr.i = tableId;
2665 ptrCheckGuard(tablePtr, ctabrecFileSize, tablerec);
2667 Uint32 len = signal->getLength();
2668 switch (requestType) {
2669 case AlterTabReq::AlterTablePrepare:
2672 case AlterTabReq::AlterTableRevert:
2674 tablePtr.p->schemaVersion = tableVersion;
2676 case AlterTabReq::AlterTableCommit:
2678 tablePtr.p->schemaVersion = newTableVersion;
2679 if (AlterTableReq::getReorgFragFlag(req->changeMask))
2682 commit_reorg(tablePtr);
2685 case AlterTabReq::AlterTableComplete:
2688 case AlterTabReq::AlterTableSumaEnable:
2691 case AlterTabReq::AlterTableSumaFilter:
2693 signal->theData[len++] = cnewestGci + 3;
2695 case AlterTabReq::AlterTableReadOnly:
2697 ndbrequire(tablePtr.p->tableStatus == Tablerec::TABLE_DEFINED);
2698 tablePtr.p->tableStatus = Tablerec::TABLE_READ_ONLY;
2699 signal->theData[0] = ZWAIT_READONLY;
2700 signal->theData[1] = tablePtr.i;
2701 signal->theData[2] = senderRef;
2702 signal->theData[3] = senderData;
2703 sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB);
2705 case AlterTabReq::AlterTableReadWrite:
2707 ndbrequire(tablePtr.p->tableStatus == Tablerec::TABLE_READ_ONLY);
2708 tablePtr.p->tableStatus = Tablerec::TABLE_DEFINED;
2718 Uint32 errCode = signal->theData[0];
2719 Uint32 connectPtr = signal->theData[1];
2724 conf->senderRef = reference();
2725 conf->senderData = senderData;
2726 conf->connectPtr = connectPtr;
2727 sendSignal(senderRef, GSN_ALTER_TAB_CONF, signal,
2728 AlterTabConf::SignalLength, JBB);
2730 else if (errCode == ~Uint32(0))
2735 ndbrequire(requestType == AlterTabReq::AlterTableSumaFilter);
2736 signal->theData[0] = ZWAIT_REORG_SUMA_FILTER_ENABLED;
2737 signal->theData[1] = cnewestGci + 3;
2738 signal->theData[2] = senderData;
2739 signal->theData[3] = connectPtr;
2740 signal->theData[4] = senderRef;
2741 wait_reorg_suma_filter_enabled(signal);
2748 ref->senderRef = reference();
2749 ref->senderData = senderData;
2750 ref->connectPtr = connectPtr;
2751 ref->errorCode = errCode;
2752 sendSignal(senderRef, GSN_ALTER_TAB_REF, signal,
2753 AlterTabRef::SignalLength, JBB);
2758 Dblqh::wait_reorg_suma_filter_enabled(
Signal* signal)
2760 if (cnewestCompletedGci >= signal->theData[1])
2763 Uint32 senderData = signal->theData[2];
2764 Uint32 connectPtr = signal->theData[3];
2765 Uint32 senderRef = signal->theData[4];
2768 conf->senderRef = reference();
2769 conf->senderData = senderData;
2770 conf->connectPtr = connectPtr;
2771 sendSignal(senderRef, GSN_ALTER_TAB_CONF, signal,
2772 AlterTabConf::SignalLength, JBB);
2775 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 500, 5);
2779 Dblqh::commit_reorg(TablerecPtr tablePtr)
2781 for (Uint32
i = 0;
i < MAX_FRAG_PER_NODE;
i++)
2785 if ((fragPtr.i = tablePtr.p->fragrec[
i]) != RNIL)
2788 c_fragment_pool.
getPtr(fragPtr);
2795 Dblqh::wait_readonly(
Signal* signal)
2799 Uint32 tableId = signal->theData[1];
2801 TablerecPtr tablePtr;
2802 tablePtr.i = tableId;
2803 ptrCheckGuard(tablePtr, ctabrecFileSize, tablerec);
2804 ndbrequire(tablePtr.p->tableStatus == Tablerec::TABLE_READ_ONLY);
2806 if (tablePtr.p->usageCountW > 0)
2809 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 3000,
2810 signal->getLength());
2814 Uint32 senderRef = signal->theData[2];
2815 Uint32 senderData = signal->theData[3];
2819 conf->senderRef = reference();
2820 conf->senderData = senderData;
2821 sendSignal(senderRef, GSN_ALTER_TAB_CONF, signal,
2822 AlterTabConf::SignalLength, JBB);
2831 void Dblqh::execTIME_SIGNAL(
Signal* signal)
2835 cLqhTimeOutCount ++;
2836 cLqhTimeOutCheckCount ++;
2838 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++)
2841 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
2844 c_max_redo_lag_counter);
2850 update_log_problem(signal, logPartPtr,
2851 LogPartRecord::P_REDO_IO_PROBLEM,
true);
2858 update_log_problem(signal, logPartPtr,
2859 LogPartRecord::P_REDO_IO_PROBLEM,
false);
2863 if (cLqhTimeOutCheckCount < 1000) {
2868 cLqhTimeOutCheckCount = 0;
2870 TcConnectionrecPtr tTcConptr;
2872 for (tTcConptr.i = 0; tTcConptr.i < ctcConnectrecFileSize;
2875 ptrAss(tTcConptr, tcConnectionrec);
2876 if ((tTcConptr.p->tcTimer != 0) &&
2877 ((tTcConptr.p->tcTimer + 12000) < cLqhTimeOutCount)) {
2878 ndbout <<
"Dblqh::execTIME_SIGNAL"<<endl
2879 <<
"Timeout found in tcConnectRecord " <<tTcConptr.i<<endl
2880 <<
" cLqhTimeOutCount = " << cLqhTimeOutCount << endl
2881 <<
" tcTimer="<<tTcConptr.p->tcTimer<<endl
2882 <<
" tcTimer+12000="<<tTcConptr.p->tcTimer + 12000<<endl;
2884 signal->theData[0] = 2307;
2885 signal->theData[1] = tTcConptr.i;
2886 execDUMP_STATE_ORD(signal);
2889 tTcConptr.p->tcTimer = 0;
2894 for (lfoPtr.i = 0; lfoPtr.i < clfoFileSize; lfoPtr.i++) {
2895 ptrAss(lfoPtr, logFileOperationRecord);
2897 ((lfoPtr.p->
lfoTimer + 12000) < cLqhTimeOutCount)) {
2898 ndbout <<
"We have lost LFO record" << endl;
2899 ndbout <<
"index = " << lfoPtr.i;
2900 ndbout <<
"State = " << lfoPtr.p->
lfoState;
2901 ndbout <<
" Page No = " << lfoPtr.p->
lfoPageNo;
2902 ndbout <<
" noPagesRw = " << lfoPtr.p->
noPagesRw;
2903 ndbout <<
"lfoWordWritten = " << lfoPtr.p->
lfoWordWritten << endl;
2904 lfoPtr.p->
lfoTimer = cLqhTimeOutCount;
2911 LcpRecordPtr TlcpPtr;
2914 ptrAss(TlcpPtr, lcpRecord);
2915 ndbout <<
"Information about LCP in this LQH" << endl
2916 <<
" lcpState="<<TlcpPtr.p->lcpState<<endl
2917 <<
" firstLcpLocAcc="<<TlcpPtr.p->firstLcpLocAcc<<endl
2918 <<
" firstLcpLocTup="<<TlcpPtr.p->firstLcpLocTup<<endl
2919 <<
" lcpAccptr="<<TlcpPtr.p->lcpAccptr<<endl
2920 <<
" lastFragmentFlag="<<TlcpPtr.p->lastFragmentFlag<<endl
2921 <<
" lcpQueued="<<TlcpPtr.p->lcpQueued<<endl
2922 <<
" reportEmptyref="<< TlcpPtr.p->reportEmptyRef<<endl
2923 <<
" reportEmpty="<<TlcpPtr.p->reportEmpty<<endl;
2935 void Dblqh::noFreeRecordLab(
Signal* signal,
2940 const Uint32 transid1 = lqhKeyReq->transId1;
2941 const Uint32 transid2 = lqhKeyReq->transId2;
2942 const Uint32 reqInfo = lqhKeyReq->requestInfo;
2944 if(errCode == ZNO_FREE_MARKER_RECORDS_ERROR ||
2945 errCode == ZNODE_SHUTDOWN_IN_PROGESS ||
2946 errCode == ZNODE_FAILURE_ERROR){
2948 releaseTcrec(signal, tcConnectptr);
2951 if (LqhKeyReq::getDirtyFlag(reqInfo) &&
2952 LqhKeyReq::getOperation(reqInfo) == ZREAD &&
2953 !LqhKeyReq::getNormalProtocolFlag(reqInfo)){
2956 ndbrequire(LqhKeyReq::getApplicationAddressFlag(reqInfo));
2957 const Uint32 apiRef = lqhKeyReq->variableData[0];
2958 const Uint32 apiOpRec = lqhKeyReq->variableData[1];
2962 tcKeyRef->connectPtr = apiOpRec;
2963 tcKeyRef->transId[0] = transid1;
2964 tcKeyRef->transId[1] = transid2;
2965 tcKeyRef->errorCode = errCode;
2966 sendTCKEYREF(signal, apiRef, signal->getSendersBlockRef(), 0);
2973 const Uint32 clientPtr = lqhKeyReq->clientConnectPtr;
2974 Uint32 TcOprec = clientPtr;
2975 if(LqhKeyReq::getSameClientAndTcFlag(reqInfo) == 1){
2976 if(LqhKeyReq::getApplicationAddressFlag(reqInfo))
2977 TcOprec = lqhKeyReq->variableData[2];
2979 TcOprec = lqhKeyReq->variableData[0];
2983 ref->userRef = clientPtr;
2984 ref->connectPtr = TcOprec;
2985 ref->errorCode = errCode;
2986 ref->transId1 = transid1;
2987 ref->transId2 = transid2;
2988 sendSignal(signal->senderBlockRef(), GSN_LQHKEYREF, signal,
2989 LqhKeyRef::SignalLength, JBB);
2998 case Tablerec::NOT_DEFINED:
3000 return ZTABLE_NOT_DEFINED;
3002 case Tablerec::ADD_TABLE_ONGOING:
3004 case Tablerec::PREP_DROP_TABLE_DONE:
3006 case Tablerec::DROP_TABLE_WAIT_USAGE:
3008 case Tablerec::DROP_TABLE_WAIT_DONE:
3010 case Tablerec::DROP_TABLE_ACC:
3012 case Tablerec::DROP_TABLE_TUP:
3014 case Tablerec::DROP_TABLE_TUX:
3016 return PrepDropTabRef::DropInProgress;
3018 case Tablerec::TABLE_DEFINED:
3019 case Tablerec::TABLE_READ_ONLY:
3021 return ZTABLE_NOT_DEFINED;
3029 Dblqh::check_tabstate(
Signal * signal,
const Tablerec * tablePtrP, Uint32 op)
3031 if (tabptr.p->
tableStatus == Tablerec::TABLE_READ_ONLY)
3034 if (op == ZREAD || op == ZREAD_EX || op == ZUNLOCK)
3039 terrorCode = ZTABLE_READ_ONLY;
3044 terrorCode = get_table_state_error(tabptr);
3046 abortErrorLab(signal);
3050 void Dblqh::LQHKEY_abort(
Signal* signal,
int errortype)
3052 switch (errortype) {
3055 terrorCode = ZCOPY_NODE_ERROR;
3059 terrorCode = ZNO_FREE_LQH_CONNECTION;
3063 terrorCode = signal->theData[1];
3067 ndbrequire((tcConnectptr.p->transactionState == TcConnectionrec::WAIT_ACC_ABORT) ||
3068 (tcConnectptr.p->transactionState == TcConnectionrec::ABORT_STOPPED) ||
3069 (tcConnectptr.p->transactionState == TcConnectionrec::ABORT_QUEUED));
3074 terrorCode = get_table_state_error(tabptr);
3078 terrorCode = ZINVALID_SCHEMA_VERSION;
3084 abortErrorLab(signal);
3087 void Dblqh::LQHKEY_error(
Signal* signal,
int errortype)
3089 switch (errortype) {
3118 void Dblqh::execLQHKEYREF(
Signal* signal)
3121 tcConnectptr.i = signal->theData[0];
3122 Uint32 tcOprec = signal->theData[1];
3123 terrorCode = signal->theData[2];
3124 Uint32 transid1 = signal->theData[3];
3125 Uint32 transid2 = signal->theData[4];
3126 if (tcConnectptr.i >= ctcConnectrecFileSize) {
3127 errorReport(signal, 3);
3131 ptrAss(tcConnectptr, tcConnectionrec);
3132 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
3134 if (likely(! ((regTcPtr->connectState == TcConnectionrec::LOG_CONNECTED) ||
3135 (regTcPtr->connectState == TcConnectionrec::COPY_CONNECTED))))
3151 if (findTransaction(transid1, transid2, tcOprec, 0) != ZOK)
3154 warningReport(signal, 14);
3159 switch (regTcPtr->connectState) {
3160 case TcConnectionrec::CONNECTED:
3162 if (regTcPtr->abortState != TcConnectionrec::ABORT_IDLE) {
3163 warningReport(signal, 15);
3166 abortErrorLab(signal);
3169 case TcConnectionrec::LOG_CONNECTED:
3171 logLqhkeyrefLab(signal);
3174 case TcConnectionrec::COPY_CONNECTED:
3176 copyLqhKeyRefLab(signal);
3180 warningReport(signal, 16);
3192 void Dblqh::execPACKED_SIGNAL(
Signal* signal)
3196 Uint32 TpackedData[28];
3197 Uint32 sig0, sig1, sig2, sig3 ,sig4, sig5, sig6;
3200 Tlength = signal->
length();
3201 Uint32 TsenderRef = signal->getSendersBlockRef();
3202 Uint32 TcommitLen = 5;
3203 Uint32 Tgci_lo_mask = ~(Uint32)0;
3205 if (unlikely(!ndb_check_micro_gcp(
getNodeInfo(refToNode(signal->getSendersBlockRef())).
m_version)))
3213 Uint32 senderBlockRef = signal->getSendersBlockRef();
3216 ndbrequire(Tlength <= 25);
3217 MEMCOPY_NO_WORDS(&TpackedData[0], &signal->theData[0], Tlength);
3218 while (Tlength > Tstep) {
3219 switch (TpackedData[Tstep] >> 28) {
3222 sig0 = TpackedData[Tstep + 0] & 0x0FFFFFFF;
3223 sig1 = TpackedData[Tstep + 1];
3224 sig2 = TpackedData[Tstep + 2];
3225 sig3 = TpackedData[Tstep + 3];
3226 sig4 = TpackedData[Tstep + 4];
3227 signal->theData[0] = sig0;
3228 signal->theData[1] = sig1;
3229 signal->theData[2] = sig2;
3230 signal->theData[3] = sig3;
3231 signal->theData[4] = sig4 & Tgci_lo_mask;
3232 signal->header.theLength = TcommitLen;
3234 Tstep += TcommitLen;
3238 sig0 = TpackedData[Tstep + 0] & 0x0FFFFFFF;
3239 sig1 = TpackedData[Tstep + 1];
3240 sig2 = TpackedData[Tstep + 2];
3241 signal->theData[0] = sig0;
3242 signal->theData[1] = sig1;
3243 signal->theData[2] = sig2;
3244 signal->header.theLength = 3;
3245 execCOMPLETE(signal);
3251 sig0 = TpackedData[Tstep + 0] & 0x0FFFFFFF;
3252 sig1 = TpackedData[Tstep + 1];
3253 sig2 = TpackedData[Tstep + 2];
3254 sig3 = TpackedData[Tstep + 3];
3255 sig4 = TpackedData[Tstep + 4];
3256 sig5 = TpackedData[Tstep + 5];
3257 sig6 = TpackedData[Tstep + 6];
3258 lqhKeyConf->connectPtr = sig0;
3259 lqhKeyConf->opPtr = sig1;
3260 lqhKeyConf->userRef = sig2;
3262 lqhKeyConf->transId1 = sig4;
3263 lqhKeyConf->transId2 = sig5;
3264 lqhKeyConf->noFiredTriggers = sig6;
3265 execLQHKEYCONF(signal);
3266 Tstep += LqhKeyConf::SignalLength;
3269 case ZREMOVE_MARKER:
3271 sig0 = TpackedData[Tstep + 1];
3272 sig1 = TpackedData[Tstep + 2];
3273 signal->theData[0] = sig0;
3274 signal->theData[1] = sig1;
3275 signal->header.theLength = 2;
3276 execREMOVE_MARKER_ORD(signal);
3279 case ZFIRE_TRIG_REQ:
3281 ndbassert(FireTrigReq::SignalLength == 4);
3282 sig0 = TpackedData[Tstep + 0] & 0x0FFFFFFF;
3283 sig1 = TpackedData[Tstep + 1];
3284 sig2 = TpackedData[Tstep + 2];
3285 sig3 = TpackedData[Tstep + 3];
3286 signal->theData[0] = sig0;
3287 signal->theData[1] = sig1;
3288 signal->theData[2] = sig2;
3289 signal->theData[3] = sig3;
3290 signal->header.theLength = FireTrigReq::SignalLength;
3291 signal->header.theSendersBlockRef = TsenderRef;
3292 execFIRE_TRIG_REQ(signal);
3293 Tstep += FireTrigReq::SignalLength;
3300 signal->header.theSendersBlockRef = senderBlockRef;
3303 ndbrequire(Tlength == Tstep);
3308 Dblqh::execREMOVE_MARKER_ORD(
Signal* signal)
3310 CommitAckMarker key;
3311 key.transid1 = signal->theData[0];
3312 key.transid2 = signal->theData[1];
3315 CommitAckMarkerPtr removedPtr;
3316 m_commitAckMarkerHash.
remove(removedPtr, key);
3317 #if (defined VM_TRACE || defined ERROR_INSERT) && defined(wl4391_todo)
3318 ndbrequire(removedPtr.i != RNIL);
3319 m_commitAckMarkerPool.
release(removedPtr);
3321 if (removedPtr.i != RNIL)
3324 m_commitAckMarkerPool.
release(removedPtr);
3328 ndbout_c(
"%u Rem marker[%.8x %.8x]", instance(), key.transid1, key.transid2);
3338 void Dblqh::execSEND_PACKED(
Signal* signal)
3340 HostRecordPtr Thostptr;
3342 UintR TpackedListIndex = cpackedListIndex;
3344 for (i = 0; i < TpackedListIndex; i++) {
3345 Thostptr.i = cpackedList[
i];
3346 ptrAss(Thostptr, hostRecord);
3348 ndbrequire(Thostptr.i - 1 < MAX_NDB_NODES - 1);
3349 if (Thostptr.p->noOfPackedWordsLqh > 0) {
3351 sendPackedSignalLqh(signal, Thostptr.p);
3353 if (Thostptr.p->noOfPackedWordsTc > 0) {
3355 sendPackedSignalTc(signal, Thostptr.p);
3357 Thostptr.p->inPackedList =
false;
3359 cpackedListIndex = 0;
3364 Dblqh::updatePackedList(
Signal* signal, HostRecord * ahostptr, Uint16 hostId)
3366 Uint32 TpackedListIndex = cpackedListIndex;
3367 if (ahostptr->inPackedList ==
false) {
3369 ahostptr->inPackedList =
true;
3370 cpackedList[TpackedListIndex] = hostId;
3371 cpackedListIndex = TpackedListIndex + 1;
3376 Dblqh::execREAD_PSEUDO_REQ(
Signal* signal){
3378 TcConnectionrecPtr regTcPtr;
3379 regTcPtr.i = signal->theData[0];
3380 ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
3382 switch(signal->theData[1])
3384 case AttributeHeader::RANGE_NO:
3385 signal->theData[0] = regTcPtr.p->m_scan_curr_range_no;
3387 case AttributeHeader::ROW_COUNT:
3388 case AttributeHeader::COMMIT_COUNT:
3391 FragrecordPtr regFragptr;
3392 regFragptr.i = regTcPtr.p->fragmentptr;
3393 c_fragment_pool.
getPtr(regFragptr);
3395 signal->theData[0] = regFragptr.p->accFragptr;
3399 case AttributeHeader::RECORDS_IN_RANGE:
3400 case AttributeHeader::INDEX_STAT_KEY:
3401 case AttributeHeader::INDEX_STAT_VALUE:
3406 tmp.i = regTcPtr.p->tcScanRec;
3407 c_scanRecordPool.
getPtr(tmp);
3408 signal->theData[0] = tmp.p->scanAccPtr;
3412 case AttributeHeader::LOCK_REF:
3420 signal->theData[0] = (getOwnNodeId() << 16) | regTcPtr.p->fragmentid;
3421 signal->theData[1] = regTcPtr.p->tcOprec;
3422 signal->theData[2] = (Uint32) regTcPtr.p->lqhKeyReqId;
3425 case AttributeHeader::OP_ID:
3428 memcpy(signal->theData, ®TcPtr.p->lqhKeyReqId, 8);
3431 case AttributeHeader::CORR_FACTOR64:
3435 tmp.i = regTcPtr.p->tcScanRec;
3438 c_scanRecordPool.
getPtr(tmp);
3439 add = tmp.p->m_curr_batch_size_rows;
3442 signal->theData[0] = regTcPtr.p->m_corrFactorLo + add;
3443 signal->theData[1] = regTcPtr.p->m_corrFactorHi;
3454 void Dblqh::execTUPKEYCONF(
Signal* signal)
3456 TcConnectionrec *regTcConnectionrec = tcConnectionrec;
3457 Uint32 ttcConnectrecFileSize = ctcConnectrecFileSize;
3459 Uint32 tcIndex = tupKeyConf->userPtr;
3461 tcConnectptr.i = tcIndex;
3462 ptrCheckGuard(tcConnectptr, ttcConnectrecFileSize, regTcConnectionrec);
3463 TcConnectionrec * regTcPtr = tcConnectptr.p;
3464 Uint32 activeCreat = regTcPtr->activeCreat;
3466 FragrecordPtr regFragptr;
3467 regFragptr.i = tcConnectptr.p->fragmentptr;
3468 c_fragment_pool.
getPtr(regFragptr);
3469 fragptr = regFragptr;
3471 switch (tcConnectptr.p->transactionState) {
3472 case TcConnectionrec::WAIT_TUP:
3474 if (tcConnectptr.p->seqNoReplica == 0)
3475 tcConnectptr.p->noFiredTriggers = tupKeyConf->noFiredTriggers;
3476 tupkeyConfLab(signal);
3478 case TcConnectionrec::COPY_TUPKEY:
3480 copyTupkeyConfLab(signal);
3482 case TcConnectionrec::SCAN_TUPKEY:
3484 scanTupkeyConfLab(signal);
3486 case TcConnectionrec::WAIT_TUP_TO_ABORT:
3492 if (unlikely(activeCreat == Fragrecord::AC_NR_COPY))
3495 ndbrequire(regTcPtr->m_nr_delete.m_cnt);
3496 regTcPtr->m_nr_delete.m_cnt--;
3497 if (regTcPtr->m_nr_delete.m_cnt)
3509 TablerecPtr tablePtr;
3510 tablePtr.i = regTcPtr->tableref;
3511 ptrCheckGuard(tablePtr, ctabrecFileSize, tablerec);
3512 ndbrequire(tablePtr.p->m_disk_table);
3518 abortCommonLab(signal);
3520 case TcConnectionrec::WAIT_ACC_ABORT:
3521 case TcConnectionrec::ABORT_QUEUED:
3537 void Dblqh::execTUPKEYREF(
Signal* signal)
3542 tcConnectptr.i = tupKeyRef->userRef;
3543 terrorCode = tupKeyRef->errorCode;
3544 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
3545 TcConnectionrec* regTcPtr = tcConnectptr.p;
3546 Uint32 activeCreat = regTcPtr->activeCreat;
3548 FragrecordPtr regFragptr;
3549 regFragptr.i = regTcPtr->fragmentptr;
3550 c_fragment_pool.
getPtr(regFragptr);
3551 fragptr = regFragptr;
3553 TRACE_OP(regTcPtr,
"TUPKEYREF");
3555 if (unlikely(activeCreat == Fragrecord::AC_NR_COPY))
3558 ndbrequire(regTcPtr->m_nr_delete.m_cnt);
3559 regTcPtr->m_nr_delete.m_cnt--;
3560 ndbassert(regTcPtr->transactionState == TcConnectionrec::WAIT_TUP ||
3561 regTcPtr->transactionState ==TcConnectionrec::WAIT_TUP_TO_ABORT);
3564 switch (tcConnectptr.p->transactionState) {
3565 case TcConnectionrec::WAIT_TUP:
3567 abortErrorLab(signal);
3569 case TcConnectionrec::COPY_TUPKEY:
3570 copyTupkeyRefLab(signal);
3572 case TcConnectionrec::SCAN_TUPKEY:
3574 scanTupkeyRefLab(signal);
3576 case TcConnectionrec::WAIT_TUP_TO_ABORT:
3582 abortCommonLab(signal);
3584 case TcConnectionrec::WAIT_ACC_ABORT:
3585 case TcConnectionrec::ABORT_QUEUED:
3592 jamLine(tcConnectptr.p->transactionState);
3598 void Dblqh::sendPackedSignalLqh(
Signal* signal, HostRecord * ahostptr)
3600 Uint32 noOfWords = ahostptr->noOfPackedWordsLqh;
3601 BlockReference hostRef = ahostptr->hostLqhBlockRef;
3602 MEMCOPY_NO_WORDS(&signal->theData[0],
3603 &ahostptr->packedWordsLqh[0],
3605 sendSignal(hostRef, GSN_PACKED_SIGNAL, signal, noOfWords, JBB);
3606 ahostptr->noOfPackedWordsLqh = 0;
3609 void Dblqh::sendPackedSignalTc(
Signal* signal, HostRecord * ahostptr)
3611 Uint32 noOfWords = ahostptr->noOfPackedWordsTc;
3612 BlockReference hostRef = ahostptr->hostTcBlockRef;
3613 MEMCOPY_NO_WORDS(&signal->theData[0],
3614 &ahostptr->packedWordsTc[0],
3616 sendSignal(hostRef, GSN_PACKED_SIGNAL, signal, noOfWords, JBB);
3617 ahostptr->noOfPackedWordsTc = 0;
3620 void Dblqh::sendCommitLqh(
Signal* signal, BlockReference alqhBlockref)
3622 HostRecordPtr Thostptr;
3623 Thostptr.i = refToNode(alqhBlockref);
3624 ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
3627 Tdata[0] = tcConnectptr.p->clientConnectrec;
3628 Tdata[1] = tcConnectptr.p->gci_hi;
3629 Tdata[2] = tcConnectptr.p->transid[0];
3630 Tdata[3] = tcConnectptr.p->transid[1];
3631 Tdata[4] = tcConnectptr.p->gci_lo;
3643 if (send_unpacked) {
3645 FragrecordPtr Tfragptr;
3646 Tfragptr.i = tcConnectptr.p->fragmentptr;
3647 c_fragment_pool.
getPtr(Tfragptr);
3648 memcpy(&signal->theData[0], &Tdata[0], len << 2);
3649 Uint32 Tnode = Thostptr.i;
3650 Uint32 instanceKey = Tfragptr.p->lqhInstanceKey;
3651 BlockReference lqhRef = numberToRef(DBLQH, instanceKey, Tnode);
3652 sendSignal(lqhRef, GSN_COMMIT, signal, len, JBB);
3656 if (Thostptr.p->noOfPackedWordsLqh > 25 - 5) {
3658 sendPackedSignalLqh(signal, Thostptr.p);
3661 updatePackedList(signal, Thostptr.p, Thostptr.i);
3664 Tdata[0] |= (ZCOMMIT << 28);
3665 Uint32 pos = Thostptr.p->noOfPackedWordsLqh;
3666 memcpy(&Thostptr.p->packedWordsLqh[pos], &Tdata[0], len << 2);
3667 Thostptr.p->noOfPackedWordsLqh = pos + len;
3670 void Dblqh::sendCompleteLqh(
Signal* signal, BlockReference alqhBlockref)
3672 HostRecordPtr Thostptr;
3673 Thostptr.i = refToNode(alqhBlockref);
3674 ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
3677 Tdata[0] = tcConnectptr.p->clientConnectrec;
3678 Tdata[1] = tcConnectptr.p->transid[0];
3679 Tdata[2] = tcConnectptr.p->transid[1];
3684 if (send_unpacked) {
3686 FragrecordPtr Tfragptr;
3687 Tfragptr.i = tcConnectptr.p->fragmentptr;
3688 c_fragment_pool.
getPtr(Tfragptr);
3689 memcpy(&signal->theData[0], &Tdata[0], len << 2);
3690 Uint32 Tnode = Thostptr.i;
3691 Uint32 instanceKey = Tfragptr.p->lqhInstanceKey;
3692 BlockReference lqhRef = numberToRef(DBLQH, instanceKey, Tnode);
3693 sendSignal(lqhRef, GSN_COMPLETE, signal, len, JBB);
3697 if (Thostptr.p->noOfPackedWordsLqh > 22) {
3699 sendPackedSignalLqh(signal, Thostptr.p);
3702 updatePackedList(signal, Thostptr.p, Thostptr.i);
3705 Tdata[0] |= (ZCOMPLETE << 28);
3706 Uint32 pos = Thostptr.p->noOfPackedWordsLqh;
3707 memcpy(&Thostptr.p->packedWordsLqh[pos], &Tdata[0], len << 2);
3708 Thostptr.p->noOfPackedWordsLqh = pos + len;
3711 void Dblqh::sendCommittedTc(
Signal* signal, BlockReference atcBlockref)
3713 if (refToInstance(atcBlockref))
3716 signal->theData[0] = tcConnectptr.p->clientConnectrec;
3717 signal->theData[1] = tcConnectptr.p->transid[0];
3718 signal->theData[2] = tcConnectptr.p->transid[1];
3719 sendSignal(atcBlockref, GSN_COMMITTED, signal, 3, JBB);
3723 HostRecordPtr Thostptr;
3724 Thostptr.i = refToNode(atcBlockref);
3725 ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
3728 Tdata[0] = tcConnectptr.p->clientConnectrec;
3729 Tdata[1] = tcConnectptr.p->transid[0];
3730 Tdata[2] = tcConnectptr.p->transid[1];
3734 const bool send_unpacked =
false;
3735 if (send_unpacked) {
3737 memcpy(&signal->theData[0], &Tdata[0], len << 2);
3738 BlockReference tcRef = Thostptr.p->hostTcBlockRef;
3739 sendSignal(tcRef, GSN_COMMITTED, signal, len, JBB);
3743 if (Thostptr.p->noOfPackedWordsTc > 22) {
3745 sendPackedSignalTc(signal, Thostptr.p);
3748 updatePackedList(signal, Thostptr.p, Thostptr.i);
3751 Tdata[0] |= (ZCOMMITTED << 28);
3752 Uint32 pos = Thostptr.p->noOfPackedWordsTc;
3753 memcpy(&Thostptr.p->packedWordsTc[pos], &Tdata[0], len << 2);
3754 Thostptr.p->noOfPackedWordsTc = pos + len;
3757 void Dblqh::sendCompletedTc(
Signal* signal, BlockReference atcBlockref)
3759 if (refToInstance(atcBlockref))
3762 signal->theData[0] = tcConnectptr.p->clientConnectrec;
3763 signal->theData[1] = tcConnectptr.p->transid[0];
3764 signal->theData[2] = tcConnectptr.p->transid[1];
3765 sendSignal(atcBlockref, GSN_COMPLETED, signal, 3, JBB);
3769 HostRecordPtr Thostptr;
3770 Thostptr.i = refToNode(atcBlockref);
3771 ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
3774 Tdata[0] = tcConnectptr.p->clientConnectrec;
3775 Tdata[1] = tcConnectptr.p->transid[0];
3776 Tdata[2] = tcConnectptr.p->transid[1];
3780 const bool send_unpacked =
false;
3781 if (send_unpacked) {
3783 memcpy(&signal->theData[0], &Tdata[0], len << 2);
3784 BlockReference tcRef = Thostptr.p->hostTcBlockRef;
3785 sendSignal(tcRef, GSN_COMMITTED, signal, len, JBB);
3789 if (Thostptr.p->noOfPackedWordsTc > 22) {
3791 sendPackedSignalTc(signal, Thostptr.p);
3794 updatePackedList(signal, Thostptr.p, Thostptr.i);
3797 Tdata[0] |= (ZCOMPLETED << 28);
3798 Uint32 pos = Thostptr.p->noOfPackedWordsTc;
3799 memcpy(&Thostptr.p->packedWordsTc[pos], &Tdata[0], len << 2);
3800 Thostptr.p->noOfPackedWordsTc = pos + len;
3803 void Dblqh::sendLqhkeyconfTc(
Signal* signal, BlockReference atcBlockref)
3806 HostRecordPtr Thostptr;
3809 Thostptr.i = refToNode(atcBlockref);
3810 ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
3811 if (refToBlock(atcBlockref) == DBTC) {
3817 if (Thostptr.p->noOfPackedWordsTc > (25 - LqhKeyConf::SignalLength)) {
3819 sendPackedSignalTc(signal, Thostptr.p);
3822 updatePackedList(signal, Thostptr.p, Thostptr.i);
3825 &Thostptr.p->packedWordsTc[Thostptr.p->noOfPackedWordsTc];
3826 Thostptr.p->noOfPackedWordsTc += LqhKeyConf::SignalLength;
3827 }
else if(refToMain(atcBlockref) == DBLQH &&
3828 refToInstance(atcBlockref) == instance()) {
3835 if (Thostptr.p->noOfPackedWordsLqh > (25 - LqhKeyConf::SignalLength)) {
3837 sendPackedSignalLqh(signal, Thostptr.p);
3840 updatePackedList(signal, Thostptr.p, Thostptr.i);
3843 &Thostptr.p->packedWordsLqh[Thostptr.p->noOfPackedWordsLqh];
3844 Thostptr.p->noOfPackedWordsLqh += LqhKeyConf::SignalLength;
3847 lqhKeyConf = (
LqhKeyConf *)signal->getDataPtrSend();
3849 Uint32 ptrAndType = tcConnectptr.i | (ZLQHKEYCONF << 28);
3850 Uint32 tcOprec = tcConnectptr.p->tcOprec;
3851 Uint32 ownRef = cownref;
3852 Uint32 readlenAi = tcConnectptr.p->readlenAi;
3853 Uint32 transid1 = tcConnectptr.p->transid[0];
3854 Uint32 transid2 = tcConnectptr.p->transid[1];
3855 Uint32 noFiredTriggers = tcConnectptr.p->noFiredTriggers;
3856 lqhKeyConf->connectPtr = ptrAndType;
3857 lqhKeyConf->opPtr = tcOprec;
3858 lqhKeyConf->userRef = ownRef;
3859 lqhKeyConf->
readLen = readlenAi;
3860 lqhKeyConf->transId1 = transid1;
3861 lqhKeyConf->transId2 = transid2;
3862 lqhKeyConf->noFiredTriggers = noFiredTriggers;
3866 lqhKeyConf->connectPtr = tcConnectptr.i;
3867 if (instance() == refToInstance(atcBlockref) &&
3868 (Thostptr.i == 0 || Thostptr.i == getOwnNodeId()))
3875 signal, LqhKeyConf::SignalLength);
3879 sendSignal(atcBlockref, GSN_LQHKEYCONF,
3880 signal, LqhKeyConf::SignalLength, JBB);
3890 void Dblqh::execKEYINFO(
Signal* signal)
3892 Uint32 tcOprec = signal->theData[0];
3893 Uint32 transid1 = signal->theData[1];
3894 Uint32 transid2 = signal->theData[2];
3896 if (findTransaction(transid1, transid2, tcOprec, 0) != ZOK) {
3901 receive_keyinfo(signal,
3902 signal->theData+KeyInfo::HeaderLength,
3903 signal->getLength()-KeyInfo::HeaderLength);
3907 Dblqh::receive_keyinfo(
Signal* signal,
3908 Uint32 * data, Uint32 len)
3910 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
3911 TcConnectionrec::TransactionState state = regTcPtr->transactionState;
3912 if (state != TcConnectionrec::WAIT_TUPKEYINFO &&
3913 state != TcConnectionrec::WAIT_SCAN_AI)
3924 handleLongTupKey(signal, data, len);
3926 if (errorCode != 0) {
3927 if (errorCode == 1) {
3932 terrorCode = errorCode;
3933 if(state == TcConnectionrec::WAIT_TUPKEYINFO)
3934 abortErrorLab(signal);
3936 abort_scan(signal, regTcPtr->tcScanRec, errorCode);
3939 if(state == TcConnectionrec::WAIT_TUPKEYINFO)
3941 FragrecordPtr regFragptr;
3942 regFragptr.i = regTcPtr->fragmentptr;
3943 c_fragment_pool.
getPtr(regFragptr);
3944 fragptr = regFragptr;
3945 endgettupkeyLab(signal);
3953 Uint32 Dblqh::handleLongTupKey(
Signal* signal,
3957 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
3958 Uint32 total = regTcPtr->save1 + len;
3959 Uint32 primKeyLen = regTcPtr->primKeyLen;
3961 if (unlikely(total > primKeyLen))
3967 Uint32
extra = total - primKeyLen;
3968 ndbrequire(extra <= 3);
3969 ndbrequire(len > extra);
3973 bool ok= appendToSection(regTcPtr->keyInfoIVal,
3979 return ZGET_DATAREC_ERROR;
3982 regTcPtr->save1 = total;
3983 return (total >= primKeyLen ? 0 : 1);
3995 void Dblqh::execATTRINFO(
Signal* signal)
3997 Uint32 tcOprec = signal->theData[0];
3998 Uint32 transid1 = signal->theData[1];
3999 Uint32 transid2 = signal->theData[2];
4001 if (findTransaction(transid1,
4003 tcOprec, 0) != ZOK) {
4008 receive_attrinfo(signal,
4009 signal->getDataPtrSend()+AttrInfo::HeaderLength,
4010 signal->getLength()-AttrInfo::HeaderLength);
4014 Dblqh::receive_attrinfo(
Signal* signal, Uint32 * dataPtr, Uint32 length)
4016 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
4017 Uint32 totReclenAi = regTcPtr->totReclenAi;
4018 Uint32 currReclenAi = regTcPtr->currReclenAi + length;
4019 regTcPtr->currReclenAi = currReclenAi;
4020 if (totReclenAi == currReclenAi) {
4021 switch (regTcPtr->transactionState) {
4022 case TcConnectionrec::WAIT_ATTR:
4025 fragptr.i = regTcPtr->fragmentptr;
4026 c_fragment_pool.
getPtr(fragptr);
4027 lqhAttrinfoLab(signal, dataPtr, length);
4028 endgettupkeyLab(signal);
4032 case TcConnectionrec::WAIT_SCAN_AI:
4034 scanAttrinfoLab(signal, dataPtr, length);
4037 case TcConnectionrec::WAIT_TUP_TO_ABORT:
4038 case TcConnectionrec::LOG_ABORT_QUEUED:
4039 case TcConnectionrec::ABORT_QUEUED:
4040 case TcConnectionrec::ABORT_STOPPED:
4041 case TcConnectionrec::WAIT_ACC_ABORT:
4042 case TcConnectionrec::WAIT_AI_AFTER_ABORT:
4044 aiStateErrorCheckLab(signal, dataPtr,length);
4049 ndbrequire(regTcPtr->abortState != TcConnectionrec::ABORT_IDLE);
4052 }
else if (currReclenAi < totReclenAi) {
4054 switch (regTcPtr->transactionState) {
4055 case TcConnectionrec::WAIT_ATTR:
4057 lqhAttrinfoLab(signal, dataPtr, length);
4060 case TcConnectionrec::WAIT_SCAN_AI:
4062 scanAttrinfoLab(signal, dataPtr, length);
4065 case TcConnectionrec::WAIT_TUP_TO_ABORT:
4066 case TcConnectionrec::LOG_ABORT_QUEUED:
4067 case TcConnectionrec::ABORT_QUEUED:
4068 case TcConnectionrec::ABORT_STOPPED:
4069 case TcConnectionrec::WAIT_ACC_ABORT:
4070 case TcConnectionrec::WAIT_AI_AFTER_ABORT:
4072 aiStateErrorCheckLab(signal, dataPtr, length);
4077 ndbrequire(regTcPtr->abortState != TcConnectionrec::ABORT_IDLE);
4081 switch (regTcPtr->transactionState) {
4082 case TcConnectionrec::WAIT_SCAN_AI:
4084 scanAttrinfoLab(signal, dataPtr, length);
4088 ndbout_c(
"%d", regTcPtr->transactionState);
4102 void Dblqh::execTUP_ATTRINFO(
Signal* signal)
4104 TcConnectionrec *regTcConnectionrec = tcConnectionrec;
4105 Uint32 tcIndex = signal->theData[0];
4106 Uint32 ttcConnectrecFileSize = ctcConnectrecFileSize;
4108 tcConnectptr.i = tcIndex;
4109 ptrCheckGuard(tcConnectptr, ttcConnectrecFileSize, regTcConnectionrec);
4110 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
4112 ndbrequire(regTcPtr->transactionState == TcConnectionrec::WAIT_TUP);
4118 ndbrequire(signal->header.theLength == 3);
4119 Uint32 tupAttrInfoWords= signal->theData[1];
4120 Uint32 tupAttrInfoIVal= signal->theData[2];
4122 ndbassert(tupAttrInfoWords > 0);
4123 ndbassert(tupAttrInfoIVal != RNIL);
4128 if (regTcPtr->attrInfoIVal != RNIL)
4131 ndbassert( !(regTcPtr->m_flags &
4132 TcConnectionrec::OP_SAVEATTRINFO) );
4133 releaseSection( regTcPtr->attrInfoIVal );
4134 regTcPtr->attrInfoIVal= RNIL;
4138 regTcPtr->attrInfoIVal= tupAttrInfoIVal;
4139 regTcPtr->currTupAiLen= tupAttrInfoWords;
4147 void Dblqh::lqhAttrinfoLab(
Signal* signal, Uint32* dataPtr, Uint32 length)
4151 if (saveAttrInfoInSection(dataPtr, length) == ZOK) {
4159 localAbortStateHandlerLab(signal);
4168 int Dblqh::findTransaction(UintR Transid1, UintR Transid2, UintR TcOprec,
4171 TcConnectionrec *regTcConnectionrec = tcConnectionrec;
4172 Uint32 ttcConnectrecFileSize = ctcConnectrecFileSize;
4173 TcConnectionrecPtr locTcConnectptr;
4175 Uint32 ThashIndex = (Transid1 ^ TcOprec) & 1023;
4176 locTcConnectptr.i = ctransidHash[ThashIndex];
4177 while (locTcConnectptr.i != RNIL) {
4178 ptrCheckGuard(locTcConnectptr, ttcConnectrecFileSize, regTcConnectionrec);
4179 if ((locTcConnectptr.p->transid[0] == Transid1) &&
4180 (locTcConnectptr.p->transid[1] == Transid2) &&
4181 (locTcConnectptr.p->tcOprec == TcOprec) &&
4182 (locTcConnectptr.p->tcHashKeyHi == hi)) {
4187 tcConnectptr.i = locTcConnectptr.i;
4188 tcConnectptr.p = locTcConnectptr.p;
4193 locTcConnectptr.i = locTcConnectptr.p->nextHashRec;
4196 return (
int)ZNOT_FOUND;
4203 int Dblqh::saveAttrInfoInSection(
const Uint32* dataPtr, Uint32 len)
4205 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
4207 bool ok= appendToSection(regTcPtr->attrInfoIVal,
4214 terrorCode = ZGET_ATTRINBUF_ERROR;
4215 return ZGET_ATTRINBUF_ERROR;
4218 if (regTcPtr->m_flags & TcConnectionrec::OP_SAVEATTRINFO)
4219 regTcPtr->currTupAiLen += len;
4230 void Dblqh::seizeTcrec()
4232 TcConnectionrecPtr locTcConnectptr;
4234 locTcConnectptr.i = cfirstfreeTcConrec;
4235 ptrCheckGuard(locTcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
4236 Uint32 nextTc = locTcConnectptr.p->nextTcConnectrec;
4237 locTcConnectptr.p->nextTcConnectrec = RNIL;
4238 locTcConnectptr.p->clientConnectrec = RNIL;
4239 locTcConnectptr.p->clientBlockref = RNIL;
4240 locTcConnectptr.p->abortState = TcConnectionrec::ABORT_IDLE;
4241 locTcConnectptr.p->tcTimer = cLqhTimeOutCount;
4242 locTcConnectptr.p->tableref = RNIL;
4243 locTcConnectptr.p->savePointId = 0;
4244 locTcConnectptr.p->gci_hi = 0;
4245 locTcConnectptr.p->gci_lo = 0;
4246 cfirstfreeTcConrec = nextTc;
4247 tcConnectptr = locTcConnectptr;
4248 locTcConnectptr.p->connectState = TcConnectionrec::CONNECTED;
4251 bool Dblqh::checkTransporterOverloaded(
Signal* signal,
4258 Uint32 tc_node = refToNode(req->tcBlockref);
4259 if (tc_node < MAX_NODES)
4261 const Uint8 op = LqhKeyReq::getOperation(req->requestInfo);
4262 if (op == ZREAD || op == ZREAD_EX || op == ZUNLOCK) {
4264 Uint32 api_node = refToNode(req->variableData[0]);
4265 if (api_node < MAX_NODES)
4269 Uint32 replica_node = LqhKeyReq::getNextReplicaNodeId(req->fragmentData);
4270 if (replica_node < MAX_NODES)
4271 mask.
set(replica_node);
4273 const Suma* suma = (
Suma*)globalData.getBlock(SUMA);
4280 void Dblqh::execSIGNAL_DROPPED_REP(
Signal* signal)
4295 Uint32 originalGSN= rep->originalGsn;
4297 DEBUG(
"SignalDroppedRep received for GSN " << originalGSN);
4299 switch(originalGSN) {
4309 const LqhKeyReq *
const truncatedLqhKeyReq =
4312 noFreeRecordLab(signal, truncatedLqhKeyReq, ZGET_DATAREC_ERROR);
4316 case GSN_SCAN_FRAGREQ:
4328 const Uint32 senderData= truncatedScanFragReq->senderData;
4329 const Uint32 transid1= truncatedScanFragReq->transId1;
4330 const Uint32 transid2= truncatedScanFragReq->transId2;
4334 ref->senderData= senderData;
4335 ref->transId1= transid1;
4336 ref->transId2= transid2;
4337 ref->errorCode= ZGET_ATTRINBUF_ERROR;
4339 sendSignal(signal->senderBlockRef(), GSN_SCAN_FRAGREF, signal,
4340 ScanFragRef::SignalLength, JBB);
4348 SimulatedBlock::execSIGNAL_DROPPED_REP(signal);
4360 void Dblqh::execLQHKEYREQ(
Signal* signal)
4362 UintR sig0, sig1, sig2, sig3, sig4, sig5;
4369 const NodeBitmask& all = globalTransporterRegistry.get_status_overloaded();
4370 if (unlikely((!all.
isclear() &&
4371 checkTransporterOverloaded(signal, all, lqhKeyReq))) ||
4372 ERROR_INSERTED_CLEAR(5047)) {
4374 releaseSections(handle);
4375 noFreeRecordLab(signal, lqhKeyReq, ZTRANSPORTER_OVERLOADED_ERROR);
4380 sig0 = lqhKeyReq->clientConnectPtr;
4381 if (cfirstfreeTcConrec != RNIL && !ERROR_INSERTED_CLEAR(5031)) {
4388 releaseSections(handle);
4389 noFreeRecordLab(signal, lqhKeyReq, ZNO_TC_CONNECT_ERROR);
4393 if(ERROR_INSERTED(5038) &&
4394 refToNode(signal->getSendersBlockRef()) != getOwnNodeId()){
4396 releaseSections(handle);
4397 SET_ERROR_INSERT_VALUE(5039);
4401 cTotalLqhKeyReqCount++;
4402 c_Counters.operations++;
4404 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
4405 Uint32 senderRef = regTcPtr->clientBlockref = signal->senderBlockRef();
4406 regTcPtr->clientConnectrec = sig0;
4407 regTcPtr->tcOprec = sig0;
4408 regTcPtr->tcHashKeyHi = 0;
4409 regTcPtr->storedProcId = ZNIL;
4410 regTcPtr->lqhKeyReqId = cTotalLqhKeyReqCount;
4411 regTcPtr->m_flags= 0;
4412 bool isLongReq=
false;
4413 if (handle.m_cnt > 0)
4416 regTcPtr->m_flags|= TcConnectionrec::OP_ISLONGREQ;
4419 UintR attrLenFlags = lqhKeyReq->attrLen;
4420 sig1 = lqhKeyReq->savePointId;
4421 sig2 = lqhKeyReq->hashValue;
4422 UintR Treqinfo = lqhKeyReq->requestInfo;
4423 sig4 = lqhKeyReq->tableSchemaVersion;
4424 sig5 = lqhKeyReq->tcBlockref;
4426 regTcPtr->savePointId = sig1;
4427 regTcPtr->hashValue = sig2;
4428 const Uint32 schemaVersion = regTcPtr->schemaVersion = LqhKeyReq::getSchemaVersion(sig4);
4429 tabptr.i = LqhKeyReq::getTableId(sig4);
4430 regTcPtr->tcBlockref = sig5;
4432 const Uint8 op = LqhKeyReq::getOperation(Treqinfo);
4433 if ((op == ZREAD || op == ZREAD_EX) && !getAllowRead()){
4434 releaseSections(handle);
4435 noFreeRecordLab(signal, lqhKeyReq, ZNODE_SHUTDOWN_IN_PROGESS);
4439 if (unlikely(get_node_status(refToNode(sig5)) != ZNODE_UP))
4441 releaseSections(handle);
4442 noFreeRecordLab(signal, lqhKeyReq, ZNODE_FAILURE_ERROR);
4448 regTcPtr->tcScanInfo = lqhKeyReq->scanInfo;
4449 regTcPtr->indTakeOver = LqhKeyReq::getScanTakeOverFlag(attrLenFlags);
4450 regTcPtr->m_reorg = LqhKeyReq::getReorgFlag(attrLenFlags);
4452 regTcPtr->readlenAi = 0;
4453 regTcPtr->currTupAiLen = 0;
4454 regTcPtr->listState = TcConnectionrec::NOT_IN_LIST;
4455 regTcPtr->logWriteState = TcConnectionrec::NOT_STARTED;
4456 regTcPtr->fragmentptr = RNIL;
4458 sig0 = lqhKeyReq->fragmentData;
4459 sig1 = lqhKeyReq->transId1;
4460 sig2 = lqhKeyReq->transId2;
4461 sig3 = lqhKeyReq->variableData[0];
4462 sig4 = lqhKeyReq->variableData[1];
4464 regTcPtr->fragmentid = LqhKeyReq::getFragmentId(sig0);
4465 regTcPtr->nextReplica = LqhKeyReq::getNextReplicaNodeId(sig0);
4466 regTcPtr->transid[0] = sig1;
4467 regTcPtr->transid[1] = sig2;
4468 regTcPtr->applRef = sig3;
4469 regTcPtr->applOprec = sig4;
4471 regTcPtr->commitAckMarker = RNIL;
4472 if (LqhKeyReq::getMarkerFlag(Treqinfo))
4474 struct CommitAckMarker check;
4475 CommitAckMarkerPtr markerPtr;
4477 check.transid1 = regTcPtr->transid[0];
4478 check.transid2 = regTcPtr->transid[1];
4480 if (m_commitAckMarkerHash.
find(markerPtr, check))
4487 markerPtr.p->reference_count++;
4489 ndbout_c(
"Inc marker[%.8x %.8x] op: %u ref: %u",
4490 markerPtr.p->transid1, markerPtr.p->transid2,
4491 tcConnectptr.i, markerPtr.p->reference_count);
4496 m_commitAckMarkerHash.
seize(markerPtr);
4497 if (markerPtr.i == RNIL)
4499 releaseSections(handle);
4500 noFreeRecordLab(signal, lqhKeyReq, ZNO_FREE_MARKER_RECORDS_ERROR);
4503 markerPtr.p->transid1 = sig1;
4504 markerPtr.p->transid2 = sig2;
4505 markerPtr.p->apiRef = sig3;
4506 markerPtr.p->apiOprec = sig4;
4507 const NodeId tcNodeId = refToNode(sig5);
4508 markerPtr.p->tcNodeId = tcNodeId;
4509 markerPtr.p->reference_count = 1;
4510 m_commitAckMarkerHash.
add(markerPtr);
4513 ndbout_c(
"%u Add marker[%.8x %.8x] op: %u", instance(), markerPtr.p->transid1, markerPtr.p->transid2, tcConnectptr.i);
4516 regTcPtr->commitAckMarker = markerPtr.i;
4519 regTcPtr->reqinfo = Treqinfo;
4520 regTcPtr->lastReplicaNo = LqhKeyReq::getLastReplicaNo(Treqinfo);
4521 regTcPtr->dirtyOp = LqhKeyReq::getDirtyFlag(Treqinfo);
4522 regTcPtr->opExec = LqhKeyReq::getInterpretedFlag(Treqinfo);
4523 regTcPtr->opSimple = LqhKeyReq::getSimpleFlag(Treqinfo);
4524 regTcPtr->seqNoReplica = LqhKeyReq::getSeqNoReplica(Treqinfo);
4525 regTcPtr->apiVersionNo = 0;
4526 regTcPtr->m_use_rowid = LqhKeyReq::getRowidFlag(Treqinfo);
4527 regTcPtr->m_dealloc = 0;
4528 if (unlikely(senderVersion < NDBD_ROWID_VERSION))
4530 regTcPtr->operation = op;
4531 regTcPtr->lockType = LqhKeyReq::getLockType(Treqinfo);
4535 regTcPtr->operation = (Operation_t) op == ZREAD_EX ? ZREAD : (Operation_t) op;
4536 regTcPtr->lockType =
4537 op == ZREAD_EX ? ZUPDATE :
4538 (Operation_t) op == ZWRITE ? ZINSERT :
4539 (Operation_t) op == ZREFRESH ? ZINSERT :
4540 (Operation_t) op == ZUNLOCK ? ZREAD :
4544 if (regTcPtr->dirtyOp)
4546 ndbrequire(regTcPtr->opSimple);
4549 CRASH_INSERTION2(5041, (op == ZREAD &&
4550 (regTcPtr->opSimple || regTcPtr->dirtyOp) &&
4551 refToNode(signal->senderBlockRef()) != cownNodeid));
4555 UintR TapplAddressInd = LqhKeyReq::getApplicationAddressFlag(Treqinfo);
4556 UintR nextPos = (TapplAddressInd << 1);
4557 UintR TsameClientAndTcOprec = LqhKeyReq::getSameClientAndTcFlag(Treqinfo);
4558 if (TsameClientAndTcOprec == 1) {
4559 regTcPtr->tcOprec = lqhKeyReq->variableData[nextPos];
4562 UintR TnextReplicasIndicator = regTcPtr->lastReplicaNo -
4563 regTcPtr->seqNoReplica;
4564 if (TnextReplicasIndicator > 1) {
4565 regTcPtr->nodeAfterNext[0] = lqhKeyReq->variableData[nextPos] & 0xFFFF;
4566 regTcPtr->nodeAfterNext[1] = lqhKeyReq->variableData[nextPos] >> 16;
4569 UintR TstoredProcIndicator = LqhKeyReq::getStoredProcFlag(attrLenFlags);
4570 if (TstoredProcIndicator == 1) {
4571 regTcPtr->storedProcId = lqhKeyReq->variableData[nextPos] & ZNIL;
4574 UintR TreadLenAiIndicator = LqhKeyReq::getReturnedReadLenAIFlag(Treqinfo);
4575 if (TreadLenAiIndicator == 1) {
4576 regTcPtr->readlenAi = lqhKeyReq->variableData[nextPos] & ZNIL;
4580 Uint32 TanyValueFlag = LqhKeyReq::getCorrFactorFlag(Treqinfo);
4581 if (isLongReq && TanyValueFlag == 1)
4586 regTcPtr->m_corrFactorLo = lqhKeyReq->variableData[nextPos + 0];
4587 regTcPtr->m_corrFactorHi = lqhKeyReq->variableData[nextPos + 1];
4591 Uint32 Tdeferred = LqhKeyReq::getDeferredConstraints(Treqinfo);
4592 if (isLongReq && Tdeferred)
4594 regTcPtr->m_flags |= TcConnectionrec::OP_DEFERRED_CONSTRAINTS;
4595 regTcPtr->m_fire_trig_pass = 0;
4598 UintR TitcKeyLen = 0;
4599 Uint32 keyLenWithLQHReq = 0;
4600 UintR TreclenAiLqhkey = 0;
4609 handle.getSection(keyInfoSection,
4610 LqhKeyReq::KeyInfoSectionNum);
4612 ndbassert(keyInfoSection.i != RNIL);
4614 regTcPtr->keyInfoIVal= keyInfoSection.i;
4615 TitcKeyLen= keyInfoSection.sz;
4616 keyLenWithLQHReq= TitcKeyLen;
4618 Uint32 totalAttrInfoLen= 0;
4619 if (handle.getSection(attrInfoSection,
4620 LqhKeyReq::AttrInfoSectionNum))
4622 regTcPtr->attrInfoIVal= attrInfoSection.i;
4623 totalAttrInfoLen= attrInfoSection.sz;
4626 regTcPtr->reclenAiLqhkey = 0;
4627 regTcPtr->currReclenAi = totalAttrInfoLen;
4628 regTcPtr->totReclenAi = totalAttrInfoLen;
4640 TreclenAiLqhkey= LqhKeyReq::getAIInLqhKeyReq(Treqinfo);
4641 regTcPtr->reclenAiLqhkey = TreclenAiLqhkey;
4642 regTcPtr->currReclenAi = TreclenAiLqhkey;
4643 TitcKeyLen = LqhKeyReq::getKeyLen(Treqinfo);
4644 regTcPtr->totReclenAi = LqhKeyReq::getAttrLen(attrLenFlags);
4647 keyLenWithLQHReq= MIN(TitcKeyLen, LqhKeyReq::MaxKeyInfo);
4649 bool ok= appendToSection(regTcPtr->keyInfoIVal,
4650 &lqhKeyReq->variableData[ nextPos ],
4655 terrorCode= ZGET_DATAREC_ERROR;
4656 abortErrorLab(signal);
4660 nextPos+= keyLenWithLQHReq;
4663 regTcPtr->primKeyLen = TitcKeyLen;
4666 if (unlikely(keyLenWithLQHReq == 0))
4668 if (refToMain(senderRef) == DBSPJ)
4671 ndbassert(! LqhKeyReq::getNrCopyFlag(Treqinfo));
4672 terrorCode = ZNO_TUPLE_FOUND;
4673 abortErrorLab(signal);
4677 if (! LqhKeyReq::getNrCopyFlag(Treqinfo))
4679 LQHKEY_error(signal, 3);
4684 sig0 = lqhKeyReq->variableData[nextPos + 0];
4685 sig1 = lqhKeyReq->variableData[nextPos + 1];
4686 regTcPtr->m_row_id.m_page_no = sig0;
4687 regTcPtr->m_row_id.m_page_idx = sig1;
4688 nextPos += 2 * LqhKeyReq::getRowidFlag(Treqinfo);
4690 sig2 = lqhKeyReq->variableData[nextPos + 0];
4695 regTcPtr->gci_hi = LqhKeyReq::getGCIFlag(Treqinfo) ? sig2 : sig3;
4696 regTcPtr->gci_lo = LqhKeyReq::getGCIFlag(Treqinfo) ? ~Uint32(0) : 0;
4697 nextPos += LqhKeyReq::getGCIFlag(Treqinfo);
4699 if (LqhKeyReq::getRowidFlag(Treqinfo))
4701 ndbassert(refToMain(senderRef) != DBTC);
4703 else if(op == ZINSERT)
4705 ndbassert(refToMain(senderRef) == DBTC);
4708 if ((LqhKeyReq::FixedSignalLength + nextPos + TreclenAiLqhkey) !=
4710 LQHKEY_error(signal, 2);
4713 UintR TseqNoReplica = regTcPtr->seqNoReplica;
4714 UintR TlastReplicaNo = regTcPtr->lastReplicaNo;
4715 if (TseqNoReplica == TlastReplicaNo) {
4717 regTcPtr->nextReplica = ZNIL;
4719 if (TseqNoReplica < TlastReplicaNo) {
4721 regTcPtr->nextSeqNoReplica = TseqNoReplica + 1;
4722 if ((regTcPtr->nextReplica == 0) ||
4723 (regTcPtr->nextReplica == cownNodeid)) {
4724 LQHKEY_error(signal, 0);
4727 LQHKEY_error(signal, 4);
4731 TcConnectionrecPtr localNextTcConnectptr;
4732 Uint32 hashIndex = (regTcPtr->transid[0] ^ regTcPtr->tcOprec) & 1023;
4733 localNextTcConnectptr.i = ctransidHash[hashIndex];
4734 ctransidHash[hashIndex] = tcConnectptr.i;
4735 regTcPtr->prevHashRec = RNIL;
4736 regTcPtr->nextHashRec = localNextTcConnectptr.i;
4737 if (localNextTcConnectptr.i != RNIL) {
4741 ptrCheckGuard(localNextTcConnectptr,
4742 ctcConnectrecFileSize, tcConnectionrec);
4744 localNextTcConnectptr.p->prevHashRec = tcConnectptr.i;
4746 if (tabptr.i >= ctabrecFileSize) {
4747 LQHKEY_error(signal, 5);
4750 ptrAss(tabptr, tablerec);
4751 if(table_version_major_lqhkeyreq(tabptr.p->schemaVersion) !=
4752 table_version_major_lqhkeyreq(schemaVersion)){
4753 LQHKEY_abort(signal, 5);
4757 if (unlikely(tabptr.p->
tableStatus != Tablerec::TABLE_DEFINED))
4759 if (check_tabstate(signal, tabptr.p, op))
4763 regTcPtr->tableref = tabptr.i;
4764 regTcPtr->m_disk_table = tabptr.p->m_disk_table;
4765 if(refToMain(signal->senderBlockRef()) == RESTORE)
4766 regTcPtr->m_disk_table &= !LqhKeyReq::getNoDiskFlag(Treqinfo);
4767 else if(op == ZREAD || op == ZREAD_EX || op == ZUPDATE)
4768 regTcPtr->m_disk_table &= !LqhKeyReq::getNoDiskFlag(Treqinfo);
4770 if (op == ZREAD || op == ZREAD_EX || op == ZUNLOCK)
4771 tabptr.p->usageCountR++;
4773 tabptr.p->usageCountW++;
4775 if (!getFragmentrec(signal, regTcPtr->fragmentid)) {
4776 LQHKEY_error(signal, 6);
4780 if (LqhKeyReq::getNrCopyFlag(Treqinfo))
4782 ndbassert(refToMain(senderRef) == DBLQH);
4783 ndbassert(LqhKeyReq::getRowidFlag(Treqinfo));
4786 ndbout_c(
"fragptr.p->fragStatus: %d",
4788 CRASH_INSERTION(5046);
4791 fragptr.p->m_copy_started_state = Fragrecord::AC_NR_COPY;
4794 Uint8 TcopyType = fragptr.p->
fragCopy;
4799 regTcPtr->activeCreat = fragptr.p->m_copy_started_state;
4800 CRASH_INSERTION(5002);
4801 CRASH_INSERTION2(5042, tabptr.i == c_error_insert_table_id);
4803 regTcPtr->activeCreat = Fragrecord::AC_NORMAL;
4805 regTcPtr->replicaType = TcopyType;
4806 regTcPtr->fragmentptr = fragptr.i;
4807 regTcPtr->m_log_part_ptr_i = logPart;
4808 Uint8 TdistKey = LqhKeyReq::getDistributionKey(attrLenFlags);
4809 if ((tfragDistKey != TdistKey) &&
4810 (regTcPtr->seqNoReplica == 0) &&
4811 (regTcPtr->dirtyOp == ZFALSE))
4821 Int8 tmp = (TdistKey - tfragDistKey);
4822 tmp = (tmp < 0 ? - tmp : tmp);
4823 if ((tmp <= 1) || (tfragDistKey == 0)) {
4824 LQHKEY_abort(signal, 0);
4827 LQHKEY_error(signal, 1);
4870 bool attrInfoToPropagate=
4871 (regTcPtr->totReclenAi != 0) &&
4872 (regTcPtr->operation != ZREAD) &&
4873 (regTcPtr->operation != ZDELETE) &&
4874 (regTcPtr->operation != ZUNLOCK);
4875 bool tupCanChangePropagatedAttrInfo= (regTcPtr->opExec == 1);
4878 attrInfoToPropagate &&
4879 (! tupCanChangePropagatedAttrInfo);
4882 regTcPtr->m_flags|= TcConnectionrec::OP_SAVEATTRINFO;
4885 if (regTcPtr->currReclenAi != 0)
4893 regTcPtr->currTupAiLen= saveAttrInfo ?
4894 regTcPtr->totReclenAi :
4903 bool ok= appendToSection(regTcPtr->attrInfoIVal,
4904 lqhKeyReq->variableData + nextPos,
4909 terrorCode= ZGET_DATAREC_ERROR;
4910 abortErrorLab(signal);
4915 regTcPtr->currTupAiLen= TreclenAiLqhkey;
4922 if (regTcPtr->primKeyLen == keyLenWithLQHReq) {
4923 endgettupkeyLab(signal);
4927 ndbassert(!isLongReq);
4929 regTcPtr->save1 = keyLenWithLQHReq;
4930 regTcPtr->transactionState = TcConnectionrec::WAIT_TUPKEYINFO;
4943 void Dblqh::endgettupkeyLab(
Signal* signal)
4945 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
4946 if (regTcPtr->totReclenAi == regTcPtr->currReclenAi) {
4951 ndbrequire(regTcPtr->currReclenAi < regTcPtr->totReclenAi);
4952 ndbassert( !(regTcPtr->m_flags &
4953 TcConnectionrec::OP_ISLONGREQ) );
4954 regTcPtr->transactionState = TcConnectionrec::WAIT_ATTR;
4976 prepareContinueAfterBlockedLab(signal);
4981 linkFragQueue(signal);
4982 regTcPtr->transactionState = TcConnectionrec::STOPPED;
4998 void Dblqh::prepareContinueAfterBlockedLab(
Signal* signal)
5011 Uint32 tc_ptr_i = tcConnectptr.i;
5012 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
5013 Uint32 activeCreat = regTcPtr->activeCreat;
5014 if (regTcPtr->operation == ZUNLOCK)
5017 handleUserUnlockRequest(signal);
5021 if (regTcPtr->indTakeOver == ZTRUE) {
5023 ttcScanOp = KeyInfo20::getScanOp(regTcPtr->tcScanInfo);
5027 key.scanNumber = KeyInfo20::getScanNo(regTcPtr->tcScanInfo);
5028 key.fragPtrI = fragptr.i;
5029 c_scanTakeOverHash.
find(scanptr, key);
5030 #ifdef TRACE_SCAN_TAKEOVER
5031 if(scanptr.i == RNIL)
5032 ndbout_c(
"not finding (%d %d)", key.scanNumber, key.fragPtrI);
5035 if (scanptr.i == RNIL) {
5037 takeOverErrorLab(signal);
5040 Uint32 accOpPtr= get_acc_ptr_from_scan_record(scanptr.p,
5043 if (accOpPtr == RNIL) {
5045 takeOverErrorLab(signal);
5048 signal->theData[1] = accOpPtr;
5049 signal->theData[2] = regTcPtr->transid[0];
5050 signal->theData[3] = regTcPtr->transid[1];
5051 EXECUTE_DIRECT(refToMain(regTcPtr->tcAccBlockref), GSN_ACC_TO_REQ,
5053 if (signal->theData[0] == (UintR)-1) {
5054 execACC_TO_REF(signal);
5071 TRACE_OP(regTcPtr,
"RECEIVED");
5072 switch (regTcPtr->operation) {
5073 case ZREAD: TRACENR(
"READ");
break;
5074 case ZUPDATE: TRACENR(
"UPDATE");
break;
5075 case ZWRITE: TRACENR(
"WRITE");
break;
5076 case ZINSERT: TRACENR(
"INSERT");
break;
5077 case ZDELETE: TRACENR(
"DELETE");
break;
5078 case ZUNLOCK: TRACENR(
"UNLOCK");
break;
5079 case ZREFRESH: TRACENR(
"REFRESH");
break;
5080 default: TRACENR(
"<Unknown: " << regTcPtr->operation <<
">");
break;
5083 TRACENR(
" tab: " << regTcPtr->tableref
5084 <<
" frag: " << regTcPtr->fragmentid
5085 <<
" activeCreat: " << (Uint32)activeCreat);
5086 if (LqhKeyReq::getNrCopyFlag(regTcPtr->reqinfo))
5088 if (LqhKeyReq::getRowidFlag(regTcPtr->reqinfo))
5089 TRACENR(
" rowid: " << regTcPtr->m_row_id);
5090 TRACENR(
" key: " << getKeyInfoWordOrZero(regTcPtr, 0));
5093 if (likely(activeCreat == Fragrecord::AC_NORMAL))
5097 ndbassert(!LqhKeyReq::getNrCopyFlag(regTcPtr->reqinfo));
5098 exec_acckeyreq(signal, tcConnectptr);
5100 else if (activeCreat == Fragrecord::AC_NR_COPY)
5102 regTcPtr->totSendlenAi = regTcPtr->totReclenAi;
5103 handle_nr_copy(signal, tcConnectptr);
5107 ndbassert(activeCreat == Fragrecord::AC_IGNORED);
5109 TRACENR(
" IGNORING (activeCreat == 2)" << endl);
5111 signal->theData[0] = tc_ptr_i;
5112 regTcPtr->transactionState = TcConnectionrec::WAIT_ACC_ABORT;
5114 signal->theData[0] = regTcPtr->tupConnectrec;
5118 regTcPtr->totSendlenAi = regTcPtr->totReclenAi;
5119 packLqhkeyreqLab(signal);
5124 Dblqh::exec_acckeyreq(
Signal* signal, TcConnectionrecPtr regTcPtr)
5127 regTcPtr.p->transactionState = TcConnectionrec::WAIT_ACC;
5128 taccreq = regTcPtr.p->operation;
5129 taccreq = taccreq + (regTcPtr.p->lockType << 4);
5130 taccreq = taccreq + (regTcPtr.p->dirtyOp << 6);
5131 taccreq = taccreq + (regTcPtr.p->replicaType << 7);
5132 taccreq = taccreq + (regTcPtr.p->apiVersionNo << 9);
5136 Uint32 sig0, sig1, sig2, sig3, sig4;
5137 sig0 = regTcPtr.p->accConnectrec;
5139 sig2 = regTcPtr.p->hashValue;
5140 sig3 = regTcPtr.p->primKeyLen;
5141 sig4 = regTcPtr.p->transid[0];
5142 signal->theData[0] = sig0;
5143 signal->theData[1] = sig1;
5144 signal->theData[2] = taccreq;
5145 signal->theData[3] = sig2;
5146 signal->theData[4] = sig3;
5147 signal->theData[5] = sig4;
5149 sig0 = regTcPtr.p->transid[1];
5150 signal->theData[6] = sig0;
5153 sendKeyinfoAcc(signal, 7);
5155 TRACE_OP(regTcPtr.p,
"ACC");
5157 EXECUTE_DIRECT(refToMain(regTcPtr.p->tcAccBlockref), GSN_ACCKEYREQ,
5158 signal, 7 + regTcPtr.p->primKeyLen);
5159 if (signal->theData[0] < RNIL) {
5160 signal->theData[0] = regTcPtr.i;
5161 execACCKEYCONF(signal);
5163 }
else if (signal->theData[0] == RNIL) {
5166 ndbrequire(signal->theData[0] == (UintR)-1);
5167 signal->theData[0] = regTcPtr.i;
5168 execACCKEYREF(signal);
5178 Uint32 op = regTcPtr.p->operation;
5180 const bool copy = LqhKeyReq::getNrCopyFlag(regTcPtr.p->reqinfo);
5182 if (!LqhKeyReq::getRowidFlag(regTcPtr.p->reqinfo))
5189 TRACENR(
" Waiting for COPY_ACTIVEREQ" << endl);
5190 ndbassert(!LqhKeyReq::getNrCopyFlag(regTcPtr.p->reqinfo));
5191 regTcPtr.p->activeCreat = Fragrecord::AC_NORMAL;
5192 exec_acckeyreq(signal, regTcPtr);
5196 regTcPtr.p->m_nr_delete.m_cnt = 1;
5197 Uint32* dst = signal->theData+24;
5199 const int len = c_tup->nr_read_pk(fragPtr, ®TcPtr.p->m_row_id, dst,
5201 const bool match = (len>0) ? compare_key(regTcPtr.p, dst, len) == 0 :
false;
5204 TRACENR(
" len: " << len <<
" match: " << match
5205 <<
" uncommitted: " << uncommitted);
5209 ndbassert(LqhKeyReq::getGCIFlag(regTcPtr.p->reqinfo));
5216 ndbassert(op == ZINSERT);
5218 TRACENR(
" Changing from INSERT to ZUPDATE" << endl);
5219 regTcPtr.p->operation = ZUPDATE;
5222 else if (len > 0 && op == ZDELETE)
5231 ndbassert(regTcPtr.p->primKeyLen == 0);
5233 TRACENR(
" performing DELETE key: "
5236 nr_copy_delete_row(signal, regTcPtr, ®TcPtr.p->m_row_id, len);
5237 ndbassert(regTcPtr.p->m_nr_delete.m_cnt);
5238 regTcPtr.p->m_nr_delete.m_cnt--;
5239 if (regTcPtr.p->m_nr_delete.m_cnt)
5244 packLqhkeyreqLab(signal);
5247 else if (len == 0 && op == ZDELETE)
5254 TRACENR(
" UPDATE_GCI" << endl);
5255 c_tup->nr_update_gci(fragPtr, ®TcPtr.p->m_row_id, regTcPtr.p->gci_hi);
5256 goto update_gci_ignore;
5270 nr_copy_delete_row(signal, regTcPtr, ®TcPtr.p->m_row_id, len);
5276 nr_copy_delete_row(signal, regTcPtr, 0, 0);
5278 TRACENR(
" RUN INSERT" << endl);
5283 if (!match && op != ZINSERT)
5287 TRACENR(
" IGNORE " << endl);
5293 if (op != ZDELETE && op != ZREFRESH)
5296 TRACENR(
" Changing from INSERT/UPDATE to ZWRITE" << endl);
5297 regTcPtr.p->operation = ZWRITE;
5302 ndbassert(!match && op == ZINSERT);
5315 nr_copy_delete_row(signal, regTcPtr, ®TcPtr.p->m_row_id, len);
5322 nr_copy_delete_row(signal, regTcPtr, 0, 0);
5324 TRACENR(
" RUN op: " << op << endl);
5330 exec_acckeyreq(signal, regTcPtr);
5335 ndbassert(!LqhKeyReq::getNrCopyFlag(regTcPtr.p->reqinfo));
5337 regTcPtr.p->activeCreat = Fragrecord::AC_IGNORED;
5338 signal->theData[0] = regTcPtr.p->tupConnectrec;
5341 packLqhkeyreqLab(signal);
5349 Dblqh::compare_key(
const TcConnectionrec* regTcPtr,
5350 const Uint32 * ptr, Uint32 len)
5352 if (regTcPtr->primKeyLen != len)
5355 ndbassert( regTcPtr->keyInfoIVal != RNIL );
5358 getSectionSegmentPool());
5360 ndbassert(regTcPtr->primKeyLen == keyInfoReader.getSize());
5364 const Uint32* keyChunk= NULL;
5365 Uint32 chunkSize= 0;
5368 bool ok= keyInfoReader.getWordsPtr(len, keyChunk, chunkSize);
5372 if ( memcmp(ptr, keyChunk, chunkSize << 2))
5383 Dblqh::nr_copy_delete_row(
Signal* signal,
5390 Uint32 tableId = regTcPtr.p->tableref;
5391 Uint32 accPtr = regTcPtr.p->accConnectrec;
5393 signal->theData[0] = accPtr;
5395 signal->theData[2] = ZDELETE + (ZDELETE << 4);
5396 signal->theData[5] = regTcPtr.p->transid[0];
5397 signal->theData[6] = regTcPtr.p->transid[1];
5403 if (g_key_descriptor_pool.getPtr(tableId)->hasCharAttr)
5405 signal->theData[3] = calculateHash(tableId, signal->theData+24);
5409 signal->theData[3] = md5_hash((Uint64*)(signal->theData+24), len);
5411 signal->theData[4] = 0;
5412 signal->theData[7] = rowid->m_page_no;
5413 signal->theData[8] = rowid->m_page_idx;
5418 keylen = regTcPtr.p->primKeyLen;
5419 signal->theData[3] = regTcPtr.p->hashValue;
5420 signal->theData[4] = keylen;
5425 sendKeyinfoAcc(signal, 7);
5427 const Uint32 ref = refToMain(regTcPtr.p->tcAccBlockref);
5431 Uint32 retValue = signal->theData[0];
5432 ndbrequire(retValue != RNIL);
5433 ndbrequire(retValue != (Uint32)-1 || rowid == 0);
5435 if (retValue == (Uint32)-1)
5441 ndbrequire(rowid == 0);
5442 signal->theData[0] = accPtr;
5443 signal->theData[1] = 0;
5452 ndbrequire(regTcPtr.p->m_dealloc == 0);
5455 c_acc->execACCKEY_ORD(signal, accPtr);
5456 signal->theData[0] = accPtr;
5460 ndbrequire(regTcPtr.p->m_dealloc == 1);
5461 int ret = c_tup->
nr_delete(signal, regTcPtr.i,
5462 fragPtr.p->
tupFragptr, ®TcPtr.p->m_row_id,
5463 regTcPtr.p->gci_hi);
5468 ndbassert(ret == 1);
5469 Uint32 pos = regTcPtr.p->m_nr_delete.m_cnt - 1;
5470 memcpy(regTcPtr.p->m_nr_delete.m_disk_ref + pos,
5472 regTcPtr.p->m_nr_delete.m_page_id[pos] = RNIL;
5473 regTcPtr.p->m_nr_delete.m_cnt = pos + 2;
5474 if (0) ndbout <<
"PENDING DISK DELETE: " <<
5475 regTcPtr.p->m_nr_delete.m_disk_ref[pos] << endl;
5478 TRACENR(
"DELETED: " << regTcPtr.p->m_row_id << endl);
5480 regTcPtr.p->m_dealloc = 0;
5481 regTcPtr.p->m_row_id = save;
5483 tcConnectptr = regTcPtr;
5487 Dblqh::get_nr_op_info(Nr_op_info* op, Uint32 page_id)
5490 tcPtr.i = op->m_ptr_i;
5491 ptrCheckGuard(tcPtr, ctcConnectrecFileSize, tcConnectionrec);
5494 c_fragment_pool.
getPtr(fragPtr, tcPtr.p->fragmentptr);
5496 op->m_gci_hi = tcPtr.p->gci_hi;
5497 op->m_gci_lo = tcPtr.p->gci_lo;
5498 op->m_tup_frag_ptr_i = fragPtr.p->
tupFragptr;
5500 ndbrequire(tcPtr.p->activeCreat == Fragrecord::AC_NR_COPY);
5501 ndbrequire(tcPtr.p->m_nr_delete.m_cnt);
5504 if (page_id == RNIL)
5507 for (Uint32 i = 0; i<2; i++)
5509 if (tcPtr.p->m_nr_delete.m_page_id[i] != RNIL)
5511 op->m_page_id = tcPtr.p->m_nr_delete.m_page_id[
i];
5512 op->m_disk_ref = tcPtr.p->m_nr_delete.m_disk_ref[
i];
5520 for (Uint32 i = 0; i<2; i++)
5522 Local_key key = tcPtr.p->m_nr_delete.m_disk_ref[
i];
5523 if (op->m_disk_ref.m_page_no == key.m_page_no &&
5524 op->m_disk_ref.m_file_no == key.m_file_no &&
5525 tcPtr.p->m_nr_delete.m_page_id[i] == RNIL)
5527 op->m_disk_ref = key;
5528 tcPtr.p->m_nr_delete.m_page_id[
i] = page_id;
5541 tcPtr.i = op->m_ptr_i;
5542 ptrCheckGuard(tcPtr, ctcConnectrecFileSize, tcConnectionrec);
5544 ndbrequire(tcPtr.p->activeCreat == Fragrecord::AC_NR_COPY);
5545 ndbrequire(tcPtr.p->m_nr_delete.m_cnt);
5547 tcPtr.p->m_nr_delete.m_cnt--;
5548 if (tcPtr.p->m_nr_delete.m_cnt == 0)
5551 tcConnectptr = tcPtr;
5552 c_fragment_pool.
getPtr(fragptr, tcPtr.p->fragmentptr);
5554 if (tcPtr.p->abortState != TcConnectionrec::ABORT_IDLE)
5557 tcPtr.p->activeCreat = Fragrecord::AC_NORMAL;
5558 abortCommonLab(signal);
5560 else if (tcPtr.p->operation == ZDELETE &&
5561 LqhKeyReq::getNrCopyFlag(tcPtr.p->reqinfo))
5567 packLqhkeyreqLab(signal);
5572 rwConcludedLab(signal);
5577 if (memcmp(&tcPtr.p->m_nr_delete.m_disk_ref[0],
5578 &op->m_disk_ref,
sizeof(
Local_key)) == 0)
5581 ndbassert(tcPtr.p->m_nr_delete.m_page_id[0] != RNIL);
5582 tcPtr.p->m_nr_delete.m_page_id[0] = tcPtr.p->m_nr_delete.m_page_id[1];
5583 tcPtr.p->m_nr_delete.m_disk_ref[0] = tcPtr.p->m_nr_delete.m_disk_ref[1];
5588 Dblqh::readPrimaryKeys(Uint32 opPtrI, Uint32 * dst,
bool xfrm)
5591 Uint64 Tmp[MAX_KEY_SIZE_IN_WORDS >> 1];
5594 regTcPtr.i = opPtrI;
5595 ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
5597 Uint32 tableId = regTcPtr.p->tableref;
5598 Uint32 keyLen = regTcPtr.p->primKeyLen;
5599 Uint32 * tmp = xfrm ? (Uint32*)Tmp : dst;
5601 copy(tmp, regTcPtr.p->keyInfoIVal);
5606 Uint32 keyPartLen[MAX_ATTRIBUTES_IN_INDEX];
5607 return xfrm_key(tableId, (Uint32*)Tmp, dst, ~0, keyPartLen);
5619 Dblqh::getKeyInfoWordOrZero(
const TcConnectionrec* regTcPtr,
5622 if (regTcPtr->keyInfoIVal != RNIL)
5625 g_sectionSegmentPool);
5627 if (keyInfoReader.getSize() >
offset)
5630 keyInfoReader.step(offset);
5633 keyInfoReader.getWord(&word);
5640 void Dblqh::unlockError(
Signal* signal, Uint32 error)
5643 abortErrorLab(signal);
5652 void Dblqh::handleUserUnlockRequest(
Signal* signal)
5655 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
5656 Uint32 tcPtrI = tcConnectptr.i;
5676 if (unlikely( regTcPtr->primKeyLen != LqhKeyReq::UnlockKeyLen ))
5679 unlockError(signal, 4109);
5684 getSectionSegmentPool());
5686 ndbrequire( keyInfoReader.getSize() == regTcPtr->primKeyLen );
5689 Uint32 tcOpRecIndex;
5691 ndbrequire( keyInfoReader.getWord( &tcOpRecIndex ) );
5692 ndbrequire( keyInfoReader.getWord( &lqhOpIdWord ) );
5700 if (unlikely( findTransaction(regTcPtr->transid[0],
5701 regTcPtr->transid[1],
5706 unlockError(signal, ZBAD_OP_REF);
5710 TcConnectionrec *
const regLockTcPtr = tcConnectptr.p;
5715 Uint32 lockOpKeyReqId = (Uint32) regLockTcPtr->lqhKeyReqId;
5716 if (unlikely( lockOpKeyReqId != lqhOpIdWord ))
5719 unlockError(signal, ZBAD_OP_REF);
5724 bool lockingOpValid =
5725 (( regLockTcPtr->operation == ZREAD ) &&
5727 ( ! regLockTcPtr->dirtyOp ) &&
5728 ( ! regLockTcPtr->opSimple ) &&
5729 ( (regLockTcPtr->lockType == ZREAD) ||
5730 (regLockTcPtr->lockType == ZUPDATE) )
5732 ( regLockTcPtr->transactionState == TcConnectionrec::PREPARED ) &&
5733 ( regLockTcPtr->commitAckMarker == RNIL ) &&
5735 ( regLockTcPtr->logWriteState ==
5736 TcConnectionrec::NOT_STARTED ));
5738 if (unlikely(! lockingOpValid))
5741 unlockError(signal, ZBAD_UNLOCK_STATE);
5748 signal->theData[0] = regLockTcPtr->accConnectrec;
5749 signal->theData[1] = 0;
5757 ndbrequire(signal->theData[1] == 0);
5768 tcConnectptr.i = tcPtrI;
5769 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
5771 ndbrequire( regTcPtr == tcConnectptr.p );
5774 regTcPtr->readlenAi = tcOpRecIndex;
5777 regTcPtr->noFiredTriggers = 0;
5780 sendLqhkeyconfTc(signal, regTcPtr->tcBlockref);
5792 void Dblqh::sendKeyinfoAcc(
Signal* signal, Uint32 Ti)
5795 copy(&signal->theData[Ti],
5796 tcConnectptr.p->keyInfoIVal);
5799 void Dblqh::execLQH_ALLOCREQ(
Signal* signal)
5801 TcConnectionrecPtr regTcPtr;
5802 FragrecordPtr regFragptr;
5805 regTcPtr.i = signal->theData[0];
5806 ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
5808 regFragptr.i = regTcPtr.p->fragmentptr;
5809 c_fragment_pool.
getPtr(regFragptr);
5811 signal->theData[0] = regTcPtr.p->tupConnectrec;
5812 signal->theData[1] = regFragptr.p->tupFragptr;
5813 signal->theData[2] = regTcPtr.p->tableref;
5814 Uint32 tup = refToMain(regTcPtr.p->tcTupBlockref);
5818 void Dblqh::execTUP_DEALLOCREQ(
Signal* signal)
5820 TcConnectionrecPtr regTcPtr;
5823 regTcPtr.i = signal->theData[4];
5828 tmp.m_page_no = signal->theData[2];
5829 tmp.m_page_idx = signal->theData[3];
5830 TRACENR(
"TUP_DEALLOC: " << tmp <<
5831 (signal->theData[5] ?
" DIRECT " :
" DELAYED") << endl);
5834 if (signal->theData[5])
5839 tmp.m_page_no = signal->theData[2];
5840 tmp.m_page_idx = signal->theData[3];
5842 if (ERROR_INSERTED(5712))
5844 ndbout <<
"TUP_DEALLOC: " << tmp << endl;
5847 EXECUTE_DIRECT(DBTUP, GSN_TUP_DEALLOCREQ, signal, signal->getLength());
5853 ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
5854 regTcPtr.p->m_row_id.m_page_no = signal->theData[2];
5855 regTcPtr.p->m_row_id.m_page_idx = signal->theData[3];
5857 TRACE_OP(regTcPtr.p,
"SET DEALLOC");
5859 ndbrequire(regTcPtr.p->m_dealloc == 0);
5860 regTcPtr.p->m_dealloc = 1;
5867 void Dblqh::execACCKEYCONF(
Signal* signal)
5869 TcConnectionrec *regTcConnectionrec = tcConnectionrec;
5870 Uint32 ttcConnectrecFileSize = ctcConnectrecFileSize;
5871 Uint32 tcIndex = signal->theData[0];
5872 Uint32 localKey1 = signal->theData[3];
5873 Uint32 localKey2 = signal->theData[4];
5876 tcConnectptr.i = tcIndex;
5877 ptrCheckGuard(tcConnectptr, ttcConnectrecFileSize, regTcConnectionrec);
5878 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
5879 if (regTcPtr->transactionState != TcConnectionrec::WAIT_ACC) {
5880 LQHKEY_abort(signal, 3);
5892 if (regTcPtr->operation == ZWRITE)
5894 ndbassert(regTcPtr->seqNoReplica == 0 ||
5895 regTcPtr->activeCreat == Fragrecord::AC_NR_COPY);
5896 Uint32 op= signal->theData[1];
5897 Uint32 requestInfo = regTcPtr->reqinfo;
5898 if(likely(op == ZINSERT || op == ZUPDATE))
5901 regTcPtr->operation = op;
5907 op = regTcPtr->operation = ZUPDATE;
5909 if (regTcPtr->seqNoReplica == 0)
5912 requestInfo &= ~(RI_OPERATION_MASK << RI_OPERATION_SHIFT);
5913 LqhKeyReq::setOperation(requestInfo, op);
5914 regTcPtr->reqinfo = requestInfo;
5926 FragrecordPtr regFragptr;
5927 regFragptr.i = regTcPtr->fragmentptr;
5928 c_fragment_pool.
getPtr(regFragptr);
5930 if(!regTcPtr->m_disk_table)
5931 acckeyconf_tupkeyreq(signal, regTcPtr, regFragptr.p,
5932 localKey1, localKey2, RNIL);
5934 acckeyconf_load_diskpage(signal, tcConnectptr, regFragptr.p,
5935 localKey1, localKey2);
5939 Dblqh::acckeyconf_tupkeyreq(
Signal* signal, TcConnectionrec* regTcPtr,
5940 Fragrecord* regFragptrP,
5941 Uint32 lkey1, Uint32 lkey2,
5944 Uint32 op = regTcPtr->operation;
5945 regTcPtr->transactionState = TcConnectionrec::WAIT_TUP;
5954 Uint32 page_idx = lkey2;
5955 Uint32 page_no = lkey1;
5956 Uint32 Ttupreq = regTcPtr->dirtyOp;
5957 Uint32
flags = regTcPtr->m_flags;
5958 Ttupreq = Ttupreq + (regTcPtr->opSimple << 1);
5959 Ttupreq = Ttupreq + (op << 6);
5960 Ttupreq = Ttupreq + (regTcPtr->opExec << 10);
5961 Ttupreq = Ttupreq + (regTcPtr->apiVersionNo << 11);
5962 Ttupreq = Ttupreq + (regTcPtr->m_use_rowid << 11);
5963 Ttupreq = Ttupreq + (regTcPtr->m_reorg << 12);
5969 regTcPtr->opExec = 0;
5973 Uint32 sig0, sig1, sig2, sig3;
5974 sig0 = regTcPtr->tupConnectrec;
5977 tupKeyReq->connectPtr = sig0;
5978 tupKeyReq->request = Ttupreq;
5979 tupKeyReq->keyRef1 = page_no;
5980 tupKeyReq->keyRef2 = page_idx;
5982 sig0 = regTcPtr->totReclenAi;
5983 sig1 = regTcPtr->applOprec;
5984 sig2 = regTcPtr->applRef;
5986 tupKeyReq->attrBufLen = sig0;
5987 tupKeyReq->opRef = sig1;
5988 tupKeyReq->applRef = sig2;
5990 sig0 = regTcPtr->storedProcId;
5991 sig1 = regTcPtr->transid[0];
5992 sig2 = regTcPtr->transid[1];
5993 sig3 = regFragptrP->tupFragptr;
5994 Uint32 tup = refToMain(regTcPtr->tcTupBlockref);
5996 tupKeyReq->storedProcedure = sig0;
5997 tupKeyReq->transId1 = sig1;
5998 tupKeyReq->transId2 = sig2;
5999 tupKeyReq->fragPtr = sig3;
6001 sig0 = regTcPtr->m_row_id.m_page_no;
6002 sig1 = regTcPtr->m_row_id.m_page_idx;
6004 tupKeyReq->primaryReplica = (tcConnectptr.p->seqNoReplica == 0)?
true:
false;
6005 tupKeyReq->coordinatorTC = tcConnectptr.p->tcBlockref;
6006 tupKeyReq->tcOpIndex = tcConnectptr.p->tcOprec;
6007 tupKeyReq->savePointId = tcConnectptr.p->savePointId;
6008 tupKeyReq->disk_page= disk_page;
6010 tupKeyReq->m_row_id_page_no = sig0;
6011 tupKeyReq->m_row_id_page_idx = sig1;
6013 TRACE_OP(regTcPtr,
"TUPKEYREQ");
6015 regTcPtr->m_use_rowid |= (op == ZINSERT || op == ZREFRESH);
6016 regTcPtr->m_row_id.m_page_no = page_no;
6017 regTcPtr->m_row_id.m_page_idx = page_idx;
6019 tupKeyReq->attrInfoIVal= RNIL;
6020 tupKeyReq->deferred_constraints =
6021 (flags & TcConnectionrec::OP_DEFERRED_CONSTRAINTS) != 0;
6027 if (tupKeyReq->attrBufLen > 0)
6029 ndbassert( regTcPtr->attrInfoIVal != RNIL );
6030 tupKeyReq->attrInfoIVal= regTcPtr->attrInfoIVal;
6033 EXECUTE_DIRECT(tup, GSN_TUPKEYREQ, signal, TupKeyReq::SignalLength);
6037 Dblqh::acckeyconf_load_diskpage(
Signal* signal, TcConnectionrecPtr regTcPtr,
6038 Fragrecord* regFragptrP,
6039 Uint32 lkey1, Uint32 lkey2)
6042 if((res= c_tup->load_diskpage(signal,
6043 regTcPtr.p->tupConnectrec,
6044 regFragptrP->tupFragptr,
6046 regTcPtr.p->operation)) > 0)
6048 acckeyconf_tupkeyreq(signal, regTcPtr.p, regFragptrP, lkey1, lkey2, res);
6052 regTcPtr.p->transactionState = TcConnectionrec::WAIT_TUP;
6053 regTcPtr.p->m_row_id.m_page_no = lkey1;
6054 regTcPtr.p->m_row_id.m_page_idx = lkey2;
6058 regTcPtr.p->transactionState = TcConnectionrec::WAIT_TUP;
6060 ref->userRef= regTcPtr.i;
6062 execTUPKEYREF(signal);
6067 Dblqh::acckeyconf_load_diskpage_callback(
Signal* signal,
6068 Uint32 callbackData,
6072 tcConnectptr.i = callbackData;
6073 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
6074 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
6076 TcConnectionrec::TransactionState state = regTcPtr->transactionState;
6077 if (likely(disk_page > 0 && state == TcConnectionrec::WAIT_TUP))
6079 FragrecordPtr fragPtr;
6080 c_fragment_pool.
getPtr(fragPtr, regTcPtr->fragmentptr);
6082 acckeyconf_tupkeyreq(signal, regTcPtr, fragPtr.p,
6083 regTcPtr->m_row_id.m_page_no,
6084 regTcPtr->m_row_id.m_page_idx,
6087 else if (state != TcConnectionrec::WAIT_TUP)
6089 ndbrequire(state == TcConnectionrec::WAIT_TUP_TO_ABORT);
6090 abortCommonLab(signal);
6095 regTcPtr->transactionState = TcConnectionrec::WAIT_TUP;
6097 ref->userRef= callbackData;
6098 ref->errorCode= disk_page;
6099 execTUPKEYREF(signal);
6115 void Dblqh::tupkeyConfLab(
Signal* signal)
6119 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
6120 Uint32 activeCreat = regTcPtr->activeCreat;
6121 Uint32 readLen = tupKeyConf->readLength;
6122 Uint32 writeLen = tupKeyConf->writeLength;
6124 TRACE_OP(regTcPtr,
"TUPKEYCONF");
6126 Uint32 accOp = regTcPtr->accConnectrec;
6127 c_acc->execACCKEY_ORD(signal, accOp);
6134 LqhKeyReq::setApplicationAddressFlag(regTcPtr->reqinfo, 1);
6135 regTcPtr->readlenAi = readLen;
6138 if (regTcPtr->operation == ZREAD &&
6139 (regTcPtr->opSimple || regTcPtr->dirtyOp))
6151 commitContinueAfterBlockedLab(signal);
6155 regTcPtr->totSendlenAi = writeLen;
6160 ndbrequire(regTcPtr->totSendlenAi == regTcPtr->currTupAiLen);
6162 if (unlikely(activeCreat == Fragrecord::AC_NR_COPY))
6165 ndbrequire(regTcPtr->m_nr_delete.m_cnt);
6166 regTcPtr->m_nr_delete.m_cnt--;
6167 if (regTcPtr->m_nr_delete.m_cnt)
6179 TablerecPtr tablePtr;
6180 tablePtr.i = regTcPtr->tableref;
6181 ptrCheckGuard(tablePtr, ctabrecFileSize, tablerec);
6182 ndbrequire(tablePtr.p->m_disk_table);
6189 rwConcludedLab(signal);
6196 void Dblqh::rwConcludedLab(
Signal* signal)
6198 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
6204 if (regTcPtr->operation == ZREAD) {
6210 packLqhkeyreqLab(signal);
6213 FragrecordPtr regFragptr = fragptr;
6214 if (regFragptr.p->logFlag == Fragrecord::STATE_FALSE){
6215 if (regTcPtr->dirtyOp == ZTRUE) {
6221 commitContinueAfterBlockedLab(signal);
6229 regTcPtr->logWriteState = TcConnectionrec::NOT_WRITTEN;
6230 packLqhkeyreqLab(signal);
6242 logLqhkeyreqLab(signal);
6248 void Dblqh::rwConcludedAiLab(
Signal* signal)
6250 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
6251 fragptr.i = regTcPtr->fragmentptr;
6260 if (regTcPtr->operation == ZREAD) {
6261 if (regTcPtr->opSimple == 1) {
6267 localCommitLab(signal);
6275 c_fragment_pool.
getPtr(fragptr);
6276 packLqhkeyreqLab(signal);
6281 c_fragment_pool.
getPtr(fragptr);
6282 if (fragptr.p->
logFlag == Fragrecord::STATE_FALSE) {
6283 if (regTcPtr->dirtyOp == ZTRUE) {
6292 localCommitLab(signal);
6304 regTcPtr->logWriteState = TcConnectionrec::NOT_WRITTEN;
6305 packLqhkeyreqLab(signal);
6317 logLqhkeyreqLab(signal);
6332 void Dblqh::logLqhkeyreqLab(
Signal* signal)
6334 UintR tcurrentFilepage;
6335 TcConnectionrecPtr tmpTcConnectptr;
6337 const bool out_of_log_buffer = cnoOfLogPages < ZMIN_LOG_PAGES_OPERATION;
6339 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
6340 logPartPtr.i = regTcPtr->m_log_part_ptr_i;
6341 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
6342 bool abort_on_redo_problems =
6343 (LqhKeyReq::getQueueOnRedoProblemFlag(regTcPtr->reqinfo) == 0);
6353 LogPartRecord *
const regLogPartPtr = logPartPtr.p;
6354 const bool problem = out_of_log_buffer || regLogPartPtr->m_log_problems != 0;
6355 if (unlikely(problem))
6357 if (abort_on_redo_problems)
6359 logLqhkeyreqLab_problems(signal);
6377 regTcPtr->transactionState = TcConnectionrec::LOG_QUEUED;
6386 logFilePtr.i = regLogPartPtr->currentLogfile;
6387 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
6397 checkNewMbyte(signal);
6408 Uint32 tcIndex = tcConnectptr.i;
6409 tmpTcConnectptr.i = regLogPartPtr->lastLogTcrec;
6410 regLogPartPtr->lastLogTcrec = tcIndex;
6411 if (tmpTcConnectptr.i == RNIL) {
6413 regLogPartPtr->firstLogTcrec = tcIndex;
6415 ptrCheckGuard(tmpTcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
6416 tmpTcConnectptr.p->nextLogTcrec = tcIndex;
6418 Uint32 fileNo = logFilePtr.p->
fileNo;
6421 regTcPtr->nextLogTcrec = RNIL;
6422 regTcPtr->prevLogTcrec = tmpTcConnectptr.i;
6423 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
6424 Uint32 pageIndex = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
6425 regTcPtr->logStartFileNo = fileNo;
6426 regTcPtr->logStartPageNo = tcurrentFilepage;
6427 regTcPtr->logStartPageIndex = pageIndex;
6431 writeLogHeader(signal);
6439 writeAttrinfoLab(signal);
6450 if (logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] == ZPAGE_HEADER_SIZE) {
6454 regTcPtr->logStopPageNo = tcurrentFilepage;
6455 regTcPtr->logWriteState = TcConnectionrec::WRITTEN;
6456 if (regTcPtr->abortState != TcConnectionrec::ABORT_IDLE) {
6462 abortCommonLab(signal);
6465 if (regTcPtr->dirtyOp != ZTRUE) {
6466 packLqhkeyreqLab(signal);
6474 writeCommitLog(signal, logPartPtr);
6478 localCommitLab(signal);
6483 Dblqh::logLqhkeyreqLab_problems(
Signal * signal)
6486 LogPartRecord *
const regLogPartPtr = logPartPtr.p;
6487 Uint32 problems = regLogPartPtr->m_log_problems;
6489 if (cnoOfLogPages < ZMIN_LOG_PAGES_OPERATION)
6492 terrorCode = ZTEMPORARY_REDO_LOG_FAILURE;
6494 else if ((problems & LogPartRecord::P_TAIL_PROBLEM) != 0)
6497 terrorCode = ZTAIL_PROBLEM_IN_LOG_ERROR;
6499 else if ((problems & LogPartRecord::P_REDO_IO_PROBLEM) != 0)
6502 terrorCode = ZREDO_IO_PROBLEM;
6504 else if ((problems & LogPartRecord::P_FILE_CHANGE_PROBLEM) != 0)
6507 terrorCode = ZFILE_CHANGE_PROBLEM_IN_LOG_ERROR;
6509 abortErrorLab(signal);
6514 Uint32 problem,
bool value)
6516 Uint32 problems = partPtr.p->m_log_problems;
6523 if ((problems & problem) == 0)
6526 problems |= problem;
6535 if ((problems & problem) != 0)
6538 problems &= ~(Uint32)problem;
6547 signal->theData[0] = ZLOG_LQHKEYREQ;
6548 signal->theData[1] = partPtr.i;
6549 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
6553 partPtr.p->m_log_problems = problems;
6563 void Dblqh::packLqhkeyreqLab(
Signal* signal)
6565 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
6566 if (regTcPtr->nextReplica == ZNIL) {
6571 sendLqhkeyconfTc(signal, regTcPtr->tcBlockref);
6572 if (! (regTcPtr->dirtyOp ||
6573 (regTcPtr->operation == ZREAD && regTcPtr->opSimple)))
6576 regTcPtr->transactionState = TcConnectionrec::PREPARED;
6577 releaseOprec(signal);
6622 UintR sig0, sig1, sig2, sig3, sig4, sig5, sig6;
6623 Treqinfo = preComputedRequestInfoMask & regTcPtr->reqinfo;
6625 Uint32 nextNodeId = regTcPtr->nextReplica;
6629 bool sendLongReq= ! ((nextVersion < NDBD_LONG_LQHKEYREQ) ||
6630 ERROR_INSERTED(5051));
6632 UintR TAiLen = sendLongReq ?
6634 MIN(regTcPtr->totSendlenAi, LqhKeyReq::MaxAttrInfo);
6637 Uint32 lqhKeyLen= sendLongReq?
6639 regTcPtr->primKeyLen;
6641 UintR TapplAddressIndicator = (regTcPtr->nextSeqNoReplica == 0 ? 0 : 1);
6642 LqhKeyReq::setApplicationAddressFlag(Treqinfo, TapplAddressIndicator);
6643 LqhKeyReq::setInterpretedFlag(Treqinfo, regTcPtr->opExec);
6644 LqhKeyReq::setSeqNoReplica(Treqinfo, regTcPtr->nextSeqNoReplica);
6645 LqhKeyReq::setAIInLqhKeyReq(Treqinfo, TAiLen);
6646 LqhKeyReq::setKeyLen(Treqinfo,lqhKeyLen);
6648 if (unlikely(nextVersion < NDBD_ROWID_VERSION))
6650 LqhKeyReq::setLockType(Treqinfo, regTcPtr->lockType);
6654 regTcPtr->m_use_rowid |=
6655 fragptr.p->m_copy_started_state == Fragrecord::AC_NR_COPY;
6656 LqhKeyReq::setRowidFlag(Treqinfo, regTcPtr->m_use_rowid);
6659 if (LqhKeyReq::getRowidFlag(Treqinfo))
6665 if (fragptr.p->m_copy_started_state != Fragrecord::AC_IGNORED)
6667 ndbassert(LqhKeyReq::getOperation(Treqinfo) != ZINSERT ||
6668 get_node_status(nextNodeId) != ZNODE_UP);
6672 UintR TreadLenAiInd = (regTcPtr->readlenAi == 0 ? 0 : 1);
6673 UintR TsameLqhAndClient = (tcConnectptr.i ==
6674 regTcPtr->tcOprec ? 0 : 1);
6675 LqhKeyReq::setSameClientAndTcFlag(Treqinfo, TsameLqhAndClient);
6676 LqhKeyReq::setReturnedReadLenAIFlag(Treqinfo, TreadLenAiInd);
6679 UintR TotReclenAi = sendLongReq ?
6681 regTcPtr->totSendlenAi;
6683 LqhKeyReq::setReorgFlag(TotReclenAi, regTcPtr->m_reorg);
6692 sig0 = tcConnectptr.i;
6693 sig1 = regTcPtr->savePointId;
6694 sig2 = regTcPtr->hashValue;
6695 sig4 = regTcPtr->tcBlockref;
6697 lqhKeyReq->clientConnectPtr = sig0;
6698 lqhKeyReq->attrLen = TotReclenAi;
6699 lqhKeyReq->savePointId = sig1;
6700 lqhKeyReq->hashValue = sig2;
6701 lqhKeyReq->requestInfo = Treqinfo;
6702 lqhKeyReq->tcBlockref = sig4;
6704 sig0 = regTcPtr->tableref + ((regTcPtr->schemaVersion << 16) & 0xFFFF0000);
6705 sig1 = regTcPtr->fragmentid + (regTcPtr->nodeAfterNext[0] << 16);
6706 sig2 = regTcPtr->transid[0];
6707 sig3 = regTcPtr->transid[1];
6708 sig4 = regTcPtr->applRef;
6709 sig5 = regTcPtr->applOprec;
6710 sig6 = regTcPtr->tcOprec;
6711 UintR nextPos = (TapplAddressIndicator << 1);
6713 lqhKeyReq->tableSchemaVersion = sig0;
6714 lqhKeyReq->fragmentData = sig1;
6715 lqhKeyReq->transId1 = sig2;
6716 lqhKeyReq->transId2 = sig3;
6718 lqhKeyReq->variableData[0] = sig4;
6719 lqhKeyReq->variableData[1] = sig5;
6720 lqhKeyReq->variableData[2] = sig6;
6722 nextPos += TsameLqhAndClient;
6724 if ((regTcPtr->lastReplicaNo - regTcPtr->nextSeqNoReplica) > 1) {
6725 sig0 = (UintR)regTcPtr->nodeAfterNext[1] +
6726 (UintR)(regTcPtr->nodeAfterNext[2] << 16);
6727 lqhKeyReq->variableData[nextPos] = sig0;
6730 sig0 = regTcPtr->readlenAi;
6731 lqhKeyReq->variableData[nextPos] = sig0;
6732 nextPos += TreadLenAiInd;
6740 if (regTcPtr->primKeyLen != 0)
6744 ndbassert(regTcPtr->keyInfoIVal != RNIL);
6746 getSection(keyInfoSection, regTcPtr->keyInfoIVal);
6747 SectionReader keyInfoReader(keyInfoSection, g_sectionSegmentPool);
6749 UintR keyLenInLqhKeyReq= MIN(LqhKeyReq::MaxKeyInfo,
6750 regTcPtr->primKeyLen);
6752 keyInfoReader.getWords(&lqhKeyReq->variableData[nextPos],
6755 nextPos+= keyLenInLqhKeyReq;
6759 sig0 = regTcPtr->gci_hi;
6762 lqhKeyReq->variableData[nextPos + 0] = tmp.m_page_no;
6763 lqhKeyReq->variableData[nextPos + 1] = tmp.m_page_idx;
6764 nextPos += 2*LqhKeyReq::getRowidFlag(Treqinfo);
6766 lqhKeyReq->variableData[nextPos + 0] = sig0;
6767 nextPos += LqhKeyReq::getGCIFlag(Treqinfo);
6770 BlockReference lqhRef = numberToRef(DBLQH,
6772 regTcPtr->nextReplica);
6774 if (likely(sendLongReq))
6782 if (regTcPtr->primKeyLen > 0)
6786 ndbassert(regTcPtr->keyInfoIVal != RNIL);
6787 getSection(keyInfoSection, regTcPtr->keyInfoIVal);
6789 handle.m_ptr[ LqhKeyReq::KeyInfoSectionNum ]= keyInfoSection;
6792 if (regTcPtr->totSendlenAi > 0)
6796 ndbassert(regTcPtr->attrInfoIVal != RNIL);
6797 getSection(attrInfoSection, regTcPtr->attrInfoIVal);
6799 handle.m_ptr[ LqhKeyReq::AttrInfoSectionNum ]= attrInfoSection;
6809 if (regTcPtr->attrInfoIVal != RNIL)
6811 ndbassert(!( regTcPtr->m_flags &
6812 TcConnectionrec::OP_SAVEATTRINFO));
6813 releaseSection(regTcPtr->attrInfoIVal);
6814 regTcPtr->attrInfoIVal= RNIL;
6823 ndbrequire(regTcPtr->totSendlenAi == 0);
6824 ndbassert(regTcPtr->keyInfoIVal == RNIL);
6825 ndbassert(regTcPtr->attrInfoIVal == RNIL);
6828 sendSignal(lqhRef, GSN_LQHKEYREQ, signal,
6829 LqhKeyReq::FixedSignalLength + nextPos,
6834 ndbassert( handle.m_cnt == 0);
6835 regTcPtr->keyInfoIVal= RNIL;
6836 regTcPtr->attrInfoIVal= RNIL;
6846 if (likely(nextPos + TAiLen + LqhKeyReq::FixedSignalLength <= 25))
6851 ndbassert(regTcPtr->attrInfoIVal != RNIL);
6853 getSection(attrInfoSection, regTcPtr->attrInfoIVal);
6854 SectionReader attrInfoReader(attrInfoSection, getSectionSegmentPool());
6856 attrInfoReader.getWords(&lqhKeyReq->variableData[nextPos],
6866 Treqinfo &= ~(Uint32)(RI_AI_IN_THIS_MASK << RI_AI_IN_THIS_SHIFT);
6867 lqhKeyReq->requestInfo = Treqinfo;
6872 sendSignal(lqhRef, GSN_LQHKEYREQ, signal,
6873 nextPos + LqhKeyReq::FixedSignalLength, JBB);
6876 if (regTcPtr->primKeyLen > LqhKeyReq::MaxKeyInfo) {
6882 Uint32 remainingAiLen= regTcPtr->totSendlenAi - TAiLen;
6884 if (remainingAiLen != 0)
6886 sig0 = regTcPtr->tcOprec;
6887 sig1 = regTcPtr->transid[0];
6888 sig2 = regTcPtr->transid[1];
6889 signal->theData[0] = sig0;
6890 signal->theData[1] = sig1;
6891 signal->theData[2] = sig2;
6894 g_sectionSegmentPool);
6896 ndbassert(attrInfoReader.getSize() == regTcPtr->totSendlenAi);
6899 attrInfoReader.step(TAiLen);
6901 while (remainingAiLen != 0)
6903 Uint32 dataInSignal= MIN(AttrInfo::DataLength, remainingAiLen);
6904 attrInfoReader.getWords(&signal->theData[3],
6906 remainingAiLen-= dataInSignal;
6907 sendSignal(lqhRef, GSN_ATTRINFO, signal,
6908 AttrInfo::HeaderLength + dataInSignal, JBB);
6915 regTcPtr->transactionState = TcConnectionrec::PREPARED;
6916 if (regTcPtr->dirtyOp == ZTRUE) {
6947 releaseOprec(signal);
6955 void Dblqh::checkNewMbyte(
Signal* signal)
6958 UintR ttotalLogSize;
6969 ttotalLogSize = ZLOG_HEAD_SIZE + tcConnectptr.p->currTupAiLen;
6970 ttotalLogSize = ttotalLogSize + tcConnectptr.p->primKeyLen;
6972 if ((ttotalLogSize + ZNEXT_LOG_SIZE) <= tcnmTmp) {
6973 ndbrequire(tcnmTmp >= ttotalLogSize);
6988 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
6989 changeMbyte(signal);
6992 ndbrequire(tcnmTmp >= ttotalLogSize);
7001 void Dblqh::writeLogHeader(
Signal* signal)
7003 Uint32 logPos = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
7004 Uint32 hashValue = tcConnectptr.p->hashValue;
7005 Uint32 operation = tcConnectptr.p->operation;
7006 Uint32 keyLen = tcConnectptr.p->primKeyLen;
7007 Uint32 aiLen = tcConnectptr.p->currTupAiLen;
7008 Local_key rowid = tcConnectptr.p->m_row_id;
7009 Uint32 totLogLen = ZLOG_HEAD_SIZE + aiLen + keyLen;
7011 if ((logPos + ZLOG_HEAD_SIZE) < ZPAGE_SIZE) {
7012 Uint32* dataPtr = &logPagePtr.p->
logPageWord[logPos];
7013 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = logPos + ZLOG_HEAD_SIZE;
7014 dataPtr[0] = ZPREP_OP_TYPE;
7015 dataPtr[1] = totLogLen;
7016 dataPtr[2] = hashValue;
7017 dataPtr[3] = operation;
7019 dataPtr[5] = keyLen;
7020 dataPtr[6] = rowid.m_page_no;
7021 dataPtr[7] = rowid.m_page_idx;
7023 writeLogWord(signal, ZPREP_OP_TYPE);
7024 writeLogWord(signal, totLogLen);
7025 writeLogWord(signal, hashValue);
7026 writeLogWord(signal, operation);
7027 writeLogWord(signal, aiLen);
7028 writeLogWord(signal, keyLen);
7029 writeLogWord(signal, rowid.m_page_no);
7030 writeLogWord(signal, rowid.m_page_idx);
7039 void Dblqh::writeKey(
Signal* signal)
7041 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
7044 g_sectionSegmentPool);
7045 const Uint32* srcPtr;
7047 Uint32 wordsWritten= 0;
7052 while (keyInfoReader.getWordsPtr(srcPtr,
7055 writeLogWords(signal, srcPtr, length);
7056 wordsWritten+= length;
7059 ndbassert( wordsWritten == regTcPtr->primKeyLen );
7067 void Dblqh::writeAttrinfoLab(
Signal* signal)
7069 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
7070 Uint32 totLen = regTcPtr->currTupAiLen;
7075 ndbassert( regTcPtr->attrInfoIVal != RNIL );
7077 g_sectionSegmentPool);
7078 const Uint32* srcPtr;
7080 Uint32 wordsWritten= 0;
7085 while (attrInfoReader.getWordsPtr(srcPtr,
7088 writeLogWords(signal, srcPtr, length);
7089 wordsWritten+= length;
7092 ndbassert( wordsWritten == totLen );
7100 void Dblqh::sendTupkey(
Signal* signal)
7102 BlockReference lqhRef = 0;
7105 FragrecordPtr Tfragptr;
7106 Tfragptr.i = tcConnectptr.p->fragmentptr;
7107 c_fragment_pool.
getPtr(Tfragptr);
7108 Uint32 Tnode = tcConnectptr.p->nextReplica;
7109 Uint32 instanceKey = Tfragptr.p->lqhInstanceKey;
7110 lqhRef = numberToRef(DBLQH, instanceKey, Tnode);
7113 signal->theData[0] = tcConnectptr.p->tcOprec;
7114 signal->theData[1] = tcConnectptr.p->transid[0];
7115 signal->theData[2] = tcConnectptr.p->transid[1];
7117 Uint32 remainingLen= tcConnectptr.p->primKeyLen -
7118 LqhKeyReq::MaxKeyInfo;
7121 g_sectionSegmentPool);
7123 ndbassert(keyInfoReader.getSize() > LqhKeyReq::MaxKeyInfo);
7126 keyInfoReader.step(LqhKeyReq::MaxKeyInfo);
7128 while (remainingLen != 0)
7130 Uint32 dataInSignal= MIN(KeyInfo::DataLength, remainingLen);
7131 keyInfoReader.getWords(&signal->theData[3],
7133 remainingLen-= dataInSignal;
7134 sendSignal(lqhRef, GSN_KEYINFO, signal,
7135 KeyInfo::HeaderLength + dataInSignal, JBB);
7139 void Dblqh::cleanUp(
Signal* signal)
7141 releaseOprec(signal);
7142 deleteTransidHash(signal);
7143 releaseTcrec(signal, tcConnectptr);
7150 void Dblqh::releaseOprec(
Signal* signal)
7152 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
7155 releaseSection(regTcPtr->keyInfoIVal);
7156 regTcPtr->keyInfoIVal = RNIL;
7157 releaseSection(regTcPtr->attrInfoIVal);
7158 regTcPtr->attrInfoIVal = RNIL;
7160 if (regTcPtr->m_dealloc)
7163 regTcPtr->m_dealloc = 0;
7166 TRACENR(
"DELETED: " << regTcPtr->m_row_id << endl);
7168 TRACE_OP(regTcPtr,
"DO DEALLOC");
7170 signal->theData[0] = regTcPtr->fragmentid;
7171 signal->theData[1] = regTcPtr->tableref;
7172 signal->theData[2] = regTcPtr->m_row_id.m_page_no;
7173 signal->theData[3] = regTcPtr->m_row_id.m_page_idx;
7174 signal->theData[4] = RNIL;
7183 void Dblqh::deleteTransidHash(
Signal* signal)
7185 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
7186 TcConnectionrecPtr prevHashptr;
7187 TcConnectionrecPtr nextHashptr;
7189 prevHashptr.i = regTcPtr->prevHashRec;
7190 nextHashptr.i = regTcPtr->nextHashRec;
7191 if (prevHashptr.i != RNIL) {
7193 ptrCheckGuard(prevHashptr, ctcConnectrecFileSize, tcConnectionrec);
7194 prevHashptr.p->nextHashRec = nextHashptr.i;
7201 Uint32 hashIndex = (regTcPtr->transid[0] ^ regTcPtr->tcOprec) & 1023;
7202 ctransidHash[hashIndex] = nextHashptr.i;
7204 if (nextHashptr.i != RNIL) {
7206 ptrCheckGuard(nextHashptr, ctcConnectrecFileSize, tcConnectionrec);
7207 nextHashptr.p->prevHashRec = prevHashptr.i;
7210 regTcPtr->prevHashRec = regTcPtr->nextHashRec = RNIL;
7222 void Dblqh::warningReport(
Signal* signal,
int place)
7228 ndbout <<
"W: Received COMMIT in wrong state in Dblqh" << endl;
7234 ndbout <<
"W: Received COMMIT with wrong transid in Dblqh" << endl;
7240 ndbout <<
"W: Received COMPLETE in wrong state in Dblqh" << endl;
7246 ndbout <<
"W: Received COMPLETE with wrong transid in Dblqh" << endl;
7252 ndbout <<
"W: Received COMMITREQ in wrong state in Dblqh" << endl;
7258 ndbout <<
"W: Received COMMITREQ with wrong transid in Dblqh" << endl;
7264 ndbout <<
"W: Received COMPLETEREQ in wrong state in Dblqh" << endl;
7270 ndbout <<
"W: Received COMPLETEREQ with wrong transid in Dblqh" << endl;
7276 ndbout <<
"W: Received ABORT with non-existing transid in Dblqh" << endl;
7282 ndbout <<
"W: Received ABORTREQ with non-existing transid in Dblqh" << endl;
7288 ndbout <<
"W: Received ABORTREQ in wrong state in Dblqh" << endl;
7294 ndbout <<
"W: Received COMMIT when tc-rec released in Dblqh" << endl;
7300 ndbout <<
"W: Received COMPLETE when tc-rec released in Dblqh" << endl;
7306 ndbout <<
"W: Received LQHKEYREF when tc-rec released in Dblqh" << endl;
7312 ndbout <<
"W: Received LQHKEYREF with wrong transid in Dblqh" << endl;
7318 ndbout <<
"W: Received LQHKEYREF when already aborting in Dblqh" << endl;
7323 ndbrequire(cstartPhase == ZNIL);
7325 ndbout <<
"W: Received LQHKEYREF in wrong state in Dblqh" << endl;
7335 void Dblqh::errorReport(
Signal* signal,
int place)
7354 systemErrorLab(signal, __LINE__);
7359 Dblqh::execFIRE_TRIG_REQ(
Signal* signal)
7361 Uint32 tcOprec = signal->theData[0];
7362 Uint32 transid1 = signal->theData[1];
7363 Uint32 transid2 = signal->theData[2];
7364 Uint32 pass = signal->theData[3];
7365 Uint32 senderRef = signal->getSendersBlockRef();
7369 if (ERROR_INSERTED_CLEAR(5064))
7375 CRASH_INSERTION(5072);
7378 if (findTransaction(transid1, transid2, tcOprec, 0) == ZOK &&
7379 !ERROR_INSERTED_CLEAR(5065) &&
7380 !ERROR_INSERTED(5070) &&
7381 !ERROR_INSERTED(5071))
7383 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
7385 if (unlikely(regTcPtr->transactionState != TcConnectionrec::PREPARED ||
7386 ERROR_INSERTED_CLEAR(5067)))
7388 err = FireTrigRef::FTR_IncorrectState;
7395 signal->theData[0] = regTcPtr->tupConnectrec;
7396 signal->theData[1] = regTcPtr->tcBlockref;
7397 signal->theData[2] = regTcPtr->tcOprec;
7398 signal->theData[3] = transid1;
7399 signal->theData[4] = transid2;
7400 signal->theData[5] = pass;
7401 Uint32 tup = refToMain(regTcPtr->tcTupBlockref);
7404 err = signal->theData[0];
7405 Uint32 cnt = signal->theData[1];
7407 if (ERROR_INSERTED_CLEAR(5066))
7412 if (ERROR_INSERTED_CLEAR(5068))
7414 if (ERROR_INSERTED_CLEAR(5069))
7420 Uint32 Tdata[FireTrigConf::SignalLength];
7422 conf->tcOpRec = tcOprec;
7423 conf->transId[0] = transid1;
7424 conf->transId[1] = transid2;
7425 conf->noFiredTriggers = cnt;
7426 sendFireTrigConfTc(signal, regTcPtr->tcBlockref, Tdata);
7433 err = FireTrigRef::FTR_UnknownOperation;
7437 if (ERROR_INSERTED_CLEAR(5070))
7440 if (ERROR_INSERTED_CLEAR(5071))
7444 ref->tcOpRec = tcOprec;
7445 ref->transId[0] = transid1;
7446 ref->transId[1] = transid2;
7448 sendSignal(senderRef, GSN_FIRE_TRIG_REF,
7449 signal, FireTrigRef::SignalLength, JBB);
7455 Dblqh::sendFireTrigConfTc(
Signal* signal,
7456 BlockReference atcBlockref,
7459 if (refToInstance(atcBlockref) != 0)
7462 memcpy(signal->theData, Tdata, 4 * FireTrigConf::SignalLength);
7463 sendSignal(atcBlockref, GSN_FIRE_TRIG_CONF,
7464 signal, FireTrigConf::SignalLength, JBB);
7468 HostRecordPtr Thostptr;
7469 Uint32 len = FireTrigConf::SignalLength;
7471 Thostptr.i = refToNode(atcBlockref);
7472 ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
7474 if (Thostptr.p->noOfPackedWordsTc > (25 - len))
7477 sendPackedSignalTc(signal, Thostptr.p);
7482 updatePackedList(signal, Thostptr.p, Thostptr.i);
7485 ndbassert(FireTrigConf::SignalLength == 4);
7486 Uint32 * dst = &Thostptr.p->packedWordsTc[Thostptr.p->noOfPackedWordsTc];
7487 Thostptr.p->noOfPackedWordsTc += len;
7488 dst[0] = Tdata[0] | (ZFIRE_TRIG_CONF << 28);
7503 ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
7504 if (regTcPtr.p->m_fire_trig_pass <= pass)
7506 regTcPtr.p->m_fire_trig_pass = pass + 1;
7519 void Dblqh::execCOMMIT(
Signal* signal)
7521 TcConnectionrec *regTcConnectionrec = tcConnectionrec;
7522 Uint32 ttcConnectrecFileSize = ctcConnectrecFileSize;
7523 Uint32 tcIndex = signal->theData[0];
7524 Uint32 gci_hi = signal->theData[1];
7525 Uint32 transid1 = signal->theData[2];
7526 Uint32 transid2 = signal->theData[3];
7527 Uint32 gci_lo = signal->theData[4];
7529 if (tcIndex >= ttcConnectrecFileSize) {
7530 errorReport(signal, 0);
7533 if (ERROR_INSERTED(5011)) {
7534 CLEAR_ERROR_INSERT_VALUE;
7535 sendSignalWithDelay(cownref, GSN_COMMIT, signal, 2000,signal->getLength());
7538 if (ERROR_INSERTED(5012)) {
7539 SET_ERROR_INSERT_VALUE(5017);
7540 sendSignalWithDelay(cownref, GSN_COMMIT, signal, 2000,signal->getLength());
7543 if (ERROR_INSERTED(5062) &&
7544 ((refToMain(signal->getSendersBlockRef()) == DBTC) ||
7545 signal->getSendersBlockRef() == reference()))
7547 Uint32 save = signal->getSendersBlockRef();
7548 ndbout_c(
"Delaying execCOMMIT");
7549 sendSignalWithDelay(cownref, GSN_COMMIT, signal, 2000, signal->getLength());
7551 if (refToMain(save) == DBTC)
7553 ndbout_c(
"killing %u", refToNode(save));
7554 signal->theData[0] = 9999;
7555 sendSignal(numberToRef(CMVMI, refToNode(save)),
7556 GSN_NDB_TAMPER, signal, 1, JBB);
7561 tcConnectptr.i = tcIndex;
7562 ptrAss(tcConnectptr, regTcConnectionrec);
7563 if ((tcConnectptr.p->transid[0] == transid1) &&
7564 (tcConnectptr.p->transid[1] == transid2)) {
7566 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
7567 TRACE_OP(regTcPtr,
"COMMIT");
7569 CRASH_INSERTION(5048);
7570 if (ERROR_INSERTED(5049))
7572 SET_ERROR_INSERT_VALUE(5048);
7575 commitReqLab(signal, gci_hi, gci_lo);
7578 warningReport(signal, 1);
7588 void Dblqh::execCOMMITREQ(
Signal* signal)
7591 Uint32 reqPtr = signal->theData[0];
7592 BlockReference reqBlockref = signal->theData[1];
7593 Uint32 gci_hi = signal->theData[2];
7594 Uint32 transid1 = signal->theData[3];
7595 Uint32 transid2 = signal->theData[4];
7596 Uint32 tcOprec = signal->theData[6];
7597 Uint32 gci_lo = signal->theData[7];
7599 if (unlikely(signal->getLength() < 8))
7603 ndbassert(!ndb_check_micro_gcp(
getNodeInfo(refToNode(signal->getSendersBlockRef())).
m_version));
7606 if (ERROR_INSERTED(5004)) {
7607 systemErrorLab(signal, __LINE__);
7609 if (ERROR_INSERTED(5017)) {
7610 CLEAR_ERROR_INSERT_VALUE;
7611 sendSignalWithDelay(cownref, GSN_COMMITREQ, signal, 2000,
7612 signal->getLength());
7615 if (findTransaction(transid1,
7617 tcOprec, 0) != ZOK) {
7618 warningReport(signal, 5);
7621 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
7622 switch (regTcPtr->transactionState) {
7623 case TcConnectionrec::PREPARED:
7624 case TcConnectionrec::LOG_COMMIT_QUEUED_WAIT_SIGNAL:
7625 case TcConnectionrec::LOG_COMMIT_WRITTEN_WAIT_SIGNAL:
7630 regTcPtr->reqBlockref = reqBlockref;
7631 regTcPtr->reqRef = reqPtr;
7632 regTcPtr->abortState = TcConnectionrec::REQ_FROM_TC;
7633 commitReqLab(signal, gci_hi, gci_lo);
7636 case TcConnectionrec::COMMITTED:
7643 regTcPtr->reqBlockref = reqBlockref;
7644 regTcPtr->reqRef = reqPtr;
7645 regTcPtr->abortState = TcConnectionrec::REQ_FROM_TC;
7646 signal->theData[0] = regTcPtr->reqRef;
7647 signal->theData[1] = cownNodeid;
7648 signal->theData[2] = regTcPtr->transid[0];
7649 signal->theData[3] = regTcPtr->transid[1];
7650 sendSignal(regTcPtr->reqBlockref, GSN_COMMITCONF, signal, 4, JBB);
7652 case TcConnectionrec::COMMIT_STOPPED:
7653 case TcConnectionrec::WAIT_TUP_COMMIT:
7655 regTcPtr->reqBlockref = reqBlockref;
7656 regTcPtr->reqRef = reqPtr;
7657 regTcPtr->abortState = TcConnectionrec::REQ_FROM_TC;
7662 warningReport(signal, 4);
7674 void Dblqh::execCOMPLETE(
Signal* signal)
7676 TcConnectionrec *regTcConnectionrec = tcConnectionrec;
7677 Uint32 ttcConnectrecFileSize = ctcConnectrecFileSize;
7678 Uint32 tcIndex = signal->theData[0];
7679 Uint32 transid1 = signal->theData[1];
7680 Uint32 transid2 = signal->theData[2];
7682 if (tcIndex >= ttcConnectrecFileSize) {
7683 errorReport(signal, 1);
7686 CRASH_INSERTION(5042);
7688 if (ERROR_INSERTED(5013)) {
7689 CLEAR_ERROR_INSERT_VALUE;
7690 sendSignalWithDelay(cownref, GSN_COMPLETE, signal, 2000, 3);
7693 if (ERROR_INSERTED(5014)) {
7694 SET_ERROR_INSERT_VALUE(5018);
7695 sendSignalWithDelay(cownref, GSN_COMPLETE, signal, 2000, 3);
7698 if (ERROR_INSERTED(5063) &&
7699 ((refToMain(signal->getSendersBlockRef()) == DBTC) ||
7700 signal->getSendersBlockRef() == reference()))
7702 Uint32 save = signal->getSendersBlockRef();
7703 ndbout_c(
"Delaying execCOMPLETE");
7704 sendSignalWithDelay(cownref, GSN_COMPLETE,signal, 2000,signal->getLength());
7706 if (refToMain(save) == DBTC)
7708 ndbout_c(
"killing %u", refToNode(save));
7709 signal->theData[0] = 9999;
7710 sendSignal(numberToRef(CMVMI, refToNode(save)),
7711 GSN_NDB_TAMPER, signal, 1, JBB);
7716 tcConnectptr.i = tcIndex;
7717 ptrAss(tcConnectptr, regTcConnectionrec);
7718 if ((tcConnectptr.p->transactionState == TcConnectionrec::COMMITTED) &&
7719 (tcConnectptr.p->transid[0] == transid1) &&
7720 (tcConnectptr.p->transid[1] == transid2)) {
7722 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
7723 TRACE_OP(regTcPtr,
"COMPLETE");
7725 if (tcConnectptr.p->seqNoReplica != 0 &&
7726 tcConnectptr.p->activeCreat == Fragrecord::AC_NORMAL) {
7728 localCommitLab(signal);
7731 else if (tcConnectptr.p->seqNoReplica == 0)
7734 completeTransLastLab(signal);
7740 completeTransNotLastLab(signal);
7744 if (tcConnectptr.p->transactionState != TcConnectionrec::COMMITTED) {
7745 warningReport(signal, 2);
7747 warningReport(signal, 3);
7755 void Dblqh::execCOMPLETEREQ(
Signal* signal)
7758 Uint32 reqPtr = signal->theData[0];
7759 BlockReference reqBlockref = signal->theData[1];
7760 Uint32 transid1 = signal->theData[2];
7761 Uint32 transid2 = signal->theData[3];
7762 Uint32 tcOprec = signal->theData[5];
7763 if (ERROR_INSERTED(5005)) {
7764 systemErrorLab(signal, __LINE__);
7766 if (ERROR_INSERTED(5018)) {
7767 CLEAR_ERROR_INSERT_VALUE;
7768 sendSignalWithDelay(cownref, GSN_COMPLETEREQ, signal, 2000, 6);
7771 if (findTransaction(transid1,
7773 tcOprec, 0) != ZOK) {
7780 signal->theData[0] = reqPtr;
7781 signal->theData[1] = cownNodeid;
7782 signal->theData[2] = transid1;
7783 signal->theData[3] = transid2;
7784 sendSignal(reqBlockref, GSN_COMPLETECONF, signal, 4, JBB);
7785 warningReport(signal, 7);
7788 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
7789 switch (regTcPtr->transactionState) {
7790 case TcConnectionrec::COMMITTED:
7792 regTcPtr->reqBlockref = reqBlockref;
7793 regTcPtr->reqRef = reqPtr;
7794 regTcPtr->abortState = TcConnectionrec::REQ_FROM_TC;
7800 case TcConnectionrec::COMMIT_STOPPED:
7801 case TcConnectionrec::WAIT_TUP_COMMIT:
7809 regTcPtr->reqBlockref = reqBlockref;
7810 regTcPtr->reqRef = reqPtr;
7811 regTcPtr->abortState = TcConnectionrec::REQ_FROM_TC;
7816 warningReport(signal, 6);
7820 if (regTcPtr->seqNoReplica != 0 &&
7821 regTcPtr->activeCreat != Fragrecord::AC_NR_COPY) {
7823 localCommitLab(signal);
7825 else if (regTcPtr->seqNoReplica == 0)
7828 completeTransLastLab(signal);
7833 completeTransNotLastLab(signal);
7840 void Dblqh::execLQHKEYCONF(
Signal* signal)
7843 Uint32 tcIndex = lqhKeyConf->opPtr;
7844 Uint32 ttcConnectrecFileSize = ctcConnectrecFileSize;
7845 TcConnectionrec *regTcConnectionrec = tcConnectionrec;
7847 if (tcIndex >= ttcConnectrecFileSize) {
7848 errorReport(signal, 2);
7851 tcConnectptr.i = tcIndex;
7852 ptrAss(tcConnectptr, regTcConnectionrec);
7853 switch (tcConnectptr.p->connectState) {
7854 case TcConnectionrec::LOG_CONNECTED:
7856 completedLab(signal);
7859 case TcConnectionrec::COPY_CONNECTED:
7861 copyCompletedLab(signal);
7865 jamLine(tcConnectptr.p->connectState);
7876 void Dblqh::commitReqLab(
Signal* signal, Uint32 gci_hi, Uint32 gci_lo)
7878 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
7879 TcConnectionrec::LogWriteState logWriteState = regTcPtr->logWriteState;
7880 TcConnectionrec::TransactionState transState = regTcPtr->transactionState;
7881 regTcPtr->gci_hi = gci_hi;
7882 regTcPtr->gci_lo = gci_lo;
7883 if (transState == TcConnectionrec::PREPARED) {
7884 if (logWriteState == TcConnectionrec::WRITTEN) {
7886 regTcPtr->transactionState = TcConnectionrec::PREPARED_RECEIVED_COMMIT;
7887 TcConnectionrecPtr saveTcPtr = tcConnectptr;
7888 Uint32 blockNo = refToMain(regTcPtr->tcTupBlockref);
7889 signal->theData[0] = regTcPtr->tupConnectrec;
7890 signal->theData[1] = gci_hi;
7891 signal->theData[2] = gci_lo;
7894 if (regTcPtr->transactionState == TcConnectionrec::LOG_COMMIT_QUEUED) {
7898 ndbrequire(regTcPtr->transactionState == TcConnectionrec::LOG_COMMIT_WRITTEN);
7899 tcConnectptr = saveTcPtr;
7900 }
else if (logWriteState == TcConnectionrec::NOT_STARTED) {
7902 }
else if (logWriteState == TcConnectionrec::NOT_WRITTEN) {
7911 regTcPtr->logWriteState = TcConnectionrec::NOT_STARTED;
7913 ndbrequire(logWriteState == TcConnectionrec::NOT_WRITTEN_WAIT);
7921 checkScanTcCompleted(signal);
7923 }
else if (transState == TcConnectionrec::LOG_COMMIT_QUEUED_WAIT_SIGNAL) {
7925 regTcPtr->transactionState = TcConnectionrec::LOG_COMMIT_QUEUED;
7927 }
else if (transState == TcConnectionrec::LOG_COMMIT_WRITTEN_WAIT_SIGNAL) {
7930 warningReport(signal, 0);
7933 if (regTcPtr->seqNoReplica == 0 ||
7934 regTcPtr->activeCreat == Fragrecord::AC_NR_COPY) {
7936 localCommitLab(signal);
7939 commitReplyLab(signal);
7943 void Dblqh::execLQH_WRITELOG_REQ(
Signal* signal)
7946 tcConnectptr.i = signal->theData[0];
7947 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
7948 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
7949 Uint32 gci_hi = signal->theData[1];
7950 Uint32 gci_lo = signal->theData[2];
7951 Uint32 newestGci = cnewestGci;
7952 TcConnectionrec::LogWriteState logWriteState = regTcPtr->logWriteState;
7953 TcConnectionrec::TransactionState transState = regTcPtr->transactionState;
7954 regTcPtr->gci_hi = gci_hi;
7955 regTcPtr->gci_lo = gci_lo;
7956 if (gci_hi > newestGci) {
7961 cnewestGci = gci_hi;
7963 if (logWriteState == TcConnectionrec::WRITTEN) {
7969 LogPartRecordPtr regLogPartPtr;
7970 Uint32 noOfLogPages = cnoOfLogPages;
7972 regLogPartPtr.i = regTcPtr->m_log_part_ptr_i;
7973 ptrCheckGuard(regLogPartPtr, clogPartFileSize, logPartRecord);
7974 if (!regLogPartPtr.p->m_log_complete_queue.isEmpty() ||
7975 (noOfLogPages == 0))
7987 linkWaitLog(signal, regLogPartPtr, regLogPartPtr.p->m_log_complete_queue);
7988 if (transState == TcConnectionrec::PREPARED) {
7990 regTcPtr->transactionState = TcConnectionrec::LOG_COMMIT_QUEUED_WAIT_SIGNAL;
7993 ndbrequire(transState == TcConnectionrec::PREPARED_RECEIVED_COMMIT);
7994 regTcPtr->transactionState = TcConnectionrec::LOG_COMMIT_QUEUED;
7998 writeCommitLog(signal, regLogPartPtr);
7999 if (transState == TcConnectionrec::PREPARED) {
8001 regTcPtr->transactionState = TcConnectionrec::LOG_COMMIT_WRITTEN_WAIT_SIGNAL;
8004 ndbrequire(transState == TcConnectionrec::PREPARED_RECEIVED_COMMIT);
8005 regTcPtr->transactionState = TcConnectionrec::LOG_COMMIT_WRITTEN;
8010 void Dblqh::localCommitLab(
Signal* signal)
8012 FragrecordPtr regFragptr;
8013 regFragptr.i = tcConnectptr.p->fragmentptr;
8014 c_fragment_pool.
getPtr(regFragptr);
8016 fragptr = regFragptr;
8022 commitContinueAfterBlockedLab(signal);
8027 linkFragQueue(signal);
8028 tcConnectptr.p->transactionState = TcConnectionrec::COMMIT_STOPPED;
8042 void Dblqh::commitContinueAfterBlockedLab(
Signal* signal)
8058 Uint32 operation = regTcPtr.p->operation;
8059 Uint32 dirtyOp = regTcPtr.p->dirtyOp;
8060 Uint32 opSimple = regTcPtr.p->opSimple;
8061 Uint32 normalProtocol = LqhKeyReq::getNormalProtocolFlag(regTcPtr.p->reqinfo);
8063 if (regTcPtr.p->activeCreat != Fragrecord::AC_IGNORED) {
8064 if (operation != ZREAD) {
8067 Uint32 sig0 = regTcPtr.p->tupConnectrec;
8068 Uint32 tup = refToMain(regTcPtr.p->tcTupBlockref);
8070 tupCommitReq->opPtr = sig0;
8071 tupCommitReq->gci_hi = regTcPtr.p->gci_hi;
8072 tupCommitReq->hashValue = regTcPtr.p->hashValue;
8073 tupCommitReq->diskpage = RNIL;
8074 tupCommitReq->gci_lo = regTcPtr.p->gci_lo;
8075 tupCommitReq->transId1 = regTcPtr.p->transid[0];
8076 tupCommitReq->transId2 = regTcPtr.p->transid[1];
8078 TupCommitReq::SignalLength);
8082 TRACENR(
"COMMIT: ");
8083 switch (regTcPtr.p->operation) {
8084 case ZREAD: TRACENR(
"READ");
break;
8085 case ZUPDATE: TRACENR(
"UPDATE");
break;
8086 case ZWRITE: TRACENR(
"WRITE");
break;
8087 case ZINSERT: TRACENR(
"INSERT");
break;
8088 case ZDELETE: TRACENR(
"DELETE");
break;
8089 case ZUNLOCK: TRACENR(
"UNLOCK");
break;
8092 TRACENR(
" tab: " << regTcPtr.p->tableref
8093 <<
" frag: " << regTcPtr.p->fragmentid
8094 <<
" activeCreat: " << (Uint32)regTcPtr.p->activeCreat);
8095 if (LqhKeyReq::getNrCopyFlag(regTcPtr.p->reqinfo))
8097 if (LqhKeyReq::getRowidFlag(regTcPtr.p->reqinfo))
8098 TRACENR(
" rowid: " << regTcPtr.p->m_row_id);
8099 TRACENR(
" key: " << getKeyInfoWordOrZero(regTcPtr.p, 0));
8101 if (signal->theData[0] != 0)
8102 TRACENR(
" TIMESLICE");
8106 if(signal->theData[0] != 0)
8108 regTcPtr.p->transactionState = TcConnectionrec::WAIT_TUP_COMMIT;
8112 TRACE_OP(regTcPtr.p,
"ACC_COMMITREQ");
8114 Uint32 acc = refToMain(regTcPtr.p->tcAccBlockref);
8115 signal->theData[0] = regTcPtr.p->accConnectrec;
8120 TRACE_OP(regTcPtr.p,
"ACC_COMMITREQ");
8122 Uint32 acc = refToMain(regTcPtr.p->tcAccBlockref);
8123 signal->theData[0] = regTcPtr.p->accConnectrec;
8127 if (dirtyOp && normalProtocol == 0)
8133 fragptr = regFragptr;
8134 tcConnectptr = regTcPtr;
8145 fragptr = regFragptr;
8146 tcConnectptr = regTcPtr;
8147 packLqhkeyreqLab(signal);
8153 fragptr = regFragptr;
8154 tcConnectptr = regTcPtr;
8155 tupcommit_conf(signal, regTcPtr.p, regFragptr.p);
8159 Dblqh::tupcommit_conf_callback(
Signal* signal, Uint32 tcPtrI)
8163 tcConnectptr.i = tcPtrI;
8164 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
8165 TcConnectionrec * tcPtr = tcConnectptr.p;
8167 ndbrequire(tcPtr->transactionState == TcConnectionrec::WAIT_TUP_COMMIT);
8169 FragrecordPtr regFragptr;
8170 regFragptr.i = tcPtr->fragmentptr;
8171 c_fragment_pool.
getPtr(regFragptr);
8172 fragptr = regFragptr;
8174 TRACE_OP(tcPtr,
"ACC_COMMITREQ");
8176 Uint32 acc = refToMain(tcPtr->tcAccBlockref);
8177 signal->theData[0] = tcPtr->accConnectrec;
8181 tcConnectptr.i = tcPtrI;
8182 tcConnectptr.p = tcPtr;
8183 tupcommit_conf(signal, tcPtr, regFragptr.p);
8187 Dblqh::tupcommit_conf(
Signal* signal,
8188 TcConnectionrec * tcPtrP,
8189 Fragrecord * regFragptr)
8191 Uint32 dirtyOp = tcPtrP->dirtyOp;
8192 Uint32 seqNoReplica = tcPtrP->seqNoReplica;
8193 Uint32 activeCreat = tcPtrP->activeCreat;
8194 if (tcPtrP->gci_hi > regFragptr->newestGci) {
8200 regFragptr->newestGci = tcPtrP->gci_hi;
8202 if (dirtyOp != ZTRUE)
8204 if (seqNoReplica == 0 || activeCreat == Fragrecord::AC_NR_COPY)
8207 commitReplyLab(signal);
8210 if (seqNoReplica == 0)
8213 completeTransLastLab(signal);
8218 completeTransNotLastLab(signal);
8227 if (tcPtrP->abortState == TcConnectionrec::ABORT_IDLE)
8230 if (activeCreat == Fragrecord::AC_NR_COPY)
8233 ndbrequire(LqhKeyReq::getNrCopyFlag(tcPtrP->reqinfo));
8234 ndbrequire(tcPtrP->m_nr_delete.m_cnt == 0);
8236 packLqhkeyreqLab(signal);
8240 ndbrequire(tcPtrP->abortState != TcConnectionrec::NEW_FROM_TC);
8242 sendLqhTransconf(signal, LqhTransConf::Committed);
8248 void Dblqh::commitReplyLab(
Signal* signal)
8253 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8254 TcConnectionrec::AbortState abortState = regTcPtr->abortState;
8255 regTcPtr->transactionState = TcConnectionrec::COMMITTED;
8256 if (abortState == TcConnectionrec::ABORT_IDLE) {
8257 Uint32 clientBlockref = regTcPtr->clientBlockref;
8258 if (regTcPtr->seqNoReplica == 0) {
8260 sendCommittedTc(signal, clientBlockref);
8264 sendCommitLqh(signal, clientBlockref);
8267 }
else if (regTcPtr->abortState == TcConnectionrec::REQ_FROM_TC) {
8269 signal->theData[0] = regTcPtr->reqRef;
8270 signal->theData[1] = cownNodeid;
8271 signal->theData[2] = regTcPtr->transid[0];
8272 signal->theData[3] = regTcPtr->transid[1];
8273 sendSignal(tcConnectptr.p->reqBlockref, GSN_COMMITCONF, signal, 4, JBB);
8275 ndbrequire(regTcPtr->abortState == TcConnectionrec::NEW_FROM_TC);
8284 void Dblqh::completeTransNotLastLab(
Signal* signal)
8286 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8287 if (regTcPtr->abortState == TcConnectionrec::ABORT_IDLE) {
8288 Uint32 clientBlockref = regTcPtr->clientBlockref;
8290 sendCompleteLqh(signal, clientBlockref);
8295 completeUnusualLab(signal);
8300 void Dblqh::completeTransLastLab(
Signal* signal)
8302 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8303 if (regTcPtr->abortState == TcConnectionrec::ABORT_IDLE) {
8304 Uint32 clientBlockref = regTcPtr->clientBlockref;
8310 sendCompletedTc(signal, clientBlockref);
8315 completeUnusualLab(signal);
8320 void Dblqh::completeUnusualLab(
Signal* signal)
8322 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8323 if (regTcPtr->abortState == TcConnectionrec::ABORT_FROM_TC) {
8325 sendAborted(signal);
8326 }
else if (regTcPtr->abortState == TcConnectionrec::NEW_FROM_TC) {
8329 ndbrequire(regTcPtr->abortState == TcConnectionrec::REQ_FROM_TC);
8331 signal->theData[0] = regTcPtr->reqRef;
8332 signal->theData[1] = cownNodeid;
8333 signal->theData[2] = regTcPtr->transid[0];
8334 signal->theData[3] = regTcPtr->transid[1];
8335 sendSignal(regTcPtr->reqBlockref,
8336 GSN_COMPLETECONF, signal, 4, JBB);
8347 void Dblqh::releaseTcrec(
Signal* signal, TcConnectionrecPtr locTcConnectptr)
8350 Uint32 op = locTcConnectptr.p->operation;
8351 locTcConnectptr.p->tcTimer = 0;
8352 locTcConnectptr.p->transactionState = TcConnectionrec::TC_NOT_CONNECTED;
8353 locTcConnectptr.p->nextTcConnectrec = cfirstfreeTcConrec;
8354 cfirstfreeTcConrec = locTcConnectptr.i;
8356 ndbassert(locTcConnectptr.p->tcScanRec == RNIL);
8359 tabPtr.i = locTcConnectptr.p->tableref;
8360 if(tabPtr.i == RNIL)
8363 ptrCheckGuard(tabPtr, ctabrecFileSize, tablerec);
8368 if (op == ZREAD || op == ZUNLOCK)
8370 ndbrequire(tabPtr.p->usageCountR > 0);
8371 tabPtr.p->usageCountR--;
8375 ndbrequire(tabPtr.p->usageCountW > 0);
8376 tabPtr.p->usageCountW--;
8380 void Dblqh::releaseTcrecLog(
Signal* signal, TcConnectionrecPtr locTcConnectptr)
8383 locTcConnectptr.p->tcTimer = 0;
8384 locTcConnectptr.p->transactionState = TcConnectionrec::TC_NOT_CONNECTED;
8385 locTcConnectptr.p->nextTcConnectrec = cfirstfreeTcConrec;
8386 cfirstfreeTcConrec = locTcConnectptr.i;
8389 tabPtr.i = locTcConnectptr.p->tableref;
8390 if(tabPtr.i == RNIL)
8401 Dblqh::remove_commit_marker(TcConnectionrec *
const regTcPtr)
8404 Uint32 commitAckMarker = regTcPtr->commitAckMarker;
8405 regTcPtr->commitAckMarker = RNIL;
8406 if (commitAckMarker == RNIL)
8409 m_commitAckMarkerHash.
getPtr(tmp, commitAckMarker);
8411 ndbout_c(
"%u remove marker[%.8x %.8x] op: %u ref: %u",
8412 instance(), tmp.p->transid1, tmp.p->transid2,
8413 Uint32(regTcPtr - tcConnectionrec), tmp.p->reference_count);
8415 ndbrequire(tmp.p->reference_count > 0);
8416 tmp.p->reference_count--;
8417 if (tmp.p->reference_count == 0)
8420 m_commitAckMarkerHash.
release(tmp);
8428 void Dblqh::execABORT(
Signal* signal)
8431 Uint32 tcOprec = signal->theData[0];
8432 BlockReference tcBlockref = signal->theData[1];
8433 Uint32 transid1 = signal->theData[2];
8434 Uint32 transid2 = signal->theData[3];
8435 CRASH_INSERTION(5003);
8436 if (ERROR_INSERTED(5015)) {
8437 CLEAR_ERROR_INSERT_VALUE;
8438 sendSignalWithDelay(cownref, GSN_ABORT, signal, 2000, 4);
8441 if (findTransaction(transid1,
8443 tcOprec, 0) != ZOK) {
8446 if(ERROR_INSERTED(5039) &&
8447 refToNode(signal->getSendersBlockRef()) != getOwnNodeId()){
8449 SET_ERROR_INSERT_VALUE(5040);
8453 if(ERROR_INSERTED(5040) &&
8454 refToNode(signal->getSendersBlockRef()) != getOwnNodeId()){
8456 SET_ERROR_INSERT_VALUE(5003);
8464 signal->theData[0] = tcOprec;
8465 signal->theData[1] = transid1;
8466 signal->theData[2] = transid2;
8467 signal->theData[3] = cownNodeid;
8468 signal->theData[4] = ZTRUE;
8469 sendSignal(tcBlockref, GSN_ABORTED, signal, 5, JBB);
8470 warningReport(signal, 8);
8474 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8475 if (ERROR_INSERTED(5100))
8477 SET_ERROR_INSERT_VALUE(5101);
8480 CRASH_INSERTION2(5101, regTcPtr->nextReplica != ZNIL);
8487 if (regTcPtr->nextReplica != ZNIL) {
8491 FragrecordPtr Tfragptr;
8492 Tfragptr.i = regTcPtr->fragmentptr;
8493 c_fragment_pool.
getPtr(Tfragptr);
8494 Uint32 Tnode = regTcPtr->nextReplica;
8495 Uint32 instanceKey = Tfragptr.p->lqhInstanceKey;
8496 BlockReference TLqhRef = numberToRef(DBLQH, instanceKey, Tnode);
8497 signal->theData[0] = regTcPtr->tcOprec;
8498 signal->theData[1] = regTcPtr->tcBlockref;
8499 signal->theData[2] = regTcPtr->transid[0];
8500 signal->theData[3] = regTcPtr->transid[1];
8501 sendSignal(TLqhRef, GSN_ABORT, signal, 4, JBB);
8503 regTcPtr->abortState = TcConnectionrec::ABORT_FROM_TC;
8505 remove_commit_marker(regTcPtr);
8506 TRACE_OP(regTcPtr,
"ABORT");
8508 abortStateHandlerLab(signal);
8517 void Dblqh::execABORTREQ(
Signal* signal)
8520 Uint32 reqPtr = signal->theData[0];
8521 BlockReference reqBlockref = signal->theData[1];
8522 Uint32 transid1 = signal->theData[2];
8523 Uint32 transid2 = signal->theData[3];
8524 Uint32 tcOprec = signal->theData[5];
8525 if (ERROR_INSERTED(5006)) {
8526 systemErrorLab(signal, __LINE__);
8528 if (ERROR_INSERTED(5016)) {
8529 CLEAR_ERROR_INSERT_VALUE;
8530 sendSignalWithDelay(cownref, GSN_ABORTREQ, signal, 2000, 6);
8533 if (findTransaction(transid1,
8535 tcOprec, 0) != ZOK) {
8536 signal->theData[0] = reqPtr;
8537 signal->theData[2] = cownNodeid;
8538 signal->theData[3] = transid1;
8539 signal->theData[4] = transid2;
8540 sendSignal(reqBlockref, GSN_ABORTCONF, signal, 5, JBB);
8541 warningReport(signal, 9);
8544 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8545 if (regTcPtr->transactionState != TcConnectionrec::PREPARED) {
8546 warningReport(signal, 10);
8549 regTcPtr->reqBlockref = reqBlockref;
8550 regTcPtr->reqRef = reqPtr;
8551 regTcPtr->abortState = TcConnectionrec::REQ_FROM_TC;
8553 abortCommonLab(signal);
8560 void Dblqh::execACC_TO_REF(
Signal* signal)
8563 terrorCode = signal->theData[1];
8564 abortErrorLab(signal);
8571 void Dblqh::execACCKEYREF(
Signal* signal)
8574 tcConnectptr.i = signal->theData[0];
8575 terrorCode = signal->theData[1];
8576 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
8577 TcConnectionrec *
const tcPtr = tcConnectptr.p;
8578 switch (tcPtr->transactionState) {
8579 case TcConnectionrec::WAIT_ACC:
8582 case TcConnectionrec::WAIT_ACC_ABORT:
8583 case TcConnectionrec::ABORT_STOPPED:
8584 case TcConnectionrec::ABORT_QUEUED:
8595 const Uint32 errCode = terrorCode;
8596 tcPtr->errorCode = errCode;
8600 TRACENR(
"ACCKEYREF: " << errCode <<
" ");
8601 switch (tcPtr->operation) {
8602 case ZREAD: TRACENR(
"READ");
break;
8603 case ZUPDATE: TRACENR(
"UPDATE");
break;
8604 case ZWRITE: TRACENR(
"WRITE");
break;
8605 case ZINSERT: TRACENR(
"INSERT");
break;
8606 case ZDELETE: TRACENR(
"DELETE");
break;
8607 case ZUNLOCK: TRACENR(
"UNLOCK");
break;
8608 default: TRACENR(
"<Unknown: " << tcPtr->operation <<
">");
break;
8611 TRACENR(
" tab: " << tcPtr->tableref
8612 <<
" frag: " << tcPtr->fragmentid
8613 <<
" activeCreat: " << (Uint32)tcPtr->activeCreat);
8614 if (LqhKeyReq::getNrCopyFlag(tcPtr->reqinfo))
8616 if (LqhKeyReq::getRowidFlag(tcPtr->reqinfo))
8617 TRACENR(
" rowid: " << tcPtr->m_row_id);
8618 TRACENR(
" key: " << getKeyInfoWordOrZero(tcPtr, 0));
8623 ndbrequire(tcPtr->activeCreat == Fragrecord::AC_NORMAL);
8624 ndbrequire(!LqhKeyReq::getNrCopyFlag(tcPtr->reqinfo));
8643 tcPtr->abortState = TcConnectionrec::ABORT_FROM_LQH;
8644 abortCommonLab(signal);
8648 void Dblqh::localAbortStateHandlerLab(
Signal* signal)
8650 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8651 if (regTcPtr->abortState != TcConnectionrec::ABORT_IDLE) {
8655 regTcPtr->abortState = TcConnectionrec::ABORT_FROM_LQH;
8656 regTcPtr->errorCode = terrorCode;
8657 abortStateHandlerLab(signal);
8661 void Dblqh::abortStateHandlerLab(
Signal* signal)
8663 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8664 switch (regTcPtr->transactionState) {
8665 case TcConnectionrec::PREPARED:
8673 if (regTcPtr->abortState == TcConnectionrec::NEW_FROM_TC) {
8675 sendLqhTransconf(signal, LqhTransConf::Prepared);
8679 case TcConnectionrec::LOG_COMMIT_WRITTEN_WAIT_SIGNAL:
8680 case TcConnectionrec::LOG_COMMIT_QUEUED_WAIT_SIGNAL:
8687 ndbrequire(regTcPtr->abortState == TcConnectionrec::NEW_FROM_TC);
8688 sendLqhTransconf(signal, LqhTransConf::Prepared);
8690 case TcConnectionrec::WAIT_TUPKEYINFO:
8691 case TcConnectionrec::WAIT_ATTR:
8699 case TcConnectionrec::WAIT_TUP:
8706 regTcPtr->transactionState = TcConnectionrec::WAIT_TUP_TO_ABORT;
8708 case TcConnectionrec::WAIT_ACC:
8710 abortContinueAfterBlockedLab(signal);
8713 case TcConnectionrec::LOG_QUEUED:
8723 case TcConnectionrec::STOPPED:
8731 releaseWaitQueue(signal);
8732 continueAfterLogAbortWriteLab(signal);
8735 case TcConnectionrec::WAIT_AI_AFTER_ABORT:
8741 continueAbortLab(signal);
8744 case TcConnectionrec::WAIT_TUP_TO_ABORT:
8745 case TcConnectionrec::ABORT_STOPPED:
8746 case TcConnectionrec::LOG_ABORT_QUEUED:
8747 case TcConnectionrec::WAIT_ACC_ABORT:
8748 case TcConnectionrec::ABORT_QUEUED:
8757 case TcConnectionrec::WAIT_TUP_COMMIT:
8758 case TcConnectionrec::COMMIT_STOPPED:
8759 case TcConnectionrec::LOG_COMMIT_QUEUED:
8760 case TcConnectionrec::COMMIT_QUEUED:
8766 if (regTcPtr->dirtyOp == ZTRUE) {
8774 if (regTcPtr->opSimple) {
8783 ndbrequire(regTcPtr->abortState == TcConnectionrec::NEW_FROM_TC);
8789 sendLqhTransconf(signal, LqhTransConf::Committed);
8792 case TcConnectionrec::COMMITTED:
8794 ndbrequire(regTcPtr->abortState == TcConnectionrec::NEW_FROM_TC);
8799 sendLqhTransconf(signal, LqhTransConf::Committed);
8810 abortCommonLab(signal);
8814 void Dblqh::abortErrorLab(
Signal* signal)
8816 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
8817 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8818 if (regTcPtr->abortState == TcConnectionrec::ABORT_IDLE) {
8820 regTcPtr->abortState = TcConnectionrec::ABORT_FROM_LQH;
8821 regTcPtr->errorCode = terrorCode;
8823 abortCommonLab(signal);
8827 void Dblqh::abortCommonLab(
Signal* signal)
8829 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8830 const Uint32 activeCreat = regTcPtr->activeCreat;
8832 remove_commit_marker(regTcPtr);
8834 if (unlikely(activeCreat == Fragrecord::AC_NR_COPY))
8837 if (regTcPtr->m_nr_delete.m_cnt)
8848 TablerecPtr tablePtr;
8849 tablePtr.i = regTcPtr->tableref;
8850 ptrCheckGuard(tablePtr, ctabrecFileSize, tablerec);
8851 ndbrequire(tablePtr.p->m_disk_table);
8857 fragptr.i = regTcPtr->fragmentptr;
8858 if (fragptr.i != RNIL) {
8860 c_fragment_pool.
getPtr(fragptr);
8866 abortContinueAfterBlockedLab(signal);
8871 linkFragQueue(signal);
8872 regTcPtr->transactionState = TcConnectionrec::ABORT_STOPPED;
8887 continueAbortLab(signal);
8891 void Dblqh::abortContinueAfterBlockedLab(
Signal* signal)
8903 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8905 TRACE_OP(regTcPtr,
"ACC ABORT");
8906 Uint32 canBlock = 2;
8907 switch(regTcPtr->transactionState){
8908 case TcConnectionrec::WAIT_TUP:
8921 regTcPtr->transactionState = TcConnectionrec::WAIT_ACC_ABORT;
8922 signal->theData[0] = regTcPtr->accConnectrec;
8923 signal->theData[1] = canBlock;
8926 if (signal->theData[1] == RNIL)
8939 execACC_ABORTCONF(signal);
8946 void Dblqh::execACC_ABORTCONF(
Signal* signal)
8949 tcConnectptr.i = signal->theData[0];
8950 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
8951 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8952 ndbrequire(regTcPtr->transactionState == TcConnectionrec::WAIT_ACC_ABORT);
8954 TRACE_OP(regTcPtr,
"ACC_ABORTCONF");
8955 signal->theData[0] = regTcPtr->tupConnectrec;
8959 continueAbortLab(signal);
8963 void Dblqh::continueAbortLab(
Signal* signal)
8965 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
8974 if (regTcPtr->logWriteState == TcConnectionrec::WRITTEN) {
8980 initLogPointers(signal);
8981 if (cnoOfLogPages == 0 ||
8992 regTcPtr->transactionState = TcConnectionrec::LOG_ABORT_QUEUED;
8995 writeAbortLog(signal);
8996 removeLogTcrec(signal);
8997 }
else if (regTcPtr->logWriteState == TcConnectionrec::NOT_STARTED) {
8999 }
else if (regTcPtr->logWriteState == TcConnectionrec::NOT_WRITTEN) {
9008 regTcPtr->logWriteState = TcConnectionrec::NOT_STARTED;
9010 ndbrequire(regTcPtr->logWriteState == TcConnectionrec::NOT_WRITTEN_WAIT);
9019 checkScanTcCompleted(signal);
9021 continueAfterLogAbortWriteLab(signal);
9025 void Dblqh::continueAfterLogAbortWriteLab(
Signal* signal)
9027 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
9029 remove_commit_marker(regTcPtr);
9031 if (regTcPtr->operation == ZREAD && regTcPtr->dirtyOp &&
9032 !LqhKeyReq::getNormalProtocolFlag(regTcPtr->reqinfo))
9037 tcKeyRef->connectPtr = regTcPtr->applOprec;
9038 tcKeyRef->transId[0] = regTcPtr->transid[0];
9039 tcKeyRef->transId[1] = regTcPtr->transid[1];
9040 tcKeyRef->errorCode = regTcPtr->errorCode;
9041 sendTCKEYREF(signal, regTcPtr->applRef, regTcPtr->tcBlockref, 0);
9045 if (regTcPtr->abortState == TcConnectionrec::ABORT_FROM_LQH) {
9049 lqhKeyRef->userRef = regTcPtr->clientConnectrec;
9050 lqhKeyRef->connectPtr = regTcPtr->tcOprec;
9051 lqhKeyRef->errorCode = regTcPtr->errorCode;
9052 lqhKeyRef->transId1 = regTcPtr->transid[0];
9053 lqhKeyRef->transId2 = regTcPtr->transid[1];
9054 sendSignal(regTcPtr->clientBlockref, GSN_LQHKEYREF, signal,
9055 LqhKeyRef::SignalLength, JBB);
9056 }
else if (regTcPtr->abortState == TcConnectionrec::ABORT_FROM_TC) {
9058 sendAborted(signal);
9059 }
else if (regTcPtr->abortState == TcConnectionrec::NEW_FROM_TC) {
9061 sendLqhTransconf(signal, LqhTransConf::Aborted);
9063 ndbrequire(regTcPtr->abortState == TcConnectionrec::REQ_FROM_TC);
9065 signal->theData[0] = regTcPtr->reqRef;
9066 signal->theData[1] = tcConnectptr.i;
9067 signal->theData[2] = cownNodeid;
9068 signal->theData[3] = regTcPtr->transid[0];
9069 signal->theData[4] = regTcPtr->transid[1];
9070 sendSignal(regTcPtr->reqBlockref, GSN_ABORTCONF,
9077 Dblqh::sendTCKEYREF(
Signal* signal, Uint32 ref, Uint32 routeRef, Uint32 cnt)
9079 const Uint32 nodeId = refToNode(ref);
9082 if (likely(connectedToNode))
9085 sendSignal(ref, GSN_TCKEYREF, signal, TcKeyRef::SignalLength, JBB);
9090 getNodeInfo(refToNode(routeRef)).m_version >= MAKE_VERSION(5,1,14))
9093 memmove(signal->theData+25, signal->theData, 4*TcKeyRef::SignalLength);
9096 ord->srcRef = reference();
9097 ord->gsn = GSN_TCKEYREF;
9100 ptr[0].p = signal->theData+25;
9101 ptr[0].sz = TcKeyRef::SignalLength;
9102 sendSignal(routeRef, GSN_ROUTE_ORD, signal, RouteOrd::SignalLength, JBB,
9108 memmove(signal->theData + 3, signal->theData, 4*TcKeyRef::SignalLength);
9109 signal->theData[0] = ZRETRY_TCKEYREF;
9110 signal->theData[1] = cnt + 1;
9111 signal->theData[2] = ref;
9112 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100,
9113 TcKeyRef::SignalLength + 3);
9128 void Dblqh::execNODE_FAILREP(
Signal* signal)
9130 UintR TfoundNodes = 0;
9132 UintR Tdata[MAX_NDB_NODES];
9137 TnoOfNodes = nodeFail->noOfNodes;
9139 for (i = 1; i < MAX_NDB_NODES; i++) {
9153 ptrAss(lcpPtr, lcpRecord);
9155 ndbrequire(
index == TnoOfNodes);
9156 ndbrequire(cnoOfNodes - 1 < MAX_NDB_NODES);
9157 for (i = 0; i < TnoOfNodes; i++) {
9158 const Uint32 nodeId = Tdata[
i];
9161 HostRecordPtr Thostptr;
9162 Thostptr.i = nodeId;
9163 ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
9164 Thostptr.p->nodestatus = ZNODE_DOWN;
9167 lcpPtr.p->m_EMPTY_LCP_REQ.
clear(nodeId);
9169 for (Uint32 j = 0; j < cnoOfNodes; j++) {
9171 if (cnodeData[j] == nodeId){
9173 cnodeStatus[j] = ZNODE_DOWN;
9180 Callback cb = { safe_cast(&Dblqh::ndbdFailBlockCleanupCallback),
9184 ndbrequire(TnoOfNodes == TfoundNodes);
9189 Dblqh::ndbdFailBlockCleanupCallback(
Signal* signal,
9190 Uint32 failedNodeId,
9197 nfCompRep->
nodeId = cownNodeid;
9199 BlockReference dihRef = !isNdbMtLqh() ? DBDIH_REF : DBLQH_REF;
9200 sendSignal(dihRef, GSN_NF_COMPLETEREP, signal,
9201 NFCompleteRep::SignalLength, JBB);
9214 void Dblqh::execLQH_TRANSREQ(
Signal* signal)
9223 Uint32 newTcPtr = signal->theData[0];
9224 BlockReference newTcBlockref = signal->theData[1];
9225 Uint32 oldNodeId = signal->theData[2];
9226 tcNodeFailptr.i = oldNodeId;
9227 ptrCheckGuard(tcNodeFailptr, ctcNodeFailrecFileSize, tcNodeFailRecord);
9228 if ((tcNodeFailptr.p->tcFailStatus == TcNodeFailRecord::TC_STATE_TRUE) ||
9229 (tcNodeFailptr.p->tcFailStatus == TcNodeFailRecord::TC_STATE_BREAK)) {
9231 tcNodeFailptr.p->lastNewTcBlockref = newTcBlockref;
9243 tcNodeFailptr.p->lastNewTcRef = newTcPtr;
9244 tcNodeFailptr.p->tcFailStatus = TcNodeFailRecord::TC_STATE_BREAK;
9247 tcNodeFailptr.p->oldNodeId = oldNodeId;
9248 tcNodeFailptr.p->newTcBlockref = newTcBlockref;
9249 tcNodeFailptr.p->newTcRef = newTcPtr;
9250 tcNodeFailptr.p->tcRecNow = 0;
9251 tcNodeFailptr.p->tcFailStatus = TcNodeFailRecord::TC_STATE_TRUE;
9252 signal->theData[0] = ZLQH_TRANS_NEXT;
9253 signal->theData[1] = tcNodeFailptr.i;
9254 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
9258 void Dblqh::lqhTransNextLab(
Signal* signal)
9264 if (tcNodeFailptr.p->tcFailStatus == TcNodeFailRecord::TC_STATE_BREAK) {
9271 tcNodeFailptr.p->newTcBlockref = tcNodeFailptr.p->lastNewTcBlockref;
9272 tcNodeFailptr.p->newTcRef = tcNodeFailptr.p->lastNewTcRef;
9273 tcNodeFailptr.p->tcRecNow = 0;
9274 tcNodeFailptr.p->tcFailStatus = TcNodeFailRecord::TC_STATE_TRUE;
9276 tstart = tcNodeFailptr.p->tcRecNow;
9277 tend = tstart + 200;
9279 for (tcConnectptr.i = tstart; tcConnectptr.i <= guard0; tcConnectptr.i++) {
9281 if (tcConnectptr.i >= ctcConnectrecFileSize) {
9289 if (ERROR_INSERTED(5061))
9291 CLEAR_ERROR_INSERT_VALUE;
9292 for (Uint32 i = 0; i < cnoOfNodes; i++)
9294 Uint32 node = cnodeData[
i];
9295 if (node != getOwnNodeId() && cnodeStatus[i] == ZNODE_UP)
9297 ndbout_c(
"clearing ERROR_INSERT in LQH:%u", node);
9298 signal->theData[0] = 0;
9299 sendSignal(numberToRef(DBLQH, node), GSN_NDB_TAMPER,
9304 signal->theData[0] = ZSCAN_MARKERS;
9305 signal->theData[1] = tcNodeFailptr.i;
9306 signal->theData[2] = 0;
9307 signal->theData[3] = RNIL;
9308 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 5000, 4);
9312 if (ERROR_INSERTED(5050))
9314 ndbout_c(
"send ZSCAN_MARKERS with 5s delay and killing master");
9315 CLEAR_ERROR_INSERT_VALUE;
9316 signal->theData[0] = ZSCAN_MARKERS;
9317 signal->theData[1] = tcNodeFailptr.i;
9318 signal->theData[2] = 0;
9319 signal->theData[3] = RNIL;
9320 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 5000, 4);
9322 signal->theData[0] = 9999;
9323 sendSignal(numberToRef(CMVMI, c_master_node_id),
9324 GSN_NDB_TAMPER, signal, 1, JBB);
9331 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
9332 if (tcConnectptr.p->transactionState != TcConnectionrec::IDLE) {
9333 if (tcConnectptr.p->transactionState != TcConnectionrec::TC_NOT_CONNECTED) {
9334 if (tcConnectptr.p->tcScanRec == RNIL) {
9335 if (refToNode(tcConnectptr.p->tcBlockref) == tcNodeFailptr.p->oldNodeId) {
9336 switch( tcConnectptr.p->operation ) {
9342 if (tcConnectptr.p->opSimple == ZTRUE) {
9349 tcConnectptr.p->tcNodeFailrec = tcNodeFailptr.i;
9350 tcConnectptr.p->abortState = TcConnectionrec::NEW_FROM_TC;
9351 abortStateHandlerLab(signal);
9356 scanptr.i = tcConnectptr.p->tcScanRec;
9357 c_scanRecordPool.
getPtr(scanptr);
9358 switch(scanptr.p->scanType){
9359 case ScanRecord::COPY:
9362 if (scanptr.p->scanNodeId == tcNodeFailptr.p->oldNodeId) {
9368 if (0) ndbout_c(
"close copy");
9369 tcConnectptr.p->tcNodeFailrec = tcNodeFailptr.i;
9370 tcConnectptr.p->abortState = TcConnectionrec::NEW_FROM_TC;
9371 closeCopyRequestLab(signal);
9376 case ScanRecord::SCAN:
9379 if (refToNode(tcConnectptr.p->tcBlockref) ==
9380 tcNodeFailptr.p->oldNodeId) {
9382 tcConnectptr.p->tcNodeFailrec = tcNodeFailptr.i;
9383 tcConnectptr.p->abortState = TcConnectionrec::NEW_FROM_TC;
9384 closeScanRequestLab(signal);
9390 ndbout_c(
"scanptr.p->scanType: %u", scanptr.p->scanType);
9391 ndbout_c(
"tcConnectptr.p->transactionState: %u",
9392 tcConnectptr.p->transactionState);
9399 #if defined VM_TRACE || defined ERROR_INSERT
9401 ndbrequire(tcConnectptr.p->tcScanRec == RNIL);
9407 #if defined VM_TRACE || defined ERROR_INSERT
9409 ndbrequire(tcConnectptr.p->tcScanRec == RNIL);
9413 tcNodeFailptr.p->tcRecNow = tend + 1;
9414 signal->theData[0] = ZLQH_TRANS_NEXT;
9415 signal->theData[1] = tcNodeFailptr.i;
9416 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
9429 tcNodeFailPtr.i = tcNodeFail;
9430 ptrCheckGuard(tcNodeFailPtr, ctcNodeFailrecFileSize, tcNodeFailRecord);
9431 const Uint32 crashedTcNodeId = tcNodeFailPtr.p->oldNodeId;
9433 if (tcNodeFailPtr.p->tcFailStatus == TcNodeFailRecord::TC_STATE_BREAK)
9442 tcNodeFailptr = tcNodeFailPtr;
9443 lqhTransNextLab(signal);
9447 CommitAckMarkerIterator iter;
9449 m_commitAckMarkerHash.
next(startBucket, iter);
9453 iter.bucket = startBucket;
9454 m_commitAckMarkerHash.
getPtr(iter.curr);
9455 m_commitAckMarkerHash.
next(iter);
9458 const Uint32 RT_BREAK = 256;
9459 for(i = 0; i<RT_BREAK || iter.bucket == startBucket; i++){
9462 if(iter.curr.i == RNIL){
9468 tcNodeFailPtr.p->tcFailStatus = TcNodeFailRecord::TC_STATE_FALSE;
9469 signal->theData[0] = tcNodeFailPtr.p->newTcRef;
9470 signal->theData[1] = cownNodeid;
9471 signal->theData[2] = LqhTransConf::LastTransConf;
9472 sendSignal(tcNodeFailPtr.p->newTcBlockref, GSN_LQH_TRANSCONF,
9477 if(iter.curr.p->tcNodeId == crashedTcNodeId){
9484 lqhTransConf->tcRef = tcNodeFailPtr.p->newTcRef;
9485 lqhTransConf->lqhNodeId = cownNodeid;
9486 lqhTransConf->operationStatus = LqhTransConf::Marker;
9487 lqhTransConf->transId1 = iter.curr.p->transid1;
9488 lqhTransConf->transId2 = iter.curr.p->transid2;
9489 lqhTransConf->apiRef = iter.curr.p->apiRef;
9490 lqhTransConf->apiOpRec = iter.curr.p->apiOprec;
9491 sendSignal(tcNodeFailPtr.p->newTcBlockref, GSN_LQH_TRANSCONF,
9494 signal->theData[0] = ZSCAN_MARKERS;
9495 signal->theData[1] = tcNodeFailPtr.i;
9496 signal->theData[2] = iter.bucket;
9497 signal->theData[3] = iter.curr.i;
9498 sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB);
9502 m_commitAckMarkerHash.
next(iter);
9505 signal->theData[0] = ZSCAN_MARKERS;
9506 signal->theData[1] = tcNodeFailPtr.i;
9507 signal->theData[2] = iter.bucket;
9508 signal->theData[3] = RNIL;
9509 sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB);
9525 void Dblqh::execACC_SCANCONF(
Signal* signal)
9529 scanptr.i = accScanConf->scanPtr;
9530 c_scanRecordPool.
getPtr(scanptr);
9531 if (scanptr.p->scanState == ScanRecord::WAIT_ACC_SCAN) {
9532 accScanConfScanLab(signal);
9534 ndbrequire(scanptr.p->scanState == ScanRecord::WAIT_ACC_COPY);
9535 accScanConfCopyLab(signal);
9542 void Dblqh::execACC_SCANREF(
Signal* signal)
9545 ndbrequire(refToMain(signal->getSendersBlockRef()) == DBTUX);
9548 ndbrequire(ref->errorCode != 0);
9550 scanptr.i = ref->scanPtr;
9551 c_scanRecordPool.
getPtr(scanptr);
9552 tcConnectptr.i = scanptr.p->scanTcrec;
9553 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
9554 tcConnectptr.p->errorCode = ref->errorCode;
9561 if (scanptr.p->scanStoredProcId != RNIL) {
9563 scanptr.p->scanCompletedStatus = ZTRUE;
9564 accScanCloseConfLab(signal);
9567 tupScanCloseConfLab(signal);
9573 void Dblqh::execNEXT_SCANCONF(
Signal* signal)
9577 scanptr.i = nextScanConf->scanPtr;
9578 c_scanRecordPool.
getPtr(scanptr);
9579 scanptr.p->m_row_id.m_page_no = nextScanConf->localKey[0];
9580 scanptr.p->m_row_id.m_page_idx = nextScanConf->localKey[1];
9583 if (signal->getLength() > 2 && nextScanConf->accOperationPtr != RNIL)
9586 regTcPtr.i = scanptr.p->scanTcrec;
9587 ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
9588 ndbassert(regTcPtr.p->fragmentid == nextScanConf->fragId);
9593 c_fragment_pool.
getPtr(fragptr);
9594 switch (scanptr.p->scanState) {
9595 case ScanRecord::WAIT_CLOSE_SCAN:
9597 accScanCloseConfLab(signal);
9599 case ScanRecord::WAIT_CLOSE_COPY:
9601 accCopyCloseConfLab(signal);
9603 case ScanRecord::WAIT_NEXT_SCAN:
9605 nextScanConfScanLab(signal);
9607 case ScanRecord::WAIT_NEXT_SCAN_COPY:
9609 nextScanConfCopyLab(signal);
9611 case ScanRecord::WAIT_RELEASE_LOCK:
9613 ndbrequire(signal->
length() == 1);
9614 scanLockReleasedLab(signal);
9617 ndbout_c(
"%d", scanptr.p->scanState);
9625 void Dblqh::execNEXT_SCANREF(
Signal* signal)
9628 ndbrequire(refToMain(signal->getSendersBlockRef()) == DBTUX);
9631 ndbrequire(ref->errorCode != 0);
9633 scanptr.i = ref->scanPtr;
9634 c_scanRecordPool.
getPtr(scanptr);
9635 tcConnectptr.i = scanptr.p->scanTcrec;
9636 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
9637 tcConnectptr.p->errorCode = ref->errorCode;
9643 scanptr.p->scanCompletedStatus = ZTRUE;
9644 accScanCloseConfLab(signal);
9650 void Dblqh::execSTORED_PROCCONF(
Signal* signal)
9653 tcConnectptr.i = signal->theData[0];
9654 Uint32 storedProcId = signal->theData[1];
9655 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
9656 scanptr.i = tcConnectptr.p->tcScanRec;
9657 c_scanRecordPool.
getPtr(scanptr);
9658 switch (scanptr.p->scanState) {
9659 case ScanRecord::WAIT_STORED_PROC_SCAN:
9661 scanptr.p->scanStoredProcId = storedProcId;
9662 storedProcConfScanLab(signal);
9664 case ScanRecord::WAIT_DELETE_STORED_PROC_ID_SCAN:
9666 tupScanCloseConfLab(signal);
9668 case ScanRecord::WAIT_STORED_PROC_COPY:
9670 scanptr.p->scanStoredProcId = storedProcId;
9671 storedProcConfCopyLab(signal);
9673 case ScanRecord::WAIT_DELETE_STORED_PROC_ID_COPY:
9675 tupCopyCloseConfLab(signal);
9685 void Dblqh::execSTORED_PROCREF(
Signal* signal)
9688 tcConnectptr.i = signal->theData[0];
9689 Uint32 errorCode = signal->theData[1];
9690 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
9691 scanptr.i = tcConnectptr.p->tcScanRec;
9692 c_scanRecordPool.
getPtr(scanptr);
9693 switch (scanptr.p->scanState) {
9694 case ScanRecord::WAIT_STORED_PROC_SCAN:
9696 scanptr.p->scanCompletedStatus = ZTRUE;
9697 scanptr.p->scanStoredProcId = signal->theData[2];
9698 tcConnectptr.p->errorCode = errorCode;
9699 closeScanLab(signal);
9720 void Dblqh::execSCAN_NEXTREQ(
Signal* signal)
9725 const Uint32 transid1 = nextReq->transId1;
9726 const Uint32 transid2 = nextReq->transId2;
9727 const Uint32 senderData = nextReq->senderData;
9728 Uint32 hashHi = signal->getSendersBlockRef();
9730 if (findTransaction(transid1, transid2, senderData, hashHi) != ZOK){
9733 " Received SCAN_NEXTREQ in LQH with close flag when closed");
9734 ndbrequire(nextReq->requestInfo == ScanFragNextReq::ZCLOSE);
9739 CRASH_INSERTION2(5021, refToNode(signal->senderBlockRef()) == cownNodeid);
9741 CRASH_INSERTION2(5022, refToNode(signal->senderBlockRef()) != cownNodeid);
9743 if (ERROR_INSERTED(5023)){
9745 if (refToNode(signal->senderBlockRef()) == cownNodeid) {
9746 CLEAR_ERROR_INSERT_VALUE;
9750 if (ERROR_INSERTED(5024)){
9752 if (refToNode(signal->senderBlockRef()) != cownNodeid) {
9753 CLEAR_ERROR_INSERT_VALUE;
9757 if (ERROR_INSERTED(5025))
9764 CLEAR_ERROR_INSERT_VALUE;
9767 if (ERROR_INSERTED(5030)){
9768 ndbout <<
"ERROR 5030" << endl;
9769 CLEAR_ERROR_INSERT_VALUE;
9774 if(ERROR_INSERTED(5036)){
9779 if (ScanFragNextReq::getCorrFactorFlag(nextReq->requestInfo))
9782 Uint32 corrFactorLo = nextReq->variableData[pos++];
9783 tcConnectptr.p->m_corrFactorLo &= 0xFFFF0000;
9784 tcConnectptr.p->m_corrFactorLo |= corrFactorLo;
9787 scanptr.i = tcConnectptr.p->tcScanRec;
9788 ndbrequire(scanptr.i != RNIL);
9789 c_scanRecordPool.
getPtr(scanptr);
9790 scanptr.p->scanTcWaiting = cLqhTimeOutCount;
9798 if (nextReq->requestInfo == ScanFragNextReq::ZCLOSE)
9801 if(ERROR_INSERTED(5034)){
9802 CLEAR_ERROR_INSERT_VALUE;
9804 if(ERROR_INSERTED(5036)){
9805 CLEAR_ERROR_INSERT_VALUE;
9808 closeScanRequestLab(signal);
9812 fragptr.i = tcConnectptr.p->fragmentptr;
9813 c_fragment_pool.
getPtr(fragptr);
9819 const Uint32 max_rows = nextReq->batch_size_rows;
9820 const Uint32 max_bytes = nextReq->batch_size_bytes;
9821 scanptr.p->m_max_batch_size_bytes = max_bytes;
9823 if (max_rows > scanptr.p->m_max_batch_size_rows)
9829 if (!seize_acc_ptr_list(scanptr.p,
9830 scanptr.p->m_max_batch_size_rows, max_rows))
9833 tcConnectptr.p->errorCode = ScanFragRef::ZTOO_MANY_ACTIVE_SCAN_ERROR;
9834 closeScanRequestLab(signal);
9837 cbookedAccOps += (max_rows - scanptr.p->m_max_batch_size_rows);
9838 scanptr.p->m_max_batch_size_rows = max_rows;
9840 else if (unlikely(max_rows < scanptr.p->m_max_batch_size_rows))
9843 cbookedAccOps -= (scanptr.p->m_max_batch_size_rows - max_rows);
9844 scanptr.p->m_max_batch_size_rows = max_rows;
9855 if ((scanptr.p->scanLockHold == ZTRUE) &&
9856 (scanptr.p->m_curr_batch_size_rows > 0)) {
9858 scanptr.p->scanReleaseCounter = 1;
9859 scanReleaseLocksLab(signal);
9868 continueScanNextReqLab(signal);
9871 void Dblqh::continueScanNextReqLab(
Signal* signal)
9873 if (scanptr.p->scanCompletedStatus == ZTRUE) {
9875 closeScanLab(signal);
9879 if(scanptr.p->m_last_row){
9881 scanptr.p->scanCompletedStatus = ZTRUE;
9882 scanptr.p->scanState = ScanRecord::WAIT_SCAN_NEXTREQ;
9883 sendScanFragConf(signal, ZFALSE);
9888 tcConnectptr.p->tcTimer = cLqhTimeOutCount;
9889 init_acc_ptr_list(scanptr.p);
9890 scanptr.p->scanFlag = NextScanReq::ZSCAN_NEXT;
9891 scanNextLoopLab(signal);
9897 void Dblqh::scanReleaseLocksLab(
Signal* signal)
9905 linkFragQueue(signal);
9906 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_RELEASE_STOPPED;
9922 continueScanReleaseAfterBlockedLab(signal);
9925 void Dblqh::continueScanReleaseAfterBlockedLab(
Signal* signal)
9927 scanptr.i = tcConnectptr.p->tcScanRec;
9928 c_scanRecordPool.
getPtr(scanptr);
9929 scanptr.p->scanState = ScanRecord::WAIT_RELEASE_LOCK;
9930 signal->theData[0] = scanptr.p->scanAccPtr;
9932 get_acc_ptr_from_scan_record(scanptr.p,
9933 scanptr.p->scanReleaseCounter -1,
9935 signal->theData[2] = NextScanReq::ZSCAN_COMMIT;
9936 sendSignal(scanptr.p->scanBlockref, GSN_NEXT_SCANREQ, signal, 3, JBB);
9953 void Dblqh::closeScanRequestLab(
Signal* signal)
9955 DEBUG(
"transactionState = " << tcConnectptr.p->transactionState);
9956 switch (tcConnectptr.p->transactionState) {
9957 case TcConnectionrec::SCAN_STATE_USED:
9958 DEBUG(
"scanState = " << scanptr.p->scanState);
9959 switch (scanptr.p->scanState) {
9960 case ScanRecord::IN_QUEUE:
9962 tupScanCloseConfLab(signal);
9964 case ScanRecord::WAIT_NEXT_SCAN:
9969 scanptr.p->scanCompletedStatus = ZTRUE;
9971 case ScanRecord::WAIT_ACC_SCAN:
9972 case ScanRecord::WAIT_STORED_PROC_SCAN:
9978 scanptr.p->scanCompletedStatus = ZTRUE;
9980 case ScanRecord::WAIT_CLOSE_SCAN:
9982 scanptr.p->scanCompletedStatus = ZTRUE;
9983 case ScanRecord::WAIT_DELETE_STORED_PROC_ID_SCAN:
9990 case ScanRecord::WAIT_RELEASE_LOCK:
9996 scanptr.p->scanCompletedStatus = ZTRUE;
9998 case ScanRecord::WAIT_SCAN_NEXTREQ:
10004 scanptr.p->scanCompletedStatus = ZTRUE;
10006 fragptr.i = tcConnectptr.p->fragmentptr;
10007 c_fragment_pool.
getPtr(fragptr);
10009 if (scanptr.p->scanLockHold == ZTRUE) {
10010 if (scanptr.p->m_curr_batch_size_rows > 0) {
10012 scanptr.p->scanReleaseCounter = 1;
10013 scanReleaseLocksLab(signal);
10017 closeScanLab(signal);
10023 case TcConnectionrec::WAIT_SCAN_AI:
10029 tupScanCloseConfLab(signal);
10032 case TcConnectionrec::SCAN_TUPKEY:
10033 case TcConnectionrec::SCAN_FIRST_STOPPED:
10034 case TcConnectionrec::SCAN_CHECK_STOPPED:
10035 case TcConnectionrec::SCAN_STOPPED:
10040 scanptr.p->scanCompletedStatus = ZTRUE;
10042 case TcConnectionrec::SCAN_RELEASE_STOPPED:
10048 scanptr.p->scanCompletedStatus = ZTRUE;
10050 case TcConnectionrec::SCAN_CLOSE_STOPPED:
10067 void Dblqh::scanLockReleasedLab(
Signal* signal)
10069 tcConnectptr.i = scanptr.p->scanTcrec;
10070 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
10072 check_send_scan_hb_rep(signal, scanptr.p, tcConnectptr.p);
10074 if (scanptr.p->scanReleaseCounter == scanptr.p->m_curr_batch_size_rows) {
10075 if ((scanptr.p->scanErrorCounter > 0) ||
10076 (scanptr.p->scanCompletedStatus == ZTRUE)) {
10078 scanptr.p->m_curr_batch_size_rows = 0;
10079 scanptr.p->m_curr_batch_size_bytes = 0;
10080 closeScanLab(signal);
10081 }
else if (scanptr.p->m_last_row && !scanptr.p->scanLockHold) {
10083 closeScanLab(signal);
10085 }
else if (scanptr.p->check_scan_batch_completed() &&
10086 scanptr.p->scanLockHold != ZTRUE) {
10088 scanptr.p->scanState = ScanRecord::WAIT_SCAN_NEXTREQ;
10089 sendScanFragConf(signal, ZFALSE);
10097 scanptr.p->m_curr_batch_size_rows = 0;
10098 scanptr.p->m_curr_batch_size_bytes = 0;
10099 continueScanNextReqLab(signal);
10101 }
else if (scanptr.p->scanReleaseCounter < scanptr.p->m_curr_batch_size_rows) {
10103 scanptr.p->scanReleaseCounter++;
10104 scanReleaseLocksLab(signal);
10106 else if (scanptr.p->scanCompletedStatus != ZTRUE)
10115 scanptr.p->scanState = ScanRecord::WAIT_SCAN_NEXTREQ;
10116 sendScanFragConf(signal, ZFALSE);
10121 closeScanLab(signal);
10126 Dblqh::seize_acc_ptr_list(ScanRecord* scanP,
10127 Uint32 curr_batch_size,
10128 Uint32 new_batch_size)
10133 Uint32 segments= (new_batch_size + (SectionSegment::DataLength -2 )) /
10134 SectionSegment::DataLength;
10136 if (segments <= scanP->scan_acc_segments)
10142 if (new_batch_size > 1)
10144 for (Uint32 i = 1 + scanP->scan_acc_segments; i <= segments; i++)
10146 Uint32 seg= seizeSegment();
10147 if (unlikely(seg == RNIL))
10151 scanP->scan_acc_segments= (i-1);
10152 release_acc_ptr_list(scanP);
10155 scanP->scan_acc_op_ptr[
i]= seg;
10158 scanP->scan_acc_segments= segments;
10163 Dblqh::release_acc_ptr_list(ScanRecord* scanP)
10165 Uint32
i, segments;
10166 segments= scanP->scan_acc_segments;
10168 for (i= 1; i <= segments; i++) {
10169 releaseSection(scanP->scan_acc_op_ptr[i]);
10171 scanP->scan_acc_segments= 0;
10172 scanP->scan_acc_index = 0;
10176 Dblqh::seizeSegment()
10182 if (!appendToSection(iVal, &junk, 1))
10189 Dblqh::init_acc_ptr_list(ScanRecord* scanP)
10191 scanP->scan_acc_index = 0;
10195 Dblqh::get_acc_ptr_from_scan_record(ScanRecord* scanP,
10200 if (!((index < MAX_PARALLEL_OP_PER_SCAN) &&
10201 index < scanP->scan_acc_index)) {
10202 ndbrequire(crash_flag);
10205 i_get_acc_ptr(scanP, acc_ptr, index);
10210 Dblqh::set_acc_ptr_in_scan_record(ScanRecord* scanP,
10211 Uint32 index, Uint32 acc)
10214 ndbrequire((index == 0 || scanP->scan_acc_index == index) &&
10215 (index < MAX_PARALLEL_OP_PER_SCAN));
10216 scanP->scan_acc_index= index + 1;
10217 i_get_acc_ptr(scanP, acc_ptr, index);
10224 void Dblqh::execSCAN_FRAGREQ(
Signal* signal)
10236 const Uint32 transid1 = scanFragReq->transId1;
10237 const Uint32 transid2 = scanFragReq->transId2;
10238 Uint32 errorCode= 0;
10241 TcConnectionrecPtr nextHashptr;
10242 Uint32 senderHi = signal->getSendersBlockRef();
10244 const Uint32 reqinfo = scanFragReq->requestInfo;
10250 const Uint32 numSections= signal->getNoOfSections();
10251 bool isLongReq= ( numSections != 0 );
10259 if (likely(isLongReq))
10262 handle.getSection(attrInfoPtr, ScanFragReq::AttrInfoSectionNum);
10263 aiLen= attrInfoPtr.sz;
10265 if (numSections == 2)
10267 handle.getSection(keyInfoPtr, ScanFragReq::KeyInfoSectionNum);
10268 keyLen= keyInfoPtr.sz;
10274 aiLen= ScanFragReq::getAttrLen(reqinfo);
10275 keyLen= (scanFragReq->fragmentNoKeyLen >> 16);
10278 const Uint32 fragId = (scanFragReq->fragmentNoKeyLen & 0xFFFF);
10279 tabptr.i = scanFragReq->tableId;
10280 const Uint32 max_rows = scanFragReq->batch_size_rows;
10281 const Uint32 scanLockMode = ScanFragReq::getLockMode(reqinfo);
10282 const Uint8 keyinfo = ScanFragReq::getKeyinfoFlag(reqinfo);
10283 const Uint8 rangeScan = ScanFragReq::getRangeScanFlag(reqinfo);
10285 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
10286 if (tabptr.p->
tableStatus != Tablerec::TABLE_DEFINED &&
10287 tabptr.p->
tableStatus != Tablerec::TABLE_READ_ONLY)
10289 senderData = scanFragReq->senderData;
10290 goto error_handler_early_1;
10293 if (cfirstfreeTcConrec != RNIL && !ERROR_INSERTED_CLEAR(5055)) {
10295 tcConnectptr.p->clientConnectrec = scanFragReq->senderData;
10296 tcConnectptr.p->clientBlockref = signal->senderBlockRef();
10297 tcConnectptr.p->savePointId = scanFragReq->savePointId;
10303 errorCode = ZNO_TC_CONNECT_ERROR;
10304 senderData = scanFragReq->senderData;
10305 goto error_handler_early;
10310 ndbrequire(scanLockMode == 0 || keyinfo);
10312 ndbrequire(max_rows > 0 && max_rows <= MAX_PARALLEL_OP_PER_SCAN);
10313 if (!getFragmentrec(signal, fragId)) {
10315 goto error_handler;
10319 if (rangeScan != DictTabInfo::isOrderedIndex(fragptr.p->
tableType)) {
10321 goto error_handler;
10325 if ((cbookedAccOps + max_rows) > cmaxAccOps) {
10327 errorCode = ScanFragRef::ZSCAN_BOOK_ACC_OP_ERROR;
10328 goto error_handler;
10331 if (ScanFragReq::getLcpScanFlag(reqinfo))
10334 ndbrequire(m_reserved_scans.
first(scanptr));
10335 m_reserved_scans.
remove(scanptr);
10337 else if (!c_scanRecordPool.
seize(scanptr))
10340 errorCode = ScanFragRef::ZNO_FREE_SCANREC_ERROR;
10341 goto error_handler;
10344 initScanTc(scanFragReq,
10350 tcConnectptr.p->save1 = 0;
10351 tcConnectptr.p->primKeyLen = keyLen;
10352 tcConnectptr.p->applRef = scanFragReq->resultRef;
10353 if (likely(isLongReq))
10355 tcConnectptr.p->attrInfoIVal= attrInfoPtr.i;
10357 tcConnectptr.p->keyInfoIVal= keyInfoPtr.i;
10364 if (ScanFragReq::getCorrFactorFlag(reqinfo))
10369 tcConnectptr.p->m_corrFactorLo = scanFragReq->variableData[0];
10370 tcConnectptr.p->m_corrFactorHi = scanFragReq->variableData[1];
10373 errorCode = initScanrec(scanFragReq, aiLen);
10374 if (errorCode != ZOK) {
10376 goto error_handler2;
10378 cbookedAccOps += max_rows;
10380 hashIndex = (tcConnectptr.p->transid[0] ^ tcConnectptr.p->tcOprec) & 1023;
10381 nextHashptr.i = ctransidHash[hashIndex];
10382 ctransidHash[hashIndex] = tcConnectptr.i;
10383 tcConnectptr.p->prevHashRec = RNIL;
10384 tcConnectptr.p->nextHashRec = nextHashptr.i;
10385 if (nextHashptr.i != RNIL) {
10391 ptrCheckGuard(nextHashptr, ctcConnectrecFileSize, tcConnectionrec);
10392 nextHashptr.p->prevHashRec = tcConnectptr.i;
10394 if ((! isLongReq ) &&
10395 ( scanptr.p->scanAiLength > 0 )) {
10397 tcConnectptr.p->transactionState = TcConnectionrec::WAIT_SCAN_AI;
10400 continueAfterReceivingAllAiLab(signal);
10405 if (scanptr.p->m_reserved == 0)
10408 c_scanRecordPool.
release(scanptr);
10413 m_reserved_scans.
add(scanptr);
10417 tcConnectptr.p->abortState = TcConnectionrec::ABORT_ACTIVE;
10418 ref->senderData = tcConnectptr.p->clientConnectrec;
10419 ref->transId1 = transid1;
10420 ref->transId2 = transid2;
10421 ref->errorCode = errorCode;
10422 sendSignal(tcConnectptr.p->clientBlockref, GSN_SCAN_FRAGREF, signal,
10423 ScanFragRef::SignalLength, JBB);
10424 releaseSections(handle);
10425 tcConnectptr.p->tcScanRec = RNIL;
10426 releaseOprec(signal);
10427 releaseTcrec(signal, tcConnectptr);
10430 error_handler_early_1:
10431 errorCode = get_table_state_error(tabptr);
10433 error_handler_early:
10434 releaseSections(handle);
10436 ref->senderData = senderData;
10437 ref->transId1 = transid1;
10438 ref->transId2 = transid2;
10439 ref->errorCode = errorCode;
10440 sendSignal(signal->senderBlockRef(), GSN_SCAN_FRAGREF, signal,
10441 ScanFragRef::SignalLength, JBB);
10444 void Dblqh::continueAfterReceivingAllAiLab(
Signal* signal)
10446 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_STATE_USED;
10448 if(scanptr.p->scanState == ScanRecord::IN_QUEUE){
10453 scanptr.p->scanState = ScanRecord::WAIT_ACC_SCAN;
10455 req->senderData = scanptr.i;
10456 req->senderRef = cownref;
10457 req->tableId = tcConnectptr.p->tableref;
10458 req->fragmentNo = tcConnectptr.p->fragmentid;
10459 req->requestInfo = 0;
10460 AccScanReq::setLockMode(req->requestInfo, scanptr.p->scanLockMode);
10461 AccScanReq::setReadCommittedFlag(req->requestInfo, scanptr.p->readCommitted);
10462 AccScanReq::setDescendingFlag(req->requestInfo, scanptr.p->descending);
10463 AccScanReq::setStatScanFlag(req->requestInfo, scanptr.p->statScan);
10465 if (refToMain(tcConnectptr.p->clientBlockref) == BACKUP)
10467 if (scanptr.p->lcpScan)
10469 AccScanReq::setNoDiskScanFlag(req->requestInfo, 1);
10470 AccScanReq::setLcpScanFlag(req->requestInfo, 1);
10475 AccScanReq::setNoDiskScanFlag(req->requestInfo,
10476 !tcConnectptr.p->m_disk_table);
10477 AccScanReq::setLcpScanFlag(req->requestInfo, 0);
10482 #if BUG_27776_FIXED
10483 AccScanReq::setNoDiskScanFlag(req->requestInfo,
10484 !tcConnectptr.p->m_disk_table);
10486 AccScanReq::setNoDiskScanFlag(req->requestInfo, 1);
10488 AccScanReq::setLcpScanFlag(req->requestInfo, 0);
10491 req->transId1 = tcConnectptr.p->transid[0];
10492 req->transId2 = tcConnectptr.p->transid[1];
10493 req->savePointId = tcConnectptr.p->savePointId;
10494 sendSignal(scanptr.p->scanBlockref, GSN_ACC_SCANREQ, signal,
10495 AccScanReq::SignalLength, JBB);
10498 void Dblqh::scanAttrinfoLab(
Signal* signal, Uint32* dataPtr, Uint32 length)
10500 scanptr.i = tcConnectptr.p->tcScanRec;
10501 c_scanRecordPool.
getPtr(scanptr);
10502 if (saveAttrInfoInSection(dataPtr, length) == ZOK) {
10503 if (tcConnectptr.p->currTupAiLen < scanptr.p->scanAiLength) {
10507 ndbrequire(tcConnectptr.p->currTupAiLen == scanptr.p->scanAiLength);
10508 continueAfterReceivingAllAiLab(signal);
10512 abort_scan(signal, scanptr.i, ZGET_ATTRINBUF_ERROR);
10515 void Dblqh::abort_scan(
Signal* signal, Uint32 scan_ptr_i, Uint32 errcode){
10517 scanptr.i = scan_ptr_i;
10518 c_scanRecordPool.
getPtr(scanptr);
10520 tcConnectptr.p->errorCode = errcode;
10521 tupScanCloseConfLab(signal);
10531 Dblqh::check_send_scan_hb_rep(
Signal* signal,
10532 ScanRecord* scanPtrP,
10533 TcConnectionrec* tcPtrP)
10535 switch(scanPtrP->scanType){
10536 case ScanRecord::SCAN:
10538 case ScanRecord::COPY:
10541 case ScanRecord::ST_IDLE:
10545 case ScanRecord::ST_IDLE:
10550 Uint64 now = cLqhTimeOutCount;
10551 Uint64 last = scanPtrP->scanTcWaiting;
10552 Uint64 timeout = cTransactionDeadlockDetectionTimeout;
10553 Uint64 limit = (3*timeout) / 4;
10556 now >= ((10 * last +
limit) / 10) || now < last;
10562 scanPtrP->scanTcWaiting = Uint32(now);
10563 if (tcPtrP->tcTimer != 0)
10565 tcPtrP->tcTimer = Uint32(now);
10569 save[0] = signal->theData[0];
10570 save[1] = signal->theData[1];
10571 save[2] = signal->theData[2];
10573 signal->theData[0] = tcPtrP->clientConnectrec;
10574 signal->theData[1] = tcPtrP->transid[0];
10575 signal->theData[2] = tcPtrP->transid[1];
10576 sendSignal(tcPtrP->clientBlockref,
10577 GSN_SCAN_HBREP, signal, 3, JBB);
10579 signal->theData[0] = save[0];
10580 signal->theData[1] = save[1];
10581 signal->theData[2] = save[2];
10585 void Dblqh::accScanConfScanLab(
Signal* signal)
10588 tcConnectptr.i = scanptr.p->scanTcrec;
10589 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
10594 if (accScanConf->flag == AccScanConf::ZEMPTY_FRAGMENT) {
10604 if (scanptr.p->scanStoredProcId != RNIL) {
10606 scanptr.p->scanCompletedStatus = ZTRUE;
10607 accScanCloseConfLab(signal);
10610 tupScanCloseConfLab(signal);
10614 check_send_scan_hb_rep(signal, scanptr.p, tcConnectptr.p);
10616 scanptr.p->scanAccPtr = accScanConf->accPtr;
10617 if (scanptr.p->rangeScan) {
10620 req->errorCode = RNIL;
10621 req->tuxScanPtrI = scanptr.p->scanAccPtr;
10623 Uint32 len = req->boundAiLength = copyNextRange(req->data, tcConnectptr.p);
10625 TuxBoundInfo::SignalLength + len);
10628 if (req->errorCode != 0) {
10635 tcConnectptr.p->errorCode = req->errorCode;
10639 scanptr.p->scanState = ScanRecord::WAIT_STORED_PROC_SCAN;
10640 if(scanptr.p->scanStoredProcId == RNIL)
10646 signal->theData[0] = tcConnectptr.p->tupConnectrec;
10647 signal->theData[1] = tcConnectptr.p->tableref;
10648 signal->theData[2] = scanptr.p->scanSchemaVersion;
10649 signal->theData[3] = ZSTORED_PROC_SCAN;
10651 signal->theData[5] = scanptr.p->scanApiBlockref;
10657 handle.m_ptr[0].i= tcConnectptr.p->attrInfoIVal;
10659 tcConnectptr.p->attrInfoIVal= RNIL;
10660 getSections(handle.m_cnt, handle.m_ptr);
10662 sendSignal(tcConnectptr.p->tcTupBlockref,
10663 GSN_STORED_PROCREQ, signal, 6, JBB,
10670 storedProcConfScanLab(signal);
10675 Dblqh::copyNextRange(Uint32 * dst, TcConnectionrec* tcPtrP)
10686 Uint32 totalLen = tcPtrP->primKeyLen;
10690 ndbassert( tcPtrP->keyInfoIVal != RNIL );
10692 g_sectionSegmentPool);
10694 if (tcPtrP->m_flags & TcConnectionrec::OP_SCANKEYINFOPOSSAVED)
10699 bool ok= keyInfoReader.setPos(tcPtrP->scanKeyInfoPos);
10708 ndbrequire( keyInfoReader.getWord(&firstWord) );
10709 const Uint32 rangeLen= (firstWord >> 16) ? (firstWord >> 16) : totalLen;
10710 Uint32 range_no = (firstWord & 0xFFF0) >> 4;
10711 tcPtrP->m_scan_curr_range_no= range_no;
10712 tcPtrP->m_corrFactorLo &= 0x0000FFFF;
10713 tcPtrP->m_corrFactorLo |= (range_no << 16);
10717 *(dst++)= firstWord;
10718 bool ok= keyInfoReader.getWords(dst, rangeLen - 1);
10722 tcPtrP->primKeyLen-= rangeLen;
10724 if (rangeLen == totalLen)
10727 releaseSection(tcPtrP->keyInfoIVal);
10728 tcPtrP->keyInfoIVal= RNIL;
10733 tcPtrP->scanKeyInfoPos= keyInfoReader.getPos();
10734 tcPtrP->m_flags|= TcConnectionrec::OP_SCANKEYINFOPOSSAVED;
10750 void Dblqh::storedProcConfScanLab(
Signal* signal)
10752 fragptr.i = tcConnectptr.p->fragmentptr;
10753 c_fragment_pool.
getPtr(fragptr);
10754 if (scanptr.p->scanCompletedStatus == ZTRUE) {
10757 closeScanLab(signal);
10766 linkFragQueue(signal);
10767 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_FIRST_STOPPED;
10782 ndbout_c(
"fragptr.p->fragStatus: %u",
10788 continueFirstScanAfterBlockedLab(signal);
10791 void Dblqh::continueFirstScanAfterBlockedLab(
Signal* signal)
10793 scanptr.i = tcConnectptr.p->tcScanRec;
10794 c_scanRecordPool.
getPtr(scanptr);
10795 scanptr.p->scanState = ScanRecord::WAIT_NEXT_SCAN;
10796 signal->theData[0] = scanptr.p->scanAccPtr;
10797 signal->theData[1] = RNIL;
10798 signal->theData[2] = NextScanReq::ZSCAN_NEXT;
10799 sendSignal(scanptr.p->scanBlockref, GSN_NEXT_SCANREQ, signal, 3, JBB);
10807 void Dblqh::execCHECK_LCP_STOP(
Signal* signal)
10810 scanptr.i = signal->theData[0];
10811 c_scanRecordPool.
getPtr(scanptr);
10812 tcConnectptr.i = scanptr.p->scanTcrec;
10813 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
10814 fragptr.i = tcConnectptr.p->fragmentptr;
10816 c_fragment_pool.
getPtr(fragptr);
10817 if (signal->theData[1] == ZTRUE) {
10819 signal->theData[0] = ZCHECK_LCP_STOP_BLOCKED;
10820 signal->theData[1] = scanptr.i;
10821 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 10, 2);
10822 signal->theData[0] = RNIL;
10827 linkFragQueue(signal);
10828 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_CHECK_STOPPED;
10829 signal->theData[0] = RNIL;
10833 void Dblqh::checkLcpStopBlockedLab(
Signal* signal)
10838 continueAfterCheckLcpStopBlocked(signal);
10842 linkFragQueue(signal);
10843 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_CHECK_STOPPED;
10861 void Dblqh::continueAfterCheckLcpStopBlocked(
Signal* signal)
10863 scanptr.i = tcConnectptr.p->tcScanRec;
10864 c_scanRecordPool.
getPtr(scanptr);
10865 signal->theData[0] = scanptr.p->scanAccPtr;
10866 signal->theData[1] = AccCheckScan::ZNOT_CHECK_LCP_STOP;
10867 EXECUTE_DIRECT(refToMain(scanptr.p->scanBlockref), GSN_ACC_CHECK_SCAN,
10876 void Dblqh::nextScanConfScanLab(
Signal* signal)
10879 tcConnectptr.i = scanptr.p->scanTcrec;
10880 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
10882 if (nextScanConf->fragId == RNIL) {
10894 if (!scanptr.p->scanLockHold)
10897 closeScanLab(signal);
10901 if (scanptr.p->scanCompletedStatus == ZTRUE) {
10902 if ((scanptr.p->scanLockHold == ZTRUE) &&
10903 (scanptr.p->m_curr_batch_size_rows > 0)) {
10905 scanptr.p->scanReleaseCounter = 1;
10906 scanReleaseLocksLab(signal);
10910 closeScanLab(signal);
10914 if (scanptr.p->m_curr_batch_size_rows > 0) {
10917 if((tcConnectptr.p->primKeyLen) == 0)
10918 scanptr.p->scanCompletedStatus = ZTRUE;
10920 scanptr.p->scanState = ScanRecord::WAIT_SCAN_NEXTREQ;
10921 sendScanFragConf(signal, ZFALSE);
10924 closeScanLab(signal);
10929 Uint32 accOpPtr = nextScanConf->accOperationPtr;
10930 if (accOpPtr == RNIL)
10936 if (scanptr.p->scanCompletedStatus == ZTRUE) {
10937 if ((scanptr.p->scanLockHold == ZTRUE) &&
10938 (scanptr.p->m_curr_batch_size_rows > 0)) {
10940 scanptr.p->scanReleaseCounter = 1;
10941 scanReleaseLocksLab(signal);
10945 closeScanLab(signal);
10949 if (scanptr.p->m_curr_batch_size_rows > 0) {
10951 scanptr.p->scanState = ScanRecord::WAIT_SCAN_NEXTREQ;
10952 sendScanFragConf(signal, ZFALSE);
10956 signal->theData[0] = scanptr.p->scanAccPtr;
10957 signal->theData[1] = AccCheckScan::ZCHECK_LCP_STOP;
10958 sendSignal(scanptr.p->scanBlockref,
10959 GSN_ACC_CHECK_SCAN, signal, 2, JBB);
10964 check_send_scan_hb_rep(signal, scanptr.p, tcConnectptr.p);
10965 set_acc_ptr_in_scan_record(scanptr.p,
10966 scanptr.p->m_curr_batch_size_rows,
10970 nextScanConfLoopLab(signal);
10973 void Dblqh::nextScanConfLoopLab(
Signal* signal)
10978 if (scanptr.p->scanCompletedStatus == ZTRUE) {
10980 if ((scanptr.p->scanLockHold == ZTRUE) &&
10981 (scanptr.p->m_curr_batch_size_rows > 0)) {
10983 scanptr.p->scanReleaseCounter = 1;
10984 scanReleaseLocksLab(signal);
10987 closeScanLab(signal);
10991 Fragrecord* fragPtrP= fragptr.p;
10992 if (scanptr.p->rangeScan) {
10995 fragPtrP= c_fragment_pool.
getPtr(fragPtrP->tableFragptr);
10998 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_TUPKEY;
10999 if(tcConnectptr.p->m_disk_table)
11001 next_scanconf_load_diskpage(signal, scanptr, tcConnectptr,fragPtrP);
11005 next_scanconf_tupkeyreq(signal, scanptr, tcConnectptr.p, fragPtrP, RNIL);
11010 Dblqh::next_scanconf_load_diskpage(
Signal* signal,
11011 ScanRecordPtr scanPtr,
11013 Fragrecord* fragPtrP)
11019 if((res= c_tup->load_diskpage_scan(signal,
11020 regTcPtr.p->tupConnectrec,
11021 fragPtrP->tupFragptr,
11022 scanPtr.p->m_row_id.m_page_no,
11023 scanPtr.p->m_row_id.m_page_idx,
11026 next_scanconf_tupkeyreq(signal, scanptr, regTcPtr.p, fragPtrP, res);
11028 else if(unlikely(res != 0))
11032 ref->userRef= regTcPtr.i;
11033 ref->errorCode= ~0;
11034 execTUPKEYREF(signal);
11039 Dblqh::next_scanconf_load_diskpage_callback(
Signal* signal,
11040 Uint32 callbackData,
11046 regTcPtr.i= callbackData;
11047 ptrCheckGuard(regTcPtr, ctcConnectrecFileSize, tcConnectionrec);
11049 ScanRecordPtr scanPtr;
11050 c_scanRecordPool.
getPtr(scanPtr, regTcPtr.p->tcScanRec);
11054 FragrecordPtr fragPtr;
11055 c_fragment_pool.
getPtr(fragPtr, regTcPtr.p->fragmentptr);
11057 if (scanPtr.p->rangeScan) {
11060 fragPtr.p = c_fragment_pool.
getPtr(fragPtr.p->tableFragptr);
11063 next_scanconf_tupkeyreq(signal, scanPtr, regTcPtr.p, fragPtr.p, disk_page);
11068 ref->userRef= callbackData;
11069 ref->errorCode= disk_page;
11070 execTUPKEYREF(signal);
11075 Dblqh::next_scanconf_tupkeyreq(
Signal* signal,
11077 TcConnectionrec * regTcPtr,
11078 Fragrecord* fragPtrP,
11082 Uint32 reqinfo = (scanPtr.p->scanLockHold == ZFALSE);
11083 reqinfo = reqinfo + (regTcPtr->operation << 6);
11084 reqinfo = reqinfo + (regTcPtr->opExec << 10);
11085 reqinfo = reqinfo + (regTcPtr->m_reorg << 12);
11089 tupKeyReq->connectPtr = regTcPtr->tupConnectrec;
11090 tupKeyReq->request = reqinfo;
11091 tupKeyReq->keyRef1 = scanPtr.p->m_row_id.m_page_no;
11092 tupKeyReq->keyRef2 = scanPtr.p->m_row_id.m_page_idx;
11093 tupKeyReq->attrBufLen = 0;
11094 tupKeyReq->opRef = scanPtr.p->scanApiOpPtr;
11095 tupKeyReq->applRef = scanPtr.p->scanApiBlockref;
11096 tupKeyReq->storedProcedure = scanPtr.p->scanStoredProcId;
11097 tupKeyReq->transId1 = regTcPtr->transid[0];
11098 tupKeyReq->transId2 = regTcPtr->transid[1];
11099 tupKeyReq->fragPtr = fragPtrP->tupFragptr;
11100 tupKeyReq->primaryReplica = (regTcPtr->seqNoReplica == 0)?
true:
false;
11101 tupKeyReq->coordinatorTC = regTcPtr->tcBlockref;
11102 tupKeyReq->tcOpIndex = regTcPtr->tcOprec;
11103 tupKeyReq->savePointId = regTcPtr->savePointId;
11104 tupKeyReq->disk_page= disk_page;
11106 tupKeyReq->attrInfoIVal= RNIL;
11107 Uint32 blockNo = refToMain(regTcPtr->tcTupBlockref);
11109 TupKeyReq::SignalLength);
11118 Dblqh::keyinfoLab(
const Uint32 * src, Uint32 len)
11120 ndbassert( tcConnectptr.p->keyInfoIVal == RNIL );
11121 ndbassert( len > 0 );
11123 if (ERROR_INSERTED(5052) || ERROR_INSERTED_CLEAR(5060))
11126 return(appendToSection(tcConnectptr.p->keyInfoIVal,
11132 Dblqh::readPrimaryKeys(ScanRecord *scanP, TcConnectionrec *tcConP, Uint32 *dst)
11134 Uint32 tableId = tcConP->tableref;
11135 Uint32 fragId = tcConP->fragmentid;
11136 Uint32 fragPageId = scanP->m_row_id.m_page_no;
11137 Uint32 pageIndex = scanP->m_row_id.m_page_idx;
11139 if(scanP->rangeScan)
11143 FragrecordPtr tFragPtr;
11145 c_fragment_pool.
getPtr(tFragPtr);
11146 tableId = tFragPtr.p->tabRef;
11149 int ret = c_tup->accReadPk(tableId, fragId, fragPageId, pageIndex, dst,
false);
11152 ndbout_c(
"readPrimaryKeys(table: %d fragment: %d [ %d %d ] -> %d",
11153 tableId, fragId, fragPageId, pageIndex, ret);
11154 ndbassert(ret > 0);
11164 void Dblqh::scanTupkeyConfLab(
Signal* signal)
11167 UintR tdata4 = conf->readLength;
11168 UintR tdata5 = conf->lastRow;
11170 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_STATE_USED;
11171 scanptr.i = tcConnectptr.p->tcScanRec;
11172 c_scanRecordPool.
getPtr(scanptr);
11174 Uint32 rows = scanptr.p->m_curr_batch_size_rows;
11175 Uint32 accOpPtr= get_acc_ptr_from_scan_record(scanptr.p, rows,
false);
11176 if (accOpPtr != (Uint32)-1)
11178 c_acc->execACCKEY_ORD(signal, accOpPtr);
11183 ndbassert(refToBlock(scanptr.p->scanBlockref) != DBACC);
11186 if (scanptr.p->scanCompletedStatus == ZTRUE) {
11190 if ((scanptr.p->scanLockHold == ZTRUE) && rows)
11193 scanptr.p->scanReleaseCounter = 1;
11194 scanReleaseLocksLab(signal);
11198 closeScanLab(signal);
11201 if (scanptr.p->scanKeyinfoFlag) {
11204 tdata4 += sendKeyinfo20(signal, scanptr.p, tcConnectptr.p);
11206 ndbrequire(scanptr.p->m_curr_batch_size_rows < MAX_PARALLEL_OP_PER_SCAN);
11207 scanptr.p->m_curr_batch_size_bytes+= tdata4;
11208 scanptr.p->m_curr_batch_size_rows = rows + 1;
11209 scanptr.p->m_last_row = tdata5;
11210 if (scanptr.p->check_scan_batch_completed() | tdata5){
11211 if (scanptr.p->scanLockHold == ZTRUE) {
11213 scanptr.p->scanState = ScanRecord::WAIT_SCAN_NEXTREQ;
11214 sendScanFragConf(signal, ZFALSE);
11218 scanptr.p->scanReleaseCounter = rows + 1;
11219 scanReleaseLocksLab(signal);
11223 if (scanptr.p->scanLockHold == ZTRUE) {
11225 scanptr.p->scanFlag = NextScanReq::ZSCAN_NEXT;
11228 scanptr.p->scanFlag = NextScanReq::ZSCAN_NEXT_COMMIT;
11231 scanNextLoopLab(signal);
11234 void Dblqh::scanNextLoopLab(
Signal* signal)
11242 linkFragQueue(signal);
11243 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_STOPPED;
11259 continueScanAfterBlockedLab(signal);
11262 void Dblqh::continueScanAfterBlockedLab(
Signal* signal)
11264 scanptr.i = tcConnectptr.p->tcScanRec;
11265 c_scanRecordPool.
getPtr(scanptr);
11267 if (scanptr.p->scanFlag == NextScanReq::ZSCAN_NEXT_ABORT) {
11269 scanptr.p->scanFlag = NextScanReq::ZSCAN_NEXT_COMMIT;
11270 accOpPtr= get_acc_ptr_from_scan_record(scanptr.p,
11271 scanptr.p->m_curr_batch_size_rows,
11273 scanptr.p->scan_acc_index--;
11274 }
else if (scanptr.p->scanFlag == NextScanReq::ZSCAN_NEXT_COMMIT) {
11276 accOpPtr= get_acc_ptr_from_scan_record(scanptr.p,
11277 scanptr.p->m_curr_batch_size_rows-1,
11283 scanptr.p->scanState = ScanRecord::WAIT_NEXT_SCAN;
11284 signal->theData[0] = scanptr.p->scanAccPtr;
11285 signal->theData[1] = accOpPtr;
11286 signal->theData[2] = scanptr.p->scanFlag;
11287 sendSignal(scanptr.p->scanBlockref, GSN_NEXT_SCANREQ, signal, 3, JBB);
11297 void Dblqh::scanTupkeyRefLab(
Signal* signal)
11299 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_STATE_USED;
11300 scanptr.i = tcConnectptr.p->tcScanRec;
11301 c_scanRecordPool.
getPtr(scanptr);
11303 Uint32 rows = scanptr.p->m_curr_batch_size_rows;
11304 Uint32 accOpPtr= get_acc_ptr_from_scan_record(scanptr.p, rows,
false);
11305 if (accOpPtr != (Uint32)-1)
11307 c_acc->execACCKEY_ORD(signal, accOpPtr);
11311 ndbassert(refToBlock(scanptr.p->scanBlockref) != DBACC);
11314 if (scanptr.p->scanCompletedStatus == ZTRUE) {
11318 if ((scanptr.p->scanLockHold == ZTRUE) && rows)
11321 scanptr.p->scanReleaseCounter = 1;
11322 scanReleaseLocksLab(signal);
11326 closeScanLab(signal);
11329 if ((terrorCode != ZSEARCH_CONDITION_FALSE) &&
11330 (terrorCode != ZNO_TUPLE_FOUND) &&
11331 (terrorCode >= ZUSER_ERROR_CODE_LIMIT)) {
11332 scanptr.p->scanErrorCounter++;
11333 tcConnectptr.p->errorCode = terrorCode;
11335 if (scanptr.p->scanLockHold == ZTRUE) {
11337 scanptr.p->scanReleaseCounter = 1;
11340 scanptr.p->m_curr_batch_size_rows = rows + 1;
11341 scanptr.p->scanReleaseCounter = rows + 1;
11347 scanReleaseLocksLab(signal);
11350 Uint32 time_passed= tcConnectptr.p->tcTimer - cLqhTimeOutCount;
11353 if (time_passed > 1)
11361 scanptr.p->scanReleaseCounter = rows + 1;
11362 scanReleaseLocksLab(signal);
11367 scanptr.p->scanFlag = NextScanReq::ZSCAN_NEXT_ABORT;
11368 scanNextLoopLab(signal);
11375 void Dblqh::closeScanLab(
Signal* signal)
11377 fragptr.i = tcConnectptr.p->fragmentptr;
11378 c_fragment_pool.
getPtr(fragptr);
11385 linkFragQueue(signal);
11386 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_CLOSE_STOPPED;
11402 continueCloseScanAfterBlockedLab(signal);
11405 void Dblqh::continueCloseScanAfterBlockedLab(
Signal* signal)
11407 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_STATE_USED;
11408 scanptr.i = tcConnectptr.p->tcScanRec;
11409 c_scanRecordPool.
getPtr(scanptr);
11410 scanptr.p->scanState = ScanRecord::WAIT_CLOSE_SCAN;
11411 signal->theData[0] = scanptr.p->scanAccPtr;
11412 signal->theData[1] = RNIL;
11413 signal->theData[2] = NextScanReq::ZSCAN_CLOSE;
11414 sendSignal(scanptr.p->scanBlockref, GSN_NEXT_SCANREQ, signal, 3, JBB);
11422 void Dblqh::accScanCloseConfLab(
Signal* signal)
11424 tcConnectptr.i = scanptr.p->scanTcrec;
11425 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
11428 if((tcConnectptr.p->primKeyLen > 0) &&
11429 (scanptr.p->scanCompletedStatus != ZTRUE))
11433 continueAfterReceivingAllAiLab(signal);
11437 scanptr.p->scanState = ScanRecord::WAIT_DELETE_STORED_PROC_ID_SCAN;
11438 signal->theData[0] = tcConnectptr.p->tupConnectrec;
11439 signal->theData[1] = tcConnectptr.p->tableref;
11440 signal->theData[2] = scanptr.p->scanSchemaVersion;
11441 signal->theData[3] = ZDELETE_STORED_PROC_ID;
11442 signal->theData[4] = scanptr.p->scanStoredProcId;
11443 signal->theData[5] = scanptr.p->scanApiBlockref;
11444 sendSignal(tcConnectptr.p->tcTupBlockref,
11445 GSN_STORED_PROCREQ, signal, 6, JBB);
11453 void Dblqh::tupScanCloseConfLab(
Signal* signal)
11455 fragptr.i = tcConnectptr.p->fragmentptr;
11456 c_fragment_pool.
getPtr(fragptr);
11457 if (tcConnectptr.p->abortState == TcConnectionrec::NEW_FROM_TC) {
11459 tcNodeFailptr.i = tcConnectptr.p->tcNodeFailrec;
11460 ptrCheckGuard(tcNodeFailptr, ctcNodeFailrecFileSize, tcNodeFailRecord);
11461 tcNodeFailptr.p->tcRecNow = tcConnectptr.i + 1;
11462 signal->theData[0] = ZLQH_TRANS_NEXT;
11463 signal->theData[1] = tcNodeFailptr.i;
11464 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
11465 }
else if (tcConnectptr.p->errorCode != 0) {
11468 ref->senderData = tcConnectptr.p->clientConnectrec;
11469 ref->transId1 = tcConnectptr.p->transid[0];
11470 ref->transId2 = tcConnectptr.p->transid[1];
11471 ref->errorCode = tcConnectptr.p->errorCode;
11472 sendSignal(tcConnectptr.p->clientBlockref, GSN_SCAN_FRAGREF, signal,
11473 ScanFragRef::SignalLength, JBB);
11476 sendScanFragConf(signal, ZSCAN_FRAG_CLOSED);
11478 finishScanrec(signal);
11479 releaseScanrec(signal);
11480 tcConnectptr.p->tcScanRec = RNIL;
11481 deleteTransidHash(signal);
11482 releaseOprec(signal);
11483 releaseTcrec(signal, tcConnectptr);
11491 Uint32 Dblqh::initScanrec(
const ScanFragReq* scanFragReq,
11494 const Uint32 reqinfo = scanFragReq->requestInfo;
11495 const Uint32 max_rows = scanFragReq->batch_size_rows;
11496 const Uint32 max_bytes = scanFragReq->batch_size_bytes;
11497 const Uint32 scanLockMode = ScanFragReq::getLockMode(reqinfo);
11498 const Uint32 scanLockHold = ScanFragReq::getHoldLockFlag(reqinfo);
11499 const Uint32 keyinfo = ScanFragReq::getKeyinfoFlag(reqinfo);
11500 const Uint32 readCommitted = ScanFragReq::getReadCommittedFlag(reqinfo);
11501 const Uint32 rangeScan = ScanFragReq::getRangeScanFlag(reqinfo);
11502 const Uint32 descending = ScanFragReq::getDescendingFlag(reqinfo);
11503 Uint32 tupScan = ScanFragReq::getTupScanFlag(reqinfo);
11504 const Uint32 scanPrio = ScanFragReq::getScanPrio(reqinfo);
11505 const Uint32 accScan = (rangeScan == 0) && (tupScan == 0);
11507 scanptr.p->scanKeyinfoFlag = keyinfo;
11508 scanptr.p->scanLockHold = scanLockHold;
11509 scanptr.p->scanCompletedStatus = ZFALSE;
11510 scanptr.p->scanType = ScanRecord::SCAN;
11511 scanptr.p->scanApiBlockref = scanFragReq->resultRef;
11512 scanptr.p->scanAiLength = aiLen;
11513 scanptr.p->scanTcrec = tcConnectptr.i;
11514 scanptr.p->scanSchemaVersion = scanFragReq->schemaVersion;
11516 scanptr.p->m_curr_batch_size_rows = 0;
11517 scanptr.p->m_curr_batch_size_bytes= 0;
11518 scanptr.p->m_max_batch_size_rows = max_rows;
11519 scanptr.p->m_max_batch_size_bytes = max_bytes;
11522 scanptr.p->scanBlockref = tcConnectptr.p->tcAccBlockref;
11523 else if (! tupScan)
11524 scanptr.p->scanBlockref = tcConnectptr.p->tcTuxBlockref;
11526 scanptr.p->scanBlockref = tcConnectptr.p->tcTupBlockref;
11528 scanptr.p->scanErrorCounter = 0;
11529 scanptr.p->scanLockMode = scanLockMode;
11530 scanptr.p->readCommitted = readCommitted;
11531 scanptr.p->rangeScan = rangeScan;
11532 scanptr.p->descending = descending;
11533 scanptr.p->tupScan = tupScan;
11534 scanptr.p->lcpScan = ScanFragReq::getLcpScanFlag(reqinfo);
11535 scanptr.p->statScan = ScanFragReq::getStatScanFlag(reqinfo);
11536 scanptr.p->scanState = ScanRecord::SCAN_FREE;
11537 scanptr.p->scanFlag = ZFALSE;
11538 scanptr.p->m_row_id.setNull();
11539 scanptr.p->scanTcWaiting = cLqhTimeOutCount;
11540 scanptr.p->scanNumber = ~0;
11541 scanptr.p->scanApiOpPtr = scanFragReq->clientOpPtr;
11542 scanptr.p->m_last_row = 0;
11543 scanptr.p->scanStoredProcId = RNIL;
11544 scanptr.p->copyPtr = RNIL;
11545 if (max_rows == 0 || (max_bytes > 0 && max_rows > max_bytes)){
11547 return ScanFragRef::ZWRONG_BATCH_SIZE;
11550 if (ERROR_INSERTED(5057))
11552 CLEAR_ERROR_INSERT_VALUE;
11553 return ScanFragRef::ZTOO_MANY_ACTIVE_SCAN_ERROR;
11556 scanptr.p->scan_acc_segments = 0;
11557 if (!seize_acc_ptr_list(scanptr.p, 0, max_rows)){
11559 return ScanFragRef::ZTOO_MANY_ACTIVE_SCAN_ERROR;
11561 init_acc_ptr_list(scanptr.p);
11566 FragrecordPtr tFragPtr;
11568 c_fragment_pool.
getPtr(tFragPtr);
11586 Uint32 start, stop;
11587 Uint32 max_parallel_scans_per_frag = c_max_parallel_scans_per_frag;
11591 stop = MAX_PARALLEL_SCANS_PER_FRAG - 1;
11593 else if (rangeScan)
11595 start = MAX_PARALLEL_SCANS_PER_FRAG;
11596 stop = start + max_parallel_scans_per_frag - 1;
11600 ndbassert(tupScan);
11601 start = MAX_PARALLEL_SCANS_PER_FRAG + max_parallel_scans_per_frag;
11602 stop = start + max_parallel_scans_per_frag - 1;
11604 ndbrequire((start < 32 * tFragPtr.p->m_scanNumberMask.Size) &&
11605 (stop < 32 * tFragPtr.p->m_scanNumberMask.Size));
11606 Uint32 free = tFragPtr.p->m_scanNumberMask.find(start);
11608 if(free == Fragrecord::ScanNumberMask::NotFound || free >= stop){
11613 return ScanFragRef::ZTOO_MANY_ACTIVE_SCAN_ERROR;
11619 scanptr.p->scanState = ScanRecord::IN_QUEUE;
11622 fragptr.p->m_queuedScans :
11623 fragptr.p->m_queuedTupScans);
11624 queue.add(scanptr);
11628 scanptr.p->scanNumber = free;
11629 tFragPtr.p->m_scanNumberMask.clear(free);
11632 active.add(scanptr);
11633 if(scanptr.p->scanKeyinfoFlag){
11635 #if defined VM_TRACE || defined ERROR_INSERT
11637 ndbrequire(!c_scanTakeOverHash.
find(tmp, * scanptr.p));
11639 #ifdef TRACE_SCAN_TAKEOVER
11640 ndbout_c(
"adding (%d %d) table: %d fragId: %d frag.i: %d tableFragptr: %d",
11641 scanptr.p->scanNumber, scanptr.p->
fragPtrI,
11642 tabptr.i, scanFragReq->fragmentNoKeyLen & 0xFFFF,
11645 c_scanTakeOverHash.
add(scanptr);
11662 tcConnectptr.p->transid[0] = transid1;
11663 tcConnectptr.p->transid[1] = transid2;
11664 tcConnectptr.p->tcScanRec = scanptr.i;
11665 tcConnectptr.p->tableref = tabptr.i;
11666 tcConnectptr.p->fragmentid = fragId;
11667 tcConnectptr.p->fragmentptr = fragptr.i;
11668 tcConnectptr.p->tcOprec = tcConnectptr.p->clientConnectrec;
11669 tcConnectptr.p->tcHashKeyHi = hashHi;
11670 tcConnectptr.p->tcBlockref = tcConnectptr.p->clientBlockref;
11671 tcConnectptr.p->errorCode = 0;
11672 tcConnectptr.p->reclenAiLqhkey = 0;
11673 tcConnectptr.p->abortState = TcConnectionrec::ABORT_IDLE;
11674 tcConnectptr.p->nextReplica = nodeId;
11675 tcConnectptr.p->currTupAiLen = 0;
11676 tcConnectptr.p->opExec = 1;
11677 tcConnectptr.p->operation = ZREAD;
11678 tcConnectptr.p->
listState = TcConnectionrec::NOT_IN_LIST;
11679 tcConnectptr.p->commitAckMarker = RNIL;
11680 tcConnectptr.p->m_scan_curr_range_no = 0;
11681 tcConnectptr.p->m_dealloc = 0;
11682 tcConnectptr.p->activeCreat = Fragrecord::AC_NORMAL;
11686 tcConnectptr.p->m_flags = TcConnectionrec::OP_SAVEATTRINFO;
11687 TablerecPtr tTablePtr;
11688 tTablePtr.i = tabptr.p->primaryTableId;
11689 ptrCheckGuard(tTablePtr, ctabrecFileSize, tablerec);
11690 tcConnectptr.p->m_disk_table = tTablePtr.p->m_disk_table &&
11691 (!req || !ScanFragReq::getNoDiskFlag(req->requestInfo));
11692 tcConnectptr.p->m_reorg =
11693 req ? ScanFragReq::getReorgFlag(req->requestInfo) : 0;
11695 tabptr.p->usageCountR++;
11703 void Dblqh::finishScanrec(
Signal* signal)
11705 release_acc_ptr_list(scanptr.p);
11707 Uint32 tupScan = scanptr.p->tupScan;
11710 fragptr.p->m_queuedScans :
11711 fragptr.p->m_queuedTupScans);
11713 if (scanptr.p->scanState == ScanRecord::IN_QUEUE)
11716 if (scanptr.p->m_reserved == 0)
11719 queue.release(scanptr);
11724 queue.remove(scanptr);
11725 m_reserved_scans.
add(scanptr);
11731 if(scanptr.p->scanKeyinfoFlag){
11734 #ifdef TRACE_SCAN_TAKEOVER
11735 ndbout_c(
"removing (%d %d)", scanptr.p->scanNumber, scanptr.p->
fragPtrI);
11737 c_scanTakeOverHash.
remove(tmp, * scanptr.p);
11738 ndbrequire(tmp.p == scanptr.p);
11742 if (scanptr.p->m_reserved == 0)
11745 scans.release(scanptr);
11750 scans.remove(scanptr);
11751 m_reserved_scans.
add(scanptr);
11754 FragrecordPtr tFragPtr;
11756 c_fragment_pool.
getPtr(tFragPtr);
11758 const Uint32 scanNumber = scanptr.p->scanNumber;
11759 ndbrequire(!tFragPtr.p->m_scanNumberMask.get(scanNumber));
11760 ScanRecordPtr restart;
11765 if(scanNumber == NR_ScanNo || !queue.first(restart)){
11767 tFragPtr.p->m_scanNumberMask.set(scanNumber);
11771 if(ERROR_INSERTED(5034)){
11773 tFragPtr.p->m_scanNumberMask.set(scanNumber);
11777 ndbrequire(restart.p->scanState == ScanRecord::IN_QUEUE);
11779 ScanRecordPtr tmpScan = scanptr;
11780 TcConnectionrecPtr tmpTc = tcConnectptr;
11782 tcConnectptr.i = restart.p->scanTcrec;
11783 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
11784 restart.p->scanNumber = scanNumber;
11786 queue.remove(restart);
11787 scans.add(restart);
11788 if(restart.p->scanKeyinfoFlag){
11790 #if defined VM_TRACE || defined ERROR_INSERT
11792 ndbrequire(!c_scanTakeOverHash.
find(tmp, * restart.p));
11794 c_scanTakeOverHash.
add(restart);
11795 #ifdef TRACE_SCAN_TAKEOVER
11796 ndbout_c(
"adding-r (%d %d)", restart.p->scanNumber, restart.p->fragPtrI);
11803 restart.p->scanState = ScanRecord::SCAN_FREE;
11804 if(tcConnectptr.p->transactionState == TcConnectionrec::SCAN_STATE_USED)
11807 continueAfterReceivingAllAiLab(signal);
11811 ndbrequire(tcConnectptr.p->transactionState == TcConnectionrec::WAIT_SCAN_AI);
11815 tcConnectptr = tmpTc;
11823 void Dblqh::releaseScanrec(
Signal* signal)
11825 scanptr.p->scanState = ScanRecord::SCAN_FREE;
11826 scanptr.p->scanType = ScanRecord::ST_IDLE;
11827 scanptr.p->scanTcWaiting = 0;
11828 cbookedAccOps -= scanptr.p->m_max_batch_size_rows;
11835 Uint32 Dblqh::sendKeyinfo20(
Signal* signal,
11836 ScanRecord * scanP,
11837 TcConnectionrec * tcConP)
11839 ndbrequire(scanP->m_curr_batch_size_rows < MAX_PARALLEL_OP_PER_SCAN);
11846 const BlockReference ref = scanP->scanApiBlockref;
11847 const Uint32 scanOp = scanP->m_curr_batch_size_rows;
11848 Uint32 nodeId = refToNode(ref);
11852 const bool is_api= (type >=
NodeInfo::API && type <= NodeInfo::REP);
11855 const bool longable =
true;
11857 Uint32 * dst = keyInfo->keyData;
11858 dst += nodeId == getOwnNodeId() ? 0 : KeyInfo20::DataLength;
11868 if (refToMain(ref) == SUMA && nodeId == getOwnNodeId())
11874 keyLen = readPrimaryKeys(scanP, tcConP, dst);
11877 Uint32 fragId = tcConP->fragmentid;
11878 keyInfo->clientOpPtr = scanP->scanApiOpPtr;
11879 keyInfo->keyLen = keyLen;
11880 keyInfo->scanInfo_Node =
11881 KeyInfo20::setScanInfo(scanOp, scanP->scanNumber) + (fragId << 20);
11882 keyInfo->transId1 = tcConP->transid[0];
11883 keyInfo->transId2 = tcConP->transid[1];
11885 Uint32 * src = signal->theData+25;
11886 if(connectedToNode)
11890 if (isNdbMtLqh() && instance() != refToInstance(ref))
11895 if (nodeId == getOwnNodeId())
11898 KeyInfo20::HeaderLength + keyLen);
11904 if(keyLen <= KeyInfo20::DataLength || !longable) {
11905 while(keyLen > KeyInfo20::DataLength){
11907 MEMCOPY_NO_WORDS(keyInfo->keyData, src, KeyInfo20::DataLength);
11908 sendSignal(ref, GSN_KEYINFO20, signal, 25, JBB);
11909 src += KeyInfo20::DataLength;;
11910 keyLen -= KeyInfo20::DataLength;
11913 MEMCOPY_NO_WORDS(keyInfo->keyData, src, keyLen);
11914 sendSignal(ref, GSN_KEYINFO20, signal,
11915 KeyInfo20::HeaderLength+keyLen, JBB);
11921 ptr[0].sz = keyLen;
11922 sendSignal(ref, GSN_KEYINFO20, signal, KeyInfo20::HeaderLength,
11933 Uint32 routeBlockref = tcConP->clientBlockref;
11935 if(keyLen < KeyInfo20::DataLength || !longable){
11938 while (keyLen > (KeyInfo20::DataLength - 1)) {
11940 MEMCOPY_NO_WORDS(keyInfo->keyData, src, KeyInfo20::DataLength - 1);
11941 keyInfo->keyData[KeyInfo20::DataLength-1] = ref;
11942 sendSignal(routeBlockref, GSN_KEYINFO20_R, signal, 25, JBB);
11943 src += KeyInfo20::DataLength - 1;
11944 keyLen -= KeyInfo20::DataLength - 1;
11947 MEMCOPY_NO_WORDS(keyInfo->keyData, src, keyLen);
11948 keyInfo->keyData[keyLen] = ref;
11949 sendSignal(routeBlockref, GSN_KEYINFO20_R, signal,
11950 KeyInfo20::HeaderLength+keyLen+1, JBB);
11954 keyInfo->keyData[0] = ref;
11957 ptr[0].sz = keyLen;
11958 sendSignal(routeBlockref, GSN_KEYINFO20_R, signal,
11959 KeyInfo20::HeaderLength+1, JBB, ptr, 1);
11967 void Dblqh::sendScanFragConf(
Signal* signal, Uint32 scanCompleted)
11969 Uint32 completed_ops= scanptr.p->m_curr_batch_size_rows;
11970 Uint32 total_len= scanptr.p->m_curr_batch_size_bytes;
11971 scanptr.p->scanTcWaiting = 0;
11973 if(ERROR_INSERTED(5037)){
11974 CLEAR_ERROR_INSERT_VALUE;
11979 NodeId tc_node_id= refToNode(tcConnectptr.p->clientBlockref);
11981 Uint32 trans_id1= tcConnectptr.p->transid[0];
11982 Uint32 trans_id2= tcConnectptr.p->transid[1];
11984 conf->senderData = tcConnectptr.p->clientConnectrec;
11985 conf->completedOps = completed_ops;
11986 conf->fragmentCompleted = scanCompleted;
11987 conf->transId1 = trans_id1;
11988 conf->transId2 = trans_id2;
11989 conf->total_len= total_len;
11990 sendSignal(tcConnectptr.p->clientBlockref, GSN_SCAN_FRAGCONF,
11991 signal, ScanFragConf::SignalLength, JBB);
11993 if(!scanptr.p->scanLockHold)
11996 scanptr.p->m_curr_batch_size_rows = 0;
11997 scanptr.p->m_curr_batch_size_bytes= 0;
12012 Dblqh::calculateHash(Uint32 tableId,
const Uint32* src)
12015 Uint64 Tmp[(MAX_KEY_SIZE_IN_WORDS*MAX_XFRM_MULTIPLY) >> 1];
12016 Uint32 keyPartLen[MAX_ATTRIBUTES_IN_INDEX];
12017 Uint32 keyLen =
xfrm_key(tableId, src, (Uint32*)Tmp,
sizeof(Tmp) >> 2,
12019 ndbrequire(keyLen);
12021 return md5_hash(Tmp, keyLen);
12028 Dblqh::execPREPARE_COPY_FRAG_REQ(
Signal* signal)
12033 CRASH_INSERTION(5045);
12035 tabptr.i = req.tableId;
12036 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
12038 Uint32 max_page = RNIL;
12040 if (getOwnNodeId() != req.startingNodeId)
12048 ndbrequire(getOwnNodeId() == req.copyNodeId);
12049 c_tup->get_frag_info(req.tableId, req.fragId, &max_page);
12052 conf->senderData = req.senderData;
12053 conf->senderRef = reference();
12054 conf->tableId = req.tableId;
12055 conf->fragId = req.fragId;
12056 conf->copyNodeId = req.copyNodeId;
12057 conf->startingNodeId = req.startingNodeId;
12058 conf->maxPageNo = max_page;
12059 sendSignal(req.senderRef, GSN_PREPARE_COPY_FRAG_CONF,
12060 signal, PrepareCopyFragConf::SignalLength, JBB);
12065 if (! DictTabInfo::isOrderedIndex(tabptr.p->
tableType))
12068 ndbrequire(getFragmentrec(signal, req.fragId));
12073 if (cstartType == NodeState::ST_SYSTEM_RESTART)
12076 signal->theData[0] = fragptr.p->
tabRef;
12077 signal->theData[1] = fragptr.p->
fragId;
12078 BlockReference accRef = calcInstanceBlockRef(DBACC);
12079 sendSignal(accRef, GSN_EXPANDCHECK2, signal, 2, JBB);
12086 fragptr.p->m_copy_started_state = Fragrecord::AC_IGNORED;
12088 fragptr.p->
logFlag = Fragrecord::STATE_FALSE;
12090 c_tup->get_frag_info(req.tableId, req.fragId, &max_page);
12094 conf->senderData = req.senderData;
12095 conf->senderRef = reference();
12096 conf->tableId = req.tableId;
12097 conf->fragId = req.fragId;
12098 conf->copyNodeId = req.copyNodeId;
12099 conf->startingNodeId = req.startingNodeId;
12100 conf->maxPageNo = max_page;
12101 sendSignal(req.senderRef, GSN_PREPARE_COPY_FRAG_CONF,
12102 signal, PrepareCopyFragConf::SignalLength, JBB);
12108 void Dblqh::execCOPY_FRAGREQ(
Signal* signal)
12112 tabptr.i = copyFragReq->tableId;
12113 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
12115 const Uint32 fragId = copyFragReq->fragId;
12116 const Uint32 copyPtr = copyFragReq->userPtr;
12117 const Uint32 userRef = copyFragReq->userRef;
12118 const Uint32 nodeId = copyFragReq->nodeId;
12119 const Uint32 gci = copyFragReq->gci;
12121 ndbrequire(cnoActiveCopy < 3);
12122 ndbrequire(getFragmentrec(signal, fragId));
12124 ndbrequire(cfirstfreeTcConrec != RNIL);
12125 ndbrequire(fragptr.p->m_scanNumberMask.
get(NR_ScanNo));
12127 Uint32 checkversion = NDB_VERSION >= MAKE_VERSION(5,1,0) ?
12128 NDBD_UPDATE_FRAG_DIST_KEY_51 : NDBD_UPDATE_FRAG_DIST_KEY_50;
12130 Uint32 nodeCount = copyFragReq->nodeCount;
12132 if (
getNodeInfo(refToNode(userRef)).m_version >= checkversion)
12134 ndbrequire(nodeCount <= MAX_REPLICAS);
12135 for (i = 0; i<nodeCount; i++)
12136 nodemask.
set(copyFragReq->nodeList[i]);
12138 Uint32 maxPage = copyFragReq->nodeList[nodeCount];
12140 Uint32 requestInfo = copyFragReq->nodeList[nodeCount + 1];
12141 if (ndb_check_prep_copy_frag_version(version) < 2)
12147 if (signal->getLength() < CopyFragReq::SignalLength + nodeCount)
12150 requestInfo = CopyFragReq::CFR_TRANSACTIONAL;
12153 if (requestInfo == CopyFragReq::CFR_NON_TRANSACTIONAL)
12163 if (DictTabInfo::isOrderedIndex(tabptr.p->
tableType)) {
12169 conf->userPtr = copyPtr;
12170 conf->sendingNodeId = cownNodeid;
12171 conf->startingNodeId = nodeId;
12172 conf->tableId = tabptr.i;
12173 conf->fragId = fragId;
12174 sendSignal(userRef, GSN_COPY_FRAGCONF, signal,
12175 CopyFragConf::SignalLength, JBB);
12180 ndbrequire(m_reserved_scans.
first(scanptr));
12181 m_reserved_scans.
remove(scanptr);
12182 scans.add(scanptr);
12191 scanptr.p->m_max_batch_size_rows = 0;
12192 scanptr.p->rangeScan = 0;
12193 scanptr.p->tupScan = 0;
12195 tcConnectptr.p->clientBlockref = userRef;
12201 scanptr.p->copyPtr = copyPtr;
12202 scanptr.p->scanType = ScanRecord::COPY;
12203 scanptr.p->scanNodeId = nodeId;
12204 scanptr.p->scanTcrec = tcConnectptr.i;
12205 scanptr.p->scanSchemaVersion = copyFragReq->schemaVersion;
12206 scanptr.p->scanCompletedStatus = ZFALSE;
12207 scanptr.p->scanErrorCounter = 0;
12208 scanptr.p->scanNumber = NR_ScanNo;
12209 scanptr.p->scanKeyinfoFlag = 0;
12211 scanptr.p->scanApiOpPtr = tcConnectptr.i;
12212 scanptr.p->scanApiBlockref = reference();
12213 fragptr.p->m_scanNumberMask.
clear(NR_ScanNo);
12214 scanptr.p->scanBlockref = ctupBlockref;
12215 scanptr.p->scanLockHold = ZFALSE;
12216 scanptr.p->m_curr_batch_size_rows = 0;
12217 scanptr.p->m_curr_batch_size_bytes= 0;
12218 scanptr.p->readCommitted = 0;
12222 (DBLQH << 20) + (cownNodeid << 8),
12224 copyFragReq->nodeId,
12226 cactiveCopy[cnoActiveCopy] = fragptr.i;
12229 tcConnectptr.p->copyCountWords = 0;
12230 tcConnectptr.p->tcOprec = tcConnectptr.i;
12231 tcConnectptr.p->tcHashKeyHi = 0;
12232 tcConnectptr.p->schemaVersion = scanptr.p->scanSchemaVersion;
12233 tcConnectptr.p->savePointId = gci;
12234 tcConnectptr.p->applRef = 0;
12235 tcConnectptr.p->transactionState = TcConnectionrec::SCAN_STATE_USED;
12237 scanptr.p->scanState = ScanRecord::WAIT_ACC_COPY;
12239 req->senderData = scanptr.i;
12240 req->senderRef = cownref;
12241 req->tableId = tabptr.i;
12242 req->fragmentNo = fragId;
12243 req->requestInfo = 0;
12245 if (requestInfo == CopyFragReq::CFR_TRANSACTIONAL)
12252 AccScanReq::setLockMode(req->requestInfo, 0);
12253 AccScanReq::setReadCommittedFlag(req->requestInfo, 0);
12254 AccScanReq::setNRScanFlag(req->requestInfo, 1);
12255 AccScanReq::setNoDiskScanFlag(req->requestInfo, 1);
12264 AccScanReq::setLockMode(req->requestInfo, 0);
12265 AccScanReq::setReadCommittedFlag(req->requestInfo, 1);
12266 scanptr.p->readCommitted = 1;
12269 req->transId1 = tcConnectptr.p->transid[0];
12270 req->transId2 = tcConnectptr.p->transid[1];
12271 req->savePointId = tcConnectptr.p->savePointId;
12272 req->maxPage = maxPage;
12273 sendSignal(scanptr.p->scanBlockref, GSN_ACC_SCANREQ, signal,
12274 AccScanReq::SignalLength + 1, JBB);
12278 ndbrequire(nodemask.
get(getOwnNodeId()));
12279 ndbrequire(nodemask.
get(nodeId));
12280 nodemask.
clear(getOwnNodeId());
12281 nodemask.
clear(nodeId);
12285 ord->tableId = tabptr.i;
12286 ord->fragId = fragId;
12287 ord->fragDistributionKey = key;
12289 while ((i = nodemask.
find(i+1)) != NdbNodeBitmask::NotFound)
12292 sendSignal(calcInstanceBlockRef(number(),
i),
12293 GSN_UPDATE_FRAG_DIST_KEY_ORD,
12294 signal, UpdateFragDistKeyOrd::SignalLength, JBB);
12301 Dblqh::execUPDATE_FRAG_DIST_KEY_ORD(
Signal * signal)
12306 tabptr.i = ord->tableId;
12307 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
12308 ndbrequire(getFragmentrec(signal, ord->fragId));
12312 void Dblqh::accScanConfCopyLab(
Signal* signal)
12315 tcConnectptr.i = scanptr.p->scanTcrec;
12316 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
12320 if (accScanConf->flag == AccScanConf::ZEMPTY_FRAGMENT) {
12326 tupCopyCloseConfLab(signal);
12329 scanptr.p->scanAccPtr = accScanConf->accPtr;
12330 scanptr.p->scanState = ScanRecord::WAIT_STORED_PROC_COPY;
12331 signal->theData[0] = tcConnectptr.p->tupConnectrec;
12332 signal->theData[1] = tcConnectptr.p->tableref;
12333 signal->theData[2] = scanptr.p->scanSchemaVersion;
12334 signal->theData[3] = ZSTORED_PROC_COPY;
12336 signal->theData[5] = scanptr.p->scanApiBlockref;
12337 sendSignal(scanptr.p->scanBlockref, GSN_STORED_PROCREQ, signal, 6, JBB);
12346 void Dblqh::storedProcConfCopyLab(
Signal* signal)
12351 fragptr.i = tcConnectptr.p->fragmentptr;
12352 c_fragment_pool.
getPtr(fragptr);
12353 if (scanptr.p->scanCompletedStatus == ZTRUE) {
12358 closeCopyLab(signal);
12361 scanptr.i = tcConnectptr.p->tcScanRec;
12362 c_scanRecordPool.
getPtr(scanptr);
12363 scanptr.p->scanState = ScanRecord::WAIT_NEXT_SCAN_COPY;
12370 linkFragQueue(signal);
12371 tcConnectptr.p->transactionState = TcConnectionrec::COPY_FIRST_STOPPED;
12386 systemErrorLab(signal, __LINE__);
12390 continueFirstCopyAfterBlockedLab(signal);
12394 void Dblqh::continueFirstCopyAfterBlockedLab(
Signal* signal)
12399 fragptr.p->m_copy_started_state = Fragrecord::AC_NR_COPY;
12400 if (ERROR_INSERTED(5714))
12402 ndbout_c(
"Starting copy of tab: %u frag: %u",
12406 scanptr.i = tcConnectptr.p->tcScanRec;
12407 c_scanRecordPool.
getPtr(scanptr);
12409 if (
false && fragptr.p->
tabRef > 4)
12411 ndbout_c(
"STOPPING COPY X = [ %d %d %d %d ]",
12412 refToBlock(scanptr.p->scanBlockref),
12413 scanptr.p->scanAccPtr, RNIL, NextScanReq::ZSCAN_NEXT);
12421 signal->theData[0] = scanptr.p->scanAccPtr;
12422 signal->theData[1] = RNIL;
12423 signal->theData[2] = NextScanReq::ZSCAN_NEXT;
12424 sendSignal(scanptr.p->scanBlockref, GSN_NEXT_SCANREQ, signal, 3, JBB);
12443 void Dblqh::nextScanConfCopyLab(
Signal* signal)
12446 tcConnectptr.i = scanptr.p->scanTcrec;
12447 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
12448 if (nextScanConf->fragId == RNIL) {
12454 if (tcConnectptr.p->copyCountWords == 0) {
12455 closeCopyLab(signal);
12462 scanptr.p->scanCompletedStatus = ZTRUE;
12463 scanptr.p->scanState = ScanRecord::WAIT_LQHKEY_COPY;
12464 if (ERROR_INSERTED(5043))
12466 CLEAR_ERROR_INSERT_VALUE;
12467 tcConnectptr.p->copyCountWords = ~0;
12468 signal->theData[0] = 9999;
12469 sendSignal(numberToRef(CMVMI, scanptr.p->scanNodeId),
12470 GSN_NDB_TAMPER, signal, 1, JBA);
12475 TcConnectionrec * tcConP = tcConnectptr.p;
12477 tcConP->m_use_rowid =
true;
12478 tcConP->m_row_id = scanptr.p->m_row_id;
12480 scanptr.p->m_curr_batch_size_rows++;
12482 if (signal->getLength() == NextScanConf::SignalLengthNoKeyInfo)
12485 ndbrequire(nextScanConf->accOperationPtr == RNIL);
12486 initCopyTc(signal, ZDELETE);
12487 set_acc_ptr_in_scan_record(scanptr.p, 0, RNIL);
12488 tcConP->gci_hi = nextScanConf->gci;
12489 tcConP->gci_lo = 0;
12491 tcConP->primKeyLen = 0;
12492 tcConP->totSendlenAi = 0;
12493 tcConP->connectState = TcConnectionrec::COPY_CONNECTED;
12505 UintR TnoOfWords = 8;
12506 TnoOfWords = TnoOfWords + MAGIC_CONSTANT;
12507 TnoOfWords = TnoOfWords + (TnoOfWords >> 2);
12524 tcConP->transid[0] = TnoOfWords;
12525 packLqhkeyreqLab(signal);
12526 tcConP->copyCountWords += TnoOfWords;
12527 scanptr.p->scanState = ScanRecord::WAIT_LQHKEY_COPY;
12528 if (tcConP->copyCountWords < cmaxWordsAtNodeRec) {
12529 nextRecordCopy(signal);
12536 if (nextScanConf->accOperationPtr == RNIL) {
12538 signal->theData[0] = scanptr.p->scanAccPtr;
12539 signal->theData[1] = AccCheckScan::ZCHECK_LCP_STOP;
12540 sendSignal(scanptr.p->scanBlockref, GSN_ACC_CHECK_SCAN, signal, 2, JBB);
12544 initCopyTc(signal, ZINSERT);
12545 set_acc_ptr_in_scan_record(scanptr.p, 0, nextScanConf->accOperationPtr);
12547 Fragrecord* fragPtrP= fragptr.p;
12548 scanptr.p->scanState = ScanRecord::WAIT_TUPKEY_COPY;
12549 tcConP->transactionState = TcConnectionrec::COPY_TUPKEY;
12550 if(tcConP->m_disk_table)
12552 next_scanconf_load_diskpage(signal, scanptr, tcConnectptr,fragPtrP);
12556 next_scanconf_tupkeyreq(signal, scanptr, tcConP, fragPtrP, RNIL);
12568 void Dblqh::execTRANSID_AI(
Signal* signal)
12574 tcConnectptr.i = signal->theData[0];
12575 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
12576 Uint32 length = signal->
length() - TransIdAI::HeaderLength;
12577 ndbrequire(tcConnectptr.p->transactionState == TcConnectionrec::COPY_TUPKEY);
12578 Uint32 * src = &signal->theData[ TransIdAI::HeaderLength ];
12579 bool ok= appendToSection(tcConnectptr.p->attrInfoIVal,
12582 if (unlikely(! ok))
12585 tcConnectptr.p->errorCode = ZGET_ATTRINBUF_ERROR;
12599 void Dblqh::copyTupkeyRefLab(
Signal* signal)
12603 scanptr.i = tcConnectptr.p->tcScanRec;
12604 c_scanRecordPool.
getPtr(scanptr);
12605 ScanRecord* scanP = scanptr.p;
12607 if (scanP->readCommitted == 0)
12621 ndbrequire(terrorCode == 626);
12624 ndbrequire(scanptr.p->scanState == ScanRecord::WAIT_TUPKEY_COPY);
12625 if (tcConnectptr.p->errorCode != 0)
12628 closeCopyLab(signal);
12632 if (scanptr.p->scanCompletedStatus == ZTRUE)
12635 closeCopyLab(signal);
12639 ndbrequire(tcConnectptr.p->copyCountWords < cmaxWordsAtNodeRec);
12640 scanptr.p->scanState = ScanRecord::WAIT_LQHKEY_COPY;
12641 nextRecordCopy(signal);
12644 void Dblqh::copyTupkeyConfLab(
Signal* signal)
12648 UintR readLength = tupKeyConf->readLength;
12649 Uint32 tableId = tcConnectptr.p->tableref;
12650 scanptr.i = tcConnectptr.p->tcScanRec;
12651 c_scanRecordPool.
getPtr(scanptr);
12652 ScanRecord* scanP = scanptr.p;
12654 if (scanP->readCommitted == 0)
12657 Uint32 accOpPtr= get_acc_ptr_from_scan_record(scanP, 0,
false);
12658 ndbassert(accOpPtr != (Uint32)-1);
12659 c_acc->execACCKEY_ORD(signal, accOpPtr);
12662 if (tcConnectptr.p->errorCode != 0) {
12664 closeCopyLab(signal);
12667 if (scanptr.p->scanCompletedStatus == ZTRUE) {
12672 closeCopyLab(signal);
12675 TcConnectionrec * tcConP = tcConnectptr.p;
12676 tcConnectptr.p->totSendlenAi = readLength;
12677 tcConnectptr.p->connectState = TcConnectionrec::COPY_CONNECTED;
12682 Uint32* tmp = signal->getDataPtrSend()+24;
12683 Uint32 len= tcConnectptr.p->primKeyLen = readPrimaryKeys(scanP, tcConP, tmp);
12685 tcConP->gci_hi = tmp[len];
12686 tcConP->gci_lo = 0;
12688 if (g_key_descriptor_pool.getPtr(tableId)->hasCharAttr)
12690 tcConnectptr.p->hashValue = calculateHash(tableId, tmp);
12694 tcConnectptr.p->hashValue = md5_hash((Uint64*)tmp, len);
12698 if (unlikely(!keyinfoLab(tmp, len)))
12704 scanptr.p->scanErrorCounter++;
12705 tcConP->errorCode= ZGET_DATAREC_ERROR;
12706 scanptr.p->scanCompletedStatus= ZTRUE;
12708 closeCopyLab(signal);
12712 LqhKeyReq::setKeyLen(tcConP->reqinfo, len);
12724 UintR TnoOfWords = readLength + len;
12725 scanP->m_curr_batch_size_bytes += 4 * TnoOfWords;
12726 TnoOfWords = TnoOfWords + MAGIC_CONSTANT;
12727 TnoOfWords = TnoOfWords + (TnoOfWords >> 2);
12744 tcConnectptr.p->transid[0] = TnoOfWords;
12745 packLqhkeyreqLab(signal);
12746 tcConnectptr.p->copyCountWords += TnoOfWords;
12747 scanptr.p->scanState = ScanRecord::WAIT_LQHKEY_COPY;
12748 if (tcConnectptr.p->copyCountWords < cmaxWordsAtNodeRec) {
12749 nextRecordCopy(signal);
12760 void Dblqh::copyCompletedLab(
Signal* signal)
12764 ndbrequire(tcConnectptr.p->transid[1] == lqhKeyConf->transId2);
12765 scanptr.i = tcConnectptr.p->tcScanRec;
12766 c_scanRecordPool.
getPtr(scanptr);
12767 if (tcConnectptr.p->copyCountWords >= cmaxWordsAtNodeRec) {
12768 tcConnectptr.p->copyCountWords -= lqhKeyConf->transId1;
12769 if (scanptr.p->scanCompletedStatus == ZTRUE) {
12774 closeCopyLab(signal);
12777 if (tcConnectptr.p->copyCountWords < cmaxWordsAtNodeRec) {
12779 nextRecordCopy(signal);
12783 tcConnectptr.p->copyCountWords -= lqhKeyConf->transId1;
12784 ndbrequire(tcConnectptr.p->copyCountWords <= cmaxWordsAtNodeRec);
12785 if (tcConnectptr.p->copyCountWords > 0) {
12795 if (scanptr.p->scanCompletedStatus == ZTRUE) {
12797 closeCopyLab(signal);
12801 if (scanptr.p->scanState == ScanRecord::WAIT_LQHKEY_COPY &&
12802 scanptr.p->scanErrorCounter)
12805 closeCopyLab(signal);
12809 if (scanptr.p->scanState == ScanRecord::WAIT_LQHKEY_COPY) {
12815 systemErrorLab(signal, __LINE__);
12821 void Dblqh::nextRecordCopy(
Signal* signal)
12823 fragptr.i = tcConnectptr.p->fragmentptr;
12824 c_fragment_pool.
getPtr(fragptr);
12825 scanptr.i = tcConnectptr.p->tcScanRec;
12826 c_scanRecordPool.
getPtr(scanptr);
12827 if (scanptr.p->scanState != ScanRecord::WAIT_LQHKEY_COPY) {
12834 systemErrorLab(signal, __LINE__);
12837 scanptr.p->scanState = ScanRecord::WAIT_NEXT_SCAN_COPY;
12844 linkFragQueue(signal);
12845 tcConnectptr.p->transactionState = TcConnectionrec::COPY_STOPPED;
12860 systemErrorLab(signal, __LINE__);
12864 continueCopyAfterBlockedLab(signal);
12868 void Dblqh::continueCopyAfterBlockedLab(
Signal* signal)
12870 scanptr.i = tcConnectptr.p->tcScanRec;
12871 c_scanRecordPool.
getPtr(scanptr);
12872 tcConnectptr.p->errorCode = 0;
12873 Uint32 acc_op_ptr= get_acc_ptr_from_scan_record(scanptr.p, 0,
false);
12874 if (acc_op_ptr != RNIL)
12876 signal->theData[0] = scanptr.p->scanAccPtr;
12877 signal->theData[1] = acc_op_ptr;
12878 signal->theData[2] = NextScanReq::ZSCAN_NEXT_COMMIT;
12879 sendSignal(scanptr.p->scanBlockref, GSN_NEXT_SCANREQ, signal, 3, JBB);
12886 signal->theData[0] = scanptr.p->scanAccPtr;
12887 signal->theData[1] = RNIL;
12888 signal->theData[2] = NextScanReq::ZSCAN_NEXT;
12889 sendSignal(scanptr.p->scanBlockref, GSN_NEXT_SCANREQ, signal, 3, JBB);
12894 void Dblqh::copyLqhKeyRefLab(
Signal* signal)
12896 ndbrequire(tcConnectptr.p->transid[1] == signal->theData[4]);
12897 Uint32 copyWords = signal->theData[3];
12898 scanptr.i = tcConnectptr.p->tcScanRec;
12899 c_scanRecordPool.
getPtr(scanptr);
12900 scanptr.p->scanErrorCounter++;
12901 tcConnectptr.p->errorCode = terrorCode;
12904 conf->transId1 = copyWords;
12905 conf->transId2 = tcConnectptr.p->transid[1];
12906 copyCompletedLab(signal);
12909 void Dblqh::closeCopyLab(
Signal* signal)
12911 if (tcConnectptr.p->copyCountWords > 0) {
12917 scanptr.p->scanState = ScanRecord::WAIT_LQHKEY_COPY;
12921 tcConnectptr.p->transid[0] = 0;
12922 tcConnectptr.p->transid[1] = 0;
12923 fragptr.i = tcConnectptr.p->fragmentptr;
12924 c_fragment_pool.
getPtr(fragptr);
12929 fragptr.p->m_copy_started_state = Fragrecord::AC_NORMAL;
12930 if (ERROR_INSERTED(5714))
12932 ndbout_c(
"Copy of tab: %u frag: %u complete",
12936 scanptr.i = tcConnectptr.p->tcScanRec;
12937 c_scanRecordPool.
getPtr(scanptr);
12938 scanptr.p->scanState = ScanRecord::WAIT_CLOSE_COPY;
12945 linkFragQueue(signal);
12946 tcConnectptr.p->transactionState = TcConnectionrec::COPY_CLOSE_STOPPED;
12961 systemErrorLab(signal, __LINE__);
12965 continueCloseCopyAfterBlockedLab(signal);
12969 void Dblqh::continueCloseCopyAfterBlockedLab(
Signal* signal)
12971 scanptr.i = tcConnectptr.p->tcScanRec;
12972 c_scanRecordPool.
getPtr(scanptr);
12973 signal->theData[0] = scanptr.p->scanAccPtr;
12974 signal->theData[1] = RNIL;
12975 signal->theData[2] = NextScanReq::ZSCAN_CLOSE;
12976 sendSignal(scanptr.p->scanBlockref, GSN_NEXT_SCANREQ, signal, 3, JBB);
12995 void Dblqh::accCopyCloseConfLab(
Signal* signal)
12997 tcConnectptr.i = scanptr.p->scanTcrec;
12998 scanptr.p->scanState = ScanRecord::WAIT_DELETE_STORED_PROC_ID_COPY;
12999 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
13000 signal->theData[0] = tcConnectptr.p->tupConnectrec;
13001 signal->theData[1] = tcConnectptr.p->tableref;
13002 signal->theData[2] = scanptr.p->scanSchemaVersion;
13003 signal->theData[3] = ZDELETE_STORED_PROC_ID;
13004 signal->theData[4] = scanptr.p->scanStoredProcId;
13005 signal->theData[5] = scanptr.p->scanApiBlockref;
13006 sendSignal(tcConnectptr.p->tcTupBlockref, GSN_STORED_PROCREQ, signal, 6, JBB);
13017 void Dblqh::tupCopyCloseConfLab(
Signal* signal)
13019 fragptr.i = tcConnectptr.p->fragmentptr;
13020 c_fragment_pool.
getPtr(fragptr);
13023 if (tcConnectptr.p->abortState == TcConnectionrec::NEW_FROM_TC) {
13025 tcNodeFailptr.i = tcConnectptr.p->tcNodeFailrec;
13026 ptrCheckGuard(tcNodeFailptr, ctcNodeFailrecFileSize, tcNodeFailRecord);
13027 tcNodeFailptr.p->tcRecNow = tcConnectptr.i + 1;
13028 signal->theData[0] = ZLQH_TRANS_NEXT;
13029 signal->theData[1] = tcNodeFailptr.i;
13030 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
13033 ref->userPtr = scanptr.p->copyPtr;
13034 ref->sendingNodeId = cownNodeid;
13035 ref->startingNodeId = scanptr.p->scanNodeId;
13036 ref->tableId = fragptr.p->
tabRef;
13037 ref->fragId = fragptr.p->
fragId;
13038 ref->errorCode = ZNODE_FAILURE_ERROR;
13039 sendSignal(tcConnectptr.p->clientBlockref, GSN_COPY_FRAGREF, signal,
13040 CopyFragRef::SignalLength, JBB);
13042 if (scanptr.p->scanErrorCounter > 0) {
13045 ref->userPtr = scanptr.p->copyPtr;
13046 ref->sendingNodeId = cownNodeid;
13047 ref->startingNodeId = scanptr.p->scanNodeId;
13048 ref->tableId = fragptr.p->
tabRef;
13049 ref->fragId = fragptr.p->
fragId;
13050 ref->errorCode = tcConnectptr.p->errorCode;
13051 sendSignal(tcConnectptr.p->clientBlockref, GSN_COPY_FRAGREF, signal,
13052 CopyFragRef::SignalLength, JBB);
13056 conf->userPtr = scanptr.p->copyPtr;
13057 conf->sendingNodeId = cownNodeid;
13058 conf->startingNodeId = scanptr.p->scanNodeId;
13059 conf->tableId = tcConnectptr.p->tableref;
13060 conf->fragId = tcConnectptr.p->fragmentid;
13061 conf->rows_lo = scanptr.p->m_curr_batch_size_rows;
13062 conf->bytes_lo = scanptr.p->m_curr_batch_size_bytes;
13063 sendSignal(tcConnectptr.p->clientBlockref, GSN_COPY_FRAGCONF, signal,
13064 CopyFragConf::SignalLength, JBB);
13067 releaseActiveCopy(signal);
13068 tcConnectptr.p->tcScanRec = RNIL;
13069 finishScanrec(signal);
13070 releaseOprec(signal);
13071 releaseTcrec(signal, tcConnectptr);
13072 releaseScanrec(signal);
13080 void Dblqh::closeCopyRequestLab(
Signal* signal)
13082 scanptr.p->scanErrorCounter++;
13083 if (0) ndbout_c(
"closeCopyRequestLab: scanState: %d", scanptr.p->scanState);
13084 switch (scanptr.p->scanState) {
13085 case ScanRecord::WAIT_TUPKEY_COPY:
13086 case ScanRecord::WAIT_NEXT_SCAN_COPY:
13092 scanptr.p->scanCompletedStatus = ZTRUE;
13093 tcConnectptr.p->copyCountWords = 0;
13095 case ScanRecord::WAIT_ACC_COPY:
13096 case ScanRecord::WAIT_STORED_PROC_COPY:
13102 scanptr.p->scanCompletedStatus = ZTRUE;
13104 case ScanRecord::WAIT_CLOSE_COPY:
13105 case ScanRecord::WAIT_DELETE_STORED_PROC_ID_COPY:
13111 case ScanRecord::WAIT_LQHKEY_COPY:
13118 tcConnectptr.p->copyCountWords = 0;
13119 closeCopyLab(signal);
13131 void Dblqh::execCOPY_ACTIVEREQ(
Signal* signal)
13133 CRASH_INSERTION(5026);
13137 Uint32 masterPtr = req->userPtr;
13138 BlockReference masterRef = req->userRef;
13139 tabptr.i = req->tableId;
13140 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
13141 Uint32 fragId = req->fragId;
13142 Uint32 flags = req->flags;
13143 if (unlikely(signal->getLength() < CopyActiveReq::SignalLength))
13149 ndbrequire(getFragmentrec(signal, fragId));
13155 TRACENR(
"tab: " << tabptr.i
13156 <<
" frag: " << fragId
13158 <<
" flags: " << hex << flags << endl);
13160 ndbrequire(cnoActiveCopy < 3);
13161 cactiveCopy[cnoActiveCopy] = fragptr.i;
13164 fragptr.p->masterPtr = masterPtr;
13166 if ((flags & CopyActiveReq::CAR_NO_LOGGING) == 0)
13169 if (fragptr.p->
lcpFlag == Fragrecord::LCP_STATE_TRUE)
13172 fragptr.p->
logFlag = Fragrecord::STATE_TRUE;
13176 if (flags & CopyActiveReq::CAR_NO_WAIT)
13180 Uint32 save = fragptr.p->
startGci;
13182 sendCopyActiveConf(signal, tabptr.i);
13193 signal->theData[0] = ZSCAN_TC_CONNECT;
13194 signal->theData[1] = 0;
13195 signal->theData[2] = tabptr.i;
13196 signal->theData[3] = fragId;
13197 sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB);
13201 void Dblqh::scanTcConnectLab(
Signal* signal, Uint32 tstartTcConnect, Uint32 fragId)
13203 Uint32 tendTcConnect;
13205 ndbrequire(getFragmentrec(signal, fragId));
13206 if ((tstartTcConnect + 200) >= ctcConnectrecFileSize) {
13208 tendTcConnect = ctcConnectrecFileSize - 1;
13211 tendTcConnect = tstartTcConnect + 200;
13213 for (tcConnectptr.i = tstartTcConnect;
13214 tcConnectptr.i <= tendTcConnect;
13215 tcConnectptr.i++) {
13217 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
13218 if (tcConnectptr.p->transactionState != TcConnectionrec::IDLE) {
13219 switch (tcConnectptr.p->logWriteState) {
13220 case TcConnectionrec::NOT_WRITTEN:
13222 if (fragptr.i == tcConnectptr.p->fragmentptr) {
13225 tcConnectptr.p->logWriteState = TcConnectionrec::NOT_WRITTEN_WAIT;
13235 if (tendTcConnect < (ctcConnectrecFileSize - 1)) {
13237 signal->theData[0] = ZSCAN_TC_CONNECT;
13238 signal->theData[1] = tendTcConnect + 1;
13239 signal->theData[2] = tabptr.i;
13240 signal->theData[3] = fragId;
13241 sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB);
13257 fragptr.p->
startGci = cnewestGci + 1;
13258 sendCopyActiveConf(signal, tabptr.i);
13270 void Dblqh::execCOPY_STATEREQ(
Signal* signal)
13275 Uint32* dataPtr = &signal->theData[2];
13276 BlockReference tmasterBlockref = signal->theData[0];
13277 Uint32 tnoCopy = 0;
13280 arrGuard(tnoCopy, 4);
13281 fragptr.i = cactiveCopy[tnoCopy];
13282 if (fragptr.i == RNIL) {
13286 c_fragment_pool.
getPtr(fragptr);
13292 scanptr.i = fragptr.p->fragScanRec[NR_ScanNo];
13293 c_scanRecordPool.
getPtr(scanptr);
13294 if (scanptr.p->scanCompletedStatus == ZTRUE) {
13296 dataPtr[3 + (tnoCopy << 2)] = ZCOPY_CLOSING;
13299 dataPtr[3 + (tnoCopy << 2)] = ZCOPY_ONGOING;
13301 dataPtr[2 + (tnoCopy << 2)] = scanptr.p->scanSchemaVersion;
13302 scanptr.p->scanApiBlockref = tmasterBlockref;
13310 dataPtr[3 + (tnoCopy << 2)] = ZCOPY_ACTIVATION;
13312 dataPtr[tnoCopy << 2] = fragptr.p->
tabRef;
13313 dataPtr[1 + (tnoCopy << 2)] = fragptr.p->
fragId;
13315 }
while (tnoCopy < cnoActiveCopy);
13316 signal->theData[0] = cownNodeid;
13317 signal->theData[1] = tnoCopy;
13318 sendSignal(tmasterBlockref, GSN_COPY_STATECONF, signal, 18, JBB);
13328 void Dblqh::initCopyTc(
Signal* signal, Operation_t op)
13330 tcConnectptr.p->operation = ZREAD;
13331 tcConnectptr.p->apiVersionNo = 0;
13332 tcConnectptr.p->opExec = 0;
13333 tcConnectptr.p->schemaVersion = scanptr.p->scanSchemaVersion;
13334 Uint32 reqinfo = 0;
13335 LqhKeyReq::setDirtyFlag(reqinfo, 1);
13336 LqhKeyReq::setSimpleFlag(reqinfo, 1);
13337 LqhKeyReq::setOperation(reqinfo, op);
13338 LqhKeyReq::setGCIFlag(reqinfo, 1);
13339 LqhKeyReq::setNrCopyFlag(reqinfo, 1);
13341 tcConnectptr.p->reqinfo = reqinfo;
13346 tcConnectptr.p->nodeAfterNext[0] = ZNIL;
13347 tcConnectptr.p->nodeAfterNext[1] = ZNIL;
13348 tcConnectptr.p->tcBlockref = cownref;
13349 tcConnectptr.p->readlenAi = 0;
13350 tcConnectptr.p->storedProcId = ZNIL;
13351 tcConnectptr.p->opExec = 0;
13352 tcConnectptr.p->nextSeqNoReplica = 0;
13353 tcConnectptr.p->dirtyOp = ZFALSE;
13354 tcConnectptr.p->lastReplicaNo = 0;
13355 tcConnectptr.p->currTupAiLen = 0;
13356 tcConnectptr.p->tcTimer = cLqhTimeOutCount;
13363 void Dblqh::sendCopyActiveConf(
Signal* signal, Uint32 tableId)
13365 releaseActiveCopy(signal);
13367 conf->userPtr = fragptr.p->masterPtr;
13368 conf->tableId = tableId;
13369 conf->fragId = fragptr.p->
fragId;
13370 conf->startingNodeId = cownNodeid;
13371 conf->startGci = fragptr.p->
startGci;
13372 sendSignal(fragptr.p->
masterBlockref, GSN_COPY_ACTIVECONF, signal,
13373 CopyActiveConf::SignalLength, JBB);
13385 void Dblqh::execEMPTY_LCP_REQ(
Signal* signal)
13388 CRASH_INSERTION(5008);
13391 ndbrequire(!isNdbMtLqh());
13394 ptrAss(lcpPtr, lcpRecord);
13396 Uint32 nodeId = refToNode(emptyLcpOrd->senderRef);
13398 lcpPtr.p->m_EMPTY_LCP_REQ.
set(nodeId);
13399 lcpPtr.p->reportEmpty =
true;
13401 if (lcpPtr.p->lcpState == LcpRecord::LCP_IDLE){
13404 switch(clcpCompletedState){
13407 sendEMPTY_LCP_CONF(signal,
true);
13411 sendEMPTY_LCP_CONF(signal,
false);
13413 case LCP_CLOSE_STARTED:
13415 case ACC_LCP_CLOSE_COMPLETED:
13417 case TUP_LCP_CLOSE_COMPLETED:
13429 #ifdef NDB_DEBUG_FULL
13430 static struct TraceLCP {
13431 void sendSignal(Uint32 ref, Uint32 gsn,
Signal* signal,
13432 Uint32 len, Uint32 prio);
13441 Uint32 theData[25];
13450 Dblqh::force_lcp(
Signal* signal)
13452 if (cLqhTimeOutCount == c_last_force_lcp_time)
13458 c_last_force_lcp_time = cLqhTimeOutCount;
13459 signal->theData[0] = 7099;
13460 sendSignal(DBDIH_REF, GSN_DUMP_STATE_ORD, signal, 1, JBB);
13463 void Dblqh::execLCP_FRAG_ORD(
Signal* signal)
13466 CRASH_INSERTION(5010);
13471 Uint32 lcpId = lcpFragOrd->lcpId;
13474 ptrAss(lcpPtr, lcpRecord);
13476 lcpPtr.p->lastFragmentFlag = lcpFragOrd->lastFragmentFlag;
13477 if (lcpFragOrd->lastFragmentFlag)
13480 CRASH_INSERTION(5054);
13481 if (lcpPtr.p->lcpState == LcpRecord::LCP_IDLE) {
13486 if (cnoOfFragsCheckpointed > 0) {
13488 completeLcpRoundLab(signal, lcpId);
13491 clcpCompletedState = LCP_IDLE;
13492 sendLCP_COMPLETE_REP(signal, lcpId);
13497 tabptr.i = lcpFragOrd->tableId;
13498 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
13501 ptrAss(lcpPtr, lcpRecord);
13502 ndbrequire(!lcpPtr.p->lcpQueued);
13504 if (c_lcpId < lcpFragOrd->lcpId)
13508 lcpPtr.p->firstFragmentFlag=
true;
13510 #ifdef ERROR_INSERT
13511 if (check_ndb_versions())
13518 if (! ((cnewestCompletedGci >= lcpFragOrd->keepGci) &&
13519 (cnewestGci >= lcpFragOrd->keepGci)))
13521 ndbout_c(
"lcpFragOrd->keepGci: %u cnewestCompletedGci: %u cnewestGci: %u",
13522 lcpFragOrd->keepGci, cnewestCompletedGci, cnewestGci);
13524 ndbrequire(cnewestCompletedGci >= lcpFragOrd->keepGci);
13525 ndbrequire(cnewestGci >= lcpFragOrd->keepGci);
13529 c_lcpId = lcpFragOrd->lcpId;
13530 ndbrequire(lcpPtr.p->lcpState == LcpRecord::LCP_IDLE);
13531 setLogTail(signal, lcpFragOrd->keepGci);
13532 ndbrequire(clcpCompletedState == LCP_IDLE);
13533 clcpCompletedState = LCP_RUNNING;
13536 if (! (tabptr.p->
tableStatus == Tablerec::TABLE_DEFINED || tabptr.p->
tableStatus == Tablerec::TABLE_READ_ONLY))
13539 LcpRecord::FragOrd fragOrd;
13540 fragOrd.fragPtrI = RNIL;
13541 fragOrd.lcpFragOrd = * lcpFragOrd;
13544 tmp.maxGciInLcp = cnewestGci;
13545 tmp.maxGciCompletedInLcp = cnewestCompletedGci;
13546 sendLCP_FRAG_REP(signal, fragOrd, &tmp);
13550 cnoOfFragsCheckpointed++;
13551 ndbrequire(getFragmentrec(signal, lcpFragOrd->fragmentId));
13553 if (lcpPtr.p->lcpState != LcpRecord::LCP_IDLE)
13555 ndbrequire(lcpPtr.p->lcpQueued ==
false);
13556 lcpPtr.p->lcpQueued =
true;
13557 lcpPtr.p->queuedFragment.fragPtrI = fragptr.i;
13558 lcpPtr.p->queuedFragment.lcpFragOrd = * lcpFragOrd;
13562 lcpPtr.p->currentFragment.fragPtrI = fragptr.i;
13563 lcpPtr.p->currentFragment.lcpFragOrd = * lcpFragOrd;
13565 sendLCP_FRAGIDREQ(signal);
13568 void Dblqh::execLCP_PREPARE_REF(
Signal* signal)
13574 lcpPtr.i = ref->senderData;
13575 ptrCheckGuard(lcpPtr, clcpFileSize, lcpRecord);
13576 ndbrequire(lcpPtr.p->lcpState == LcpRecord::LCP_WAIT_FRAGID);
13578 fragptr.i = lcpPtr.p->currentFragment.fragPtrI;
13579 c_fragment_pool.
getPtr(fragptr);
13581 ndbrequire(ref->tableId == fragptr.p->
tabRef);
13582 ndbrequire(ref->fragmentId == fragptr.p->
fragId);
13584 tabptr.i = ref->tableId;
13585 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
13587 ndbrequire(lcpPtr.p->m_outstanding);
13588 lcpPtr.p->m_outstanding--;
13593 ndbrequire(refToMain(signal->getSendersBlockRef()) == BACKUP);
13594 lcpPtr.p->m_error = ref->errorCode;
13596 if (lcpPtr.p->m_outstanding == 0)
13600 if(lcpPtr.p->firstFragmentFlag)
13604 lcpPtr.p->firstFragmentFlag=
false;
13609 *ord = lcpPtr.p->currentFragment.lcpFragOrd;
13617 *ord = lcpPtr.p->currentFragment.lcpFragOrd;
13619 signal, signal->
length(), 0);
13630 lcpPtr.p->lcpState = LcpRecord::LCP_COMPLETED;
13631 contChkpNextFragLab(signal);
13640 void Dblqh::execLCP_PREPARE_CONF(
Signal* signal)
13646 lcpPtr.i = conf->senderData;
13647 ptrCheckGuard(lcpPtr, clcpFileSize, lcpRecord);
13648 ndbrequire(lcpPtr.p->lcpState == LcpRecord::LCP_WAIT_FRAGID);
13650 fragptr.i = lcpPtr.p->currentFragment.fragPtrI;
13651 c_fragment_pool.
getPtr(fragptr);
13654 if (refToBlock(signal->getSendersBlockRef()) != PGMAN)
13656 ndbrequire(conf->tableId == fragptr.p->
tabRef);
13657 ndbrequire(conf->fragmentId == fragptr.p->
fragId);
13660 ndbrequire(lcpPtr.p->m_outstanding);
13661 lcpPtr.p->m_outstanding--;
13662 if (lcpPtr.p->m_outstanding == 0)
13666 if(lcpPtr.p->firstFragmentFlag)
13670 lcpPtr.p->firstFragmentFlag=
false;
13676 *ord = lcpPtr.p->currentFragment.lcpFragOrd;
13684 *ord = lcpPtr.p->currentFragment.lcpFragOrd;
13686 signal, signal->
length(), 0);
13697 if (lcpPtr.p->m_error)
13701 lcpPtr.p->lcpState = LcpRecord::LCP_COMPLETED;
13702 contChkpNextFragLab(signal);
13706 lcpPtr.p->lcpState = LcpRecord::LCP_WAIT_HOLDOPS;
13707 lcpPtr.p->lcpState = LcpRecord::LCP_START_CHKP;
13713 ndbrequire(lcpPtr.p->currentFragment.lcpFragOrd.lcpNo < MAX_LCP_STORED);
13714 fragptr.p->maxGciInLcp = fragptr.p->
newestGci;
13719 *ord = lcpPtr.p->currentFragment.lcpFragOrd;
13721 lgman.exec_lcp_frag_ord(signal);
13724 *ord = lcpPtr.p->currentFragment.lcpFragOrd;
13730 req->tableId = lcpPtr.p->currentFragment.lcpFragOrd.tableId;
13731 req->fragmentNo = 0;
13732 req->backupPtr = m_backup_ptr;
13733 req->backupId = lcpPtr.p->currentFragment.lcpFragOrd.lcpId;
13736 #ifdef NDB_DEBUG_FULL
13737 if(ERROR_INSERTED(5904))
13739 g_trace_lcp.sendSignal(BACKUP_REF, GSN_BACKUP_FRAGMENT_REQ, signal,
13740 BackupFragmentReq::SignalLength, JBB);
13745 if (ERROR_INSERTED(5044) &&
13746 (fragptr.p->
tabRef == c_error_insert_table_id) &&
13752 ndbout_c(
"table: %d frag: %d", fragptr.p->
tabRef, fragptr.p->
fragId);
13753 SET_ERROR_INSERT_VALUE(5027);
13754 sendSignalWithDelay(reference(), GSN_START_RECREQ, signal, 10000, 1);
13756 else if (ERROR_INSERTED(5053))
13758 BlockReference backupRef = calcInstanceBlockRef(BACKUP);
13759 sendSignalWithDelay(backupRef, GSN_BACKUP_FRAGMENT_REQ, signal,
13760 150, BackupFragmentReq::SignalLength);
13764 BlockReference backupRef = calcInstanceBlockRef(BACKUP);
13765 sendSignal(backupRef, GSN_BACKUP_FRAGMENT_REQ, signal,
13766 BackupFragmentReq::SignalLength, JBB);
13772 void Dblqh::execBACKUP_FRAGMENT_REF(
Signal* signal)
13777 "Unable to store fragment during LCP. NDBFS Error: %u",
13781 (ref->errorCode & FsRef::FS_ERR_BIT)?
13782 NDBD_EXIT_AFS_UNKNOWN
13787 void Dblqh::execBACKUP_FRAGMENT_CONF(
Signal* signal)
13793 ptrCheckGuard(lcpPtr, clcpFileSize, lcpRecord);
13794 ndbrequire(lcpPtr.p->lcpState == LcpRecord::LCP_START_CHKP);
13795 lcpPtr.p->lcpState = LcpRecord::LCP_COMPLETED;
13804 fragptr.i = lcpPtr.p->currentFragment.fragPtrI;
13805 c_fragment_pool.
getPtr(fragptr);
13810 #if defined VM_TRACE || defined ERROR_INSERT
13811 if (fragptr.p->
newestGci != fragptr.p->maxGciInLcp)
13813 ndbout_c(
"tab: %u frag: %u increasing maxGciInLcp from %u to %u",
13816 fragptr.p->maxGciInLcp, fragptr.p->
newestGci);
13820 fragptr.p->maxGciInLcp = fragptr.p->
newestGci;
13822 contChkpNextFragLab(signal);
13827 Dblqh::sendLCP_FRAG_REP(
Signal * signal,
13828 const LcpRecord::FragOrd & fragOrd,
13829 const Fragrecord * fragPtrP)
const
13831 ndbrequire(fragOrd.lcpFragOrd.lcpNo < MAX_LCP_STORED);
13833 lcpReport->nodeId = cownNodeid;
13834 lcpReport->lcpId = fragOrd.lcpFragOrd.lcpId;
13835 lcpReport->lcpNo = fragOrd.lcpFragOrd.lcpNo;
13836 lcpReport->tableId = fragOrd.lcpFragOrd.tableId;
13837 lcpReport->fragId = fragOrd.lcpFragOrd.fragmentId;
13838 lcpReport->maxGciCompleted = fragPtrP->maxGciCompletedInLcp;
13839 lcpReport->maxGciStarted = fragPtrP->maxGciInLcp;
13841 Uint32 ref = DBDIH_REF;
13847 lcpReport->nodeId = LcpFragRep::BROADCAST_REQ;
13848 sendSignal(ref, GSN_LCP_FRAG_REP, signal,
13849 LcpFragRep::SignalLength, JBB);
13852 void Dblqh::contChkpNextFragLab(
Signal* signal)
13865 lcpPtr.p->lcpState = LcpRecord::LCP_BLOCKED_COMP;
13872 sendLCP_FRAG_REP(signal, lcpPtr.p->currentFragment,
13873 c_fragment_pool.
getPtr(lcpPtr.p->currentFragment.fragPtrI));
13878 if (lcpPtr.p->lcpQueued) {
13883 lcpPtr.p->lcpQueued =
false;
13884 lcpPtr.p->currentFragment = lcpPtr.p->queuedFragment;
13889 sendLCP_FRAGIDREQ(signal);
13893 lcpPtr.p->lcpState = LcpRecord::LCP_IDLE;
13894 if (lcpPtr.p->lastFragmentFlag){
13899 completeLcpRoundLab(signal, lcpPtr.p->currentFragment.lcpFragOrd.lcpId);
13903 if (lcpPtr.p->reportEmpty) {
13905 sendEMPTY_LCP_CONF(signal,
false);
13910 void Dblqh::sendLCP_FRAGIDREQ(
Signal* signal)
13912 TablerecPtr tabPtr;
13913 tabPtr.i = lcpPtr.p->currentFragment.lcpFragOrd.tableId;
13914 ptrAss(tabPtr, tablerec);
13916 if(tabPtr.p->tableStatus != Tablerec::TABLE_DEFINED)
13922 contChkpNextFragLab(signal);
13926 lcpPtr.p->m_error = 0;
13927 lcpPtr.p->m_outstanding = 1;
13929 ndbrequire(tabPtr.p->tableStatus == Tablerec::TABLE_DEFINED ||
13930 tabPtr.p->tableStatus == Tablerec::TABLE_READ_ONLY);
13932 lcpPtr.p->lcpState = LcpRecord::LCP_WAIT_FRAGID;
13934 req->senderData = lcpPtr.i;
13935 req->senderRef = reference();
13936 req->lcpNo = lcpPtr.p->currentFragment.lcpFragOrd.lcpNo;
13937 req->tableId = lcpPtr.p->currentFragment.lcpFragOrd.tableId;
13938 req->fragmentId = lcpPtr.p->currentFragment.lcpFragOrd.fragmentId;
13939 req->lcpId = lcpPtr.p->currentFragment.lcpFragOrd.lcpId % MAX_LCP_STORED;
13940 req->backupPtr = m_backup_ptr;
13941 req->backupId = lcpPtr.p->currentFragment.lcpFragOrd.lcpId;
13942 BlockReference backupRef = calcInstanceBlockRef(BACKUP);
13943 sendSignal(backupRef, GSN_LCP_PREPARE_REQ, signal,
13944 LcpPrepareReq::SignalLength, JBB);
13948 void Dblqh::sendEMPTY_LCP_CONF(
Signal* signal,
bool idle)
13958 rep->senderNodeId = getOwnNodeId();
13962 rep->tableId = lcpPtr.p->currentFragment.lcpFragOrd.tableId;
13963 rep->fragmentId = lcpPtr.p->currentFragment.lcpFragOrd.fragmentId;
13964 rep->lcpNo = lcpPtr.p->currentFragment.lcpFragOrd.lcpNo;
13965 rep->lcpId = lcpPtr.p->currentFragment.lcpFragOrd.lcpId;
13970 rep->fragmentId = ~0;
13972 rep->lcpId = c_lcpId;
13975 lcpPtr.p->m_EMPTY_LCP_REQ.
copyto(NdbNodeBitmask::Size, sig->receiverGroup);
13976 sendSignal(DBDIH_REF, GSN_EMPTY_LCP_REP, signal,
13977 EmptyLcpRep::SignalLength + EmptyLcpConf::SignalLength, JBB);
13979 lcpPtr.p->reportEmpty =
false;
13980 lcpPtr.p->m_EMPTY_LCP_REQ.
clear();
13987 void Dblqh::completeLcpRoundLab(
Signal* signal, Uint32 lcpId)
13989 clcpCompletedState = LCP_CLOSE_STARTED;
13992 ptrAss(lcpPtr, lcpRecord);
13993 lcpPtr.p->m_outstanding = 0;
13996 req->senderData= lcpPtr.i;
13997 req->senderRef= reference();
13998 req->backupPtr= m_backup_ptr;
13999 req->backupId= lcpId;
14001 BlockReference backupRef = calcInstanceBlockRef(BACKUP);
14003 lcpPtr.p->m_outstanding++;
14004 sendSignal(backupRef, GSN_END_LCP_REQ, signal,
14005 EndLcpReq::SignalLength, JBB);
14010 lcpPtr.p->m_outstanding++;
14011 sendSignal(PGMAN_REF, GSN_END_LCP_REQ, signal,
14012 EndLcpReq::SignalLength, JBB);
14014 lcpPtr.p->m_outstanding++;
14015 sendSignal(LGMAN_REF, GSN_END_LCP_REQ, signal,
14016 EndLcpReq::SignalLength, JBB);
14019 signal, EndLcpReq::SignalLength, 0);
14030 void Dblqh::execEND_LCPCONF(
Signal* signal)
14034 ptrAss(lcpPtr, lcpRecord);
14036 ndbrequire(clcpCompletedState == LCP_CLOSE_STARTED);
14037 ndbrequire(lcpPtr.p->m_outstanding);
14039 lcpPtr.p->m_outstanding--;
14040 if(lcpPtr.p->m_outstanding == 0)
14043 clcpCompletedState = LCP_IDLE;
14044 sendLCP_COMPLETE_REP(signal, lcpPtr.p->currentFragment.lcpFragOrd.lcpId);
14046 CRASH_INSERTION(5056);
14050 void Dblqh::sendLCP_COMPLETE_REP(
Signal* signal, Uint32 lcpId)
14052 cnoOfFragsCheckpointed = 0;
14053 ndbrequire((cnoOfNodes - 1) < (MAX_NDB_NODES - 1));
14058 ptrAss(lcpPtr, lcpRecord);
14059 lcpPtr.p->lastFragmentFlag =
false;
14060 lcpPtr.p->firstFragmentFlag =
false;
14063 rep->nodeId = getOwnNodeId();
14064 rep->lcpId = lcpId;
14065 rep->blockNo = DBLQH;
14067 Uint32 ref = DBDIH_REF;
14073 rep->nodeId = LcpFragRep::BROADCAST_REQ;
14075 sendSignal(ref, GSN_LCP_COMPLETE_REP, signal,
14076 LcpCompleteRep::SignalLength, JBB);
14078 if(lcpPtr.p->reportEmpty){
14080 sendEMPTY_LCP_CONF(signal,
true);
14083 if (cstartRecReq < SRR_FIRST_LCP_DONE)
14086 ndbrequire(cstartRecReq == SRR_REDO_COMPLETE);
14087 cstartRecReq = SRR_FIRST_LCP_DONE;
14095 Dblqh::execLCP_COMPLETE_REP(
Signal* signal)
14101 Uint32 keepGci = rep->keepGci;
14102 setLogTail(signal, keepGci);
14113 void Dblqh::sendStartLcp(
Signal* signal)
14130 void Dblqh::setLogTail(
Signal* signal, Uint32 keepGci)
14132 LogPartRecordPtr sltLogPartPtr;
14133 LogFileRecordPtr sltLogFilePtr;
14135 UintR tsltStartMbyte;
14139 for (sltLogPartPtr.i = 0; sltLogPartPtr.i < clogPartFileSize; sltLogPartPtr.i++) {
14141 bool TchangeMB =
false;
14143 ptrAss(sltLogPartPtr, logPartRecord);
14144 findLogfile(signal, sltLogPartPtr.p->logTailFileNo,
14145 sltLogPartPtr, &sltLogFilePtr);
14147 tsltMbyte = sltLogPartPtr.p->logTailMbyte;
14148 tsltStartMbyte = tsltMbyte;
14150 if (sltLogFilePtr.i == sltLogPartPtr.p->currentLogfile) {
14154 if (sltLogFilePtr.p->currentMbyte >= sltLogPartPtr.p->logTailMbyte) {
14174 for (tsltIndex = tsltStartMbyte;
14175 tsltIndex <= clogFileSize - 1;
14177 if (sltLogFilePtr.p->logMaxGciStarted[tsltIndex] >= keepGci) {
14183 if (tsltIndex != 0) {
14185 tsltMbyte = tsltIndex - 1;
14191 tsltMbyte = clogFileSize - 1;
14192 sltLogFilePtr.i = sltLogFilePtr.p->prevLogFile;
14193 ptrCheckGuard(sltLogFilePtr, clogFileFileSize, logFileRecord);
14198 if (tsltFlag == ZTRUE) {
14203 if (tsltIndex == sltLogFilePtr.p->currentMbyte) {
14209 tsltMbyte = sltLogFilePtr.p->currentMbyte;
14215 sltLogFilePtr.i = sltLogFilePtr.p->nextLogFile;
14216 ptrCheckGuard(sltLogFilePtr, clogFileFileSize, logFileRecord);
14217 if (sltLogFilePtr.i == sltLogPartPtr.p->currentLogfile) {
14221 tsltStartMbyte = 0;
14226 UintR ToldTailFileNo = sltLogPartPtr.p->logTailFileNo;
14227 UintR ToldTailMByte = sltLogPartPtr.p->logTailMbyte;
14235 arrGuard(tsltMbyte, clogFileSize);
14236 sltLogPartPtr.p->logTailFileNo =
14237 sltLogFilePtr.p->logLastPrepRef[tsltMbyte] >> 16;
14238 sltLogPartPtr.p->logTailMbyte =
14239 sltLogFilePtr.p->logLastPrepRef[tsltMbyte] & 65535;
14243 ndbout_c(
"part: %u setLogTail(gci: %u): file: %u mb: %u",
14244 sltLogPartPtr.p->logPartNo,
14246 sltLogPartPtr.p->logTailFileNo,
14247 sltLogPartPtr.p->logTailMbyte);
14250 bool tailmoved = !(ToldTailFileNo == sltLogPartPtr.p->logTailFileNo &&
14251 ToldTailMByte == sltLogPartPtr.p->logTailMbyte);
14253 LogFileRecordPtr tmpfile;
14254 tmpfile.i = sltLogPartPtr.p->currentLogfile;
14255 ptrCheckGuard(tmpfile, clogFileFileSize, logFileRecord);
14257 LogPosition head = { tmpfile.p->fileNo, tmpfile.p->currentMbyte };
14258 LogPosition tail = { sltLogPartPtr.p->logTailFileNo,
14259 sltLogPartPtr.p->logTailMbyte};
14260 Uint64 mb = free_log(head, tail, sltLogPartPtr.p->noLogFiles,
14263 if (mb <= c_free_mb_force_lcp_limit)
14271 if (tailmoved && mb > c_free_mb_tail_problem_limit)
14274 update_log_problem(signal, sltLogPartPtr,
14275 LogPartRecord::P_TAIL_PROBLEM,
false);
14277 else if (!tailmoved && mb <= c_free_mb_force_lcp_limit)
14303 TcConnectionrecPtr tmp;
14304 tmp.i = sltLogPartPtr.p->firstLogTcrec;
14308 ptrCheckGuard(tmp, ctcConnectrecFileSize, tcConnectionrec);
14309 Uint32 fileNo = tmp.p->logStartFileNo;
14310 Uint32 mbyte = tmp.p->logStartPageNo >> ZTWOLOG_NO_PAGES_IN_MBYTE;
14312 if (fileNo == sltLogPartPtr.p->logTailFileNo &&
14313 mbyte == sltLogPartPtr.p->logTailMbyte)
14332 logPartPtr = sltLogPartPtr;
14334 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
14336 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
14337 changeMbyte(signal);
14361 #if defined VM_TRACE || defined ERROR_INSERT
14362 static Uint32 m_gcp_monitor = 0;
14365 void Dblqh::execGCP_SAVEREQ(
Signal* signal)
14370 CRASH_INSERTION(5000);
14372 if (ERROR_INSERTED(5007)){
14373 CLEAR_ERROR_INSERT_VALUE;
14374 sendSignalWithDelay(cownref, GSN_GCP_SAVEREQ, signal, 10000,
14379 if (unlikely(refToNode(signal->getSendersBlockRef()) != getOwnNodeId()))
14389 ndbassert(!isMultiThreaded());
14391 ndbassert(!ndb_check_micro_gcp
14393 (signal->getSendersBlockRef())).
m_version));
14394 EXECUTE_DIRECT(DBDIH, GSN_GCP_SAVEREQ, signal, signal->getLength());
14398 const Uint32 dihBlockRef = saveReq->dihBlockRef;
14399 const Uint32 dihPtr = saveReq->dihPtr;
14400 const Uint32 gci = saveReq->gci;
14402 #if defined VM_TRACE || defined ERROR_INSERT
14403 if (!isNdbMtLqh()) {
14404 ndbrequire(m_gcp_monitor == 0 ||
14405 (m_gcp_monitor == gci) ||
14406 (m_gcp_monitor + 1) == gci);
14408 m_gcp_monitor = gci;
14413 saveRef->dihPtr = dihPtr;
14414 saveRef->nodeId = getOwnNodeId();
14415 saveRef->gci = gci;
14416 saveRef->errorCode = GCPSaveRef::NodeShutdownInProgress;
14417 sendSignal(dihBlockRef, GSN_GCP_SAVEREF, signal,
14418 GCPSaveRef::SignalLength, JBB);
14422 Uint32 saveNewestCompletedGci = cnewestCompletedGci;
14423 cnewestCompletedGci = gci;
14425 if (cstartRecReq < SRR_REDO_COMPLETE)
14431 saveRef->dihPtr = dihPtr;
14432 saveRef->nodeId = getOwnNodeId();
14433 saveRef->gci = gci;
14434 saveRef->errorCode = GCPSaveRef::NodeRestartInProgress;
14435 sendSignal(dihBlockRef, GSN_GCP_SAVEREF, signal,
14436 GCPSaveRef::SignalLength, JBB);
14440 ndbrequire(gci >= saveNewestCompletedGci);
14442 if (gci == saveNewestCompletedGci)
14448 if (ccurrentGcprec == RNIL) {
14455 saveConf->dihPtr = dihPtr;
14456 saveConf->nodeId = getOwnNodeId();
14457 saveConf->gci = cnewestCompletedGci;
14458 sendSignal(dihBlockRef, GSN_GCP_SAVECONF, signal,
14459 GCPSaveConf::SignalLength, JBA);
14468 gcpPtr.i = ccurrentGcprec;
14469 ptrCheckGuard(gcpPtr, cgcprecFileSize, gcpRecord);
14475 ndbrequire(ccurrentGcprec == RNIL);
14476 cnewestCompletedGci = gci;
14477 if (gci > cnewestGci) {
14482 if(cstartRecReq < SRR_FIRST_LCP_DONE)
14488 saveRef->dihPtr = dihPtr;
14489 saveRef->nodeId = getOwnNodeId();
14490 saveRef->gci = gci;
14491 saveRef->errorCode = GCPSaveRef::NodeRestartInProgress;
14492 sendSignal(dihBlockRef, GSN_GCP_SAVEREF, signal,
14493 GCPSaveRef::SignalLength, JBB);
14495 if (ERROR_INSERTED(5052))
14498 signal->theData[0] = 9999;
14499 sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, 300, 1);
14504 CRASH_INSERTION(5052);
14506 #ifdef GCP_TIMER_HACK
14507 NdbTick_getMicroTimer(&globalData.gcp_timer_save[0]);
14510 ccurrentGcprec = 0;
14511 gcpPtr.i = ccurrentGcprec;
14512 ptrCheckGuard(gcpPtr, cgcprecFileSize, gcpRecord);
14516 gcpPtr.p->
gcpId = gci;
14517 bool tlogActive =
false;
14518 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
14519 ptrAss(logPartPtr, logPartRecord);
14528 signal->theData[0] = ZLOG_LQHKEYREQ;
14529 signal->theData[1] = logPartPtr.i;
14530 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
14536 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
14538 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
14539 writeCompletedGciLog(signal);
14542 if (tlogActive ==
true) {
14546 initGcpRecLab(signal);
14547 startTimeSupervision(signal);
14556 Dblqh::execSUB_GCP_COMPLETE_REP(
Signal* signal)
14559 Uint32 len = signal->getLength();
14561 sendSignal(SUMA_REF, GSN_SUB_GCP_COMPLETE_REP, signal, len, JBB);
14567 void Dblqh::startTimeSupervision(
Signal* signal)
14569 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
14571 ptrAss(logPartPtr, logPartRecord);
14578 signal->theData[0] = ZTIME_SUPERVISION;
14579 signal->theData[1] = logPartPtr.i;
14580 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
14589 void Dblqh::initGcpRecLab(
Signal* signal)
14596 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
14598 ptrAss(logPartPtr, logPartRecord);
14606 logPartPtr.p->
gcprec = 0;
14610 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
14611 gcpPtr.p->
gcpFilePtr[logPartPtr.i] = logFilePtr.i;
14613 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
14614 if (logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] == ZPAGE_HEADER_SIZE) {
14624 gcpPtr.p->
gcpWordNo[logPartPtr.i] = ZPAGE_SIZE - 1;
14634 for (Ti = clogPartFileSize; Ti < ZLOG_PART_FILE_SIZE; Ti++) {
14651 Dblqh::checkGcpCompleted(
Signal* signal,
14652 Uint32 tcgcPageWritten,
14653 Uint32 tcgcWordWritten)
14658 gcpPtr.i = logPartPtr.p->
gcprec;
14659 if (gcpPtr.i != RNIL)
14666 ptrCheckGuard(gcpPtr, cgcprecFileSize, gcpRecord);
14667 if (gcpPtr.p->
gcpFilePtr[logPartPtr.i] == logFilePtr.i) {
14672 if (tcgcPageWritten < gcpPtr.p->gcpPageNo[logPartPtr.i]) {
14679 if (tcgcPageWritten == gcpPtr.p->
gcpPageNo[logPartPtr.i]) {
14680 if (tcgcWordWritten < gcpPtr.p->gcpWordNo[logPartPtr.i]) {
14692 logPartPtr.p->
gcprec = RNIL;
14695 for (tcgcJ = 0; tcgcJ < clogPartFileSize; tcgcJ++)
14707 if (tcgcFlag == ZFALSE)
14712 if (tcgcFlag == ZTRUE)
14723 for (Ti = 0; Ti < clogPartFileSize; Ti++) {
14724 LogFileRecordPtr loopLogFilePtr;
14725 loopLogFilePtr.i = gcpPtr.p->
gcpFilePtr[Ti];
14726 ptrCheckGuard(loopLogFilePtr, clogFileFileSize, logFileRecord);
14729 signal->theData[0] = loopLogFilePtr.p->fileRef;
14730 signal->theData[1] = cownref;
14731 signal->theData[2] = gcpPtr.p->
gcpFilePtr[Ti];
14732 sendSignal(NDBFS_REF, GSN_FSSYNCREQ, signal, 3, JBA);
14734 ndbrequire((loopLogFilePtr.p->logFileStatus ==
14736 (loopLogFilePtr.p->logFileStatus ==
14738 (loopLogFilePtr.p->logFileStatus ==
14740 signal->theData[0] = loopLogFilePtr.i;
14741 execFSSYNCCONF(signal);
14752 Dblqh::execFSSYNCCONF(
Signal* signal)
14754 GcpRecordPtr localGcpPtr;
14755 LogFileRecordPtr localLogFilePtr;
14756 LogPartRecordPtr localLogPartPtr;
14757 localLogFilePtr.i = signal->theData[0];
14758 ptrCheckGuard(localLogFilePtr, clogFileFileSize, logFileRecord);
14759 localLogPartPtr.i = localLogFilePtr.p->logPartRec;
14760 ptrCheckGuard(localLogPartPtr, clogPartFileSize, logPartRecord);
14761 localGcpPtr.i = ccurrentGcprec;
14762 ptrCheckGuard(localGcpPtr, cgcprecFileSize, gcpRecord);
14763 localGcpPtr.p->gcpSyncReady[localLogPartPtr.i] = ZTRUE;
14768 ndbout_c(
"part: %u file: %u gci: %u SYNC CONF",
14769 localLogPartPtr.p->logPartNo,
14770 localLogFilePtr.p->fileNo,
14771 localGcpPtr.p->gcpId);
14773 for (Ti = 0; Ti < clogPartFileSize; Ti++) {
14775 if (localGcpPtr.p->gcpSyncReady[Ti] == ZFALSE) {
14781 #ifdef GCP_TIMER_HACK
14782 NdbTick_getMicroTimer(&globalData.gcp_timer_save[1]);
14786 saveConf->dihPtr = localGcpPtr.p->gcpUserptr;
14787 saveConf->nodeId = getOwnNodeId();
14788 saveConf->gci = localGcpPtr.p->gcpId;
14789 sendSignal(localGcpPtr.p->gcpBlockref, GSN_GCP_SAVECONF, signal,
14790 GCPSaveConf::SignalLength, JBA);
14791 ccurrentGcprec = RNIL;
14811 void Dblqh::execFSCLOSECONF(
Signal* signal)
14814 logFilePtr.i = signal->theData[0];
14815 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
14816 logFilePtr.p->
fileRef = RNIL;
14821 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
14822 ndbout_c(
"part: %u file: %u CLOSE CONF",
14828 case LogFileRecord::CLOSE_SR_READ_INVALIDATE_PAGES:
14833 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
14835 readFileInInvalidate(signal, 2);
14838 case LogFileRecord::CLOSE_SR_READ_INVALIDATE_SEARCH_FILES:
14843 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
14845 readFileInInvalidate(signal, 4);
14847 case LogFileRecord::CLOSE_SR_READ_INVALIDATE_SEARCH_LAST_FILE:
14851 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
14853 readFileInInvalidate(signal, 7);
14855 case LogFileRecord::CLOSE_SR_WRITE_INVALIDATE_PAGES:
14860 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
14862 writeFileInInvalidate(signal, 1);
14864 case LogFileRecord::CLOSING_INIT:
14866 logFileInitDone++ ;
14867 closingInitLab(signal);
14871 closingSrLab(signal);
14875 closeExecSrLab(signal);
14877 case LogFileRecord::CLOSING_EXEC_SR_COMPLETED:
14879 closeExecSrCompletedLab(signal);
14883 closeWriteLogLab(signal);
14885 case LogFileRecord::CLOSING_EXEC_LOG:
14887 closeExecLogLab(signal);
14889 #ifndef NO_REDO_OPEN_FILE_CACHE
14890 case LogFileRecord::CLOSING_EXEC_LOG_CACHED:
14893 release(signal, m_redo_open_file_cache);
14898 systemErrorLab(signal, __LINE__);
14907 void Dblqh::execFSOPENCONF(
Signal* signal)
14910 initFsopenconf(signal);
14912 case LogFileRecord::OPEN_SR_READ_INVALIDATE_PAGES:
14915 readFileInInvalidate(signal, 0);
14917 case LogFileRecord::OPEN_SR_READ_INVALIDATE_SEARCH_FILES:
14920 readFileInInvalidate(signal, 5);
14922 case LogFileRecord::OPEN_SR_WRITE_INVALIDATE_PAGES:
14925 writeFileInInvalidate(signal, 0);
14927 case LogFileRecord::OPENING_INIT:
14930 openFileInitLab(signal);
14935 openSrFrontpageLab(signal);
14940 openSrLastFileLab(signal);
14945 openSrNextFileLab(signal);
14950 openExecSrStartLab(signal);
14952 case LogFileRecord::OPEN_EXEC_SR_NEW_MBYTE:
14955 openExecSrNewMbyteLab(signal);
14957 case LogFileRecord::OPEN_SR_FOURTH_PHASE:
14960 openSrFourthPhaseLab(signal);
14962 case LogFileRecord::OPEN_SR_FOURTH_NEXT:
14965 openSrFourthNextLab(signal);
14967 case LogFileRecord::OPEN_SR_FOURTH_ZERO:
14970 openSrFourthZeroLab(signal);
14976 case LogFileRecord::OPEN_EXEC_LOG:
14979 #ifndef NO_REDO_OPEN_FILE_CACHE
14982 m_redo_open_file_cache.m_lru.addFirst(logFilePtr);
14985 case LogFileRecord::OPEN_EXEC_LOG_CACHED:
14988 openExecLogLab(signal);
14992 systemErrorLab(signal, __LINE__);
14998 Dblqh::execFSOPENREF(
Signal* signal)
15002 Uint32 err = ref->errorCode;
15003 if (err == FsRef::fsErrInvalidFileSize)
15007 "Invalid file size for redo logfile, "
15008 " size only changable with --initial");
15010 NDBD_EXIT_INVALID_CONFIG,
15015 SimulatedBlock::execFSOPENREF(signal);
15021 void Dblqh::execFSREADCONF(
Signal* signal)
15024 initFsrwconf(signal,
false);
15027 case LogFileOperationRecord::READ_SR_LAST_MBYTE:
15029 releaseLfo(signal);
15030 readSrLastMbyteLab(signal);
15034 releaseLfo(signal);
15035 readSrFrontpageLab(signal);
15039 releaseLfo(signal);
15040 readSrLastFileLab(signal);
15044 releaseLfo(signal);
15045 readSrNextFileLab(signal);
15047 case LogFileOperationRecord::READ_EXEC_SR:
15049 readExecSrLab(signal);
15051 case LogFileOperationRecord::READ_EXEC_LOG:
15053 readExecLogLab(signal);
15055 case LogFileOperationRecord::READ_SR_INVALIDATE_PAGES:
15057 invalidateLogAfterLastGCI(signal);
15059 case LogFileOperationRecord::READ_SR_INVALIDATE_SEARCH_FILES:
15061 invalidateLogAfterLastGCI(signal);
15063 case LogFileOperationRecord::READ_SR_FOURTH_PHASE:
15065 releaseLfo(signal);
15066 readSrFourthPhaseLab(signal);
15068 case LogFileOperationRecord::READ_SR_FOURTH_ZERO:
15070 releaseLfo(signal);
15071 readSrFourthZeroLab(signal);
15075 systemErrorLab(signal, __LINE__);
15083 void Dblqh::execFSREADREF(
Signal* signal)
15086 lfoPtr.i = signal->theData[0];
15087 ptrCheckGuard(lfoPtr, clfoFileSize, logFileOperationRecord);
15089 case LogFileOperationRecord::READ_SR_LAST_MBYTE:
15101 case LogFileOperationRecord::READ_EXEC_SR:
15104 case LogFileOperationRecord::READ_EXEC_LOG:
15107 case LogFileOperationRecord::READ_SR_FOURTH_PHASE:
15110 case LogFileOperationRecord::READ_SR_FOURTH_ZERO:
15113 case LogFileOperationRecord::READ_SR_INVALIDATE_PAGES:
15122 sprintf(msg,
"File system read failed during LogFileOperationRecord state %d", (Uint32)lfoPtr.p->
lfoState);
15123 fsRefError(signal,__LINE__,msg);
15130 void Dblqh::execFSWRITECONF(
Signal* signal)
15133 initFsrwconf(signal,
true);
15135 case LogFileOperationRecord::WRITE_SR_INVALIDATE_PAGES:
15137 invalidateLogAfterLastGCI(signal);
15138 CRASH_INSERTION(5047);
15140 case LogFileOperationRecord::WRITE_PAGE_ZERO:
15142 writePageZeroLab(signal, __LINE__);
15143 releaseLfo(signal);
15145 case LogFileOperationRecord::LAST_WRITE_IN_FILE:
15147 lastWriteInFileLab(signal);
15151 initWriteEndLab(signal);
15155 logMBytesInitDone++;
15156 initFirstPageLab(signal);
15158 case LogFileOperationRecord::WRITE_GCI_ZERO:
15160 writeGciZeroLab(signal);
15162 case LogFileOperationRecord::WRITE_DIRTY:
15164 writeDirtyLab(signal);
15166 case LogFileOperationRecord::WRITE_INIT_MBYTE:
15168 logMBytesInitDone++;
15169 writeInitMbyteLab(signal);
15173 writeLogfileLab(signal);
15175 case LogFileOperationRecord::FIRST_PAGE_WRITE_IN_LOGFILE:
15177 firstPageWriteLab(signal);
15179 case LogFileOperationRecord::WRITE_SR_INVALIDATE_PAGES_UPDATE_PAGE0:
15182 releaseLfo(signal);
15183 signal->theData[0] = ZSR_FOURTH_COMP;
15184 signal->theData[1] = logPartPtr.i;
15185 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
15189 systemErrorLab(signal, __LINE__);
15197 void Dblqh::execFSWRITEREF(
Signal* signal)
15200 lfoPtr.i = signal->theData[0];
15201 ptrCheckGuard(lfoPtr, clfoFileSize, logFileOperationRecord);
15202 terrorCode = signal->theData[1];
15204 case LogFileOperationRecord::WRITE_PAGE_ZERO:
15207 case LogFileOperationRecord::LAST_WRITE_IN_FILE:
15216 case LogFileOperationRecord::WRITE_GCI_ZERO:
15219 case LogFileOperationRecord::WRITE_DIRTY:
15222 case LogFileOperationRecord::WRITE_INIT_MBYTE:
15228 case LogFileOperationRecord::FIRST_PAGE_WRITE_IN_LOGFILE:
15231 case LogFileOperationRecord::WRITE_SR_INVALIDATE_PAGES:
15233 systemErrorLab(signal, __LINE__);
15240 sprintf(msg,
"File system write failed during LogFileOperationRecord state %d", (Uint32)lfoPtr.p->
lfoState);
15241 fsRefError(signal,__LINE__,msg);
15250 void Dblqh::initFsopenconf(
Signal* signal)
15252 logFilePtr.i = signal->theData[0];
15253 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
15254 logFilePtr.p->
fileRef = signal->theData[1];
15256 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
15265 void Dblqh::initFsrwconf(
Signal* signal,
bool write)
15267 LogPageRecordPtr logP;
15268 Uint32 noPages, totPages;
15269 lfoPtr.i = signal->theData[0];
15270 ptrCheckGuard(lfoPtr, clfoFileSize, logFileOperationRecord);
15273 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
15275 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
15277 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
15280 ndbassert(totPages > 0);
15284 Uint32 bytesWritten = totPages * 32768;
15290 logP.p->logPageWord[ZPOS_IN_WRITING]= 0;
15291 logP.p->logPageWord[ZPOS_IN_FREE_LIST]= 0;
15292 if (noPages == totPages)
15295 logP.i= logP.p->logPageWord[ZNEXT_PAGE];
15298 ptrCheckGuard(logP, clogPageFileSize, logPageRecord);
15315 void Dblqh::timeSup(
Signal* signal)
15317 LogPageRecordPtr origLogPagePtr;
15318 Uint32 wordWritten;
15321 logPartPtr.i = signal->theData[0];
15322 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
15324 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
15326 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
15342 if (((logFilePtr.p->
currentFilepage + 1) & (ZPAGES_IN_MBYTE -1)) == 0) {
15348 changeMbyte(signal);
15354 wordWritten = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] - 1;
15355 origLogPagePtr.i = logPagePtr.i;
15356 origLogPagePtr.p = logPagePtr.p;
15357 seizeLogpage(signal);
15359 &origLogPagePtr.p->logPageWord[0],
15361 ndbrequire(wordWritten < ZPAGE_SIZE);
15364 completedLogPage(signal, ZENFORCE_WRITE, __LINE__);
15374 if (wordWritten == (ZPAGE_HEADER_SIZE - 1)) {
15383 releaseLogpage(signal);
15387 wordWritten, __LINE__);
15399 void Dblqh::writeLogfileLab(
Signal* signal)
15406 case LogFileRecord::NOT_ONGOING:
15408 checkGcpCompleted(signal,
15413 case LogFileRecord::BOTH_WRITES_ONGOING:
15415 ndbout_c(
"not crashing!!");
15418 case LogFileRecord::WRITE_PAGE_ZERO_ONGOING:
15419 case LogFileRecord::LAST_WRITE_ONGOING:
15426 systemErrorLab(signal, __LINE__);
15430 releaseLfoPages(signal);
15431 releaseLfo(signal);
15435 void Dblqh::closeWriteLogLab(
Signal* signal)
15465 void Dblqh::firstPageWriteLab(
Signal* signal)
15467 releaseLfo(signal);
15471 Uint32 fileNo = logFilePtr.p->
fileNo;
15474 releaseLogpage(signal);
15483 if (logFilePtr.p->
fileChangeState == LogFileRecord::BOTH_WRITES_ONGOING) {
15492 ndbrequire(logFilePtr.p->
fileChangeState == LogFileRecord::FIRST_WRITE_ONGOING);
15496 logFilePtr.p->
fileChangeState = LogFileRecord::WRITE_PAGE_ZERO_ONGOING;
15503 writePageZeroLab(signal, __LINE__);
15515 Uint32 currLogFile = logFilePtr.i;
15517 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
15519 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
15520 logPagePtr.p->
logPageWord[ZPAGE_HEADER_SIZE + ZPOS_FILE_NO] = fileNo;
15521 writeSinglePage(signal, 0, ZPAGE_SIZE - 1, __LINE__);
15523 lfoPtr.p->
lfoState = LogFileOperationRecord::WRITE_PAGE_ZERO;
15529 void Dblqh::lastWriteInFileLab(
Signal* signal)
15531 LogFileRecordPtr locLogFilePtr;
15536 checkGcpCompleted(signal,
15539 releaseLfoPages(signal);
15540 releaseLfo(signal);
15545 ptrCheckGuard(locLogFilePtr, clogFileFileSize, logFileRecord);
15546 if (logFilePtr.i != locLogFilePtr.i) {
15547 if (logFilePtr.i != locLogFilePtr.p->nextLogFile) {
15548 if (logFilePtr.p->
fileNo != 0) {
15558 closeFile(signal, logFilePtr, __LINE__);
15572 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
15573 if (logFilePtr.p->
fileChangeState == LogFileRecord::BOTH_WRITES_ONGOING) {
15581 ndbrequire(logFilePtr.p->
fileChangeState == LogFileRecord::LAST_WRITE_ONGOING);
15585 logFilePtr.p->
fileChangeState = LogFileRecord::WRITE_PAGE_ZERO_ONGOING;
15586 Uint32 fileNo = logFilePtr.p->
fileNo;
15593 writePageZeroLab(signal, __LINE__);
15605 Uint32 currLogFile = logFilePtr.i;
15607 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
15609 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
15610 logPagePtr.p->
logPageWord[ZPAGE_HEADER_SIZE + ZPOS_FILE_NO] = fileNo;
15611 writeSinglePage(signal, 0, ZPAGE_SIZE - 1, __LINE__);
15613 lfoPtr.p->
lfoState = LogFileOperationRecord::WRITE_PAGE_ZERO;
15619 void Dblqh::writePageZeroLab(
Signal* signal, Uint32 from)
15621 if ((logPartPtr.p->m_log_problems & LogPartRecord::P_FILE_CHANGE_PROBLEM)!= 0)
15624 update_log_problem(signal, logPartPtr,
15625 LogPartRecord::P_FILE_CHANGE_PROBLEM,
15636 bool res = checkGcpCompleted(signal,
15641 gcpPtr.i = ccurrentGcprec;
15642 ptrCheckGuard(gcpPtr, cgcprecFileSize, gcpRecord);
15644 infoEvent(
"KESO completing GCP %u in writePageZeroLab from %u",
15645 gcpPtr.p->
gcpId, from);
15658 void Dblqh::openFileInitLab(
Signal* signal)
15661 seizeLogpage(signal);
15662 if (m_use_om_init == 0)
15665 initLogpage(signal);
15666 writeSinglePage(signal, (clogFileSize * ZPAGES_IN_MBYTE) - 1,
15667 ZPAGE_SIZE - 1, __LINE__,
false);
15674 initWriteEndLab(signal);
15679 void Dblqh::initWriteEndLab(
Signal* signal)
15681 releaseLfo(signal);
15682 initLogpage(signal);
15683 if (logFilePtr.p->
fileNo == 0) {
15690 logPagePtr.p->
logPageWord[ZPOS_MAX_GCI_STARTED] = 0;
15691 logPagePtr.p->
logPageWord[ZPOS_MAX_GCI_COMPLETED] = 0;
15698 writeFileHeaderOpen(signal, ZINIT);
15702 void Dblqh::initFirstPageLab(
Signal* signal)
15704 releaseLfo(signal);
15705 if (logFilePtr.p->
fileNo == 0) {
15711 initLogpage(signal);
15713 logPagePtr.p->
logPageWord[ZPAGE_HEADER_SIZE] = ZCOMPLETED_GCI_TYPE;
15714 logPagePtr.p->
logPageWord[ZPAGE_HEADER_SIZE + 1] = 1;
15715 writeSinglePage(signal, 1, ZPAGE_SIZE - 1, __LINE__,
false);
15716 lfoPtr.p->
lfoState = LogFileOperationRecord::WRITE_GCI_ZERO;
15720 writeInitMbyte(signal);
15724 void Dblqh::writeGciZeroLab(
Signal* signal)
15726 releaseLfo(signal);
15728 writeInitMbyte(signal);
15732 void Dblqh::writeInitMbyteLab(
Signal* signal)
15734 releaseLfo(signal);
15738 releaseLogpage(signal);
15740 closeFile(signal, logFilePtr, __LINE__);
15743 writeInitMbyte(signal);
15747 void Dblqh::closingInitLab(
Signal* signal)
15751 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
15754 checkInitCompletedLab(signal);
15759 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
15760 openLogfileInit(signal);
15765 void Dblqh::checkInitCompletedLab(
Signal* signal)
15773 logPartPtr.p->
logLap = 1;
15775 if (m_use_om_init && ++logPartPtr.i != clogPartFileSize)
15778 ptrAss(logPartPtr, logPartRecord);
15780 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
15781 openLogfileInit(signal);
15785 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++)
15788 ptrAss(logPartPtr, logPartRecord);
15800 enable_global_variables();
15802 logfileInitCompleteReport(signal);
15803 sendNdbSttorryLab(signal);
15810 void Dblqh::initLfo(
Signal* signal)
15826 void Dblqh::initLogfile(
Signal* signal, Uint32 fileNo)
15833 logFilePtr.p->
fileName[0] = (UintR)-1;
15834 logFilePtr.p->
fileName[1] = (UintR)-1;
15835 logFilePtr.p->
fileName[2] = fileNo;
15837 tilTmp = (tilTmp << 8) + 1;
15838 tilTmp = (tilTmp << 8) + (8 + logPartPtr.p->
logPartNo);
15839 tilTmp = (tilTmp << 8) + 255;
15840 logFilePtr.p->
fileName[3] = tilTmp;
15844 logFilePtr.p->
fileNo = fileNo;
15847 logFilePtr.p->lastLfo = RNIL;
15856 for (tilIndex = 0; tilIndex < clogFileSize; tilIndex++) {
15867 void Dblqh::initLogpage(
Signal* signal)
15869 TcConnectionrecPtr ilpTcConnectptr;
15872 logPagePtr.p->
logPageWord[ZPOS_MAX_GCI_COMPLETED] =
15874 logPagePtr.p->
logPageWord[ZPOS_MAX_GCI_STARTED] = cnewestGci;
15875 logPagePtr.p->
logPageWord[ZPOS_VERSION] = NDB_VERSION;
15877 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_HEADER_SIZE;
15879 if (ilpTcConnectptr.i != RNIL) {
15881 ptrCheckGuard(ilpTcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
15883 (ilpTcConnectptr.p->logStartFileNo << 16) +
15884 (ilpTcConnectptr.p->logStartPageNo >> ZTWOLOG_NO_PAGES_IN_MBYTE);
15888 (logFilePtr.p->
fileNo << 16) +
15898 void Dblqh::openFileRw(
Signal* signal,
15899 LogFileRecordPtr olfLogFilePtr,
15903 signal->theData[0] = cownref;
15904 signal->theData[1] = olfLogFilePtr.i;
15905 signal->theData[2] = olfLogFilePtr.p->fileName[0];
15906 signal->theData[3] = olfLogFilePtr.p->fileName[1];
15907 signal->theData[4] = olfLogFilePtr.p->fileName[2];
15908 signal->theData[5] = olfLogFilePtr.p->fileName[3];
15909 signal->theData[6] = FsOpenReq::OM_READWRITE | FsOpenReq::OM_AUTOSYNC | FsOpenReq::OM_CHECK_SIZE;
15911 signal->theData[6] |= FsOpenReq::OM_DIRECT;
15913 signal->theData[6] |= FsOpenReq::OM_WRITE_BUFFER;
15915 req->auto_sync_size = MAX_REDO_PAGES_WITHOUT_SYNCH *
sizeof(LogPageRecord);
15916 Uint64 sz = clogFileSize;
15917 sz *= 1024; sz *= 1024;
15918 req->file_size_hi = (Uint32)(sz >> 32);
15919 req->file_size_lo = (Uint32)(sz & 0xFFFFFFFF);
15920 sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA);
15928 void Dblqh::openLogfileInit(
Signal* signal)
15932 signal->theData[0] = cownref;
15933 signal->theData[1] = logFilePtr.i;
15934 signal->theData[2] = logFilePtr.p->
fileName[0];
15935 signal->theData[3] = logFilePtr.p->
fileName[1];
15936 signal->theData[4] = logFilePtr.p->
fileName[2];
15937 signal->theData[5] = logFilePtr.p->
fileName[3];
15938 signal->theData[6] = FsOpenReq::OM_READWRITE | FsOpenReq::OM_TRUNCATE | FsOpenReq::OM_CREATE | FsOpenReq::OM_AUTOSYNC | FsOpenReq::OM_WRITE_BUFFER;
15940 signal->theData[6] |= FsOpenReq::OM_DIRECT;
15942 Uint64 sz = Uint64(clogFileSize) * 1024 * 1024;
15943 req->file_size_hi = Uint32(sz >> 32);
15944 req->file_size_lo = Uint32(sz);
15945 req->page_size = File_formats::NDB_PAGE_SIZE;
15949 signal->theData[6] |= FsOpenReq::OM_INIT;
15952 req->auto_sync_size = MAX_REDO_PAGES_WITHOUT_SYNCH *
sizeof(LogPageRecord);
15953 sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA);
15957 Dblqh::execFSWRITEREQ(
Signal* signal)
15965 m_shared_page_pool.
getPtr(page_ptr, req->data.pageData[0]);
15967 LogFileRecordPtr currLogFilePtr;
15968 currLogFilePtr.i = req->userPointer;
15969 ptrCheckGuard(currLogFilePtr, clogFileFileSize, logFileRecord);
15971 LogPartRecordPtr currLogPartPtr;
15972 currLogPartPtr.i = currLogFilePtr.p->logPartRec;
15973 ptrCheckGuard(currLogPartPtr, clogPartFileSize, logPartRecord);
15975 Uint32 page_no = req->varIndex;
15976 LogPageRecordPtr currLogPagePtr;
15977 currLogPagePtr.p = (LogPageRecord*)page_ptr.p;
15979 bzero(page_ptr.p,
sizeof(LogPageRecord));
15984 else if (((page_no % ZPAGES_IN_MBYTE) == 0) ||
15985 (page_no == ((clogFileSize * ZPAGES_IN_MBYTE) - 1)))
15987 currLogPagePtr.p->logPageWord[ZPOS_LOG_LAP] = currLogPartPtr.p->logLap;
15988 currLogPagePtr.p->logPageWord[ZPOS_MAX_GCI_COMPLETED] =
15989 currLogPartPtr.p->logPartNewestCompletedGCI;
15990 currLogPagePtr.p->logPageWord[ZPOS_MAX_GCI_STARTED] = cnewestGci;
15991 currLogPagePtr.p->logPageWord[ZPOS_VERSION] = NDB_VERSION;
15992 currLogPagePtr.p->logPageWord[ZPOS_NO_LOG_FILES] =
15993 currLogPartPtr.p->noLogFiles;
15994 currLogPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_HEADER_SIZE;
15995 currLogPagePtr.p->logPageWord[ZLAST_LOG_PREP_REF] =
15996 (currLogFilePtr.p->fileNo << 16) +
15997 (currLogFilePtr.p->currentFilepage >> ZTWOLOG_NO_PAGES_IN_MBYTE);
15999 currLogPagePtr.p->logPageWord[ZNEXT_PAGE] = RNIL;
16000 currLogPagePtr.p->logPageWord[ZPOS_CHECKSUM] =
16001 calcPageCheckSum(currLogPagePtr);
16005 currLogPagePtr.p->logPageWord[ZNEXT_PAGE] = RNIL;
16006 currLogPagePtr.p->logPageWord[ZPOS_CHECKSUM] =
16007 calcPageCheckSum(currLogPagePtr);
16017 void Dblqh::openNextLogfile(
Signal* signal)
16019 LogFileRecordPtr onlLogFilePtr;
16029 ptrCheckGuard(onlLogFilePtr, clogFileFileSize, logFileRecord);
16031 ndbrequire(onlLogFilePtr.p->fileNo == 0);
16036 signal->theData[0] = cownref;
16037 signal->theData[1] = onlLogFilePtr.i;
16038 signal->theData[2] = onlLogFilePtr.p->fileName[0];
16039 signal->theData[3] = onlLogFilePtr.p->fileName[1];
16040 signal->theData[4] = onlLogFilePtr.p->fileName[2];
16041 signal->theData[5] = onlLogFilePtr.p->fileName[3];
16042 signal->theData[6] = FsOpenReq::OM_READWRITE | FsOpenReq::OM_AUTOSYNC | FsOpenReq::OM_CHECK_SIZE | FsOpenReq::OM_WRITE_BUFFER;
16044 signal->theData[6] |= FsOpenReq::OM_DIRECT;
16045 req->auto_sync_size = MAX_REDO_PAGES_WITHOUT_SYNCH *
sizeof(LogPageRecord);
16046 Uint64 sz = clogFileSize;
16047 sz *= 1024; sz *= 1024;
16048 req->file_size_hi = (Uint32)(sz >> 32);
16049 req->file_size_lo = (Uint32)(sz & 0xFFFFFFFF);
16050 sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA);
16059 void Dblqh::releaseLfo(
Signal* signal)
16063 LogFileOperationRecordPtr TlfoPtr;
16064 TlfoPtr.i = cfirstfreeLfo;
16065 while (TlfoPtr.i != RNIL){
16066 ptrCheckGuard(TlfoPtr, clfoFileSize, logFileOperationRecord);
16067 ndbrequire(TlfoPtr.i != lfoPtr.i);
16068 TlfoPtr.i = TlfoPtr.p->nextLfo;
16071 lfoPtr.p->
nextLfo = cfirstfreeLfo;
16073 cfirstfreeLfo = lfoPtr.i;
16082 void Dblqh::releaseLfoPages(
Signal* signal)
16085 while (logPagePtr.i != RNIL)
16087 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
16088 Uint32 tmp = logPagePtr.p->
logPageWord[ZNEXT_PAGE];
16089 releaseLogpage(signal);
16090 logPagePtr.i = tmp;
16099 void Dblqh::releaseLogpage(
Signal* signal)
16103 ndbrequire(logPagePtr.p->
logPageWord[ZPOS_IN_FREE_LIST] == 0);
16107 logPagePtr.p->
logPageWord[ZNEXT_PAGE] = cfirstfreeLogPage;
16110 cfirstfreeLogPage = logPagePtr.i;
16117 void Dblqh::seizeLfo(
Signal* signal)
16119 lfoPtr.i = cfirstfreeLfo;
16120 ptrCheckGuard(lfoPtr, clfoFileSize, logFileOperationRecord);
16121 cfirstfreeLfo = lfoPtr.p->
nextLfo;
16123 lfoPtr.p->
lfoTimer = cLqhTimeOutCount;
16130 void Dblqh::seizeLogfile(
Signal* signal)
16132 logFilePtr.i = cfirstfreeLogFile;
16133 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
16145 void Dblqh::seizeLogpage(
Signal* signal)
16148 logPagePtr.i = cfirstfreeLogPage;
16149 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
16153 cfirstfreeLogPage = logPagePtr.p->
logPageWord[ZNEXT_PAGE];
16155 bzero(logPagePtr.p,
sizeof(LogPageRecord));
16158 logPagePtr.p->
logPageWord[ZPOS_IN_FREE_LIST] = 0;
16169 void Dblqh::writeFileDescriptor(
Signal* signal)
16171 TcConnectionrecPtr wfdTcConnectptr;
16181 printf(
"part: %u file: %u setting logMaxGciCompleted[%u] = %u logMaxGciStarted[%u]: %u lastPrepRef[%u]: ",
16191 ndbout_c(
"file: %u mb: %u (RNIL)",
16198 ptrCheckGuard(wfdTcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
16199 ndbout_c(
"file: %u mb: %u",
16200 wfdTcConnectptr.p->logStartFileNo,
16201 wfdTcConnectptr.p->logStartPageNo >> ZTWOLOG_NO_PAGES_IN_MBYTE);
16208 if (wfdTcConnectptr.i != RNIL) {
16210 ptrCheckGuard(wfdTcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
16211 twfdFileNo = wfdTcConnectptr.p->logStartFileNo;
16212 twfdMbyte = wfdTcConnectptr.p->logStartPageNo >> ZTWOLOG_NO_PAGES_IN_MBYTE;
16214 (twfdFileNo << 16) + twfdMbyte;
16227 void Dblqh::writeFileHeaderOpen(
Signal* signal, Uint32 wmoType)
16229 UintR twmoNoLogDescriptors;
16234 logPagePtr.p->
logPageWord[ZPAGE_HEADER_SIZE + ZPOS_LOG_TYPE] = ZFD_TYPE;
16235 logPagePtr.p->
logPageWord[ZPAGE_HEADER_SIZE + ZPOS_FILE_NO] =
16237 if (logPartPtr.p->
noLogFiles > cmaxLogFilesInPageZero) {
16239 twmoNoLogDescriptors = cmaxLogFilesInPageZero;
16242 twmoNoLogDescriptors = logPartPtr.p->
noLogFiles;
16244 logPagePtr.p->
logPageWord[ZPAGE_HEADER_SIZE + ZPOS_NO_FD] =
16245 twmoNoLogDescriptors;
16248 Uint32 pos = ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE;
16249 LogFileRecordPtr filePtr = logFilePtr;
16250 for (Uint32 fd = 0; fd < twmoNoLogDescriptors; fd++)
16253 ptrCheckGuard(filePtr, clogFileFileSize, logFileRecord);
16254 for (Uint32 mb = 0; mb < clogFileSize; mb ++)
16257 Uint32 pos0 = pos + fd * (ZFD_MBYTE_SIZE * clogFileSize) + mb;
16258 Uint32 pos1 = pos0 + clogFileSize;
16259 Uint32 pos2 = pos1 + clogFileSize;
16260 arrGuard(pos0, ZPAGE_SIZE);
16261 arrGuard(pos1, ZPAGE_SIZE);
16262 arrGuard(pos2, ZPAGE_SIZE);
16263 logPagePtr.p->
logPageWord[pos0] = filePtr.p->logMaxGciCompleted[mb];
16264 logPagePtr.p->
logPageWord[pos1] = filePtr.p->logMaxGciStarted[mb];
16265 logPagePtr.p->
logPageWord[pos2] = filePtr.p->logLastPrepRef[mb];
16267 filePtr.i = filePtr.p->prevLogFile;
16269 pos += (twmoNoLogDescriptors * ZFD_MBYTE_SIZE * clogFileSize);
16270 arrGuard(pos, ZPAGE_SIZE);
16271 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = pos;
16272 logPagePtr.p->
logPageWord[pos] = ZNEXT_LOG_RECORD_TYPE;
16280 if (wmoType == ZINIT) {
16282 writeSinglePage(signal, 0, ZPAGE_SIZE - 1, __LINE__,
false);
16286 writeSinglePage(signal, 0, ZPAGE_SIZE - 1, __LINE__,
true);
16287 lfoPtr.p->
lfoState = LogFileOperationRecord::FIRST_PAGE_WRITE_IN_LOGFILE;
16290 if (wmoType == ZNORMAL) {
16296 seizeLogpage(signal);
16297 initLogpage(signal);
16312 void Dblqh::writeInitMbyte(
Signal* signal)
16314 if (m_use_om_init == 0)
16317 initLogpage(signal);
16318 writeSinglePage(signal, logFilePtr.p->
currentMbyte * ZPAGES_IN_MBYTE,
16319 ZPAGE_SIZE - 1, __LINE__,
false);
16320 lfoPtr.p->
lfoState = LogFileOperationRecord::WRITE_INIT_MBYTE;
16321 checkReportStatus(signal);
16328 writeInitMbyteLab(signal);
16338 void Dblqh::writeSinglePage(
Signal* signal, Uint32 pageNo,
16339 Uint32 wordWritten, Uint32 place,
16347 writeDbgInfoPageHeader(logPagePtr, place, pageNo, wordWritten);
16349 logPagePtr.p->
logPageWord[ZPOS_CHECKSUM] = calcPageCheckSum(logPagePtr);
16359 signal->theData[0] = logFilePtr.p->
fileRef;
16360 signal->theData[1] = cownref;
16361 signal->theData[2] = lfoPtr.i;
16362 signal->theData[3] = sync ? ZLIST_OF_PAIRS_SYNCH : ZLIST_OF_PAIRS;
16363 signal->theData[4] = ZVAR_NO_LOG_PAGE_WORD;
16364 signal->theData[5] = 1;
16365 signal->theData[6] = logPagePtr.i;
16366 signal->theData[7] = pageNo;
16367 sendSignal(NDBFS_REF, GSN_FSWRITEREQ, signal, 8, JBA);
16369 ndbrequire(logFilePtr.p->
fileRef != RNIL);
16375 ndbout_c(
"writeSingle 1 page at part: %u file: %u page: %u (mb: %u)",
16379 pageNo >> ZTWOLOG_NO_PAGES_IN_MBYTE);
16398 void Dblqh::openSrFrontpageLab(
Signal* signal)
16400 readSinglePage(signal, 0);
16411 void Dblqh::readSrFrontpageLab(
Signal* signal)
16413 Uint32 fileNo = logPagePtr.p->
logPageWord[ZPAGE_HEADER_SIZE + ZPOS_FILE_NO];
16419 readSrLastFileLab(signal);
16426 releaseLogpage(signal);
16428 closeFile(signal, logFilePtr, __LINE__);
16429 LogFileRecordPtr locLogFilePtr;
16430 findLogfile(signal, fileNo, logPartPtr, &locLogFilePtr);
16432 openFileRw(signal, locLogFilePtr);
16436 void Dblqh::openSrLastFileLab(
Signal* signal)
16438 readSinglePage(signal, 0);
16443 void Dblqh::readSrLastFileLab(
Signal* signal)
16448 ndbout_c(
"readSrLastFileLab part: %u logExecState: %u logPartState: %u logLap: %u",
16454 if (logPartPtr.p->
noLogFiles > cmaxLogFilesInPageZero) {
16456 initGciInLogFileRec(signal, cmaxLogFilesInPageZero);
16459 initGciInLogFileRec(signal, logPartPtr.p->
noLogFiles);
16461 releaseLogpage(signal);
16467 readSinglePage(signal, 0);
16468 lfoPtr.p->
lfoState = LogFileOperationRecord::READ_SR_LAST_MBYTE;
16473 void Dblqh::readSrLastMbyteLab(
Signal* signal)
16482 ndbout_c(
"readSrLastMbyteLab part: %u file: %u lastMbyte: %u",
16491 logPagePtr.p->
logPageWord[ZPOS_MAX_GCI_COMPLETED];
16496 releaseLogpage(signal);
16497 if (logFilePtr.p->
currentMbyte < (clogFileSize - 1)) {
16500 readSinglePage(signal, ZPAGES_IN_MBYTE * logFilePtr.p->
currentMbyte);
16501 lfoPtr.p->
lfoState = LogFileOperationRecord::READ_SR_LAST_MBYTE;
16511 logPartPtr.p->
lastMbyte = clogFileSize - 1;
16515 closeFile(signal, logFilePtr, __LINE__);
16516 if (logPartPtr.p->
noLogFiles > cmaxLogFilesInPageZero) {
16518 if (logFilePtr.p->
fileNo >= cmaxLogFilesInPageZero) {
16520 fileNo = logFilePtr.p->
fileNo - cmaxLogFilesInPageZero;
16525 cmaxLogFilesInPageZero;
16535 logPartPtr.p->
noLogFiles - (cmaxLogFilesInPageZero - 1);
16539 logPartPtr.p->
noLogFiles - cmaxLogFilesInPageZero;
16541 LogFileRecordPtr locLogFilePtr;
16542 findLogfile(signal, fileNo, logPartPtr, &locLogFilePtr);
16544 openFileRw(signal, locLogFilePtr);
16555 void Dblqh::openSrNextFileLab(
Signal* signal)
16557 readSinglePage(signal, 0);
16562 void Dblqh::readSrNextFileLab(
Signal* signal)
16566 initGciInLogFileRec(signal, cmaxLogFilesInPageZero);
16571 releaseLogpage(signal);
16573 closeFile(signal, logFilePtr, __LINE__);
16576 if (logFilePtr.p->
fileNo >= cmaxLogFilesInPageZero) {
16578 fileNo = logFilePtr.p->
fileNo - cmaxLogFilesInPageZero;
16583 cmaxLogFilesInPageZero;
16598 LogFileRecordPtr locLogFilePtr;
16599 findLogfile(signal, fileNo, logPartPtr, &locLogFilePtr);
16601 openFileRw(signal, locLogFilePtr);
16611 void Dblqh::closingSrLab(
Signal* signal)
16615 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
16619 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
16635 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
16637 ptrAss(logPartPtr, logPartRecord);
16649 signal->theData[0] = ZSR_PHASE3_START;
16650 signal->theData[1] = ZSR_PHASE1_COMPLETED;
16651 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
16671 void Dblqh::execSTART_FRAGREQ(
Signal* signal)
16676 tabptr.i = startFragReq->tableId;
16677 Uint32 fragId = startFragReq->fragId;
16679 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
16680 if (!getFragmentrec(signal, fragId)) {
16681 startFragRefLab(signal);
16686 Uint32 lcpNo = startFragReq->lcpNo;
16687 Uint32 noOfLogNodes = startFragReq->noOfLogNodes;
16688 Uint32 lcpId = startFragReq->lcpId;
16689 Uint32 requestInfo = startFragReq->requestInfo;
16690 if (signal->getLength() < StartFragReq::SignalLength)
16693 requestInfo = StartFragReq::SFR_RESTORE_LCP;
16696 bool doprint =
false;
16697 #ifdef ERROR_INSERT
16703 if (doprint || noOfLogNodes > 1)
16705 printSTART_FRAG_REQ(stdout, signal->getDataPtr(), signal->getLength(),
16709 ndbrequire(noOfLogNodes <= MAX_LOG_EXEC);
16711 fragptr.p->
srBlockref = startFragReq->userRef;
16712 fragptr.p->srUserptr = startFragReq->userPtr;
16714 if (lcpNo == (MAX_LCP_STORED - 1)) {
16716 fragptr.p->
lcpId[lcpNo] = lcpId;
16717 }
else if (lcpNo < (MAX_LCP_STORED - 1)) {
16719 fragptr.p->
lcpId[lcpNo] = lcpId;
16721 ndbrequire(lcpNo == ZNIL);
16724 fragptr.p->srNoLognodes = noOfLogNodes;
16725 fragptr.p->
logFlag = Fragrecord::STATE_FALSE;
16726 fragptr.p->srStatus = Fragrecord::SS_IDLE;
16728 if (requestInfo == StartFragReq::SFR_COPY_FRAG)
16730 ndbrequire(lcpNo == ZNIL);
16731 Uint32
n = fragptr.p->srLqhLognode[0] = startFragReq->lqhLogNode[0];
16732 ndbrequire(ndbd_non_trans_copy_frag_req(
getNodeInfo(n).m_version));
16738 if (noOfLogNodes > 0)
16741 for (Uint32 i = 0; i < noOfLogNodes; i++) {
16743 fragptr.p->srStartGci[
i] = startFragReq->startGci[
i];
16744 fragptr.p->srLastGci[
i] = startFragReq->lastGci[
i];
16745 fragptr.p->srLqhLognode[
i] = startFragReq->lqhLogNode[
i];
16747 fragptr.p->
newestGci = startFragReq->lastGci[noOfLogNodes - 1];
16763 if (requestInfo == StartFragReq::SFR_COPY_FRAG)
16767 else if (lcpNo == ZNIL)
16778 c_lcp_complete_fragments.add(fragptr);
16780 signal->theData[0] = tabptr.i;
16781 signal->theData[1] = fragId;
16782 BlockReference accRef = calcInstanceBlockRef(DBACC);
16783 sendSignal(accRef, GSN_EXPANDCHECK2, signal, 2, JBB);
16784 c_tup->disk_restart_lcp_id(tabptr.i, fragId, RNIL);
16791 c_tup->disk_restart_lcp_id(tabptr.i, fragId, lcpId);
16794 if (ERROR_INSERTED(5055))
16796 ndbrequire(c_lcpId == 0 || lcpId == 0 || c_lcpId == lcpId);
16802 c_lcpId = (c_lcpId == 0 ? lcpId : c_lcpId);
16803 c_lcpId = (c_lcpId < lcpId ? c_lcpId : lcpId);
16806 c_lcp_waiting_fragments.add(fragptr);
16807 if(c_lcp_restoring_fragments.isEmpty())
16808 send_restore_lcp(signal);
16812 Dblqh::send_restore_lcp(
Signal * signal)
16814 c_lcp_waiting_fragments.
first(fragptr);
16815 c_lcp_waiting_fragments.remove(fragptr);
16816 c_lcp_restoring_fragments.add(fragptr);
16822 req->senderData = fragptr.i;
16823 req->senderRef = reference();
16824 req->tableId = fragptr.p->
tabRef;
16825 req->fragmentId = fragptr.p->
fragId;
16828 BlockReference restoreRef = calcInstanceBlockRef(RESTORE);
16829 sendSignal(restoreRef, GSN_RESTORE_LCP_REQ, signal,
16830 RestoreLcpReq::SignalLength, JBB);
16836 tabptr.i = fragptr.p->
tabRef;
16837 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
16841 req->senderData = fragptr.i;
16842 req->senderRef = reference();
16843 req->tableId = fragptr.p->
tabRef;
16844 req->fragId = fragptr.p->
fragId;
16845 req->nodeId = getOwnNodeId();
16846 req->schemaVersion = tabptr.p->schemaVersion;
16847 req->distributionKey = 0;
16848 req->gci = fragptr.p->
lcpId[0];
16849 req->nodeCount = 0;
16850 req->nodeList[1] = CopyFragReq::CFR_NON_TRANSACTIONAL;
16852 BlockReference ref = numberToRef(DBLQH, instanceKey,
16853 fragptr.p->srLqhLognode[0]);
16855 sendSignal(ref, GSN_COPY_FRAGREQ, signal,
16856 CopyFragReq::SignalLength, JBB);
16861 Dblqh::execCOPY_FRAGREF(
Signal* signal)
16866 Uint32 errorCode = ref->errorCode;
16869 sysErr->errorCode = SystemError::CopyFragRefError;
16870 sysErr->errorRef = reference();
16871 sysErr->data[0] = errorCode;
16872 sysErr->data[1] = 0;
16873 sendSignal(NDBCNTR_REF, GSN_SYSTEM_ERROR, signal,
16874 SystemError::SignalLength, JBB);
16878 Dblqh::execCOPY_FRAGCONF(
Signal* signal)
16883 signal->getDataPtr());
16884 c_fragment_pool.
getPtr(fragptr, conf->senderData);
16887 Uint32 rows_lo = conf->rows_lo;
16888 Uint32 bytes_lo = conf->bytes_lo;
16890 signal->theData[1] = getOwnNodeId();
16891 signal->theData[2] = fragptr.p->
tabRef;
16892 signal->theData[3] = fragptr.p->
fragId;
16893 signal->theData[4] = rows_lo;
16894 signal->theData[5] = 0;
16895 signal->theData[6] = bytes_lo;
16896 signal->theData[7] = 0;
16897 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 8, JBB);
16902 conf->senderData = fragptr.i;
16903 execRESTORE_LCP_CONF(signal);
16907 void Dblqh::startFragRefLab(
Signal* signal)
16910 BlockReference userRef = startFragReq->userRef;
16911 Uint32 userPtr = startFragReq->userPtr;
16912 signal->theData[0] = userPtr;
16913 signal->theData[1] = terrorCode;
16914 signal->theData[2] = cownNodeid;
16915 sendSignal(userRef, GSN_START_FRAGREF, signal, 3, JBB);
16919 void Dblqh::execRESTORE_LCP_REF(
Signal* signal)
16926 void Dblqh::execRESTORE_LCP_CONF(
Signal* signal)
16930 fragptr.i = conf->senderData;
16931 c_fragment_pool.
getPtr(fragptr);
16933 c_lcp_restoring_fragments.remove(fragptr);
16934 c_lcp_complete_fragments.add(fragptr);
16940 tabptr.i = fragptr.p->
tabRef;
16941 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
16943 signal->theData[0] = fragptr.p->
tabRef;
16944 signal->theData[1] = fragptr.p->
fragId;
16945 BlockReference accRef = calcInstanceBlockRef(DBACC);
16946 sendSignal(accRef, GSN_EXPANDCHECK2, signal, 2, JBB);
16948 if (!c_lcp_waiting_fragments.isEmpty())
16950 send_restore_lcp(signal);
16954 if (c_lcp_restoring_fragments.isEmpty() &&
16955 cstartRecReq == SRR_START_REC_REQ_ARRIVED)
16967 csrExecUndoLogState = EULS_STARTED;
16969 ptrAss(lcpPtr, lcpRecord);
16970 lcpPtr.p->m_outstanding = 1;
16972 if (cstartType == NodeState::ST_INITIAL_NODE_RESTART)
16978 signal->theData[0] = LGMAN_REF;
16979 sendSignal(reference(), GSN_START_RECCONF, signal, 1, JBB);
16986 signal->theData[0] = c_lcpId;
16987 sendSignal(LGMAN_REF, GSN_START_RECREQ, signal, 1, JBB);
16992 signal->theData[0] = c_lcpId;
16993 signal->theData[1] = LGMAN;
16994 sendSignal(DBLQH_REF, GSN_START_RECREQ, signal, 2, JBB);
17003 void Dblqh::execSTART_RECREQ(
Signal* signal)
17005 CRASH_INSERTION(5027);
17009 cmasterDihBlockref = req->senderRef;
17011 crestartOldestGci = req->keepGci;
17012 crestartNewestGci = req->lastCompletedGci;
17013 cnewestGci = req->newestGci;
17014 cstartRecReqData = req->senderData;
17016 if (check_ndb_versions())
17018 ndbrequire(crestartOldestGci <= crestartNewestGci);
17021 ndbrequire(req->receivingNodeId == cownNodeid);
17023 cnewestCompletedGci = cnewestGci;
17024 cstartRecReq = SRR_START_REC_REQ_ARRIVED;
17026 if (signal->getLength() == StartRecReq::SignalLength)
17030 tmp.
assign(NdbNodeBitmask::Size, req->sr_nodes);
17031 if (!tmp.
equal(m_sr_nodes))
17033 char buf0[100], buf1[100];
17034 ndbout_c(
"execSTART_RECREQ chaning srnodes from %s to %s",
17039 m_sr_nodes.
assign(NdbNodeBitmask::Size, req->sr_nodes);
17044 cstartRecReqData = RNIL;
17047 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
17048 ptrAss(logPartPtr, logPartRecord);
17059 if (c_lcp_restoring_fragments.isEmpty())
17062 csrExecUndoLogState = EULS_STARTED;
17065 ptrAss(lcpPtr, lcpRecord);
17066 lcpPtr.p->m_outstanding = 1;
17068 if (cstartType == NodeState::ST_INITIAL_NODE_RESTART)
17074 signal->theData[0] = LGMAN_REF;
17075 sendSignal(reference(), GSN_START_RECCONF, signal, 1, JBB);
17082 signal->theData[0] = c_lcpId;
17083 sendSignal(LGMAN_REF, GSN_START_RECREQ, signal, 1, JBB);
17088 signal->theData[0] = c_lcpId;
17089 signal->theData[1] = LGMAN;
17090 sendSignal(DBLQH_REF, GSN_START_RECREQ, signal, 2, JBB);
17098 void Dblqh::execSTART_RECCONF(
Signal* signal)
17102 ptrAss(lcpPtr, lcpRecord);
17103 ndbrequire(csrExecUndoLogState == EULS_STARTED);
17104 ndbrequire(lcpPtr.p->m_outstanding);
17106 Uint32 sender= signal->theData[0];
17108 if (ERROR_INSERTED(5055))
17110 CLEAR_ERROR_INSERT_VALUE;
17113 lcpPtr.p->m_outstanding--;
17114 if(lcpPtr.p->m_outstanding)
17120 switch(refToBlock(sender)){
17126 lcpPtr.p->m_outstanding++;
17130 signal->theData[0] = c_lcpId;
17131 sendSignal(TSMAN_REF, GSN_START_RECREQ, signal, 1, JBB);
17136 signal->theData[0] = c_lcpId;
17137 signal->theData[1] = TSMAN;
17138 sendSignal(DBLQH_REF, GSN_START_RECREQ, signal, 2, JBB);
17147 csrExecUndoLogState = EULS_COMPLETED;
17149 if(cstartType == NodeState::ST_INITIAL_NODE_RESTART)
17152 cstartRecReq = SRR_REDO_COMPLETE;
17154 rebuildOrderedIndexes(signal, 0);
17158 startExecSr(signal);
17164 void Dblqh::execSTART_RECREF(
Signal* signal)
17171 Dblqh::rebuildOrderedIndexes(
Signal* signal, Uint32 tableId)
17178 infoEvent(
"LQH: Starting to rebuild ordered indexes");
17181 if (tableId >= ctabrecFileSize)
17185 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++)
17188 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
17189 LogFileRecordPtr logFile;
17191 ptrCheckGuard(logFile, clogFileFileSize, logFileRecord);
17193 LogPosition head = { logFile.p->fileNo, logFile.p->currentMbyte };
17195 logPartPtr.p->logTailMbyte};
17196 Uint64 mb = free_log(head, tail, logPartPtr.p->
noLogFiles, clogFileSize);
17197 if (mb <= c_free_mb_tail_problem_limit)
17200 update_log_problem(signal, logPartPtr,
17201 LogPartRecord::P_TAIL_PROBLEM,
true);
17210 signal->theData[0] = 12003;
17211 sendSignal(LGMAN_REF, GSN_DUMP_STATE_ORD, signal, 1, JBB);
17215 conf->startingNodeId = getOwnNodeId();
17216 conf->senderData = cstartRecReqData;
17217 sendSignal(cmasterDihBlockref, GSN_START_RECCONF, signal,
17218 StartRecConf::SignalLength, JBB);
17220 infoEvent(
"LQH: Rebuild ordered indexes complete");
17224 tabptr.i = tableId;
17225 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
17226 if (! (DictTabInfo::isOrderedIndex(tabptr.p->
tableType) &&
17227 tabptr.p->
tableStatus == Tablerec::TABLE_DEFINED))
17230 signal->theData[0] = ZREBUILD_ORDERED_INDEXES;
17231 signal->theData[1] = tableId + 1;
17232 sendSignal(reference(), GSN_CONTINUEB, signal, 2, JBB);
17236 signal->theData[0] = NDB_LE_RebuildIndex;
17237 signal->theData[1] = instance();
17238 signal->theData[2] = tableId;
17239 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 3, JBB);
17242 req->senderRef = reference();
17243 req->senderData = tableId;
17244 req->requestType = BuildIndxImplReq::RF_BUILD_OFFLINE;
17249 req->indexId = tableId;
17250 req->tableId = tabptr.p->primaryTableId;
17251 req->parallelism = 0;
17252 sendSignal(calcInstanceBlockRef(DBTUP), GSN_BUILD_INDX_IMPL_REQ, signal,
17253 BuildIndxImplReq::SignalLength, JBB);
17257 Dblqh::execBUILD_INDX_IMPL_REF(
Signal * signal)
17264 Dblqh::execBUILD_INDX_IMPL_CONF(
Signal* signal)
17268 Uint32 tableId = conf->senderData;
17269 rebuildOrderedIndexes(signal, tableId + 1);
17270 infoEvent(
"LQH: index %u rebuild done", tableId);
17276 void Dblqh::execSTART_EXEC_SR(
Signal* signal)
17279 fragptr.i = signal->theData[0];
17280 Uint32 next = RNIL;
17282 if (fragptr.i == RNIL)
17293 signal->theData[0] = cownNodeid;
17298 sendSignal(rg, GSN_EXEC_SRREQ, signal, 1, JBB);
17303 const Uint32 sz = NdbNodeBitmask::Size;
17304 m_sr_nodes.
copyto(sz, &signal->theData[1]);
17305 sendSignal(DBLQH_REF, GSN_EXEC_SRREQ, signal, 1 + sz, JBB);
17310 c_lcp_complete_fragments.
getPtr(fragptr);
17311 next = fragptr.p->nextList;
17313 if (fragptr.p->srNoLognodes > csrPhasesCompleted)
17316 cnoOutstandingExecFragReq++;
17318 Uint32 index = csrPhasesCompleted;
17319 arrGuard(index, MAX_LOG_EXEC);
17320 Uint32 Tnode = fragptr.p->srLqhLognode[
index];
17322 BlockReference ref = numberToRef(DBLQH, instanceKey, Tnode);
17323 fragptr.p->srStatus = Fragrecord::SS_STARTED;
17331 execFragReq->userPtr = fragptr.i;
17332 execFragReq->userRef = cownref;
17333 execFragReq->tableId = fragptr.p->
tabRef;
17334 execFragReq->fragId = fragptr.p->
fragId;
17335 execFragReq->startGci = fragptr.p->srStartGci[index];
17336 execFragReq->lastGci = fragptr.p->srLastGci[index];
17337 execFragReq->dst = ref;
17343 sendSignal(DBLQH_REF, GSN_EXEC_FRAGREQ, signal,
17344 ExecFragReq::SignalLength, JBB);
17346 else if (ndb_route_exec_frag(
getNodeInfo(refToNode(ref)).m_version))
17350 sendSignal(numberToRef(DBLQH, refToNode(ref)), GSN_EXEC_FRAGREQ, signal,
17351 ExecFragReq::SignalLength, JBB);
17357 sendSignal(ref, GSN_EXEC_FRAGREQ, signal,
17358 ExecFragReq::SignalLength, JBB);
17361 signal->theData[0] = next;
17362 sendSignal(cownref, GSN_START_EXEC_SR, signal, 1, JBB);
17374 void Dblqh::execEXEC_FRAGREQ(
Signal* signal)
17378 tabptr.i = execFragReq->tableId;
17379 Uint32 fragId = execFragReq->fragId;
17380 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
17381 ndbrequire(getFragmentrec(signal, fragId));
17390 cnoFragmentsExecSr++;
17394 void Dblqh::sendExecFragRefLab(
Signal* signal)
17397 BlockReference retRef = execFragReq->userRef;
17398 Uint32 retPtr = execFragReq->userPtr;
17400 signal->theData[0] = retPtr;
17401 signal->theData[1] = terrorCode;
17402 sendSignal(retRef, GSN_EXEC_FRAGREF, signal, 2, JBB);
17409 void Dblqh::execEXEC_FRAGCONF(
Signal* signal)
17412 fragptr.i = signal->theData[0];
17413 c_fragment_pool.
getPtr(fragptr);
17414 fragptr.p->srStatus = Fragrecord::SS_COMPLETED;
17416 ndbrequire(cnoOutstandingExecFragReq);
17417 cnoOutstandingExecFragReq--;
17418 if (fragptr.p->srNoLognodes == csrPhasesCompleted + 1)
17422 fragptr.p->
logFlag = Fragrecord::STATE_TRUE;
17425 signal->theData[0] = fragptr.p->srUserptr;
17426 signal->theData[1] = cownNodeid;
17427 sendSignal(fragptr.p->
srBlockref, GSN_START_FRAGCONF, signal, 2, JBB);
17436 void Dblqh::execEXEC_FRAGREF(
Signal* signal)
17439 terrorCode = signal->theData[1];
17440 systemErrorLab(signal, __LINE__);
17447 void Dblqh::execEXEC_SRCONF(
Signal* signal)
17450 Uint32 nodeId = signal->theData[0];
17451 arrGuard(nodeId, MAX_NDB_NODES);
17452 m_sr_exec_sr_conf.
set(nodeId);
17454 if (!m_sr_nodes.
equal(m_sr_exec_sr_conf))
17464 if (cnoOutstandingExecFragReq != 0)
17473 m_sr_exec_sr_conf.
clear(nodeId);
17474 ndbout <<
"delay: reqs=" << cnoOutstandingExecFragReq << endl;
17475 sendSignalWithDelay(reference(), GSN_EXEC_SRCONF,
17476 signal, 10, signal->getLength());
17484 m_sr_exec_sr_conf.
clear();
17485 cnoFragmentsExecSr = 0;
17491 ndbrequire(cnoOutstandingExecFragReq == 0);
17493 execSrCompletedLab(signal);
17497 void Dblqh::execSrCompletedLab(
Signal* signal)
17499 csrPhasesCompleted++;
17504 if (csrPhasesCompleted >= MAX_LOG_EXEC) {
17518 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
17520 ptrAss(logPartPtr, logPartRecord);
17522 logPartPtr.p->
logLastGci = crestartNewestGci;
17524 logPartPtr.p->
logExecState = LogPartRecord::LES_SEARCH_STOP;
17532 systemErrorLab(signal, __LINE__);
17538 ndbout_c(
"part: %u srLogLimits SR_FOURTH_PHASE %u-%u (file: %u mb: %u)",
17546 signal->theData[0] = ZSR_LOG_LIMITS;
17547 signal->theData[1] = logPartPtr.i;
17549 signal->theData[3] = logPartPtr.p->
lastMbyte;
17550 sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB);
17559 csrPhaseStarted = ZSR_PHASE1_COMPLETED;
17560 startExecSr(signal);
17568 void Dblqh::execEXEC_SRREQ(
Signal* signal)
17571 Uint32 nodeId = signal->theData[0];
17572 ndbrequire(nodeId < MAX_NDB_NODES);
17573 m_sr_exec_sr_req.
set(nodeId);
17574 if (!m_sr_exec_sr_req.
equal(m_sr_nodes))
17584 m_sr_exec_sr_req.
clear();
17586 if (csrPhasesCompleted != 0) {
17590 if (cnoFragmentsExecSr == 0) {
17595 srPhase3Comp(signal);
17606 signal->theData[0] = ZSR_PHASE3_START;
17607 signal->theData[1] = ZSR_PHASE2_COMPLETED;
17608 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
17628 void Dblqh::srPhase3Start(
Signal* signal)
17630 UintR tsrPhaseStarted;
17634 tsrPhaseStarted = signal->theData[1];
17635 if (csrPhaseStarted == ZSR_NO_PHASE_STARTED) {
17637 csrPhaseStarted = tsrPhaseStarted;
17640 ndbrequire(csrPhaseStarted != tsrPhaseStarted);
17641 ndbrequire(csrPhaseStarted != ZSR_BOTH_PHASES_STARTED);
17643 csrPhaseStarted = ZSR_BOTH_PHASES_STARTED;
17644 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
17646 ptrAss(logPartPtr, logPartRecord);
17649 if (csrPhasesCompleted == 0) {
17654 logPartPtr.p->
logLastGci = crestartNewestGci;
17662 c_lcp_complete_fragments.
first(fragptr);
17663 signal->theData[0] = ZSR_GCI_LIMITS;
17664 signal->theData[1] = fragptr.i;
17665 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
17673 void Dblqh::srGciLimits(
Signal* signal)
17676 fragptr.i = signal->theData[0];
17677 Uint32 loopCount = 0;
17679 ptrAss(logPartPtr, logPartRecord);
17680 while (fragptr.i != RNIL){
17682 c_lcp_complete_fragments.
getPtr(fragptr);
17697 if (loopCount > 20) {
17699 signal->theData[0] = ZSR_GCI_LIMITS;
17700 signal->theData[1] = fragptr.p->nextList;
17701 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
17705 fragptr.i = fragptr.p->nextList;
17719 for(Uint32 i = 1; i < clogPartFileSize; i++)
17721 LogPartRecordPtr tmp;
17723 ptrAss(tmp, logPartRecord);
17725 tmp.p->logLastGci = logPartPtr.p->
logLastGci;
17728 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
17730 ptrAss(logPartPtr, logPartRecord);
17731 logPartPtr.p->
logExecState = LogPartRecord::LES_SEARCH_STOP;
17734 ndbout_c(
"part: %u srLogLimits (srGciLimits) %u-%u (file: %u mb: %u)",
17741 signal->theData[0] = ZSR_LOG_LIMITS;
17742 signal->theData[1] = logPartPtr.i;
17744 signal->theData[3] = logPartPtr.p->
lastMbyte;
17745 sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB);
17754 void Dblqh::srLogLimits(
Signal* signal)
17756 Uint32 tlastPrepRef;
17760 logPartPtr.i = signal->theData[0];
17761 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
17762 logFilePtr.i = signal->theData[1];
17763 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
17764 tmbyte = signal->theData[2];
17765 Uint32 loopCount = 0;
17771 ndbrequire(tmbyte < clogFileSize);
17772 if (logPartPtr.p->
logExecState == LogPartRecord::LES_SEARCH_STOP)
17785 logPartPtr.p->
logExecState = LogPartRecord::LES_SEARCH_START;
17788 ndbout_c(
"part: %u srLogLimits found stop pos file: %u mb: %u logMaxGciCompleted[tmbyte]: %u (lastGci: %u)",
17796 else if (DEBUG_REDO)
17798 ndbout_c(
"SEARCH STOP SKIP part: %u file: %u mb: %u "
17799 "logMaxGciCompleted: %u > %u",
17814 if (logPartPtr.p->
logExecState == LogPartRecord::LES_SEARCH_START)
17826 ndbout_c(
"part: %u srLogLimits found start pos file: %u mb: %u logMaxGciStarted[tmbyte]: %u (startGci: %u)",
17832 ndbout_c(
"part: %u srLogLimits lastPrepRef => file: %u mb: %u",
17838 logPartPtr.p->
startMbyte = tlastPrepRef & 65535;
17839 LogFileRecordPtr locLogFilePtr;
17840 findLogfile(signal, tlastPrepRef >> 16, logPartPtr, &locLogFilePtr);
17842 logPartPtr.p->
logExecState = LogPartRecord::LES_EXEC_LOG;
17844 else if (DEBUG_REDO)
17846 ndbout_c(
"SEARCH START SKIP part: %u file: %u mb: %u "
17847 "logMaxGciCompleted: %u >= %u",
17855 if (logPartPtr.p->
logExecState != LogPartRecord::LES_EXEC_LOG) {
17858 tmbyte = clogFileSize - 1;
17860 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
17866 ndbrequire(logPartPtr.p->
lastMbyte != tmbyte);
17868 if (loopCount > 20) {
17870 signal->theData[0] = ZSR_LOG_LIMITS;
17871 signal->theData[1] = logPartPtr.i;
17872 signal->theData[2] = logFilePtr.i;
17873 signal->theData[3] = tmbyte;
17874 sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB);
17886 LogFileRecordPtr tmp;
17888 ptrCheckGuard(tmp, clogFileFileSize, logFileRecord);
17889 ndbout_c(
"srLogLimits part: %u gci: %u-%u start file: %u mb: %u stop file: %u mb: %u",
17893 tlastPrepRef >> 16,
17894 tlastPrepRef & 65535,
17909 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
17911 openFileRw(signal, logFilePtr);
17912 send_runredo_event(signal, logPartPtr.p, logPartPtr.p->
logStartGci);
17923 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
17925 logPartPtr.p->logTailMbyte = logPartPtr.p->
startMbyte;
17930 LogFileRecordPtr locLogFilePtr;
17931 findLogfile(signal, logPartPtr.p->
headFileNo, logPartPtr, &locLogFilePtr);
17932 locLogFilePtr.p->logFileStatus = LogFileRecord::OPEN_SR_FOURTH_PHASE;
17933 openFileRw(signal, locLogFilePtr);
17938 void Dblqh::openExecSrStartLab(
Signal* signal)
17954 readExecSrNewMbyte(signal);
17971 void Dblqh::readExecSrLab(
Signal* signal)
17973 buildLinkedLogPageList(signal);
17979 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_HEADER_SIZE;
17981 LogPartRecord::LES_WAIT_READ_EXEC_SR_NEW_MBYTE) {
17994 moveToPageRef(signal);
17995 releaseLfo(signal);
18000 checkReadExecSr(signal);
18001 if (logPartPtr.p->
logExecState == LogPartRecord::LES_EXEC_LOG) {
18003 signal->theData[0] = ZEXEC_SR;
18004 signal->theData[1] = logPartPtr.i;
18005 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
18011 void Dblqh::openExecSrNewMbyteLab(
Signal* signal)
18013 readExecSrNewMbyte(signal);
18017 void Dblqh::closeExecSrLab(
Signal* signal)
18019 LogFileRecordPtr locLogFilePtr;
18022 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
18024 ptrCheckGuard(locLogFilePtr, clogFileFileSize, logFileRecord);
18025 locLogFilePtr.p->logFileStatus = LogFileRecord::OPEN_EXEC_SR_NEW_MBYTE;
18026 openFileRw(signal, locLogFilePtr);
18030 void Dblqh::writeDirtyLab(
Signal* signal)
18032 releaseLfo(signal);
18033 signal->theData[0] = logPartPtr.i;
18041 void Dblqh::execSr(
Signal* signal)
18043 LogFileRecordPtr nextLogFilePtr;
18044 LogPageRecordPtr tmpLogPagePtr;
18047 const char * crash_msg = 0;
18050 logPartPtr.i = signal->theData[0];
18051 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
18056 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
18058 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
18059 if (logPagePtr.p->
logPageWord[ZPOS_DIRTY] == ZDIRTY) {
18062 case LogPartRecord::LES_EXEC_LOG_COMPLETED:
18063 case LogPartRecord::LES_EXEC_LOG_NEW_FILE:
18064 case LogPartRecord::LES_EXEC_LOG_NEW_MBYTE:
18070 writeDirty(signal, __LINE__);
18073 case LogPartRecord::LES_EXEC_LOG:
18081 writeDirty(signal, __LINE__);
18097 case LogPartRecord::LES_EXEC_LOG_COMPLETED:
18099 releaseMmPages(signal);
18100 logFilePtr.p->
logFileStatus = LogFileRecord::CLOSING_EXEC_SR_COMPLETED;
18101 closeFile(signal, logFilePtr, __LINE__);
18104 case LogPartRecord::LES_EXEC_LOG_NEW_MBYTE:
18107 readExecSrNewMbyte(signal);
18110 case LogPartRecord::LES_EXEC_LOG_NEW_FILE:
18114 ptrCheckGuard(nextLogFilePtr, clogFileFileSize, logFileRecord);
18115 nextLogFilePtr.p->currentMbyte = 0;
18117 closeFile(signal, logFilePtr, __LINE__);
18120 case LogPartRecord::LES_EXEC_LOG:
18126 systemErrorLab(signal, __LINE__);
18131 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
18147 readExecSr(signal);
18148 logPartPtr.p->
logExecState = LogPartRecord::LES_WAIT_READ_EXEC_SR;
18152 logWord = readLogword(signal);
18156 case ZPREP_OP_TYPE:
18158 logWord = readLogword(signal);
18159 stepAhead(signal, logWord - 2);
18164 case ZINVALID_COMMIT_TYPE:
18166 stepAhead(signal, ZCOMMIT_LOG_SIZE - 1);
18172 CommitLogRecord commitLogRecord;
18175 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
18176 readCommitLog(signal, &commitLogRecord);
18177 if (tcConnectptr.p->gci_hi > crestartNewestGci) {
18185 ptrCheckGuard(tmpLogPagePtr, clogPageFileSize, logPageRecord);
18187 tmpLogPagePtr.p->logPageWord[logPartPtr.p->
savePageIndex] =
18188 ZINVALID_COMMIT_TYPE;
18189 tmpLogPagePtr.p->logPageWord[ZPOS_DIRTY] = ZDIRTY;
18198 Uint32 result = checkIfExecLog(signal);
18199 if (result == ZOK) {
18207 tcConnectptr.p->fragmentptr = fragptr.i;
18208 findPageRef(signal, &commitLogRecord);
18210 if (logPagePtr.i != RNIL) {
18212 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = commitLogRecord.startPageIndex;
18214 execLogRecord(signal);
18219 findLogfile(signal, commitLogRecord.fileNo, logPartPtr, &logFilePtr);
18223 #ifndef NO_REDO_PAGE_CACHE
18226 evict(m_redo_page_cache, cnt);
18228 readExecLog(signal);
18229 lfoPtr.p->
lfoState = LogFileOperationRecord::READ_EXEC_LOG;
18237 #ifndef NO_REDO_OPEN_FILE_CACHE
18238 openFileRw_cache(signal, logFilePtr);
18240 logFilePtr.p->
logFileStatus = LogFileRecord::OPEN_EXEC_LOG;
18241 openFileRw(signal, logFilePtr);
18253 stepAhead(signal, ZABORT_LOG_SIZE - 1);
18267 if (unlikely(logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] !=
18268 (ZPAGE_HEADER_SIZE + ZPOS_NO_FD)))
18271 logWord = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
18272 crash_msg =
"ZFD_TYPE at incorrect position!";
18276 Uint32 noFdDescriptors =
18277 logPagePtr.p->
logPageWord[ZPAGE_HEADER_SIZE + ZPOS_NO_FD];
18279 (ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE) +
18280 (noFdDescriptors * ZFD_MBYTE_SIZE * clogFileSize);
18285 case ZNEXT_LOG_RECORD_TYPE:
18287 stepAhead(signal, ZPAGE_SIZE - logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX]);
18291 case ZNEXT_MBYTE_TYPE:
18312 logWord = ZNEXT_MBYTE_TYPE;
18313 crash_msg =
"end of log wo/ having found last GCI";
18320 if (logFilePtr.p->
currentMbyte < (clogFileSize - 1)) {
18322 logPartPtr.p->
logExecState = LogPartRecord::LES_EXEC_LOG_NEW_MBYTE;
18324 ndbrequire(logFilePtr.p->
currentMbyte == (clogFileSize - 1));
18329 logPartPtr.p->
logExecState = LogPartRecord::LES_EXEC_LOG_NEW_FILE;
18334 case ZCOMPLETED_GCI_TYPE:
18336 logWord = readLogword(signal);
18339 ndbout_c(
"found gci: %u part: %u file: %u page: %u (mb: %u)",
18354 if (csrPhasesCompleted == 0) {
18366 ndbout_c(
"execSr part: %u logLap: %u",
18375 logPartPtr.p->
logExecState = LogPartRecord::LES_EXEC_LOG_COMPLETED;
18376 send_runredo_event(signal, logPartPtr.p, logPartPtr.p->
logLastGci);
18387 crash_msg =
"Invalid logword";
18399 signal->theData[0] = RNIL;
18400 signal->theData[1] = logPartPtr.i;
18401 Uint32 tmp = logFilePtr.p->
fileName[3];
18402 tmp = (tmp >> 8) & 0xff;
18403 signal->theData[2] = tmp;
18404 signal->theData[3] = logFilePtr.p->
fileNo;
18407 signal->theData[6] = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
18408 signal->theData[7] = logWord;
18409 signal->theData[8] = line;
18413 "Error while reading REDO log. from %d\n"
18414 "part: %u D=%d, F=%d Mb=%d FP=%d W1=%d W2=%d : %s gci: %u",
18415 signal->theData[8],
18417 signal->theData[2],
18418 signal->theData[3],
18419 signal->theData[4],
18420 signal->theData[5],
18421 signal->theData[6],
18422 signal->theData[7],
18423 crash_msg ? crash_msg :
"",
18426 ndbout_c(
"%s", buf);
18427 ndbout_c(
"logPartPtr.p->logExecState: %u", logPartPtr.p->
logExecState);
18428 ndbout_c(
"crestartOldestGci: %u", crestartOldestGci);
18429 ndbout_c(
"crestartNewestGci: %u", crestartNewestGci);
18430 ndbout_c(
"csrPhasesCompleted: %u", csrPhasesCompleted);
18431 ndbout_c(
"logPartPtr.p->logStartGci: %u", logPartPtr.p->
logStartGci);
18432 ndbout_c(
"logPartPtr.p->logLastGci: %u", logPartPtr.p->
logLastGci);
18434 progError(__LINE__, NDBD_EXIT_SR_REDOLOG, buf);
18441 void Dblqh::execDEBUG_SIG(
Signal* signal)
18453 "Error while reading REDO log. from %d\n"
18454 "D=%d, F=%d Mb=%d FP=%d W1=%d W2=%d",
18455 signal->theData[8],
18456 signal->theData[2], signal->theData[3], signal->theData[4],
18457 signal->theData[5], signal->theData[6], signal->theData[7]);
18459 progError(__LINE__, NDBD_EXIT_SR_REDOLOG, buf);
18466 void Dblqh::closeExecLogLab(
Signal* signal)
18469 signal->theData[0] = ZEXEC_SR;
18470 signal->theData[1] = logFilePtr.p->
logPartRec;
18471 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
18475 void Dblqh::openExecLogLab(
Signal* signal)
18477 #ifndef NO_REDO_PAGE_CACHE
18482 Uint32 MAX_EXTRA_READ = 9;
18491 evict(m_redo_page_cache, cnt);
18494 readExecLog(signal);
18495 lfoPtr.p->
lfoState = LogFileOperationRecord::READ_EXEC_LOG;
18499 void Dblqh::readExecLogLab(
Signal* signal)
18501 buildLinkedLogPageList(signal);
18502 #ifndef NO_REDO_PAGE_CACHE
18503 addCachePages(m_redo_page_cache,
18508 logPartPtr.p->
logExecState = LogPartRecord::LES_EXEC_LOGREC_FROM_FILE;
18513 execLogRecord(signal);
18521 void Dblqh::execLogRecord(
Signal* signal)
18526 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
18527 fragptr.i = tcConnectptr.p->fragmentptr;
18528 c_fragment_pool.
getPtr(fragptr);
18532 readLogHeader(signal);
18534 readAttrinfo(signal);
18535 initReqinfoExecSr(signal);
18538 tcConnectptr.p->nextReplica = refToNode(ref);
18539 tcConnectptr.p->connectState = TcConnectionrec::LOG_CONNECTED;
18540 tcConnectptr.p->tcOprec = tcConnectptr.i;
18541 tcConnectptr.p->tcHashKeyHi = 0;
18542 packLqhkeyreqLab(signal);
18553 Dblqh::nextLogFilePtr(Uint32 logFilePtrI)
18555 LogFileRecordPtr tmp;
18556 tmp.i = logFilePtrI;
18557 ptrCheckGuard(tmp, clogFileFileSize, logFileRecord);
18558 return tmp.p->nextLogFile;
18562 Dblqh::invalidateLogAfterLastGCI(
Signal* signal)
18565 if (logPartPtr.p->
logExecState != LogPartRecord::LES_EXEC_LOG_INVALIDATE) {
18567 systemError(signal, __LINE__);
18572 systemError(signal, __LINE__);
18576 case LogFileOperationRecord::READ_SR_INVALIDATE_SEARCH_FILES:
18582 releaseLfo(signal);
18583 releaseLogpage(signal);
18589 readFileInInvalidate(signal, 3);
18599 readFileInInvalidate(signal, 6);
18604 case LogFileOperationRecord::READ_SR_INVALIDATE_PAGES:
18617 releaseLfo(signal);
18618 releaseLogpage(signal);
18619 readFileInInvalidate(signal, 1);
18629 case LogFileOperationRecord::WRITE_SR_INVALIDATE_PAGES:
18632 releaseLfo(signal);
18633 releaseLogpage(signal);
18642 if (logFilePtr.p->
fileNo == 0)
18650 ndbrequire(logPartPtr.p->
logLap);
18653 ndbout_c(
"invalidateLogAfterLastGCI part: %u wrap from file 0 -> logLap: %u",
18658 if (invalidateCloseFile(signal, logPartPtr, logFilePtr,
18659 LogFileRecord::CLOSE_SR_WRITE_INVALIDATE_PAGES))
18664 writeFileInInvalidate(signal, 1);
18667 writeFileInInvalidate(signal, 0);
18676 Dblqh::writeFileInInvalidate(
Signal* signal,
int stepPrev)
18685 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
18698 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
18701 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
18703 exitFromInvalidate(signal);
18712 ndbout_c(
"invalidate part: %u open for write %u",
18715 logFilePtr.p->
logFileStatus =LogFileRecord::OPEN_SR_WRITE_INVALIDATE_PAGES;
18716 openFileRw(signal, logFilePtr);
18720 seizeLogpage(signal);
18725 bzero(logPagePtr.p,
sizeof(LogPageRecord));
18727 ZPAGE_SIZE - 1, __LINE__);
18729 lfoPtr.p->
lfoState = LogFileOperationRecord::WRITE_SR_INVALIDATE_PAGES;
18734 Dblqh::invalidateCloseFile(
Signal* signal,
18737 LogFileRecord::LogFileStatus status)
18740 if (filePtr.p->
fileNo != 0 &&
18747 ndbout_c(
"invalidate part: %u close %u(%u) state: %u (%u)",
18755 closeFile(signal, filePtr, __LINE__);
18761 void Dblqh::readFileInInvalidate(
Signal* signal,
int stepNext)
18767 ndbout_c(
"readFileInInvalidate part: %u file: %u stepNext: %u",
18776 lfoPtr.p->
lfoState = LogFileOperationRecord::READ_SR_INVALIDATE_PAGES;
18786 if (invalidateCloseFile(signal, logPartPtr, logFilePtr,
18787 LogFileRecord::CLOSE_SR_READ_INVALIDATE_PAGES))
18803 lfoPtr.p->
lfoState = LogFileOperationRecord::READ_SR_INVALIDATE_PAGES;
18813 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
18818 if (logFilePtr.p->
fileNo == 0)
18827 ndbout_c(
"readFileInInvalidate part: %u step: %u wrap to file 0 -> logLap: %u",
18838 ndbout_c(
"invalidate part: %u step: %u open for read %u",
18841 logFilePtr.p->
logFileStatus =LogFileRecord::OPEN_SR_READ_INVALIDATE_PAGES;
18842 openFileRw(signal, logFilePtr);
18848 lfoPtr.p->
lfoState = LogFileOperationRecord::READ_SR_INVALIDATE_PAGES;
18855 if (invalidateCloseFile
18856 (signal, logPartPtr, logFilePtr,
18857 LogFileRecord::CLOSE_SR_READ_INVALIDATE_SEARCH_FILES))
18869 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
18874 if (logFilePtr.p->
fileNo == 0)
18883 ndbout_c(
"readFileInInvalidate part: %u step: %u wrap to file 0 -> logLap: %u",
18893 ndbout_c(
"invalidate part: %u step: %u open for read %u",
18897 LogFileRecord::OPEN_SR_READ_INVALIDATE_SEARCH_FILES;
18898 openFileRw(signal, logFilePtr);
18910 LogFileOperationRecord::READ_SR_INVALIDATE_SEARCH_FILES;
18917 if (invalidateCloseFile
18918 (signal, logPartPtr, logFilePtr,
18919 LogFileRecord::CLOSE_SR_READ_INVALIDATE_SEARCH_LAST_FILE))
18931 if (logFilePtr.p->
fileNo == 0)
18939 ndbrequire(logPartPtr.p->
logLap);
18942 ndbout_c(
"invalidateLogAfterLastGCI part: %u step: %u wrap from file 0 -> logLap: %u",
18948 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
18959 if (! ((cstartType == NodeState::ST_INITIAL_START) ||
18960 (cstartType == NodeState::ST_INITIAL_NODE_RESTART)))
18966 Uint32 lastMbytePageNo =
18967 logPartPtr.p->
lastMbyte << ZTWOLOG_NO_PAGES_IN_MBYTE;
18973 ndbout_c(
"readFileInInvalidate part: %u step: %u moving invalidatePageNo from %u to %u (lastMbyte)",
18982 readFileInInvalidate(signal, 1);
18991 void Dblqh::exitFromInvalidate(
Signal* signal)
18998 printf(
"exitFromInvalidate part: %u head file: %u page: %u open: ",
19003 LogFileRecordPtr tmp;
19008 ptrCheckGuard(tmp, clogFileFileSize, logFileRecord);
19013 printf(
"%u ", tmp.p->fileNo);
19015 tmp.i = tmp.p->nextLogFile;
19016 }
while (tmp.i != logPartPtr.p->
currentLogfile && tmp.i != RNIL);
19020 ptrCheckGuard(tmp, clogFileFileSize, logFileRecord);
19022 LogPosition head = { tmp.p->fileNo, tmp.p->currentMbyte };
19024 logPartPtr.p->logTailMbyte};
19025 Uint64 mb = free_log(head, tail, logPartPtr.p->
noLogFiles, clogFileSize);
19026 Uint64 total = logPartPtr.p->
noLogFiles * Uint64(clogFileSize);
19027 ndbout_c(
"head: [ %u %u ] tail: [ %u %u ] free: %llu total: %llu",
19028 head.m_file_no, head.m_mbyte,
19029 tail.m_file_no, tail.m_mbyte,
19034 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
19036 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
19037 logPagePtr.p->
logPageWord[ZPAGE_HEADER_SIZE + ZPOS_FILE_NO] =
19039 writeSinglePage(signal, 0, ZPAGE_SIZE - 1, __LINE__);
19042 lfoPtr.p->
lfoState = LogFileOperationRecord::WRITE_SR_INVALIDATE_PAGES_UPDATE_PAGE0;
19050 void Dblqh::completedLab(
Signal* signal)
19052 Uint32 result = returnExecLog(signal);
19057 if (result == ZOK) {
19059 execLogRecord(signal);
19061 }
else if (result == ZNOT_OK) {
19063 signal->theData[0] = ZEXEC_SR;
19064 signal->theData[1] = logPartPtr.i;
19065 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
19081 void Dblqh::logLqhkeyrefLab(
Signal* signal)
19083 Uint32 result = returnExecLog(signal);
19084 switch (tcConnectptr.p->operation) {
19088 if (unlikely(terrorCode != ZNO_TUPLE_FOUND))
19093 if (unlikely(terrorCode != ZTUPLE_ALREADY_EXIST && terrorCode != 899))
19101 if (result == ZOK) {
19103 execLogRecord(signal);
19105 }
else if (result == ZNOT_OK) {
19107 signal->theData[0] = ZEXEC_SR;
19108 signal->theData[1] = logPartPtr.i;
19109 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
19121 tmp.
appfmt(
"You have found a bug!"
19122 " Failed op (%s) during REDO table: %d fragment: %d err: %d",
19123 tcConnectptr.p->operation == ZINSERT ?
"INSERT" :
19124 tcConnectptr.p->operation == ZUPDATE ?
"UPDATE" :
19125 tcConnectptr.p->operation == ZDELETE ?
"DELETE" :
19126 tcConnectptr.p->operation == ZWRITE ?
"WRITE" :
"<unknown>",
19127 tcConnectptr.p->tableref,
19128 tcConnectptr.p->fragmentid,
19130 progError(__LINE__, NDBD_EXIT_SYSTEM_ERROR,
19134 void Dblqh::closeExecSrCompletedLab(
Signal* signal)
19137 signal->theData[0] = logFilePtr.p->
logPartRec;
19138 execLogComp(signal);
19146 void Dblqh::execLogComp(
Signal* signal)
19148 logPartPtr.i = signal->theData[0];
19149 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
19150 logPartPtr.p->
logPartState = LogPartRecord::SR_THIRD_PHASE_COMPLETED;
19155 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
19157 releaseTcrecLog(signal, tcConnectptr);
19158 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
19160 ptrAss(logPartPtr, logPartRecord);
19161 if (logPartPtr.p->
logPartState != LogPartRecord::SR_THIRD_PHASE_COMPLETED) {
19164 systemErrorLab(signal, __LINE__);
19182 #ifndef NO_REDO_PAGE_CACHE
19183 release(m_redo_page_cache);
19186 #ifndef NO_REDO_OPEN_FILE_CACHE
19187 release(signal, m_redo_open_file_cache);
19189 execLogComp_extra_files_closed(signal);
19194 Dblqh::execLogComp_extra_files_closed(
Signal * signal)
19196 c_lcp_complete_fragments.
first(fragptr);
19197 signal->theData[0] = ZSEND_EXEC_CONF;
19198 signal->theData[1] = fragptr.i;
19199 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
19207 void Dblqh::sendExecConf(
Signal* signal)
19210 fragptr.i = signal->theData[0];
19211 Uint32 loopCount = 0;
19212 while (fragptr.i != RNIL) {
19213 c_lcp_complete_fragments.
getPtr(fragptr);
19214 Uint32 next = fragptr.p->nextList;
19227 signal->theData[1] = ref;
19228 sendSignal(DBLQH_REF, GSN_EXEC_FRAGCONF, signal, 2, JBB);
19230 else if (refToInstance(ref) != 0 &&
19231 ndb_route_exec_frag(
getNodeInfo(refToNode(ref)).m_version))
19235 signal->theData[1] = ref;
19236 sendSignal(numberToRef(refToMain(ref), refToNode(ref)),
19237 GSN_EXEC_FRAGCONF, signal, 2, JBB);
19243 sendSignal(ref, GSN_EXEC_FRAGCONF, signal, 1, JBB);
19249 if (loopCount > 20) {
19251 signal->theData[0] = ZSEND_EXEC_CONF;
19252 signal->theData[1] = next;
19253 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
19264 srPhase3Comp(signal);
19270 void Dblqh::srPhase3Comp(
Signal* signal)
19274 signal->theData[0] = cownNodeid;
19279 sendSignal(rg, GSN_EXEC_SRCONF, signal, 1, JBB);
19284 const Uint32 sz = NdbNodeBitmask::Size;
19285 m_sr_nodes.
copyto(sz, &signal->theData[1]);
19286 sendSignal(DBLQH_REF, GSN_EXEC_SRCONF, signal, 1 + sz, JBB);
19305 void Dblqh::initFourth(
Signal* signal)
19307 LogFileRecordPtr locLogFilePtr;
19309 logPartPtr.i = signal->theData[0];
19310 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
19311 crestartNewestGci = 1;
19312 crestartOldestGci = 1;
19321 logPartPtr.p->logTailMbyte = 0;
19323 ptrCheckGuard(locLogFilePtr, clogFileFileSize, logFileRecord);
19324 locLogFilePtr.p->logFileStatus = LogFileRecord::OPEN_SR_FOURTH_PHASE;
19325 openFileRw(signal, locLogFilePtr);
19329 void Dblqh::openSrFourthPhaseLab(
Signal* signal)
19335 readSinglePage(signal, logPartPtr.p->
headPageNo);
19336 lfoPtr.p->
lfoState = LogFileOperationRecord::READ_SR_FOURTH_PHASE;
19340 void Dblqh::readSrFourthPhaseLab(
Signal* signal)
19364 Uint32 gci = crestartNewestGci;
19365 if (crestartOldestGci > gci)
19372 ndbout_c(
"readSrFourthPhaseLab: gci %u => %u",
19373 gci, crestartOldestGci);
19374 gci = crestartOldestGci;
19377 cnewestCompletedGci = gci;
19382 logPartPtr.p->
headPageNo >> ZTWOLOG_NO_PAGES_IN_MBYTE;
19388 initLogpage(signal);
19392 ((logFilePtr.p->
currentMbyte + 1) * ZPAGES_IN_MBYTE) -
19394 (ZPAGE_SIZE - ZPAGE_HEADER_SIZE)) -
19400 LogFileRecordPtr locLogFilePtr;
19403 ptrCheckGuard(locLogFilePtr, clogFileFileSize, logFileRecord);
19404 locLogFilePtr.p->logFileStatus = LogFileRecord::OPEN_SR_FOURTH_NEXT;
19405 openFileRw(signal, locLogFilePtr);
19413 openSrFourthZeroSkipInitLab(signal);
19419 void Dblqh::openSrFourthNextLab(
Signal* signal)
19425 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
19428 openSrFourthZeroSkipInitLab(signal);
19432 logFilePtr.p->
logFileStatus = LogFileRecord::OPEN_SR_FOURTH_ZERO;
19433 openFileRw(signal, logFilePtr);
19438 void Dblqh::openSrFourthZeroLab(
Signal* signal)
19440 openSrFourthZeroSkipInitLab(signal);
19444 void Dblqh::openSrFourthZeroSkipInitLab(
Signal* signal)
19453 systemErrorLab(signal, __LINE__);
19457 readSinglePage(signal, 0);
19458 lfoPtr.p->
lfoState = LogFileOperationRecord::READ_SR_FOURTH_ZERO;
19462 void Dblqh::readSrFourthZeroLab(
Signal* signal)
19475 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
19478 logPartPtr.p->
logExecState = LogPartRecord::LES_EXEC_LOG_INVALIDATE;
19480 readFileInInvalidate(signal, 3);
19488 void Dblqh::srFourthComp(
Signal* signal)
19491 logPartPtr.i = signal->theData[0];
19492 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
19493 logPartPtr.p->
logPartState = LogPartRecord::SR_FOURTH_PHASE_COMPLETED;
19494 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
19496 ptrAss(logPartPtr, logPartRecord);
19497 if (logPartPtr.p->
logPartState != LogPartRecord::SR_FOURTH_PHASE_COMPLETED) {
19500 systemErrorLab(signal, __LINE__);
19519 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
19520 ptrAss(logPartPtr, logPartRecord);
19524 if ((cstartType == NodeState::ST_INITIAL_START) ||
19525 (cstartType == NodeState::ST_INITIAL_NODE_RESTART)) {
19528 ndbrequire(cinitialStartOngoing == ZTRUE);
19529 cinitialStartOngoing = ZFALSE;
19530 cstartRecReq = SRR_REDO_COMPLETE;
19531 checkStartCompletedLab(signal);
19533 }
else if ((cstartType == NodeState::ST_NODE_RESTART) ||
19534 (cstartType == NodeState::ST_SYSTEM_RESTART)) {
19537 if(cstartType == NodeState::ST_SYSTEM_RESTART)
19540 if (c_lcp_complete_fragments.
first(fragptr))
19543 signal->theData[0] = ZENABLE_EXPAND_CHECK;
19544 signal->theData[1] = fragptr.i;
19545 sendSignal(reference(), GSN_CONTINUEB, signal, 2, JBB);
19550 cstartRecReq = SRR_REDO_COMPLETE;
19552 rebuildOrderedIndexes(signal, 0);
19584 void Dblqh::systemErrorLab(
Signal* signal,
int line)
19586 systemError(signal, line);
19596 void Dblqh::aiStateErrorCheckLab(
Signal* signal, Uint32* dataPtr, Uint32 length)
19598 ndbrequire(tcConnectptr.p->abortState != TcConnectionrec::ABORT_IDLE);
19599 if (tcConnectptr.p->transactionState != TcConnectionrec::IDLE) {
19607 if (tcConnectptr.p->activeCreat == Fragrecord::AC_IGNORED) {
19621 if (saveAttrInfoInSection(dataPtr, length) == ZOK) {
19623 if (tcConnectptr.p->transactionState ==
19624 TcConnectionrec::WAIT_AI_AFTER_ABORT) {
19625 if (tcConnectptr.p->currTupAiLen == tcConnectptr.p->totReclenAi) {
19635 tcConnectptr.p->abortState = TcConnectionrec::ABORT_IDLE;
19636 rwConcludedAiLab(signal);
19639 ndbrequire(tcConnectptr.p->currTupAiLen < tcConnectptr.p->totReclenAi);
19651 tcConnectptr.p->errorCode = terrorCode;
19652 tcConnectptr.p->activeCreat = Fragrecord::AC_NORMAL;
19653 if (tcConnectptr.p->transactionState ==
19654 TcConnectionrec::WAIT_AI_AFTER_ABORT) {
19660 continueAbortLab(signal);
19678 void Dblqh::takeOverErrorLab(
Signal* signal)
19680 terrorCode = ZTAKE_OVER_ERROR;
19681 abortErrorLab(signal);
19689 void Dblqh::execTESTSIG(
Signal* signal)
19692 Uint32 userpointer = signal->theData[0];
19693 BlockReference userblockref = signal->theData[1];
19694 Uint32
testcase = signal->theData[2];
19696 signal->theData[0] = userpointer;
19697 signal->theData[1] = cownref;
19698 signal->theData[2] = testcase;
19699 sendSignal(userblockref, GSN_TESTSIG, signal, 25, JBB);
19711 void Dblqh::execMEMCHECKREQ(
Signal* signal)
19713 Uint32* dataPtr = &signal->theData[0];
19715 BlockReference userblockref = signal->theData[0];
19717 for (Uint32 i = 0; i < 7; i++)
19719 addfragptr.i = cfirstfreeAddfragrec;
19720 while (addfragptr.i != RNIL) {
19721 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
19722 addfragptr.i = addfragptr.p->nextAddfragrec;
19731 tabptr.i < ctabrecFileSize;
19733 ptrAss(tabptr, tablerec);
19734 if (tabptr.p->
tableStatus == Tablerec::NOT_DEFINED) {
19739 tcConnectptr.i = cfirstfreeTcConrec;
19740 while (tcConnectptr.i != RNIL) {
19741 ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
19742 tcConnectptr.i = tcConnectptr.p->nextTcConnectrec;
19745 sendSignal(userblockref, GSN_MEMCHECKCONF, signal, 10, JBB);
19758 void Dblqh::buildLinkedLogPageList(
Signal* signal)
19760 LogPageRecordPtr bllLogPagePtr;
19764 Uint32 prev = RNIL;
19765 for (UintR tbllIndex = 0; tbllIndex < lfoPtr.p->
noPagesRw; tbllIndex++) {
19772 ptrCheckGuard(bllLogPagePtr, clogPageFileSize, logPageRecord);
19784 bllLogPagePtr.p->logPageWord[ZPREV_PAGE] = prev;
19785 bllLogPagePtr.p->logPageWord[ZNEXT_PAGE] =
19787 bllLogPagePtr.p->logPageWord[ZPOS_DIRTY] = ZNOT_DIRTY;
19788 prev = bllLogPagePtr.i;
19791 ptrCheckGuard(bllLogPagePtr, clogPageFileSize, logPageRecord);
19792 bllLogPagePtr.p->logPageWord[ZNEXT_PAGE] = RNIL;
19799 void Dblqh::changeMbyte(
Signal* signal)
19801 writeNextLog(signal);
19802 writeFileDescriptor(signal);
19810 Uint32 Dblqh::checkIfExecLog(
Signal* signal)
19812 tabptr.i = tcConnectptr.p->tableref;
19813 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
19814 if (getFragmentrec(signal, tcConnectptr.p->fragmentid) &&
19815 (table_version_major(tabptr.p->schemaVersion) == table_version_major(tcConnectptr.p->schemaVersion))) {
19820 i < fragptr.p->execSrNoReplicas;
19824 if (tcConnectptr.p->gci_hi <= fragptr.p->
execSrLastGci[i]) {
19843 void Dblqh::checkReadExecSr(
Signal* signal)
19845 logPartPtr.p->
logExecState = LogPartRecord::LES_EXEC_LOG;
19849 ZREAD_AHEAD_SIZE) {
19863 readExecSr(signal);
19864 logPartPtr.p->
logExecState = LogPartRecord::LES_WAIT_READ_EXEC_SR;
19875 void Dblqh::checkScanTcCompleted(
Signal* signal)
19877 tcConnectptr.p->logWriteState = TcConnectionrec::NOT_STARTED;
19878 fragptr.i = tcConnectptr.p->fragmentptr;
19879 c_fragment_pool.
getPtr(fragptr);
19883 fragptr.p->
startGci = cnewestGci + 1;
19884 tabptr.i = tcConnectptr.p->tableref;
19885 ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
19886 sendCopyActiveConf(signal, tcConnectptr.p->tableref);
19894 void Dblqh::closeFile(
Signal* signal,
19895 LogFileRecordPtr clfLogFilePtr, Uint32 line)
19897 signal->theData[0] = clfLogFilePtr.p->fileRef;
19898 signal->theData[1] = cownref;
19899 signal->theData[2] = clfLogFilePtr.i;
19900 signal->theData[3] = ZCLOSE_NO_DELETE;
19901 signal->theData[4] = line;
19902 sendSignal(NDBFS_REF, GSN_FSCLOSEREQ, signal, 5, JBA);
19916 void Dblqh::completedLogPage(
Signal* signal, Uint32 clpType, Uint32 place)
19918 LogPageRecordPtr clpLogPagePtr;
19919 LogPageRecordPtr wlpLogPagePtr;
19929 ptrCheckGuard(clpLogPagePtr, clogPageFileSize, logPageRecord);
19930 clpLogPagePtr.p->logPageWord[ZNEXT_PAGE] = logPagePtr.i;
19936 if (clpType != ZLAST_WRITE_IN_FILE) {
19937 if (clpType != ZENFORCE_WRITE) {
19943 twlpType = clpType;
19951 Uint32* dataPtr = &signal->theData[6];
19955 dataPtr[twlpNoPages] = wlpLogPagePtr.i;
19957 ptrCheckGuard(wlpLogPagePtr, clogPageFileSize, logPageRecord);
19959 writeDbgInfoPageHeader(wlpLogPagePtr, place,
19963 wlpLogPagePtr.p->logPageWord[ZPOS_CHECKSUM] = calcPageCheckSum(wlpLogPagePtr);
19964 wlpLogPagePtr.i = wlpLogPagePtr.p->logPageWord[ZNEXT_PAGE];
19965 }
while (wlpLogPagePtr.i != RNIL);
19966 ndbrequire(twlpNoPages < 9);
19973 signal->theData[0] = logFilePtr.p->
fileRef;
19974 signal->theData[1] = cownref;
19975 signal->theData[2] = lfoPtr.i;
19976 if (twlpType == ZLAST_WRITE_IN_FILE) {
19978 signal->theData[3] = ZLIST_OF_MEM_PAGES_SYNCH;
19981 signal->theData[3] = ZLIST_OF_MEM_PAGES;
19983 signal->theData[4] = ZVAR_NO_LOG_PAGE_WORD;
19984 signal->theData[5] = twlpNoPages;
19985 sendSignal(NDBFS_REF, GSN_FSWRITEREQ, signal, 15, JBA);
19987 ndbrequire(logFilePtr.p->
fileRef != RNIL);
19989 logPartPtr.p->
m_io_tracker.send_io(32768*twlpNoPages);
19993 ndbout_c(
"writing %d pages at part: %u file: %u page: %u (mb: %u)",
19998 logFilePtr.p->
filePosition >> ZTWOLOG_NO_PAGES_IN_MBYTE);
20001 if (twlpType == ZNORMAL) {
20004 }
else if (twlpType == ZLAST_WRITE_IN_FILE) {
20006 lfoPtr.p->
lfoState = LogFileOperationRecord::LAST_WRITE_IN_FILE;
20008 ndbrequire(twlpType == ZENFORCE_WRITE);
20036 void Dblqh::deleteFragrec(Uint32 fragId)
20038 Uint32 indexFound= RNIL;
20040 for (Uint32 i = 0; i < MAX_FRAG_PER_NODE; i++) {
20042 if (tabptr.p->fragid[i] == fragId) {
20043 fragptr.i = tabptr.p->fragrec[
i];
20048 if (fragptr.i != RNIL) {
20050 c_fragment_pool.
getPtr(fragptr);
20051 tabptr.p->fragid[indexFound] = ZNIL;
20052 tabptr.p->fragrec[indexFound] = RNIL;
20054 c_fragment_pool.
release(fragptr);
20066 void Dblqh::findLogfile(
Signal* signal,
20068 LogPartRecordPtr flfLogPartPtr,
20069 LogFileRecordPtr* parLogFilePtr)
20071 LogFileRecordPtr locLogFilePtr;
20072 locLogFilePtr.i = flfLogPartPtr.p->firstLogfile;
20073 Uint32 loopCount = 0;
20075 ptrCheckGuard(locLogFilePtr, clogFileFileSize, logFileRecord);
20076 if (locLogFilePtr.p->fileNo == fileNo) {
20078 ndbrequire(loopCount == fileNo);
20079 parLogFilePtr->i = locLogFilePtr.i;
20080 parLogFilePtr->p = locLogFilePtr.p;
20083 locLogFilePtr.i = locLogFilePtr.p->nextLogFile;
20085 if (loopCount >= flfLogPartPtr.p->noLogFiles &&
20090 ndbrequire(loopCount < flfLogPartPtr.p->noLogFiles);
20096 "Unable to restart, failed while reading redo."
20097 " Likely invalid change of configuration");
20099 NDBD_EXIT_INVALID_CONFIG,
20107 void Dblqh::findPageRef(
Signal* signal, CommitLogRecord* commitLogRecord)
20111 logPagePtr.i = RNIL;
20112 if (ERROR_INSERTED(5020)) {
20118 ptrCheckGuard(pageRefPtr, cpageRefFileSize, pageRefRecord);
20119 if (commitLogRecord->fileNo == pageRefPtr.p->prFileNo) {
20120 if (commitLogRecord->startPageNo >= pageRefPtr.p->prPageNo) {
20121 if (commitLogRecord->startPageNo < (Uint16) (pageRefPtr.p->prPageNo + 8)) {
20123 tfprIndex = commitLogRecord->startPageNo - pageRefPtr.p->prPageNo;
20124 logPagePtr.i = pageRefPtr.p->pageRef[tfprIndex];
20125 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
20130 pageRefPtr.i = pageRefPtr.p->prPrev;
20131 }
while (pageRefPtr.i != RNIL);
20133 #ifndef NO_REDO_PAGE_CACHE
20134 RedoPageCache& cache = m_redo_page_cache;
20135 RedoCacheLogPageRecord key;
20136 key.m_part_no = logPartPtr.p->
logPartNo;
20137 key.m_file_no = commitLogRecord->fileNo;
20138 key.m_page_no = commitLogRecord->startPageNo;
20140 if (cache.m_hash.find(pagePtr, key))
20143 if (cache.m_lru.hasPrev(pagePtr))
20146 cache.m_lru.remove(pagePtr);
20147 cache.m_lru.addFirst(pagePtr);
20149 logPagePtr.i = pagePtr.i;
20150 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
20153 Uint32
extra = commitLogRecord->stopPageNo - commitLogRecord->startPageNo;
20154 for (Uint32 i = 0; i<extra; i++)
20157 Uint32 prevPtrI = loopPtr.i;
20159 if (loopPtr.i == RNIL)
20166 key.m_page_no = commitLogRecord->startPageNo + i + 1;
20167 if (cache.m_hash.find(pagePtr, key))
20175 tmp.p =
reinterpret_cast<LogPageRecord*
>(pagePtr.p);
20183 logPagePtr.i = RNIL;
20184 cache.m_multi_miss++;
20186 ndbout_c(
"Found part: %u file: %u page: %u but not next page(%u) %u",
20188 commitLogRecord->fileNo,
20189 commitLogRecord->startPageNo,
20191 commitLogRecord->startPageNo + i + 1);
20196 ptrCheckGuard(loopPtr, clogPageFileSize, logPageRecord);
20197 pagePtr.i = loopPtr.i;
20198 pagePtr.p =
reinterpret_cast<RedoCacheLogPageRecord*
>(loopPtr.p);
20199 if (cache.m_lru.hasPrev(pagePtr))
20202 cache.m_lru.remove(pagePtr);
20203 cache.m_lru.addFirst(pagePtr);
20210 cache.m_multi_page++;
20222 Dblqh::getFirstInLogQueue(
Signal* signal,
20225 TcConnectionrecPtr tmp;
20231 tmp.i = queue->firstElement;
20236 tmp.i = queue->firstElement;
20238 ptrCheckGuard(tmp, ctcConnectrecFileSize, tcConnectionrec);
20239 queue->firstElement = tmp.p->nextTcLogQueue;
20240 if (queue->firstElement == RNIL) {
20242 queue->lastElement = RNIL;
20253 bool Dblqh::getFragmentrec(
Signal* signal, Uint32 fragId)
20255 for (Uint32 i = 0; i < MAX_FRAG_PER_NODE; i++) {
20257 if (tabptr.p->fragid[i] == fragId) {
20258 fragptr.i = tabptr.p->fragrec[
i];
20259 c_fragment_pool.
getPtr(fragptr);
20270 void Dblqh::initialiseAddfragrec(
Signal* signal)
20272 if (caddfragrecFileSize != 0) {
20273 for (addfragptr.i = 0; addfragptr.i < caddfragrecFileSize; addfragptr.i++) {
20274 ptrAss(addfragptr, addFragRecord);
20275 addfragptr.p->addfragStatus = AddFragRecord::FREE;
20276 addfragptr.p->nextAddfragrec = addfragptr.i + 1;
20278 addfragptr.i = caddfragrecFileSize - 1;
20279 ptrAss(addfragptr, addFragRecord);
20280 addfragptr.p->nextAddfragrec = RNIL;
20281 cfirstfreeAddfragrec = 0;
20284 cfirstfreeAddfragrec = RNIL;
20292 void Dblqh::initialiseFragrec(
Signal* signal)
20296 while(tmp.seize(fragptr))
20299 new (fragptr.p) Fragrecord();
20302 fragptr.p->srStatus = Fragrecord::SS_IDLE;
20311 void Dblqh::initialiseGcprec(
Signal* signal)
20315 if (cgcprecFileSize != 0) {
20316 for (gcpPtr.i = 0; gcpPtr.i < cgcprecFileSize; gcpPtr.i++) {
20317 ptrAss(gcpPtr, gcpRecord);
20318 for (tigpIndex = 0; tigpIndex < ZLOG_PART_FILE_SIZE; tigpIndex++) {
20330 void Dblqh::initialiseLcpRec(
Signal* signal)
20332 if (clcpFileSize != 0) {
20333 for (lcpPtr.i = 0; lcpPtr.i < clcpFileSize; lcpPtr.i++) {
20334 ptrAss(lcpPtr, lcpRecord);
20335 lcpPtr.p->lcpState = LcpRecord::LCP_IDLE;
20336 lcpPtr.p->lcpQueued =
false;
20337 lcpPtr.p->reportEmpty =
false;
20338 lcpPtr.p->firstFragmentFlag =
false;
20339 lcpPtr.p->lastFragmentFlag =
false;
20348 void Dblqh::initialiseLfo(
Signal* signal)
20350 if (clfoFileSize != 0) {
20351 for (lfoPtr.i = 0; lfoPtr.i < clfoFileSize; lfoPtr.i++) {
20352 ptrAss(lfoPtr, logFileOperationRecord);
20355 lfoPtr.p->
nextLfo = lfoPtr.i + 1;
20357 lfoPtr.i = clfoFileSize - 1;
20358 ptrAss(lfoPtr, logFileOperationRecord);
20363 cfirstfreeLfo = RNIL;
20371 void Dblqh::initialiseLogFile(
Signal* signal)
20373 if (clogFileFileSize != 0) {
20374 for (logFilePtr.i = 0; logFilePtr.i < clogFileFileSize; logFilePtr.i++) {
20375 ptrAss(logFilePtr, logFileRecord);
20389 "Failed to alloc mbyte(%u) arrays for logfile %u",
20390 clogFileSize, logFilePtr.i);
20391 progError(__LINE__, NDBD_EXIT_MEMALLOC, buf);
20395 logFilePtr.i = clogFileFileSize - 1;
20396 ptrAss(logFilePtr, logFileRecord);
20398 cfirstfreeLogFile = 0;
20401 cfirstfreeLogFile = RNIL;
20409 void Dblqh::initialiseLogPage(
Signal* signal)
20420 void Dblqh::initialiseLogPart(
Signal* signal)
20422 for (logPartPtr.i = 0; logPartPtr.i < clogPartFileSize; logPartPtr.i++) {
20423 ptrAss(logPartPtr, logPartRecord);
20431 void Dblqh::initialisePageRef(
Signal* signal)
20433 if (cpageRefFileSize != 0) {
20434 for (pageRefPtr.i = 0;
20435 pageRefPtr.i < cpageRefFileSize;
20437 ptrAss(pageRefPtr, pageRefRecord);
20438 pageRefPtr.p->prNext = pageRefPtr.i + 1;
20440 pageRefPtr.i = cpageRefFileSize - 1;
20441 ptrAss(pageRefPtr, pageRefRecord);
20442 pageRefPtr.p->prNext = RNIL;
20443 cfirstfreePageRef = 0;
20446 cfirstfreePageRef = RNIL;
20455 void Dblqh::initialiseRecordsLab(
Signal* signal, Uint32 data,
20456 Uint32 retRef, Uint32 retData)
20462 m_sr_nodes.
clear();
20463 m_sr_exec_sr_req.
clear();
20464 m_sr_exec_sr_conf.
clear();
20465 for (i = 0; i < 4; i++) {
20466 cactiveCopy[
i] = RNIL;
20469 ccurrentGcprec = RNIL;
20470 caddNodeState = ZFALSE;
20471 cstartRecReq = SRR_INITIAL;
20473 cnewestCompletedGci = 0;
20474 crestartOldestGci = 0;
20475 crestartNewestGci = 0;
20476 csrPhaseStarted = ZSR_NO_PHASE_STARTED;
20477 csrPhasesCompleted = 0;
20478 cmasterDihBlockref = 0;
20479 cnoFragmentsExecSr = 0;
20480 cnoOutstandingExecFragReq = 0;
20481 clcpCompletedState = LCP_IDLE;
20482 csrExecUndoLogState = EULS_IDLE;
20484 cnoOfFragsCheckpointed = 0;
20488 initialiseAddfragrec(signal);
20500 initialiseFragrec(signal);
20504 initialiseGcprec(signal);
20505 initialiseLcpRec(signal);
20509 initialiseLogPage(signal);
20513 initialiseLfo(signal);
20517 initialiseLogFile(signal);
20518 initialiseLogPart(signal);
20522 initialisePageRef(signal);
20526 initialiseScanrec(signal);
20530 initialiseTabrec(signal);
20534 initialiseTcNodeFailRec(signal);
20535 initialiseTcrec(signal);
20538 conf->senderRef = reference();
20539 conf->senderData = retData;
20540 sendSignal(retRef, GSN_READ_CONFIG_CONF, signal,
20541 ReadConfigConf::SignalLength, JBB);
20550 signal->theData[0] = ZINITIALISE_RECORDS;
20551 signal->theData[1] = data + 1;
20552 signal->theData[2] = 0;
20553 signal->theData[3] = retRef;
20554 signal->theData[4] = retData;
20555 sendSignal(reference(), GSN_CONTINUEB, signal, 5, JBB);
20564 void Dblqh::initialiseScanrec(
Signal* signal)
20566 ndbrequire(cscanrecFileSize > 1);
20568 while (tmp.seize(scanptr)){
20571 scanptr.p->scanType = ScanRecord::ST_IDLE;
20572 scanptr.p->scanState = ScanRecord::SCAN_FREE;
20573 scanptr.p->scanTcWaiting = 0;
20574 scanptr.p->nextHash = RNIL;
20575 scanptr.p->prevHash = RNIL;
20576 scanptr.p->scan_acc_index= 0;
20577 scanptr.p->scan_acc_segments= 0;
20578 scanptr.p->m_reserved = 0;
20586 m_reserved_scans.
seize(scanptr);
20587 scanptr.p->m_reserved = 1;
20588 m_reserved_scans.
seize(scanptr);
20589 scanptr.p->m_reserved = 1;
20597 void Dblqh::initialiseTabrec(
Signal* signal)
20599 if (ctabrecFileSize != 0) {
20600 for (tabptr.i = 0; tabptr.i < ctabrecFileSize; tabptr.i++) {
20602 ptrAss(tabptr, tablerec);
20604 tabptr.p->usageCountR = 0;
20605 tabptr.p->usageCountW = 0;
20606 for (Uint32 i = 0; i < MAX_FRAG_PER_NODE; i++) {
20607 tabptr.p->fragid[
i] = ZNIL;
20608 tabptr.p->fragrec[
i] = RNIL;
20618 void Dblqh::initialiseTcrec(
Signal* signal)
20620 if (ctcConnectrecFileSize != 0) {
20621 for (tcConnectptr.i = 0;
20622 tcConnectptr.i < ctcConnectrecFileSize;
20623 tcConnectptr.i++) {
20625 ptrAss(tcConnectptr, tcConnectionrec);
20626 tcConnectptr.p->transactionState = TcConnectionrec::TC_NOT_CONNECTED;
20627 tcConnectptr.p->tcScanRec = RNIL;
20628 tcConnectptr.p->logWriteState = TcConnectionrec::NOT_STARTED;
20629 tcConnectptr.p->keyInfoIVal = RNIL;
20630 tcConnectptr.p->attrInfoIVal = RNIL;
20631 tcConnectptr.p->m_flags= 0;
20632 tcConnectptr.p->tcTimer = 0;
20633 tcConnectptr.p->nextTcConnectrec = tcConnectptr.i + 1;
20635 tcConnectptr.i = ctcConnectrecFileSize - 1;
20636 ptrAss(tcConnectptr, tcConnectionrec);
20637 tcConnectptr.p->nextTcConnectrec = RNIL;
20638 cfirstfreeTcConrec = 0;
20641 cfirstfreeTcConrec = RNIL;
20649 void Dblqh::initialiseTcNodeFailRec(
Signal* signal)
20651 if (ctcNodeFailrecFileSize != 0) {
20652 for (tcNodeFailptr.i = 0;
20653 tcNodeFailptr.i < ctcNodeFailrecFileSize;
20654 tcNodeFailptr.i++) {
20655 ptrAss(tcNodeFailptr, tcNodeFailRecord);
20656 tcNodeFailptr.p->tcFailStatus = TcNodeFailRecord::TC_STATE_FALSE;
20666 void Dblqh::initFragrec(
Signal* signal,
20671 new (fragptr.p) Fragrecord();
20672 fragptr.p->m_scanNumberMask.
set();
20675 fragptr.p->lastWaitQueue = RNIL;
20680 fragptr.p->
logFlag = Fragrecord::STATE_TRUE;
20681 fragptr.p->
lcpFlag = Fragrecord::LCP_STATE_TRUE;
20682 for (Uint32 i = 0; i < MAX_LCP_STORED; i++) {
20683 fragptr.p->
lcpId[
i] = 0;
20686 fragptr.p->maxGciInLcp = 0;
20689 fragptr.p->
tabRef = tableId;
20690 fragptr.p->
fragId = fragId;
20691 fragptr.p->srStatus = Fragrecord::SS_IDLE;
20697 fragptr.p->m_copy_started_state = 0;
20716 void Dblqh::initGciInLogFileRec(
Signal* signal, Uint32 noFdDescriptors)
20718 LogFileRecordPtr filePtr = logFilePtr;
20719 Uint32 pos = ZPAGE_HEADER_SIZE + ZFD_HEADER_SIZE;
20720 for (Uint32 fd = 0; fd < noFdDescriptors; fd++)
20723 for (Uint32 mb = 0; mb < clogFileSize; mb++)
20726 Uint32 pos0 = pos + fd * (ZFD_MBYTE_SIZE * clogFileSize) + mb;
20727 Uint32 pos1 = pos0 + clogFileSize;
20728 Uint32 pos2 = pos1 + clogFileSize;
20729 arrGuard(pos0, ZPAGE_SIZE);
20730 arrGuard(pos1, ZPAGE_SIZE);
20731 arrGuard(pos2, ZPAGE_SIZE);
20732 filePtr.p->logMaxGciCompleted[mb] = logPagePtr.p->
logPageWord[pos0];
20733 filePtr.p->logMaxGciStarted[mb] = logPagePtr.p->
logPageWord[pos1];
20734 filePtr.p->logLastPrepRef[mb] = logPagePtr.p->
logPageWord[pos2];
20736 if (fd + 1 < noFdDescriptors)
20739 filePtr.i = filePtr.p->prevLogFile;
20740 ptrCheckGuard(filePtr, clogFileFileSize, logFileRecord);
20750 void Dblqh::initLcpSr(
Signal* signal,
20757 lcpPtr.p->lcpQueued =
false;
20758 lcpPtr.p->currentFragment.fragPtrI = fragPtr;
20759 lcpPtr.p->currentFragment.lcpFragOrd.lcpNo = lcpNo;
20760 lcpPtr.p->currentFragment.lcpFragOrd.lcpId = lcpId;
20761 lcpPtr.p->currentFragment.lcpFragOrd.tableId = tableId;
20762 lcpPtr.p->currentFragment.lcpFragOrd.fragmentId = fragId;
20763 lcpPtr.p->lcpState = LcpRecord::LCP_SR_WAIT_FRAGID;
20770 void Dblqh::initLogpart(
Signal* signal)
20776 logPartPtr.p->
logLap = 0;
20778 logPartPtr.p->logTailMbyte = 0;
20784 logPartPtr.p->
gcprec = RNIL;
20790 logPartPtr.p->m_log_problems = 0;
20792 ndbrequire(lpinfo.partCount == clogPartFileSize);
20793 logPartPtr.p->
logPartNo = lpinfo.partNo[logPartPtr.i];
20803 void Dblqh::initLogPointers(
Signal* signal)
20805 logPartPtr.i = tcConnectptr.p->m_log_part_ptr_i;
20806 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
20808 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
20810 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
20817 void Dblqh::initReqinfoExecSr(
Signal* signal)
20819 UintR Treqinfo = 0;
20820 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
20821 LqhKeyReq::setKeyLen(Treqinfo, regTcPtr->primKeyLen);
20832 LqhKeyReq::setDirtyFlag(Treqinfo, 1);
20836 LqhKeyReq::setSimpleFlag(Treqinfo, 1);
20837 LqhKeyReq::setGCIFlag(Treqinfo, 1);
20841 LqhKeyReq::setOperation(Treqinfo, regTcPtr->operation);
20842 regTcPtr->reqinfo = Treqinfo;
20851 regTcPtr->lastReplicaNo = 0;
20852 regTcPtr->apiVersionNo = 0;
20853 regTcPtr->nextSeqNoReplica = 0;
20854 regTcPtr->opExec = 0;
20855 regTcPtr->storedProcId = ZNIL;
20856 regTcPtr->readlenAi = 0;
20857 regTcPtr->nodeAfterNext[0] = ZNIL;
20858 regTcPtr->nodeAfterNext[1] = ZNIL;
20859 regTcPtr->dirtyOp = ZFALSE;
20860 regTcPtr->tcBlockref = cownref;
20861 regTcPtr->m_reorg = 0;
20868 bool Dblqh::insertFragrec(
Signal* signal, Uint32 fragId)
20871 if(c_fragment_pool.
seize(fragptr) ==
false)
20873 terrorCode = ZNO_FREE_FRAGMENTREC;
20876 for (Uint32 i = 0; i < MAX_FRAG_PER_NODE; i++) {
20878 if (tabptr.p->fragid[i] == ZNIL) {
20880 tabptr.p->fragid[
i] = fragId;
20881 tabptr.p->fragrec[
i] = fragptr.i;
20885 c_fragment_pool.
release(fragptr);
20886 terrorCode = ZTOO_MANY_FRAGMENTS;
20898 void Dblqh::linkFragQueue(
Signal* signal)
20900 TcConnectionrecPtr lfqTcConnectptr;
20901 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
20902 Fragrecord *
const regFragPtr = fragptr.p;
20903 Uint32 tcIndex = tcConnectptr.i;
20905 lfqTcConnectptr.i = regFragPtr->lastWaitQueue;
20906 regTcPtr->nextTc = RNIL;
20907 regFragPtr->lastWaitQueue = tcIndex;
20908 regTcPtr->prevTc = lfqTcConnectptr.i;
20909 ndbrequire(regTcPtr->listState == TcConnectionrec::NOT_IN_LIST);
20910 regTcPtr->listState = TcConnectionrec::WAIT_QUEUE_LIST;
20911 if (lfqTcConnectptr.i != RNIL) {
20913 ptrCheckGuard(lfqTcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
20914 lfqTcConnectptr.p->nextTc = tcIndex;
20916 regFragPtr->firstWaitQueue = tcIndex;
20930 Dblqh::linkWaitLog(
Signal* signal,
20931 LogPartRecordPtr regLogPartPtr,
20932 LogPartRecord::OperationQueue & queue)
20934 TcConnectionrecPtr lwlTcConnectptr;
20939 lwlTcConnectptr.i = queue.lastElement;
20940 if (lwlTcConnectptr.i == RNIL) {
20942 queue.firstElement = tcConnectptr.i;
20945 ptrCheckGuard(lwlTcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
20946 lwlTcConnectptr.p->nextTcLogQueue = tcConnectptr.i;
20948 queue.lastElement = tcConnectptr.i;
20949 tcConnectptr.p->nextTcLogQueue = RNIL;
20951 if (regLogPartPtr.p->LogLqhKeyReqSent == ZFALSE)
20954 regLogPartPtr.p->LogLqhKeyReqSent = ZTRUE;
20955 signal->theData[0] = ZLOG_LQHKEYREQ;
20956 signal->theData[1] = regLogPartPtr.i;
20957 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
20970 void Dblqh::logNextStart(
Signal* signal)
20972 LogPartRecordPtr lnsLogPartPtr;
20973 UintR tlnsStillWaiting;
20974 LogPartRecord *
const regLogPartPtr = logPartPtr.p;
20976 if (regLogPartPtr->m_log_prepare_queue.isEmpty() &&
20977 regLogPartPtr->m_log_complete_queue.isEmpty() &&
20978 (regLogPartPtr->waitWriteGciLog != LogPartRecord::WWGL_TRUE))
20986 if (!regLogPartPtr->m_log_prepare_queue.isEmpty() ||
20987 !regLogPartPtr->m_log_complete_queue.isEmpty())
20991 if (regLogPartPtr->LogLqhKeyReqSent == ZFALSE)
20994 regLogPartPtr->LogLqhKeyReqSent = ZTRUE;
20995 signal->theData[0] = ZLOG_LQHKEYREQ;
20996 signal->theData[1] = logPartPtr.i;
20997 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
21001 if (regLogPartPtr->waitWriteGciLog != LogPartRecord::WWGL_TRUE)
21015 writeCompletedGciLog(signal);
21017 tlnsStillWaiting = ZFALSE;
21018 for (lnsLogPartPtr.i = 0; lnsLogPartPtr.i < clogPartFileSize; lnsLogPartPtr.i++) {
21020 ptrAss(lnsLogPartPtr, logPartRecord);
21021 if (lnsLogPartPtr.p->waitWriteGciLog == LogPartRecord::WWGL_TRUE) {
21023 tlnsStillWaiting = ZTRUE;
21026 if (tlnsStillWaiting == ZFALSE) {
21028 signal->theData[0] = ZINIT_GCP_REC;
21029 sendSignal(cownref, GSN_CONTINUEB, signal, 1, JBB);
21040 void Dblqh::moveToPageRef(
Signal* signal)
21042 LogPageRecordPtr mprLogPagePtr;
21043 PageRefRecordPtr mprPageRefPtr;
21053 PageRefRecordPtr iprPageRefPtr;
21055 if ((logPartPtr.p->
mmBufferSize + 8) >= ZMAX_MM_BUFFER_SIZE) {
21058 ptrCheckGuard(pageRefPtr, cpageRefFileSize, pageRefRecord);
21059 releasePrPages(signal);
21060 removePageRef(signal);
21065 seizePageRef(signal);
21072 ptrCheckGuard(iprPageRefPtr, cpageRefFileSize, pageRefRecord);
21073 iprPageRefPtr.p->prNext = pageRefPtr.i;
21075 pageRefPtr.p->prPrev = logPartPtr.p->
lastPageRef;
21078 pageRefPtr.p->prFileNo = logFilePtr.p->
fileNo;
21079 pageRefPtr.p->prPageNo = lfoPtr.p->
lfoPageNo;
21083 arrGuard(tmprIndex, 8);
21084 pageRefPtr.p->pageRef[tmprIndex] = mprLogPagePtr.i;
21085 tmprIndex = tmprIndex + 1;
21086 ptrCheckGuard(mprLogPagePtr, clogPageFileSize, logPageRecord);
21087 mprLogPagePtr.i = mprLogPagePtr.p->logPageWord[ZNEXT_PAGE];
21088 if (mprLogPagePtr.i != RNIL) {
21092 mprPageRefPtr.i = pageRefPtr.p->prPrev;
21093 if (mprPageRefPtr.i != RNIL) {
21095 ptrCheckGuard(mprPageRefPtr, cpageRefFileSize, pageRefRecord);
21096 mprLogPagePtr.i = mprPageRefPtr.p->pageRef[7];
21097 ptrCheckGuard(mprLogPagePtr, clogPageFileSize, logPageRecord);
21098 mprLogPagePtr.p->logPageWord[ZNEXT_PAGE] = pageRefPtr.p->pageRef[0];
21107 void Dblqh::readAttrinfo(
Signal* signal)
21109 Uint32 remainingLen = tcConnectptr.p->totSendlenAi;
21110 tcConnectptr.p->reclenAiLqhkey = 0;
21111 if (remainingLen == 0) {
21116 readLogData(signal, remainingLen, tcConnectptr.p->attrInfoIVal);
21124 void Dblqh::readCommitLog(
Signal* signal, CommitLogRecord* commitLogRecord)
21126 Uint32 trclPageIndex = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
21127 if ((trclPageIndex + (ZCOMMIT_LOG_SIZE - 1)) < ZPAGE_SIZE) {
21129 tcConnectptr.p->tableref = logPagePtr.p->
logPageWord[trclPageIndex + 0];
21130 tcConnectptr.p->schemaVersion = logPagePtr.p->
logPageWord[trclPageIndex + 1];
21131 tcConnectptr.p->fragmentid = logPagePtr.p->
logPageWord[trclPageIndex + 2];
21132 commitLogRecord->fileNo = logPagePtr.p->
logPageWord[trclPageIndex + 3];
21133 commitLogRecord->startPageNo = logPagePtr.p->
logPageWord[trclPageIndex + 4];
21134 commitLogRecord->startPageIndex = logPagePtr.p->
logPageWord[trclPageIndex + 5];
21135 commitLogRecord->stopPageNo = logPagePtr.p->
logPageWord[trclPageIndex + 6];
21136 tcConnectptr.p->gci_hi = logPagePtr.p->
logPageWord[trclPageIndex + 7];
21137 tcConnectptr.p->gci_lo = 0;
21139 (trclPageIndex + ZCOMMIT_LOG_SIZE) - 1;
21142 tcConnectptr.p->tableref = readLogword(signal);
21143 tcConnectptr.p->schemaVersion = readLogword(signal);
21144 tcConnectptr.p->fragmentid = readLogword(signal);
21145 commitLogRecord->fileNo = readLogword(signal);
21146 commitLogRecord->startPageNo = readLogword(signal);
21147 commitLogRecord->startPageIndex = readLogword(signal);
21148 commitLogRecord->stopPageNo = readLogword(signal);
21149 tcConnectptr.p->gci_hi = readLogword(signal);
21150 tcConnectptr.p->gci_lo = 0;
21152 tcConnectptr.p->transid[0] = logPartPtr.i + 65536;
21153 tcConnectptr.p->transid[1] = (DBLQH << 20) + (cownNodeid << 8);
21162 void Dblqh::readExecLog(
Signal* signal)
21170 arrGuard(trelI + 1, 16);
21173 (UintR)~trelIndex; trelIndex--) {
21175 seizeLogpage(signal);
21176 arrGuard(trelI, 16);
21184 signal->theData[0] = logFilePtr.p->
fileRef;
21185 signal->theData[1] = cownref;
21186 signal->theData[2] = lfoPtr.i;
21187 signal->theData[3] = ZLIST_OF_MEM_PAGES;
21188 signal->theData[4] = ZVAR_NO_LOG_PAGE_WORD;
21189 signal->theData[5] = lfoPtr.p->
noPagesRw;
21200 sendSignal(NDBFS_REF, GSN_FSREADREQ, signal, 16, JBA);
21204 ndbout_c(
"readExecLog %u page at part: %u file: %u page: %u (mb: %u)",
21218 void Dblqh::readExecSrNewMbyte(
Signal* signal)
21225 readExecSr(signal);
21226 logPartPtr.p->
logExecState = LogPartRecord::LES_WAIT_READ_EXEC_SR_NEW_MBYTE;
21234 void Dblqh::readExecSr(
Signal* signal)
21242 for (tresIndex = 7; (UintR)~tresIndex; tresIndex--) {
21248 seizeLogpage(signal);
21251 lfoPtr.p->
lfoState = LogFileOperationRecord::READ_EXEC_SR;
21257 signal->theData[0] = logFilePtr.p->
fileRef;
21258 signal->theData[1] = cownref;
21259 signal->theData[2] = lfoPtr.i;
21260 signal->theData[3] = ZLIST_OF_MEM_PAGES;
21261 signal->theData[4] = ZVAR_NO_LOG_PAGE_WORD;
21262 signal->theData[5] = 8;
21271 signal->theData[14] = tresPageid;
21272 sendSignal(NDBFS_REF, GSN_FSREADREQ, signal, 15, JBA);
21276 ndbout_c(
"readExecSr %u page at part: %u file: %u page: %u (mb: %u)",
21281 tresPageid >> ZTWOLOG_NO_PAGES_IN_MBYTE);
21290 void Dblqh::readKey(
Signal* signal)
21292 Uint32 remainingLen = tcConnectptr.p->primKeyLen;
21293 ndbrequire(remainingLen != 0);
21295 readLogData(signal, remainingLen, tcConnectptr.p->keyInfoIVal);
21303 void Dblqh::readLogData(
Signal* signal, Uint32 noOfWords, Uint32& sectionIVal)
21305 Uint32 logPos = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
21306 if ((logPos + noOfWords) >= ZPAGE_SIZE) {
21307 for (Uint32 i = 0; i < noOfWords; i++)
21310 Uint32
word= readLogwordExec(signal);
21311 bool ok= appendToSection(sectionIVal,
21318 bool ok= appendToSection(sectionIVal,
21322 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = logPos + noOfWords;
21331 void Dblqh::readLogHeader(
Signal* signal)
21333 Uint32 logPos = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
21334 if ((logPos + ZLOG_HEAD_SIZE) < ZPAGE_SIZE) {
21336 tcConnectptr.p->hashValue = logPagePtr.p->
logPageWord[logPos + 2];
21337 tcConnectptr.p->operation = logPagePtr.p->
logPageWord[logPos + 3];
21338 tcConnectptr.p->totSendlenAi = logPagePtr.p->
logPageWord[logPos + 4];
21339 tcConnectptr.p->primKeyLen = logPagePtr.p->
logPageWord[logPos + 5];
21340 tcConnectptr.p->m_row_id.m_page_no = logPagePtr.p->
logPageWord[logPos + 6];
21341 tcConnectptr.p->m_row_id.m_page_idx = logPagePtr.p->
logPageWord[logPos+ 7];
21342 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = logPos + ZLOG_HEAD_SIZE;
21345 readLogwordExec(signal);
21346 readLogwordExec(signal);
21347 tcConnectptr.p->hashValue = readLogwordExec(signal);
21348 tcConnectptr.p->operation = readLogwordExec(signal);
21349 tcConnectptr.p->totSendlenAi = readLogwordExec(signal);
21350 tcConnectptr.p->primKeyLen = readLogwordExec(signal);
21351 tcConnectptr.p->m_row_id.m_page_no = readLogwordExec(signal);
21352 tcConnectptr.p->m_row_id.m_page_idx = readLogwordExec(signal);
21355 tcConnectptr.p->m_use_rowid = (tcConnectptr.p->operation == ZINSERT);
21364 Uint32 Dblqh::readLogword(
Signal* signal)
21366 Uint32 logPos = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
21367 ndbrequire(logPos < ZPAGE_SIZE);
21368 Uint32 logWord = logPagePtr.p->
logPageWord[logPos];
21370 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = logPos;
21371 if (logPos >= ZPAGE_SIZE) {
21373 logPagePtr.i = logPagePtr.p->
logPageWord[ZNEXT_PAGE];
21374 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
21375 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_HEADER_SIZE;
21390 Uint32 Dblqh::readLogwordExec(
Signal* signal)
21392 Uint32 logPos = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
21393 ndbrequire(logPos < ZPAGE_SIZE);
21394 Uint32 logWord = logPagePtr.p->
logPageWord[logPos];
21396 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = logPos;
21397 if (logPos >= ZPAGE_SIZE) {
21399 logPagePtr.i = logPagePtr.p->
logPageWord[ZNEXT_PAGE];
21400 if (logPagePtr.i != RNIL){
21401 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
21402 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_HEADER_SIZE;
21419 void Dblqh::readSinglePage(
Signal* signal, Uint32 pageNo)
21423 seizeLogpage(signal);
21427 signal->theData[0] = logFilePtr.p->
fileRef;
21428 signal->theData[1] = cownref;
21429 signal->theData[2] = lfoPtr.i;
21430 signal->theData[3] = ZLIST_OF_PAIRS;
21431 signal->theData[4] = ZVAR_NO_LOG_PAGE_WORD;
21432 signal->theData[5] = 1;
21433 signal->theData[6] = logPagePtr.i;
21434 signal->theData[7] = pageNo;
21435 sendSignal(NDBFS_REF, GSN_FSREADREQ, signal, 8, JBA);
21439 ndbout_c(
"readSinglePage 1 page at part: %u file: %u page: %u (mb: %u)",
21443 pageNo >> ZTWOLOG_NO_PAGES_IN_MBYTE);
21451 void Dblqh::releaseActiveCopy(
Signal* signal)
21458 for (tracIndex = 0; tracIndex < 4; tracIndex++) {
21459 if (tracFlag == ZFALSE) {
21461 if (cactiveCopy[tracIndex] == fragptr.i) {
21466 if (tracIndex < 3) {
21468 cactiveCopy[tracIndex - 1] = cactiveCopy[tracIndex];
21471 cactiveCopy[3] = RNIL;
21475 ndbrequire(tracFlag == ZTRUE);
21484 void Dblqh::releaseAddfragrec(
Signal* signal)
21486 addfragptr.p->addfragStatus = AddFragRecord::FREE;
21487 addfragptr.p->nextAddfragrec = cfirstfreeAddfragrec;
21488 cfirstfreeAddfragrec = addfragptr.i;
21495 void Dblqh::releasePageRef(
Signal* signal)
21497 pageRefPtr.p->prNext = cfirstfreePageRef;
21498 cfirstfreePageRef = pageRefPtr.i;
21505 void Dblqh::releaseMmPages(
Signal* signal)
21510 if (pageRefPtr.i != RNIL) {
21512 ptrCheckGuard(pageRefPtr, cpageRefFileSize, pageRefRecord);
21513 releasePrPages(signal);
21514 removePageRef(signal);
21523 void Dblqh::releasePrPages(
Signal* signal)
21527 for (trppIndex = 0; trppIndex <= 7; trppIndex++) {
21529 logPagePtr.i = pageRefPtr.p->pageRef[trppIndex];
21530 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
21531 releaseLogpage(signal);
21540 void Dblqh::releaseWaitQueue(
Signal* signal)
21542 TcConnectionrecPtr rwaTcNextConnectptr;
21543 TcConnectionrecPtr rwaTcPrevConnectptr;
21545 fragptr.i = tcConnectptr.p->fragmentptr;
21546 c_fragment_pool.
getPtr(fragptr);
21547 rwaTcPrevConnectptr.i = tcConnectptr.p->prevTc;
21548 rwaTcNextConnectptr.i = tcConnectptr.p->nextTc;
21549 if (tcConnectptr.p->
listState != TcConnectionrec::WAIT_QUEUE_LIST) {
21551 systemError(signal, __LINE__);
21553 tcConnectptr.p->
listState = TcConnectionrec::NOT_IN_LIST;
21554 if (rwaTcNextConnectptr.i != RNIL) {
21556 ptrCheckGuard(rwaTcNextConnectptr, ctcConnectrecFileSize, tcConnectionrec);
21557 rwaTcNextConnectptr.p->prevTc = rwaTcPrevConnectptr.i;
21560 fragptr.p->lastWaitQueue = rwaTcPrevConnectptr.i;
21562 if (rwaTcPrevConnectptr.i != RNIL) {
21564 ptrCheckGuard(rwaTcPrevConnectptr, ctcConnectrecFileSize, tcConnectionrec);
21565 rwaTcPrevConnectptr.p->nextTc = rwaTcNextConnectptr.i;
21578 void Dblqh::removeLogTcrec(
Signal* signal)
21580 TcConnectionrecPtr rloTcNextConnectptr;
21581 TcConnectionrecPtr rloTcPrevConnectptr;
21582 rloTcPrevConnectptr.i = tcConnectptr.p->prevLogTcrec;
21583 rloTcNextConnectptr.i = tcConnectptr.p->nextLogTcrec;
21584 if (rloTcNextConnectptr.i != RNIL) {
21586 ptrCheckGuard(rloTcNextConnectptr, ctcConnectrecFileSize, tcConnectionrec);
21587 rloTcNextConnectptr.p->prevLogTcrec = rloTcPrevConnectptr.i;
21592 if (rloTcPrevConnectptr.i != RNIL) {
21594 ptrCheckGuard(rloTcPrevConnectptr, ctcConnectrecFileSize, tcConnectionrec);
21595 rloTcPrevConnectptr.p->nextLogTcrec = rloTcNextConnectptr.i;
21607 void Dblqh::removePageRef(
Signal* signal)
21609 PageRefRecordPtr rprPageRefPtr;
21612 if (pageRefPtr.i != RNIL) {
21614 ptrCheckGuard(pageRefPtr, cpageRefFileSize, pageRefRecord);
21615 if (pageRefPtr.p->prNext == RNIL) {
21622 rprPageRefPtr.i = pageRefPtr.p->prNext;
21623 ptrCheckGuard(rprPageRefPtr, cpageRefFileSize, pageRefRecord);
21624 rprPageRefPtr.p->prPrev = RNIL;
21626 releasePageRef(signal);
21634 Uint32 Dblqh::returnExecLog(
Signal* signal)
21636 tcConnectptr.p->connectState = TcConnectionrec::CONNECTED;
21637 initLogPointers(signal);
21639 Uint32 result = checkIfExecLog(signal);
21640 if (result == ZOK) {
21646 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
21655 LogPartRecord::LES_EXEC_LOGREC_FROM_FILE) {
21661 ptrCheckGuard(lfoPtr, clfoFileSize, logFileOperationRecord);
21662 releaseLfoPages(signal);
21663 releaseLfo(signal);
21664 logPartPtr.p->
logExecState = LogPartRecord::LES_EXEC_LOG;
21667 LogFileRecordPtr clfLogFilePtr;
21669 ptrCheckGuard(clfLogFilePtr, clogFileFileSize, logFileRecord);
21670 #ifndef NO_REDO_OPEN_FILE_CACHE
21671 closeFile_cache(signal, clfLogFilePtr, __LINE__);
21673 clfLogFilePtr.p->logFileStatus = LogFileRecord::CLOSING_EXEC_LOG;
21674 closeFile(signal, clfLogFilePtr, __LINE__);
21676 result = ZCLOSE_FILE;
21683 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
21693 void Dblqh::seizeAddfragrec(
Signal* signal)
21695 addfragptr.i = cfirstfreeAddfragrec;
21696 ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord);
21697 cfirstfreeAddfragrec = addfragptr.p->nextAddfragrec;
21699 addfragptr.p->accConnectptr = RNIL;
21700 addfragptr.p->tupConnectptr = RNIL;
21701 addfragptr.p->tuxConnectptr = RNIL;
21702 addfragptr.p->defValSectionI = RNIL;
21703 addfragptr.p->defValNextPos = 0;
21704 bzero(&addfragptr.p->m_createTabReq,
sizeof(addfragptr.p->m_createTabReq));
21705 bzero(&addfragptr.p->m_lqhFragReq,
sizeof(addfragptr.p->m_lqhFragReq));
21706 bzero(&addfragptr.p->m_addAttrReq,
sizeof(addfragptr.p->m_addAttrReq));
21707 bzero(&addfragptr.p->m_dropFragReq,
sizeof(addfragptr.p->m_dropFragReq));
21708 bzero(&addfragptr.p->m_dropTabReq,
sizeof(addfragptr.p->m_dropTabReq));
21709 addfragptr.p->addfragErrorCode = 0;
21710 addfragptr.p->attrSentToTup = 0;
21711 addfragptr.p->attrReceived = 0;
21712 addfragptr.p->totalAttrReceived = 0;
21723 void Dblqh::seizePageRef(
Signal* signal)
21725 pageRefPtr.i = cfirstfreePageRef;
21726 ptrCheckGuard(pageRefPtr, cpageRefFileSize, pageRefRecord);
21727 cfirstfreePageRef = pageRefPtr.p->prNext;
21728 pageRefPtr.p->prNext = RNIL;
21735 void Dblqh::sendAborted(
Signal* signal)
21738 if (tcConnectptr.p->nextReplica == ZNIL) {
21743 signal->theData[0] = tcConnectptr.p->tcOprec;
21744 signal->theData[1] = tcConnectptr.p->transid[0];
21745 signal->theData[2] = tcConnectptr.p->transid[1];
21746 signal->theData[3] = cownNodeid;
21747 signal->theData[4] = TlastInd;
21748 sendSignal(tcConnectptr.p->tcBlockref, GSN_ABORTED, signal, 5, JBB);
21756 void Dblqh::sendLqhTransconf(
Signal* signal, LqhTransConf::OperationStatus stat)
21758 tcNodeFailptr.i = tcConnectptr.p->tcNodeFailrec;
21759 ptrCheckGuard(tcNodeFailptr, ctcNodeFailrecFileSize, tcNodeFailRecord);
21761 Uint32 reqInfo = 0;
21762 LqhTransConf::setReplicaType(reqInfo, tcConnectptr.p->replicaType);
21763 LqhTransConf::setReplicaNo(reqInfo, tcConnectptr.p->seqNoReplica);
21764 LqhTransConf::setLastReplicaNo(reqInfo, tcConnectptr.p->lastReplicaNo);
21765 LqhTransConf::setSimpleFlag(reqInfo, tcConnectptr.p->opSimple);
21766 LqhTransConf::setDirtyFlag(reqInfo, tcConnectptr.p->dirtyOp);
21767 LqhTransConf::setOperation(reqInfo, tcConnectptr.p->operation);
21770 lqhTransConf->tcRef = tcNodeFailptr.p->newTcRef;
21771 lqhTransConf->lqhNodeId = cownNodeid;
21772 lqhTransConf->operationStatus = stat;
21773 lqhTransConf->lqhConnectPtr = tcConnectptr.i;
21774 lqhTransConf->transId1 = tcConnectptr.p->transid[0];
21775 lqhTransConf->transId2 = tcConnectptr.p->transid[1];
21776 lqhTransConf->oldTcOpRec = tcConnectptr.p->tcOprec;
21777 lqhTransConf->requestInfo = reqInfo;
21778 lqhTransConf->gci_hi = tcConnectptr.p->gci_hi;
21779 lqhTransConf->nextNodeId1 = tcConnectptr.p->nextReplica;
21780 lqhTransConf->nextNodeId2 = tcConnectptr.p->nodeAfterNext[0];
21781 lqhTransConf->nextNodeId3 = tcConnectptr.p->nodeAfterNext[1];
21782 lqhTransConf->apiRef = tcConnectptr.p->applRef;
21783 lqhTransConf->apiOpRec = tcConnectptr.p->applOprec;
21784 lqhTransConf->tableId = tcConnectptr.p->tableref;
21785 lqhTransConf->gci_lo = tcConnectptr.p->gci_lo;
21786 lqhTransConf->fragId = tcConnectptr.p->fragmentid;
21787 sendSignal(tcNodeFailptr.p->newTcBlockref, GSN_LQH_TRANSCONF,
21788 signal, LqhTransConf::SignalLength, JBB);
21789 tcNodeFailptr.p->tcRecNow = tcConnectptr.i + 1;
21790 signal->theData[0] = ZLQH_TRANS_NEXT;
21791 signal->theData[1] = tcNodeFailptr.i;
21792 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
21796 ndbout_c(
"sending LQH_TRANSCONF %u transid: H'%.8x, H'%.8x op: %u state: %u(%u) marker: %u",
21798 tcConnectptr.p->transid[0],
21799 tcConnectptr.p->transid[1],
21800 tcConnectptr.p->operation,
21801 tcConnectptr.p->transactionState,
21803 tcConnectptr.p->commitAckMarker);
21812 void Dblqh::startExecSr(
Signal* signal)
21814 c_lcp_complete_fragments.
first(fragptr);
21815 signal->theData[0] = fragptr.i;
21816 sendSignal(cownref, GSN_START_EXEC_SR, signal, 1, JBB);
21826 void Dblqh::stepAhead(
Signal* signal, Uint32 stepAheadWords)
21830 tsaPos = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
21831 while ((stepAheadWords + tsaPos) >= ZPAGE_SIZE) {
21833 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_SIZE;
21834 stepAheadWords = stepAheadWords - (ZPAGE_SIZE - tsaPos);
21836 logPagePtr.i = logPagePtr.p->
logPageWord[ZNEXT_PAGE];
21838 ptrCheckGuardErr(logPagePtr, clogPageFileSize, logPageRecord,
21839 NDBD_EXIT_SR_REDOLOG);
21840 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_HEADER_SIZE;
21843 tsaPos = ZPAGE_HEADER_SIZE;
21845 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = stepAheadWords + tsaPos;
21853 void Dblqh::writeAbortLog(
Signal* signal)
21855 if ((ZABORT_LOG_SIZE + ZNEXT_LOG_SIZE) >
21858 changeMbyte(signal);
21862 writeLogWord(signal, ZABORT_TYPE);
21863 writeLogWord(signal, tcConnectptr.p->transid[0]);
21864 writeLogWord(signal, tcConnectptr.p->transid[1]);
21872 void Dblqh::writeCommitLog(
Signal* signal, LogPartRecordPtr regLogPartPtr)
21874 LogFileRecordPtr regLogFilePtr;
21875 LogPageRecordPtr regLogPagePtr;
21876 TcConnectionrec *
const regTcPtr = tcConnectptr.p;
21877 regLogFilePtr.i = regLogPartPtr.p->currentLogfile;
21878 ptrCheckGuard(regLogFilePtr, clogFileFileSize, logFileRecord);
21879 regLogPagePtr.i = regLogFilePtr.p->currentLogpage;
21880 Uint32 twclTmp = regLogFilePtr.p->remainingWordsInMbyte;
21881 ptrCheckGuard(regLogPagePtr, clogPageFileSize, logPageRecord);
21882 logPartPtr = regLogPartPtr;
21883 logFilePtr = regLogFilePtr;
21884 logPagePtr = regLogPagePtr;
21885 if ((ZCOMMIT_LOG_SIZE + ZNEXT_LOG_SIZE) > twclTmp) {
21887 changeMbyte(signal);
21891 Uint32 twclLogPos = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
21892 Uint32 tableId = regTcPtr->tableref;
21893 Uint32 schemaVersion = regTcPtr->schemaVersion;
21894 Uint32 fragId = regTcPtr->fragmentid;
21895 Uint32 fileNo = regTcPtr->logStartFileNo;
21896 Uint32 startPageNo = regTcPtr->logStartPageNo;
21897 Uint32 pageIndex = regTcPtr->logStartPageIndex;
21898 Uint32 stopPageNo = regTcPtr->logStopPageNo;
21899 Uint32 gci = regTcPtr->gci_hi;
21902 if ((twclLogPos + ZCOMMIT_LOG_SIZE) >= ZPAGE_SIZE) {
21903 writeLogWord(signal, ZCOMMIT_TYPE);
21904 writeLogWord(signal, tableId);
21905 writeLogWord(signal, schemaVersion);
21906 writeLogWord(signal, fragId);
21907 writeLogWord(signal, fileNo);
21908 writeLogWord(signal, startPageNo);
21909 writeLogWord(signal, pageIndex);
21910 writeLogWord(signal, stopPageNo);
21911 writeLogWord(signal, gci);
21913 Uint32* dataPtr = &logPagePtr.p->
logPageWord[twclLogPos];
21914 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = twclLogPos + ZCOMMIT_LOG_SIZE;
21915 dataPtr[0] = ZCOMMIT_TYPE;
21916 dataPtr[1] = tableId;
21917 dataPtr[2] = schemaVersion;
21918 dataPtr[3] = fragId;
21919 dataPtr[4] = fileNo;
21920 dataPtr[5] = startPageNo;
21921 dataPtr[6] = pageIndex;
21922 dataPtr[7] = stopPageNo;
21925 TcConnectionrecPtr rloTcNextConnectptr;
21926 TcConnectionrecPtr rloTcPrevConnectptr;
21927 rloTcPrevConnectptr.i = regTcPtr->prevLogTcrec;
21928 rloTcNextConnectptr.i = regTcPtr->nextLogTcrec;
21929 if (rloTcNextConnectptr.i != RNIL) {
21931 ptrCheckGuard(rloTcNextConnectptr, ctcConnectrecFileSize, tcConnectionrec);
21932 rloTcNextConnectptr.p->prevLogTcrec = rloTcPrevConnectptr.i;
21934 regLogPartPtr.p->lastLogTcrec = rloTcPrevConnectptr.i;
21936 if (rloTcPrevConnectptr.i != RNIL) {
21938 ptrCheckGuard(rloTcPrevConnectptr, ctcConnectrecFileSize, tcConnectionrec);
21939 rloTcPrevConnectptr.p->nextLogTcrec = rloTcNextConnectptr.i;
21941 regLogPartPtr.p->firstLogTcrec = rloTcNextConnectptr.i;
21953 void Dblqh::writeCompletedGciLog(
Signal* signal)
21955 if ((ZCOMPLETED_GCI_LOG_SIZE + ZNEXT_LOG_SIZE) >
21958 changeMbyte(signal);
21964 SET_ERROR_INSERT_VALUE(5000);
21972 ndbout_c(
"writeCompletedGciLog gci: %u part: %u file: %u page: %u (mb: %u)",
21973 cnewestCompletedGci,
21980 writeLogWord(signal, ZCOMPLETED_GCI_TYPE);
21981 writeLogWord(signal, cnewestCompletedGci);
21990 void Dblqh::writeDirty(
Signal* signal, Uint32 place)
21992 logPagePtr.p->
logPageWord[ZPOS_DIRTY] = ZNOT_DIRTY;
21996 writeDbgInfoPageHeader(logPagePtr, place, logPartPtr.p->
prevFilepage,
21999 logPagePtr.p->
logPageWord[ZPOS_CHECKSUM] = calcPageCheckSum(logPagePtr);
22005 lfoPtr.p->
lfoState = LogFileOperationRecord::WRITE_DIRTY;
22007 signal->theData[0] = logFilePtr.p->
fileRef;
22008 signal->theData[1] = cownref;
22009 signal->theData[2] = lfoPtr.i;
22010 signal->theData[3] = ZLIST_OF_PAIRS_SYNCH;
22011 signal->theData[4] = ZVAR_NO_LOG_PAGE_WORD;
22012 signal->theData[5] = 1;
22013 signal->theData[6] = logPagePtr.i;
22015 sendSignal(NDBFS_REF, GSN_FSWRITEREQ, signal, 8, JBA);
22017 ndbrequire(logFilePtr.p->
fileRef != RNIL);
22023 ndbout_c(
"writeDirty 1 page at part: %u file: %u page: %u (mb: %u)",
22027 logPartPtr.p->
prevFilepage >> ZTWOLOG_NO_PAGES_IN_MBYTE);
22036 void Dblqh::writeLogWord(
Signal* signal, Uint32 data)
22038 Uint32 logPos = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
22039 ndbrequire(logPos < ZPAGE_SIZE);
22041 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = logPos + 1;
22042 if ((logPos + 1) == ZPAGE_SIZE) {
22044 completedLogPage(signal, ZNORMAL, __LINE__);
22045 seizeLogpage(signal);
22046 initLogpage(signal);
22057 void Dblqh::writeLogWords(
Signal* signal,
const Uint32* data, Uint32 len)
22059 Uint32 logPos = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
22060 ndbrequire(logPos < ZPAGE_SIZE);
22061 Uint32 wordsThisPage= ZPAGE_SIZE - logPos;
22063 while (len >= wordsThisPage)
22066 MEMCOPY_NO_WORDS(&logPagePtr.p->
logPageWord[logPos],
22069 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_SIZE;
22070 data+= wordsThisPage;
22071 len-= wordsThisPage;
22075 completedLogPage(signal, ZNORMAL, __LINE__);
22076 seizeLogpage(signal);
22077 initLogpage(signal);
22081 logPos = logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX];
22082 ndbrequire(logPos < ZPAGE_SIZE);
22083 wordsThisPage= ZPAGE_SIZE - logPos;
22089 ndbassert( len < wordsThisPage );
22091 MEMCOPY_NO_WORDS(&logPagePtr.p->
logPageWord[logPos],
22094 logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] = logPos + len;
22097 ndbassert( logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] < ZPAGE_SIZE );
22109 void Dblqh::writeNextLog(
Signal* signal)
22111 LogFileRecordPtr wnlNextLogFilePtr;
22112 UintR twnlNextFileNo;
22113 UintR twnlNewMbyte;
22114 UintR twnlRemWords;
22115 UintR twnlNextMbyte;
22123 twnlRemWords = ZPAGE_SIZE - ZPAGE_HEADER_SIZE;
22124 twnlRemWords = twnlRemWords * ZPAGES_IN_MBYTE;
22126 ptrCheckGuard(wnlNextLogFilePtr, clogFileFileSize, logFileRecord);
22130 ndbrequire(logPagePtr.p->
logPageWord[ZCURR_PAGE_INDEX] < ZPAGE_SIZE);
22133 if (logFilePtr.p->
currentMbyte == (clogFileSize - 1)) {
22139 twnlRemWords = twnlRemWords - (ZPAGE_SIZE - ZPAGE_HEADER_SIZE);
22150 completedLogPage(signal, ZLAST_WRITE_IN_FILE, __LINE__);
22151 if (wnlNextLogFilePtr.p->fileNo == 0) {
22160 logFilePtr.i = wnlNextLogFilePtr.i;
22161 logFilePtr.p = wnlNextLogFilePtr.p;
22169 completedLogPage(signal, ZENFORCE_WRITE, __LINE__);
22182 logFilePtr.p->
filePosition = twnlNewMbyte * ZPAGES_IN_MBYTE;
22185 seizeLogpage(signal);
22189 if (logFilePtr.p->
fileNo == 0) {
22191 releaseLogpage(signal);
22193 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
22196 initLogpage(signal);
22205 writeFileHeaderOpen(signal, ZNORMAL);
22206 openNextLogfile(signal);
22211 if (logFilePtr.p->
currentMbyte == logPartPtr.p->logTailMbyte)
22223 "Head/Tail met in REDO log, logpart: %u"
22224 " file: %u mbyte: %u state: %u log-problem: %u",
22229 logPartPtr.p->m_log_problems);
22232 signal->theData[0] = 2398;
22233 execDUMP_STATE_ORD(signal);
22234 progError(__LINE__, NDBD_EXIT_NO_MORE_REDOLOG, buf);
22235 systemError(signal, __LINE__);
22238 if (logFilePtr.p->
currentMbyte == (clogFileSize - 1)) {
22244 update_log_problem(signal, logPartPtr,
22245 LogPartRecord::P_FILE_CHANGE_PROBLEM,
22248 twnlNextFileNo = wnlNextLogFilePtr.p->fileNo;
22252 twnlNextFileNo = logFilePtr.p->
fileNo;
22255 LogPosition head = { twnlNextFileNo, twnlNextMbyte };
22257 Uint64 free_mb = free_log(head, tail, logPartPtr.p->
noLogFiles, clogFileSize);
22258 if (free_mb <= c_free_mb_force_lcp_limit)
22264 if (free_mb <= c_free_mb_tail_problem_limit)
22267 update_log_problem(signal, logPartPtr, LogPartRecord::P_TAIL_PROBLEM,
true);
22270 if (ERROR_INSERTED(5058) &&
22271 (twnlNextMbyte + 3 >= clogFileSize) &&
22272 logFilePtr.p->
fileNo != 0 &&
22276 srand((
int)time(0));
22277 Uint32 wait = 3 + (rand() % 5);
22279 suspendFile(signal, logFilePtr, 0);
22281 signal->theData[0] = 9999;
22282 sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, wait * 1000, 1);
22283 CLEAR_ERROR_INSERT_VALUE;
22286 if (ERROR_INSERTED(5059) &&
22287 twnlNextMbyte == 4 &&
22288 logFilePtr.p->
fileNo != 0)
22290 signal->theData[0] = 9999;
22291 sendSignal(CMVMI_REF, GSN_NDB_TAMPER, signal, 1, JBA);
22297 Dblqh::validate_filter(
Signal* signal)
22299 Uint32 * start = signal->theData + 1;
22300 Uint32 * end = signal->theData + signal->getLength();
22303 infoEvent(
"No filter specified, not listing...");
22304 if (!ERROR_INSERTED(4002))
22322 infoEvent(
"Invalid filter op: 0x%x pos: %ld",
22324 (
long int)(start - (signal->theData + 1)));
22331 infoEvent(
"Invalid filter, unexpected end");
22341 Uint32 len = signal->getLength();
22342 Uint32* start = signal->theData + 3;
22343 Uint32* end = signal->theData + len;
22344 while (start < end)
22348 if (tcRec.p->tableref != * (start + 1))
22353 if (refToNode(tcRec.p->applRef) != * (start + 1))
22358 if (tcRec.p->transid[0] != * (start + 1) ||
22359 tcRec.p->transid[1] != * (start + 2))
22364 if (refToNode(tcRec.p->tcBlockref) != * (start + 1))
22383 Uint32 *
temp = signal->theData + 25;
22384 memcpy(temp, signal->theData, 4 * len);
22387 const char* op =
"<Unknown>";
22388 if (tcRec.p->tcScanRec != RNIL)
22391 sp.i = tcRec.p->tcScanRec;
22392 c_scanRecordPool.
getPtr(sp);
22394 if (sp.p->scanLockMode)
22396 else if(sp.p->scanLockHold)
22401 switch(sp.p->scanState){
22402 case ScanRecord::WAIT_NEXT_SCAN:
22405 case ScanRecord::IN_QUEUE:
22408 case ScanRecord::SCAN_FREE:
22409 case ScanRecord::WAIT_STORED_PROC_COPY:
22410 case ScanRecord::WAIT_STORED_PROC_SCAN:
22411 case ScanRecord::WAIT_NEXT_SCAN_COPY:
22412 case ScanRecord::WAIT_DELETE_STORED_PROC_ID_SCAN:
22413 case ScanRecord::WAIT_DELETE_STORED_PROC_ID_COPY:
22414 case ScanRecord::WAIT_ACC_COPY:
22415 case ScanRecord::WAIT_ACC_SCAN:
22416 case ScanRecord::WAIT_SCAN_NEXTREQ:
22417 case ScanRecord::WAIT_CLOSE_SCAN:
22418 case ScanRecord::WAIT_CLOSE_COPY:
22419 case ScanRecord::WAIT_RELEASE_LOCK:
22420 case ScanRecord::WAIT_TUPKEY_COPY:
22421 case ScanRecord::WAIT_LQHKEY_COPY:
22427 switch(tcRec.p->operation){
22429 if (tcRec.p->lockType)
22431 else if(!tcRec.p->dirtyOp)
22436 case ZINSERT: op =
"INSERT";
break;
22437 case ZUPDATE: op =
"UPDATE";
break;
22438 case ZDELETE: op =
"DELETE";
break;
22439 case ZWRITE: op =
"WRITE";
break;
22440 case ZUNLOCK: op =
"UNLOCK";
break;
22443 switch(tcRec.p->transactionState){
22444 case TcConnectionrec::IDLE:
22445 case TcConnectionrec::WAIT_ACC:
22448 case TcConnectionrec::WAIT_TUPKEYINFO:
22449 case TcConnectionrec::WAIT_ATTR:
22452 case TcConnectionrec::WAIT_TUP:
22455 case TcConnectionrec::WAIT_TUP_COMMIT:
22458 case TcConnectionrec::PREPARED:
22461 case TcConnectionrec::COMMITTED:
22464 case TcConnectionrec::STOPPED:
22465 case TcConnectionrec::LOG_QUEUED:
22466 case TcConnectionrec::LOG_COMMIT_WRITTEN_WAIT_SIGNAL:
22467 case TcConnectionrec::LOG_COMMIT_QUEUED_WAIT_SIGNAL:
22468 case TcConnectionrec::COMMIT_STOPPED:
22469 case TcConnectionrec::LOG_COMMIT_QUEUED:
22470 case TcConnectionrec::COMMIT_QUEUED:
22471 case TcConnectionrec::WAIT_ACC_ABORT:
22472 case TcConnectionrec::ABORT_QUEUED:
22473 case TcConnectionrec::ABORT_STOPPED:
22474 case TcConnectionrec::WAIT_AI_AFTER_ABORT:
22475 case TcConnectionrec::LOG_ABORT_QUEUED:
22476 case TcConnectionrec::WAIT_TUP_TO_ABORT:
22477 case TcConnectionrec::WAIT_SCAN_AI:
22478 case TcConnectionrec::SCAN_STATE_USED:
22479 case TcConnectionrec::SCAN_FIRST_STOPPED:
22480 case TcConnectionrec::SCAN_CHECK_STOPPED:
22481 case TcConnectionrec::SCAN_STOPPED:
22482 case TcConnectionrec::SCAN_RELEASE_STOPPED:
22483 case TcConnectionrec::SCAN_CLOSE_STOPPED:
22484 case TcConnectionrec::COPY_CLOSE_STOPPED:
22485 case TcConnectionrec::COPY_FIRST_STOPPED:
22486 case TcConnectionrec::COPY_STOPPED:
22487 case TcConnectionrec::SCAN_TUPKEY:
22488 case TcConnectionrec::COPY_TUPKEY:
22489 case TcConnectionrec::TC_NOT_CONNECTED:
22490 case TcConnectionrec::PREPARED_RECEIVED_COMMIT:
22491 case TcConnectionrec::LOG_COMMIT_WRITTEN:
22493 tcRec.p->transactionState);
22499 "OP[%u]: Tab: %d frag: %d TC: %u API: %d(0x%x)"
22500 "transid: H'%.8x H'%.8x op: %s state: %s",
22503 tcRec.p->fragmentid,
22504 refToNode(tcRec.p->tcBlockref),
22505 refToNode(tcRec.p->applRef),
22506 refToBlock(tcRec.p->applRef),
22507 tcRec.p->transid[0], tcRec.p->transid[1],
22511 if (!ERROR_INSERTED(4002))
22514 ndbout_c(
"%s", buf);
22516 memcpy(signal->theData, temp, 4*len);
22521 Dblqh::execDUMP_STATE_ORD(
Signal* signal)
22525 Uint32 arg= dumpState->args[0];
22526 if(dumpState->args[0] == DumpStateOrd::CommitAckMarkersSize){
22527 infoEvent(
"LQH: m_commitAckMarkerPool: %d free size: %d",
22528 m_commitAckMarkerPool.getNoOfFree(),
22529 m_commitAckMarkerPool.getSize());
22531 if(dumpState->args[0] == DumpStateOrd::CommitAckMarkersDump){
22532 infoEvent(
"LQH: m_commitAckMarkerPool: %d free size: %d",
22533 m_commitAckMarkerPool.getNoOfFree(),
22534 m_commitAckMarkerPool.getSize());
22536 CommitAckMarkerIterator iter;
22537 for(m_commitAckMarkerHash.
first(iter); iter.curr.i != RNIL;
22538 m_commitAckMarkerHash.
next(iter)){
22539 infoEvent(
"CommitAckMarker: i = %d (H'%.8x, H'%.8x)"
22540 " ApiRef: 0x%x apiOprec: 0x%x TcNodeId: %d, ref_count: %u",
22542 iter.curr.p->transid1,
22543 iter.curr.p->transid2,
22544 iter.curr.p->apiRef,
22545 iter.curr.p->apiOprec,
22546 iter.curr.p->tcNodeId,
22547 iter.curr.p->reference_count);
22552 if(dumpState->args[0] == DumpStateOrd::LqhDumpNoLogPages){
22553 infoEvent(
"LQH: Log pages : %d Free: %d",
22559 if(dumpState->args[0] == DumpStateOrd::LqhDumpAllDefinedTabs){
22560 for(Uint32 i = 0; i<ctabrecFileSize; i++){
22561 TablerecPtr tabPtr;
22563 ptrAss(tabPtr, tablerec);
22564 if(tabPtr.p->tableStatus != Tablerec::NOT_DEFINED){
22565 infoEvent(
"Table %d Status: %d Usage: [ r: %u w: %u ]",
22566 i, tabPtr.p->tableStatus,
22567 tabPtr.p->usageCountR, tabPtr.p->usageCountW);
22569 for (Uint32 j = 0; j<MAX_FRAG_PER_NODE; j++)
22571 FragrecordPtr fragPtr;
22572 if ((fragPtr.i = tabPtr.p->fragrec[j]) != RNIL)
22574 c_fragment_pool.
getPtr(fragPtr);
22576 tabPtr.p->fragid[j],
22577 fragPtr.p->fragDistributionKey);
22586 if (dumpState->args[0] == DumpStateOrd::LqhDumpAllScanRec){
22587 Uint32 recordNo = 0;
22588 if (signal->
length() == 1)
22589 infoEvent(
"LQH: Dump all ScanRecords - size: %d",
22591 else if (signal->
length() == 2)
22592 recordNo = dumpState->args[1];
22596 dumpState->args[0] = DumpStateOrd::LqhDumpOneScanRec;
22597 dumpState->args[1] = recordNo;
22598 execDUMP_STATE_ORD(signal);
22600 if (recordNo < cscanrecFileSize-1){
22601 dumpState->args[0] = DumpStateOrd::LqhDumpAllScanRec;
22602 dumpState->args[1] = recordNo+1;
22603 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 2, JBB);
22609 if (dumpState->args[0] == DumpStateOrd::LqhDumpAllActiveScanRec){
22610 Uint32 recordNo = 0;
22611 if (signal->
length() == 1)
22612 infoEvent(
"LQH: Dump active ScanRecord - size: %d",
22614 else if (signal->
length() == 2)
22615 recordNo = dumpState->args[1];
22621 c_scanRecordPool.
getPtr(sp);
22622 if (sp.p->scanState != ScanRecord::SCAN_FREE){
22623 dumpState->args[0] = DumpStateOrd::LqhDumpOneScanRec;
22624 dumpState->args[1] = recordNo;
22625 execDUMP_STATE_ORD(signal);
22628 if (recordNo < cscanrecFileSize-1){
22629 dumpState->args[0] = DumpStateOrd::LqhDumpAllActiveScanRec;
22630 dumpState->args[1] = recordNo+1;
22631 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 2, JBB);
22636 if(dumpState->args[0] == DumpStateOrd::LqhDumpOneScanRec){
22637 Uint32 recordNo = RNIL;
22638 if (signal->
length() == 2)
22639 recordNo = dumpState->args[1];
22643 if (recordNo >= cscanrecFileSize)
22648 c_scanRecordPool.
getPtr(sp);
22649 infoEvent(
"Dblqh::ScanRecord[%d]: state=%d, type=%d, "
22650 "complStatus=%d, scanNodeId=%d",
22654 sp.p->scanCompletedStatus,
22656 infoEvent(
" apiBref=0x%x, scanAccPtr=%d",
22657 sp.p->scanApiBlockref,
22659 infoEvent(
" copyptr=%d, ailen=%d, complOps=%d, concurrOps=%d",
22661 sp.p->scanAiLength,
22662 sp.p->m_curr_batch_size_rows,
22663 sp.p->m_max_batch_size_rows);
22665 sp.p->scanErrorCounter,
22666 sp.p->scanSchemaVersion);
22667 infoEvent(
" stpid=%d, flag=%d, lhold=%d, lmode=%d, num=%d",
22668 sp.p->scanStoredProcId,
22670 sp.p->scanLockHold,
22671 sp.p->scanLockMode,
22673 infoEvent(
" relCount=%d, TCwait=%d, TCRec=%d, KIflag=%d",
22674 sp.p->scanReleaseCounter,
22675 sp.p->scanTcWaiting,
22677 sp.p->scanKeyinfoFlag);
22680 if(dumpState->args[0] == DumpStateOrd::LqhDumpLcpState){
22683 infoEvent(
" clcpCompletedState=%d, c_lcpId=%d, cnoOfFragsCheckpointed=%d",
22684 clcpCompletedState,
22686 cnoOfFragsCheckpointed);
22688 LcpRecordPtr TlcpPtr;
22691 ptrAss(TlcpPtr, lcpRecord);
22692 infoEvent(
" lcpState=%d lastFragmentFlag=%d",
22693 TlcpPtr.p->lcpState, TlcpPtr.p->lastFragmentFlag);
22694 infoEvent(
"currentFragment.fragPtrI=%d",
22695 TlcpPtr.p->currentFragment.fragPtrI);
22696 infoEvent(
"currentFragment.lcpFragOrd.tableId=%d",
22697 TlcpPtr.p->currentFragment.lcpFragOrd.tableId);
22698 infoEvent(
" lcpQueued=%d reportEmpty=%d",
22699 TlcpPtr.p->lcpQueued,
22700 TlcpPtr.p->reportEmpty);
22701 char buf[8*_NDB_NODE_BITMASK_SIZE+1];
22703 TlcpPtr.p->m_EMPTY_LCP_REQ.getText(buf));
22707 if (dumpState->args[0] == DumpStateOrd::LQHLogFileInitStatus){
22708 reportStatus(signal);
22712 #ifdef ERROR_INSERT
22713 #ifdef NDB_DEBUG_FULL
22714 if(dumpState->args[0] == DumpStateOrd::LCPContinue){
22715 switch(cerrorInsert){
22717 CLEAR_ERROR_INSERT_VALUE;
22718 g_trace_lcp.restore(*globalData.getBlock(BACKUP), signal);
22727 if(arg == 2304 || arg == 2305)
22731 void * logPartPtr = 0;
22733 GcpRecordPtr gcp; gcp.i = RNIL;
22734 for(i = 0; i < clogPartFileSize; i++)
22738 ptrCheckGuard(lp, clogPartFileSize, logPartRecord);
22739 ndbout_c(
"LP %d blockInstance: %d partNo: %d state: %d WW_Gci: %d gcprec: %d flq: %u %u currfile: %d tailFileNo: %d logTailMbyte: %d cnoOfLogPages: %u problems: 0x%x",
22750 lp.p->logTailMbyte,
22752 lp.p->m_log_problems);
22754 if(gcp.i == RNIL && lp.p->
gcprec != RNIL)
22757 LogFileRecordPtr logFilePtr;
22761 ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
22762 ndbout_c(
" file %d(%d) FileChangeState: %d logFileStatus: %d currentMbyte: %d currentFilepage %d",
22763 logFilePtr.p->fileNo,
22765 logFilePtr.p->fileChangeState,
22766 logFilePtr.p->logFileStatus,
22767 logFilePtr.p->currentMbyte,
22768 logFilePtr.p->currentFilepage);
22769 logFilePtr.i = logFilePtr.p->nextLogFile;
22770 }
while(logFilePtr.i != first);
22775 ptrCheckGuard(gcp, cgcprecFileSize, gcpRecord);
22776 for(i = 0; i<4; i++)
22778 ndbout_c(
" GCP %d file: %d state: %d sync: %d page: %d word: %d",
22779 i, gcp.p->gcpFilePtr[i], gcp.p->gcpLogPartState[i],
22780 gcp.p->gcpSyncReady[i],
22781 gcp.p->gcpPageNo[i],
22782 gcp.p->gcpWordNo[i]);
22788 progError(__LINE__, NDBD_EXIT_SYSTEM_ERROR,
22789 "Please report this as a bug. "
22790 "Provide as much info as possible, expecially all the "
22791 "ndb_*_out.log files, Thanks. "
22792 "Shutting down node due to failed handling of GCP_SAVEREQ");
22797 if (dumpState->args[0] == DumpStateOrd::LqhErrorInsert5042 && (signal->getLength() >= 2))
22799 c_error_insert_table_id = dumpState->args[1];
22800 if (signal->getLength() == 2)
22802 SET_ERROR_INSERT_VALUE(5042);
22806 SET_ERROR_INSERT_VALUE(dumpState->args[2]);
22810 TcConnectionrec *regTcConnectionrec = tcConnectionrec;
22811 Uint32 ttcConnectrecFileSize = ctcConnectrecFileSize;
22814 for(Uint32 i = 0; i<1024; i++)
22816 TcConnectionrecPtr tcRec;
22817 tcRec.i = ctransidHash[
i];
22818 while(tcRec.i != RNIL)
22820 ptrCheckGuard(tcRec, ttcConnectrecFileSize, regTcConnectionrec);
22821 ndbout <<
"TcConnectionrec " << tcRec.i;
22822 signal->theData[0] = 2307;
22823 signal->theData[1] = tcRec.i;
22824 execDUMP_STATE_ORD(signal);
22825 tcRec.i = tcRec.p->nextHashRec;
22830 if(arg == 2307 || arg == 2308)
22832 TcConnectionrecPtr tcRec;
22833 tcRec.i = signal->theData[1];
22834 ptrCheckGuard(tcRec, ttcConnectrecFileSize, regTcConnectionrec);
22836 ndbout <<
" transactionState = " << tcRec.p->transactionState<<endl;
22837 ndbout <<
" operation = " << tcRec.p->operation<<endl;
22838 ndbout <<
" tcNodeFailrec = " << tcRec.p->tcNodeFailrec
22839 <<
" seqNoReplica = " << tcRec.p->seqNoReplica
22841 ndbout <<
" replicaType = " << tcRec.p->replicaType
22842 <<
" reclenAiLqhkey = " << tcRec.p->reclenAiLqhkey
22843 <<
" opExec = " << tcRec.p->opExec
22845 ndbout <<
" opSimple = " << tcRec.p->opSimple
22846 <<
" nextSeqNoReplica = " << tcRec.p->nextSeqNoReplica
22847 <<
" lockType = " << tcRec.p->lockType
22849 ndbout <<
" lastReplicaNo = " << tcRec.p->lastReplicaNo
22850 <<
" indTakeOver = " << tcRec.p->indTakeOver
22851 <<
" dirtyOp = " << tcRec.p->dirtyOp
22853 ndbout <<
" activeCreat = " << tcRec.p->activeCreat
22854 <<
" tcBlockref = " << hex << tcRec.p->tcBlockref
22855 <<
" reqBlockref = " << hex << tcRec.p->reqBlockref
22856 <<
" primKeyLen = " << tcRec.p->primKeyLen
22857 <<
" nrcopyflag = " << LqhKeyReq::getNrCopyFlag(tcRec.p->reqinfo)
22859 ndbout <<
" nextReplica = " << tcRec.p->nextReplica
22860 <<
" tcBlockref = " << hex << tcRec.p->tcBlockref
22861 <<
" reqBlockref = " << hex << tcRec.p->reqBlockref
22862 <<
" primKeyLen = " << tcRec.p->primKeyLen
22864 ndbout <<
" logStopPageNo = " << tcRec.p->logStopPageNo
22865 <<
" logStartPageNo = " << tcRec.p->logStartPageNo
22866 <<
" logStartPageIndex = " << tcRec.p->logStartPageIndex
22868 ndbout <<
" errorCode = " << tcRec.p->errorCode
22869 <<
" clientBlockref = " << hex << tcRec.p->clientBlockref
22870 <<
" applRef = " << hex << tcRec.p->applRef
22871 <<
" totSendlenAi = " << tcRec.p->totSendlenAi
22873 ndbout <<
" totReclenAi = " << tcRec.p->totReclenAi
22874 <<
" tcScanRec = " << tcRec.p->tcScanRec
22875 <<
" tcScanInfo = " << tcRec.p->tcScanInfo
22876 <<
" tcOprec = " << hex << tcRec.p->tcOprec
22878 ndbout <<
" tableref = " << tcRec.p->tableref
22879 <<
" simpleTcConnect = " << tcRec.p->simpleTcConnect
22880 <<
" storedProcId = " << tcRec.p->storedProcId
22881 <<
" schemaVersion = " << tcRec.p->schemaVersion
22883 ndbout <<
" reqinfo = " << tcRec.p->reqinfo
22884 <<
" reqRef = " << tcRec.p->reqRef
22885 <<
" readlenAi = " << tcRec.p->readlenAi
22886 <<
" prevTc = " << tcRec.p->prevTc
22888 ndbout <<
" prevLogTcrec = " << tcRec.p->prevLogTcrec
22889 <<
" prevHashRec = " << tcRec.p->prevHashRec
22890 <<
" nodeAfterNext0 = " << tcRec.p->nodeAfterNext[0]
22891 <<
" nodeAfterNext1 = " << tcRec.p->nodeAfterNext[1]
22893 ndbout <<
" nextTcConnectrec = " << tcRec.p->nextTcConnectrec
22894 <<
" nextTc = " << tcRec.p->nextTc
22895 <<
" nextTcLogQueue = " << tcRec.p->nextTcLogQueue
22896 <<
" nextLogTcrec = " << tcRec.p->nextLogTcrec
22898 ndbout <<
" nextHashRec = " << tcRec.p->nextHashRec
22899 <<
" logWriteState = " << tcRec.p->logWriteState
22900 <<
" logStartFileNo = " << tcRec.p->logStartFileNo
22901 <<
" listState = " << tcRec.p->listState
22903 ndbout <<
" gci_hi = " << tcRec.p->gci_hi
22904 <<
" gci_lo = " << tcRec.p->gci_lo
22905 <<
" fragmentptr = " << tcRec.p->fragmentptr
22906 <<
" fragmentid = " << tcRec.p->fragmentid
22908 ndbout <<
" hashValue = " << tcRec.p->hashValue
22909 <<
" currTupAiLen = " << tcRec.p->currTupAiLen
22910 <<
" currReclenAi = " << tcRec.p->currReclenAi
22912 ndbout <<
" tcTimer = " << tcRec.p->tcTimer
22913 <<
" clientConnectrec = " << tcRec.p->clientConnectrec
22914 <<
" applOprec = " << hex << tcRec.p->applOprec
22915 <<
" abortState = " << tcRec.p->abortState
22917 ndbout <<
" transid0 = " << hex << tcRec.p->transid[0]
22918 <<
" transid1 = " << hex << tcRec.p->transid[1]
22919 <<
" key[0] = " << getKeyInfoWordOrZero(tcRec.p, 0)
22920 <<
" key[1] = " << getKeyInfoWordOrZero(tcRec.p, 1)
22922 ndbout <<
" key[2] = " << getKeyInfoWordOrZero(tcRec.p, 2)
22923 <<
" key[3] = " << getKeyInfoWordOrZero(tcRec.p, 3)
22924 <<
" m_nr_delete.m_cnt = " << tcRec.p->m_nr_delete.m_cnt
22926 switch (tcRec.p->transactionState) {
22928 case TcConnectionrec::SCAN_STATE_USED:
22929 if (tcRec.p->tcScanRec < cscanrecFileSize){
22930 ScanRecordPtr TscanPtr;
22931 c_scanRecordPool.
getPtr(TscanPtr, tcRec.p->tcScanRec);
22932 ndbout <<
" scanState = " << TscanPtr.p->scanState << endl;
22934 ndbout <<
" copyPtr="<<TscanPtr.p->copyPtr
22935 <<
" scanAccPtr="<<TscanPtr.p->scanAccPtr
22936 <<
" scanAiLength="<<TscanPtr.p->scanAiLength
22938 ndbout <<
" m_curr_batch_size_rows="<<
22939 TscanPtr.p->m_curr_batch_size_rows
22940 <<
" m_max_batch_size_rows="<<
22941 TscanPtr.p->m_max_batch_size_rows
22942 <<
" scanErrorCounter="<<TscanPtr.p->scanErrorCounter
22944 ndbout <<
" scanSchemaVersion="<<TscanPtr.p->scanSchemaVersion
22945 <<
" scanStoredProcId="<<TscanPtr.p->scanStoredProcId
22946 <<
" scanTcrec="<<TscanPtr.p->scanTcrec
22948 ndbout <<
" scanType="<<TscanPtr.p->scanType
22949 <<
" scanApiBlockref="<<TscanPtr.p->scanApiBlockref
22950 <<
" scanNodeId="<<TscanPtr.p->scanNodeId
22951 <<
" scanCompletedStatus="<<TscanPtr.p->scanCompletedStatus
22953 ndbout <<
" scanFlag="<<TscanPtr.p->scanFlag
22954 <<
" scanLockHold="<<TscanPtr.p->scanLockHold
22955 <<
" scanLockMode="<<TscanPtr.p->scanLockMode
22956 <<
" scanNumber="<<TscanPtr.p->scanNumber
22958 ndbout <<
" scanReleaseCounter="<<TscanPtr.p->scanReleaseCounter
22959 <<
" scanTcWaiting="<<TscanPtr.p->scanTcWaiting
22960 <<
" scanKeyinfoFlag="<<TscanPtr.p->scanKeyinfoFlag
22963 ndbout <<
"No connected scan record found" << endl;
22969 ndbrequire(arg != 2308);
22972 #ifdef NDBD_TRACENR
22973 if (arg == 5712 || arg == 5713)
22977 traceopout = &ndbout;
22979 else if (arg == 5713)
22981 traceopout = tracenrout;
22983 SET_ERROR_INSERT_VALUE(arg);
22990 Uint32 len = signal->getLength() - 1;
22997 if (validate_filter(signal))
23000 memmove(signal->theData + 3, signal->theData + 1, 4 * len);
23001 signal->theData[0] = 2351;
23002 signal->theData[1] = 0;
23003 signal->theData[2] = RNIL;
23004 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, len + 3, JBB);
23006 infoEvent(
"Starting dump of operations");
23014 Uint32
bucket = signal->theData[1];
23015 Uint32
record = signal->theData[2];
23016 Uint32 len = signal->getLength();
23017 TcConnectionrecPtr tcRec;
23018 if (record != RNIL)
23025 ptrCheckGuard(tcRec, ttcConnectrecFileSize, regTcConnectionrec);
23027 Uint32 hashIndex = (tcRec.p->transid[0] ^ tcRec.p->tcOprec) & 1023;
23028 if (hashIndex != bucket)
23036 if (tcRec.p->nextHashRec == RNIL &&
23037 tcRec.p->prevHashRec == RNIL &&
23038 ctransidHash[hashIndex] != record)
23045 if (record == RNIL)
23048 signal->theData[2] = RNIL;
23049 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal,
23050 signal->getLength(), JBB);
23054 else if ((record = ctransidHash[bucket]) == RNIL)
23061 signal->theData[1] = bucket;
23062 signal->theData[2] = RNIL;
23063 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal,
23064 signal->getLength(), JBB);
23070 if (ERROR_INSERTED(4002))
23082 ptrCheckGuard(tcRec, ttcConnectrecFileSize, regTcConnectionrec);
23085 for (Uint32 i = 0; i<32; i++)
23088 bool print = match_and_print(signal, tcRec);
23090 tcRec.i = tcRec.p->nextHashRec;
23091 if (tcRec.i == RNIL || print)
23097 ptrCheckGuard(tcRec, ttcConnectrecFileSize, regTcConnectionrec);
23100 if (tcRec.i == RNIL)
23107 signal->theData[1] = bucket;
23108 signal->theData[2] = RNIL;
23109 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, len, JBB);
23115 if (ERROR_INSERTED(4002))
23126 signal->theData[2] = tcRec.i;
23127 sendSignalWithDelay(reference(), GSN_DUMP_STATE_ORD, signal, 200, len);
23132 if (arg == 2352 && signal->getLength() == 2)
23135 Uint32 opNo = signal->theData[1];
23136 TcConnectionrecPtr tcRec;
23137 if (opNo < ttcConnectrecFileSize)
23141 ptrCheckGuard(tcRec, ttcConnectrecFileSize, regTcConnectionrec);
23144 if (tcRec.p->keyInfoIVal != RNIL)
23148 g_sectionSegmentPool);
23151 while (keyInfoReader.getWord(&keyWord))
23152 key.
appfmt(
"0x%x ", keyWord);
23157 "OP[%u]: transid: 0x%x 0x%x key: %s",
23159 tcRec.p->transid[0], tcRec.p->transid[1], key.
c_str());
23164 if (arg == DumpStateOrd::SchemaResourceSnapshot)
23166 RSS_AP_SNAPSHOT_SAVE(c_fragment_pool);
23170 if (arg == DumpStateOrd::SchemaResourceCheckLeak)
23172 RSS_AP_SNAPSHOT_CHECK(c_fragment_pool);
23179 for (Uint32 i = 0; i<1024; i++)
23181 if (ctransidHash[i] != RNIL)
23189 bool markers = m_commitAckMarkerPool.getNoOfFree() !=
23190 m_commitAckMarkerPool.getSize();
23191 if (unlikely(ops || markers))
23196 ndbout_c(
"LQH: m_commitAckMarkerPool: %d free size: %d",
23197 m_commitAckMarkerPool.getNoOfFree(),
23198 m_commitAckMarkerPool.getSize());
23200 CommitAckMarkerIterator iter;
23201 for(m_commitAckMarkerHash.
first(iter); iter.curr.i != RNIL;
23202 m_commitAckMarkerHash.
next(iter))
23204 ndbout_c(
"CommitAckMarker: i = %d (H'%.8x, H'%.8x)"
23205 " ApiRef: 0x%x apiOprec: 0x%x TcNodeId: %d ref_count: %u",
23207 iter.curr.p->transid1,
23208 iter.curr.p->transid2,
23209 iter.curr.p->apiRef,
23210 iter.curr.p->apiOprec,
23211 iter.curr.p->tcNodeId,
23212 iter.curr.p->reference_count);
23215 SET_ERROR_INSERT_VALUE(4002);
23216 signal->theData[0] = 2350;
23225 if (cstartRecReq < SRR_REDO_COMPLETE)
23231 for(Uint32 i = 0; i<4; i++)
23234 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
23235 LogFileRecordPtr logFile;
23236 logFile.i = logPartPtr.p->currentLogfile;
23237 ptrCheckGuard(logFile, clogFileFileSize, logFileRecord);
23239 LogPosition head = { logFile.p->fileNo, logFile.p->currentMbyte };
23240 LogPosition tail = { logPartPtr.p->logTailFileNo,
23241 logPartPtr.p->logTailMbyte};
23242 Uint64 mb = free_log(head, tail, logPartPtr.p->noLogFiles, clogFileSize);
23243 Uint64 total = logPartPtr.p->noLogFiles * Uint64(clogFileSize);
23244 signal->theData[0] = NDB_LE_RedoStatus;
23245 signal->theData[1] =
i;
23246 signal->theData[2] = head.m_file_no;
23247 signal->theData[3] = head.m_mbyte;
23248 signal->theData[4] = tail.m_file_no;
23249 signal->theData[5] = tail.m_mbyte;
23250 signal->theData[6] = Uint32(total >> 32);
23251 signal->theData[7] = Uint32(total);
23252 signal->theData[8] = Uint32(mb >> 32);
23253 signal->theData[9] = Uint32(mb);
23254 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 10, JBB);
23262 if (cstartRecReq < SRR_REDO_COMPLETE)
23268 for(Uint32 i = 0; i<clogPartFileSize; i++)
23271 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
23272 LogFileRecordPtr logFile;
23273 logFile.i = logPartPtr.p->currentLogfile;
23274 ptrCheckGuard(logFile, clogFileFileSize, logFileRecord);
23276 LogPosition head = { logFile.p->fileNo, logFile.p->currentMbyte };
23277 LogPosition tail = { logPartPtr.p->logTailFileNo,
23278 logPartPtr.p->logTailMbyte};
23279 Uint64 mb = free_log(head, tail, logPartPtr.p->noLogFiles, clogFileSize);
23280 Uint64 total = logPartPtr.p->noLogFiles * Uint64(clogFileSize);
23281 ndbout_c(
"REDO part: %u HEAD: file: %u mbyte: %u TAIL: file: %u mbyte: %u total: %llu free: %llu (mb)",
23282 logPartPtr.p->logPartNo,
23283 head.m_file_no, head.m_mbyte,
23284 tail.m_file_no, tail.m_mbyte,
23292 void Dblqh::execDBINFO_SCANREQ(
Signal *signal)
23301 switch(req.tableId){
23302 case Ndbinfo::LOGSPACES_TABLEID:
23304 Uint32 logpart =
cursor->data[0];
23305 while(logpart < clogPartFileSize)
23309 logPartPtr.i = logpart;
23310 ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
23312 LogFileRecordPtr logFile;
23313 logFile.i = logPartPtr.p->currentLogfile;
23314 ptrCheckGuard(logFile, clogFileFileSize, logFileRecord);
23316 LogPosition head = { logFile.p->fileNo, logFile.p->currentMbyte };
23317 LogPosition tail = { logPartPtr.p->logTailFileNo,
23318 logPartPtr.p->logTailMbyte};
23319 Uint64 mb = free_log(head, tail, logPartPtr.p->noLogFiles, clogFileSize);
23320 Uint64 total = logPartPtr.p->noLogFiles * Uint64(clogFileSize);
23324 row.write_uint32(getOwnNodeId());
23325 row.write_uint32(0);
23326 row.write_uint32(0);
23327 row.write_uint32(logpart);
23329 row.write_uint64(total*1024*1024);
23330 row.write_uint64((total-mb)*1024*1024);
23331 row.write_uint64(high*1024*1024);
23332 ndbinfo_send_row(signal, req, row, rl);
23334 if (rl.need_break(req))
23337 ndbinfo_send_scan_break(signal, req, rl, logpart);
23344 case Ndbinfo::LOGBUFFERS_TABLEID:
23346 const size_t entry_size =
sizeof(LogPageRecord);
23347 const Uint64 free = cnoOfLogPages;
23348 const Uint64 total = clogPageCount;
23349 const Uint64 high = 0;
23352 row.write_uint32(getOwnNodeId());
23353 row.write_uint32(0);
23354 row.write_uint32(0);
23355 row.write_uint32(instance());
23357 row.write_uint64(total*entry_size);
23358 row.write_uint64((total-free)*entry_size);
23359 row.write_uint64(high*entry_size);
23360 ndbinfo_send_row(signal, req, row, rl);
23365 case Ndbinfo::COUNTERS_TABLEID:
23368 { Ndbinfo::OPERATIONS_COUNTER, c_Counters.operations }
23370 const size_t num_counters =
sizeof(counters) /
sizeof(counters[0]);
23372 Uint32 i =
cursor->data[0];
23373 BlockNumber bn = blockToMain(number());
23374 while(i < num_counters)
23378 row.write_uint32(getOwnNodeId());
23379 row.write_uint32(bn);
23380 row.write_uint32(instance());
23381 row.write_uint32(counters[i].
id);
23383 row.write_uint64(counters[i].val);
23384 ndbinfo_send_row(signal, req, row, rl);
23386 if (rl.need_break(req))
23389 ndbinfo_send_scan_break(signal, req, rl, i);
23400 ndbinfo_send_scan_conf(signal, req, rl);
23415 Dblqh::execCREATE_TRIG_IMPL_REQ(
Signal* signal)
23427 req->senderRef = reference();
23428 BlockReference tupRef = calcInstanceBlockRef(DBTUP);
23429 sendSignal(tupRef, GSN_CREATE_TRIG_IMPL_REQ, signal,
23430 signal->getLength(), JBB, &handle);
23434 Dblqh::execCREATE_TRIG_IMPL_CONF(
Signal* signal)
23438 BlockReference dictRef = !isNdbMtLqh() ? DBDICT_REF : DBLQH_REF;
23439 sendSignal(dictRef, GSN_CREATE_TRIG_IMPL_CONF, signal,
23440 CreateTrigImplConf::SignalLength, JBB);
23444 Dblqh::execCREATE_TRIG_IMPL_REF(
Signal* signal)
23448 BlockReference dictRef = !isNdbMtLqh() ? DBDICT_REF : DBLQH_REF;
23449 sendSignal(dictRef, GSN_CREATE_TRIG_IMPL_REF, signal,
23450 CreateTrigImplRef::SignalLength, JBB);
23454 Dblqh::execDROP_TRIG_IMPL_REQ(
Signal* signal)
23459 req->senderRef = reference();
23460 BlockReference tupRef = calcInstanceBlockRef(DBTUP);
23461 sendSignal(tupRef, GSN_DROP_TRIG_IMPL_REQ, signal,
23462 DropTrigImplReq::SignalLength, JBB);
23466 Dblqh::execDROP_TRIG_IMPL_CONF(
Signal* signal)
23470 BlockReference dictRef = !isNdbMtLqh() ? DBDICT_REF : DBLQH_REF;
23471 sendSignal(dictRef, GSN_DROP_TRIG_IMPL_CONF, signal,
23472 DropTrigImplConf::SignalLength, JBB);
23476 Dblqh::execDROP_TRIG_IMPL_REF(
Signal* signal)
23480 BlockReference dictRef = !isNdbMtLqh() ? DBDICT_REF : DBLQH_REF;
23481 sendSignal(dictRef, GSN_DROP_TRIG_IMPL_REF, signal,
23482 DropTrigImplRef::SignalLength, JBB);
23485 Uint32 Dblqh::calcPageCheckSum(LogPageRecordPtr logP){
23486 Uint32 checkSum = 37;
23488 for (Uint32 i = (ZPOS_CHECKSUM+1); i<ZPAGE_SIZE; i++)
23489 checkSum = logP.p->logPageWord[i] ^ checkSum;
23494 #ifdef NDB_DEBUG_FULL
23495 #ifdef ERROR_INSERT
23497 TraceLCP::sendSignal(Uint32 ref, Uint32 gsn,
Signal* signal,
23498 Uint32 len, Uint32 prio)
23501 s.type = Sig::Sig_send;
23502 s.header = signal->header;
23503 s.header.theVerId_signalNumber = gsn;
23504 s.header.theReceiversBlockNumber = ref;
23505 s.header.theLength = len;
23506 memcpy(s.theData, signal->theData, 4 * len);
23507 m_signals.push_back(s);
23508 assert(signal->getNoOfSections() == 0);
23512 TraceLCP::save(
Signal* signal){
23514 s.type = Sig::Sig_save;
23515 s.header = signal->header;
23516 memcpy(s.theData, signal->theData, 4 * signal->getLength());
23517 m_signals.push_back(s);
23518 assert(signal->getNoOfSections() == 0);
23523 Uint32 cnt = m_signals.size();
23524 for(Uint32 i = 0; i<cnt; i++){
23525 sig->header = m_signals[
i].header;
23526 memcpy(sig->theData, m_signals[i].theData, 4 * sig->getLength());
23527 switch(m_signals[i].type){
23528 case Sig::Sig_send:
23529 lqh.sendSignal(sig->header.theReceiversBlockNumber,
23530 sig->header.theVerId_signalNumber,
23532 sig->header.theLength,
23535 case Sig::Sig_save:
23545 void Dblqh::writeDbgInfoPageHeader(LogPageRecordPtr logP, Uint32 place,
23546 Uint32 pageNo, Uint32 wordWritten)
23548 logP.p->logPageWord[ZPOS_LOG_TIMER]= logPartPtr.p->logTimer;
23549 logP.p->logPageWord[ZPOS_PREV_PAGE_NO]= logP.p->logPageWord[ZPOS_PAGE_NO];
23550 logP.p->logPageWord[ZPOS_PAGE_I]= logP.i;
23551 logP.p->logPageWord[ZPOS_PLACE_WRITTEN_FROM]= place;
23552 logP.p->logPageWord[ZPOS_PAGE_NO]= pageNo;
23553 logP.p->logPageWord[ZPOS_PAGE_FILE_NO]= logFilePtr.p->fileNo;
23554 logP.p->logPageWord[ZPOS_WORD_WRITTEN]= wordWritten;
23555 logP.p->logPageWord[ZPOS_IN_WRITING]= 1;
23558 void Dblqh::initReportStatus(
Signal* signal){
23559 NDB_TICKS current_time = NdbTick_CurrentMillisecond();
23560 m_next_report_time = current_time +
23561 ((NDB_TICKS)m_startup_report_frequency) * ((NDB_TICKS)1000);
23564 void Dblqh::checkReportStatus(
Signal* signal){
23565 if (m_startup_report_frequency == 0)
23568 NDB_TICKS current_time = NdbTick_CurrentMillisecond();
23569 if (current_time > m_next_report_time)
23571 reportStatus(signal);
23572 m_next_report_time = current_time +
23573 ((NDB_TICKS)m_startup_report_frequency) * ((NDB_TICKS)1000);
23577 void Dblqh::reportStatus(
Signal* signal){
23578 const int signal_length = 6;
23581 signal->theData[1] = reference();
23582 for (
int i = 2; i < signal_length; i++)
23583 signal->theData[i] = 0;
23585 signal->theData[2] = totalLogFiles;
23586 signal->theData[3] = logFileInitDone;
23587 signal->theData[4] = totallogMBytes;
23588 signal->theData[5] = logMBytesInitDone;
23590 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, signal_length, JBB);
23593 void Dblqh::logfileInitCompleteReport(
Signal* signal){
23594 const int signal_length = 6;
23597 signal->theData[1] = reference();
23598 signal->theData[2] = totalLogFiles;
23599 signal->theData[3] = logFileInitDone;
23600 signal->theData[4] = totallogMBytes;
23601 signal->theData[5] = logMBytesInitDone;
23602 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, signal_length, JBB);
23605 #ifdef NDBD_TRACENR
23610 <<
"[ " << hex << regTcPtr->transid[0]
23611 <<
" " << hex << regTcPtr->transid[1] <<
" ] " << dec
23613 <<
" " << (Operation_t)regTcPtr->operation
23614 <<
" " << regTcPtr->tableref
23615 <<
"(" << regTcPtr->fragmentid <<
")"
23616 <<
"(" << (regTcPtr->seqNoReplica == 0 ?
"P" :
"B") <<
")" ;
23619 (* traceopout) <<
"key=[" << hex;
23620 if (regTcPtr->keyInfoIVal != RNIL)
23623 g_sectionSegmentPool);
23626 while (keyInfoReader.getWord(&keyWord))
23627 (* traceopout) << hex << keyWord <<
" ";
23629 (* traceopout) <<
"] ";
23632 if (regTcPtr->m_use_rowid)
23633 (* traceopout) <<
" " << regTcPtr->m_row_id;
23634 (* traceopout) << endl;
23639 Dblqh::get_node_status(Uint32 nodeId)
const
23641 HostRecordPtr Thostptr;
23642 Thostptr.i = nodeId;
23643 ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
23644 return Thostptr.p->nodestatus;
23647 #ifndef NO_REDO_PAGE_CACHE
23651 #define MIN_REDO_PAGES_FREE 64
23656 LogPageRecordPtr save = logPagePtr;
23657 cache.m_lru.remove(pagePtr);
23658 cache.m_hash.remove(pagePtr);
23660 ndbout_c(
"evict part: %u file: %u page: %u cnoOfLogPages: %u",
23661 pagePtr.p->m_part_no,
23662 pagePtr.p->m_file_no,
23663 pagePtr.p->m_page_no,
23666 logPagePtr.i = pagePtr.i;
23667 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
23670 prevPagePtr.i = logPagePtr.p->
logPageWord[ZPREV_PAGE];
23671 nextPagePtr.i = logPagePtr.p->
logPageWord[ZNEXT_PAGE];
23672 if (prevPagePtr.i != RNIL)
23680 ptrCheckGuard(prevPagePtr, clogPageFileSize, logPageRecord);
23681 ndbrequire(prevPagePtr.p->
logPageWord[ZNEXT_PAGE] == logPagePtr.i);
23685 if (nextPagePtr.i != RNIL)
23692 ptrCheckGuard(nextPagePtr, clogPageFileSize, logPageRecord);
23693 ndbrequire(nextPagePtr.p->
logPageWord[ZPREV_PAGE] == logPagePtr.i);
23702 Dblqh::evict(RedoPageCache& cache, Uint32 cnt)
23704 while (cnoOfLogPages < (cnt + MIN_REDO_PAGES_FREE) && !cache.m_lru.isEmpty())
23708 cache.m_lru.last(pagePtr);
23709 do_evict(cache, pagePtr);
23714 Dblqh::addCachePages(RedoPageCache& cache,
23716 Uint32 startPageNo,
23717 LogFileOperationRecord* lfoPtrP)
23719 Uint32 cnt = lfoPtrP->noPagesRw;
23721 filePtr.i = lfoPtrP->logFileRec;
23722 ptrCheckGuard(filePtr, clogFileFileSize, logFileRecord);
23726 if (cnoOfLogPages < cnt + MIN_REDO_PAGES_FREE)
23734 for (Uint32 i = 0; i<cnt ; i++)
23737 pagePtr.i = lfoPtrP->logPageArray[
i];
23738 cache.m_pool.getPtr(pagePtr);
23739 pagePtr.p->m_part_no = partNo;
23740 pagePtr.p->m_page_no = startPageNo +
i;
23741 pagePtr.p->m_file_no = filePtr.p->
fileNo;
23743 bool found =
false;
23745 RedoCacheLogPageRecord key;
23746 key.m_part_no = partNo;
23747 key.m_page_no = startPageNo +
i;
23748 key.m_file_no = filePtr.p->
fileNo;
23750 if (cache.m_hash.find(tmp, key))
23754 do_evict(cache, tmp);
23758 cache.m_hash.add(pagePtr);
23759 cache.m_lru.addFirst(pagePtr);
23761 ndbout_c(
"adding(%u) part: %u file: %u page: %u cnoOfLogPages: %u cnt: %u",
23763 pagePtr.p->m_part_no,
23764 pagePtr.p->m_file_no,
23765 pagePtr.p->m_page_no,
23774 lfoPtrP->firstLfoPage = RNIL;
23778 Dblqh::release(RedoPageCache& cache)
23780 while (!cache.m_lru.isEmpty())
23784 cache.m_lru.last(pagePtr);
23785 cache.m_lru.remove(pagePtr);
23787 logPagePtr.i = pagePtr.i;
23788 ptrCheckGuard(logPagePtr, clogPageFileSize, logPageRecord);
23791 cache.m_hash.removeAll();
23793 #if defined VM_TRACE || defined ERROR_INSERT || 1
23794 ndbout_c(
"RedoPageCache: avoided %u (%u/%u) page-reads",
23795 cache.m_hits, cache.m_multi_page, cache.m_multi_miss);
23798 cache.m_multi_page = 0;
23799 cache.m_multi_miss = 0;
23803 #ifndef NO_REDO_OPEN_FILE_CACHE
23805 #define MAX_CACHED_OPEN_FILES 4
23808 Dblqh::openFileRw_cache(
Signal* signal,
23809 LogFileRecordPtr filePtr)
23818 m_redo_open_file_cache.m_hits++;
23820 if (m_redo_open_file_cache.m_lru.hasPrev(filePtr))
23823 m_redo_open_file_cache.m_lru.remove(filePtr);
23824 m_redo_open_file_cache.m_lru.addFirst(filePtr);
23827 filePtr.p->logFileStatus = LogFileRecord::OPEN_EXEC_LOG_CACHED;
23829 signal->theData[0] = filePtr.i;
23830 signal->theData[1] = filePtr.p->fileRef;
23831 sendSignal(reference(), GSN_FSOPENCONF, signal, 2, JBB);
23835 filePtr.p->logFileStatus = LogFileRecord::OPEN_EXEC_LOG;
23836 openFileRw(signal, filePtr,
false);
23840 Dblqh::closeFile_cache(
Signal* signal,
23841 LogFileRecordPtr filePtr,
23846 filePtr.p->logFileStatus = LogFileRecord::CLOSING_EXEC_LOG_CACHED;
23847 if (m_redo_open_file_cache.m_lru.count() >= MAX_CACHED_OPEN_FILES)
23860 m_redo_open_file_cache.m_lru.last(evictPtr);
23861 while (evictPtr.p->
logPartRec != logPartRec)
23864 ndbrequire(m_redo_open_file_cache.m_lru.prev(evictPtr));
23866 m_redo_open_file_cache.m_lru.remove(evictPtr);
23867 evictPtr.p->
logFileStatus = LogFileRecord::CLOSING_EXEC_LOG;
23868 closeFile(signal, evictPtr, line);
23873 signal->theData[0] = ZEXEC_SR;
23874 signal->theData[1] = filePtr.p->logPartRec;
23875 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
23880 Dblqh::release(
Signal* signal, RedoOpenFileCache & cache)
23884 while (m_redo_open_file_cache.m_lru.first(closePtr))
23887 m_redo_open_file_cache.m_lru.remove(closePtr);
23888 if (closePtr.p->
logFileStatus == LogFileRecord::CLOSING_EXEC_LOG_CACHED)
23891 closePtr.p->
logFileStatus = LogFileRecord::CLOSING_EXEC_LOG_CACHED;
23892 m_redo_open_file_cache.m_close_cnt ++;
23893 signal->theData[0] = closePtr.p->
fileRef;
23894 signal->theData[1] = reference();
23895 signal->theData[2] = closePtr.i;
23896 signal->theData[3] = ZCLOSE_NO_DELETE;
23897 signal->theData[4] = __LINE__;
23898 sendSignal(NDBFS_REF, GSN_FSCLOSEREQ, signal, 5, JBA);
23903 ndbout_c(
"Found file with state: %u",
23908 ndbout_c(
"RedoOpenFileCache: Avoided %u file-open/close closed: %u",
23909 m_redo_open_file_cache.m_hits,
23910 m_redo_open_file_cache.m_close_cnt);
23911 m_redo_open_file_cache.m_hits = 0;
23912 m_redo_open_file_cache.m_close_cnt = 0;
23913 execLogComp_extra_files_closed(signal);
23919 Dblqh::check_ndb_versions()
const
23922 for (Uint32 i = 0; i < cnoOfNodes; i++)
23924 Uint32 node = cnodeData[
i];
23925 if (cnodeStatus[i] == ZNODE_UP)
23937 Dblqh::suspendFile(
Signal* signal, Uint32 filePtrI, Uint32 millis)
23941 ptrCheckGuard(tmp, clogFileFileSize, logFileRecord);
23942 suspendFile(signal, tmp, millis);
23949 signal->theData[0] = logFilePtr.p->
fileRef;
23950 signal->theData[1] = millis;
23951 sendSignal(NDBFS_REF, GSN_FSSUSPENDORD, signal, 2, JBA);
23955 Dblqh::send_runredo_event(
Signal* signal, LogPartRecord * lp, Uint32 gci)
23957 signal->theData[0] = NDB_LE_RunRedo;
23958 signal->theData[1] = lp->logPartNo;
23959 signal->theData[2] = csrPhasesCompleted;
23960 signal->theData[3] = lp->logStartGci;
23961 signal->theData[4] = gci;
23962 signal->theData[5] = lp->logLastGci;
23965 LogFileRecordPtr filePtr;
23966 filePtr.i = lp->startLogfile;
23967 ptrCheckGuard(filePtr, clogFileFileSize, logFileRecord);
23968 signal->theData[6] = filePtr.p->fileNo;
23969 signal->theData[7] = lp->startMbyte;
23971 filePtr.i = lp->currentLogfile;
23972 ptrCheckGuard(filePtr, clogFileFileSize, logFileRecord);
23973 signal->theData[8] = filePtr.p->fileNo;
23974 signal->theData[9] = filePtr.p->currentMbyte;
23976 filePtr.i = lp->stopLogfile;
23977 ptrCheckGuard(filePtr, clogFileFileSize, logFileRecord);
23978 signal->theData[10] = filePtr.p->fileNo;
23979 signal->theData[11] = lp->stopMbyte;
23980 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 12, JBB);
23984 Dblqh::IOTracker::init(Uint32 partNo)
23986 bzero(
this,
sizeof(*
this));
23987 m_log_part_no = partNo;
23993 Uint32 t = m_current_time;
23995 if ((t / SAMPLE_TIME) == (now / SAMPLE_TIME))
23998 m_current_time = now;
23999 if (m_sample_completed_bytes >= m_sample_sent_bytes)
24007 m_sample_sent_bytes = 0;
24008 m_sample_completed_bytes = 0;
24013 Uint32 elapsed = now - t;
24014 m_save_written_bytes[m_save_pos] += m_sample_completed_bytes;
24015 m_save_elapsed_millis[m_save_pos] += elapsed;
24017 m_curr_written_bytes += m_sample_completed_bytes;
24018 m_curr_elapsed_millis += elapsed;
24020 Uint32 bps = (1000 * m_sample_completed_bytes) / elapsed;
24021 Uint32 lag = bps ? m_sum_outstanding_bytes / bps : 30;
24022 if (
false && lag >= 30)
24024 g_eventLogger->
info(
"part: %u tick(%u) m_sample_completed_bytes: %u m_sample_sent_bytes: %u elapsed: %u kbps: %u lag: %u",
24026 now, m_sample_completed_bytes, m_sample_sent_bytes,
24027 elapsed, bps/1000, lag);
24030 m_sample_sent_bytes -= m_sample_completed_bytes;
24031 m_sample_completed_bytes = 0;
24035 Uint32 save_lag_cnt = m_lag_cnt;
24036 if ((now / SLIDING_WINDOW_LEN) != (t / SLIDING_WINDOW_LEN))
24038 Uint32 lag = m_curr_written_bytes ?
24039 ((Uint64(m_sum_outstanding_bytes) / 1000) * Uint64(m_curr_elapsed_millis)) / m_curr_written_bytes:
24048 Uint32 tmp = m_lag_cnt;
24049 m_lag_cnt += (lag / maxlag);
24050 if (tmp < maxlag_cnt && m_lag_cnt >= maxlag_cnt)
24060 if (m_lag_cnt >= maxlag_cnt)
24069 if (m_lag_cnt == 0 && lag == 0)
24072 else if (lag > 0 && m_lag_cnt == 0)
24074 g_eventLogger->
info(
"part: %u : time to complete: %u",
24075 m_log_part_no, lag);
24077 else if (m_lag_cnt < maxlag_cnt && m_lag_cnt == save_lag_cnt)
24079 g_eventLogger->
info(
"part: %u : time to complete: %u lag_cnt: %u => %u => retVal: %d",
24088 g_eventLogger->
info(
"part: %u : sum_outstanding: %ukb avg_written: %ukb avg_elapsed: %ums time to complete: %u lag_cnt: %u => %u retVal: %d",
24089 m_log_part_no, m_sum_outstanding_bytes / 1024, m_curr_written_bytes/1024, m_curr_elapsed_millis,
24090 lag, save_lag_cnt, m_lag_cnt, retVal);
24097 Uint32 last = (m_save_pos + 1) % SLIDING_WINDOW_HISTORY_LEN;
24098 assert(m_curr_written_bytes >= m_save_written_bytes[last]);
24099 assert(m_curr_elapsed_millis >= m_save_elapsed_millis[last]);
24100 m_curr_written_bytes -= m_save_written_bytes[last];
24101 m_curr_elapsed_millis -= m_save_elapsed_millis[last];
24102 m_save_written_bytes[last] = 0;
24103 m_save_elapsed_millis[last] = 0;
24110 Dblqh::IOTracker::send_io(Uint32 bytes)
24112 m_sum_outstanding_bytes += bytes;
24113 m_sample_sent_bytes += bytes;
24117 Dblqh::IOTracker::complete_io(Uint32 bytes)
24119 assert(m_sum_outstanding_bytes >= bytes);
24121 m_sum_outstanding_bytes -= bytes;
24122 m_sample_completed_bytes += bytes;