21 #include <AttributeHeader.hpp>
22 #include <signaldata/AccFrag.hpp>
23 #include <signaldata/AccScan.hpp>
24 #include <signaldata/NextScan.hpp>
25 #include <signaldata/AccLock.hpp>
26 #include <signaldata/EventReport.hpp>
27 #include <signaldata/FsConf.hpp>
28 #include <signaldata/FsRef.hpp>
29 #include <signaldata/FsRemoveReq.hpp>
30 #include <signaldata/DropTab.hpp>
31 #include <signaldata/DumpStateOrd.hpp>
32 #include <signaldata/TuxMaint.hpp>
33 #include <signaldata/DbinfoScan.hpp>
34 #include <signaldata/TransIdAI.hpp>
35 #include <KeyDescriptor.hpp>
38 #define DEBUG(x) ndbout << "DBACC: "<< x << endl;
44 #define vlqrequire(x) do { if (unlikely(!(x))) {\
45 dump_lock_queue(loPtr); \
46 ndbrequire(false); } } while(0)
48 #define vlqrequire(x) ndbrequire(x)
49 #define dump_lock_queue(x)
54 #include "../dbtup/Dbtup.hpp"
55 #include "../dblqh/Dblqh.hpp"
72 void Dbacc::execCONTINUEB(
Signal* signal)
77 tcase = signal->theData[0];
78 tdata0 = signal->theData[1];
81 case ZINITIALISE_RECORDS:
83 initialiseRecordsLab(signal, signal->theData[3], signal->theData[4]);
89 Uint32 tableId = signal->theData[1];
90 releaseRootFragResources(signal, tableId);
96 Uint32 fragIndex = signal->theData[1];
97 releaseFragResources(signal, fragIndex);
103 Uint32 fragIndex = signal->theData[1];
104 Uint32 dirIndex = signal->theData[2];
105 Uint32 startIndex = signal->theData[3];
106 releaseDirResources(signal, fragIndex, dirIndex, startIndex);
134 void Dbacc::execNDB_STTOR(
Signal* signal)
140 cndbcntrRef = signal->theData[0];
141 cmynodeid = signal->theData[1];
142 tstartphase = signal->theData[2];
143 tStartType = signal->theData[3];
144 switch (tstartphase) {
147 ndbsttorryLab(signal);
151 ndbsttorryLab(signal);
164 ndbsttorryLab(signal);
172 void Dbacc::execSTTOR(
Signal* signal)
175 Uint32 tstartphase = signal->theData[1];
176 switch (tstartphase) {
179 ndbrequire((c_tup = (
Dbtup*)globalData.getBlock(DBTUP, instance())) != 0);
180 ndbrequire((c_lqh = (
Dblqh*)globalData.getBlock(DBLQH, instance())) != 0);
183 tuserblockref = signal->theData[3];
184 csignalkey = signal->theData[6];
185 sttorrysignalLab(signal);
192 void Dbacc::ndbrestart1Lab(
Signal* signal)
194 cmynodeid = globalData.ownId;
195 cownBlockref = calcInstanceBlockRef(DBACC);
197 cminusOne = czero - 1;
202 void Dbacc::initialiseRecordsLab(
Signal* signal, Uint32 ref, Uint32 data)
207 initialiseTableRec(signal);
217 initialiseDirRec(signal);
221 initialiseDirRangeRec(signal);
225 initialiseFragRec(signal);
229 initialiseOverflowRec(signal);
233 initialiseOperationRec(signal);
237 initialisePageRec(signal);
244 initialiseScanRec(signal);
251 conf->senderRef = reference();
252 conf->senderData = data;
253 sendSignal(ref, GSN_READ_CONFIG_CONF, signal,
254 ReadConfigConf::SignalLength, JBB);
263 signal->theData[0] = ZINITIALISE_RECORDS;
264 signal->theData[1] = tdata0 + 1;
265 signal->theData[2] = 0;
266 signal->theData[3] = ref;
267 signal->theData[4] = data;
268 sendSignal(reference(), GSN_CONTINUEB, signal, 5, JBB);
275 void Dbacc::ndbsttorryLab(
Signal* signal)
277 signal->theData[0] = cownBlockref;
278 sendSignal(cndbcntrRef, GSN_NDB_STTORRY, signal, 1, JBB);
285 void Dbacc::execREAD_CONFIG_REQ(
Signal* signal)
288 Uint32 ref = req->senderRef;
289 Uint32 senderData = req->senderData;
290 ndbrequire(req->noOfParameters == 0);
295 m_ctx.m_config.getOwnConfigIterator();
298 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_ACC_DIR_RANGE, &cdirrangesize));
299 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_ACC_DIR_ARRAY, &cdirarraysize));
300 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_ACC_FRAGMENT, &cfragmentsize));
301 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_ACC_OP_RECS, &coprecsize));
302 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_ACC_OVERFLOW_RECS,
304 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_ACC_PAGE8, &cpagesize));
305 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_ACC_TABLE, &ctablesize));
306 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_ACC_SCAN, &cscanRecSize));
308 ndbrestart1Lab(signal);
310 c_memusage_report_frequency = 0;
311 ndb_mgm_get_int_parameter(p, CFG_DB_MEMREPORT_FREQUENCY,
312 &c_memusage_report_frequency);
315 initialiseRecordsLab(signal, ref, senderData);
322 void Dbacc::sttorrysignalLab(
Signal* signal)
324 signal->theData[0] = csignalkey;
325 signal->theData[1] = 3;
327 signal->theData[2] = 2;
329 signal->theData[3] = ZSPH1;
330 signal->theData[4] = 255;
331 BlockReference cntrRef = !isNdbMtLqh() ? NDBCNTR_REF : DBACC_REF;
332 sendSignal(cntrRef, GSN_STTORRY, signal, 5, JBB);
341 void Dbacc::initialiseDirRec(
Signal* signal)
343 DirectoryarrayPtr idrDirptr;
344 ndbrequire(cdirarraysize > 0);
345 for (idrDirptr.i = 0; idrDirptr.i < cdirarraysize; idrDirptr.i++) {
347 ptrAss(idrDirptr, directoryarray);
348 for (Uint32
i = 0;
i <= 255;
i++) {
349 idrDirptr.p->pagep[
i] = RNIL;
353 cfirstfreedir = RNIL;
360 void Dbacc::initialiseDirRangeRec(
Signal* signal)
362 DirRangePtr idrDirRangePtr;
364 ndbrequire(cdirrangesize > 0);
365 for (idrDirRangePtr.i = 0; idrDirRangePtr.i < cdirrangesize; idrDirRangePtr.i++) {
367 ptrAss(idrDirRangePtr, dirRange);
368 idrDirRangePtr.p->dirArray[0] = idrDirRangePtr.i + 1;
369 for (Uint32
i = 1;
i < 256;
i++) {
370 idrDirRangePtr.p->dirArray[
i] = RNIL;
373 idrDirRangePtr.i = cdirrangesize - 1;
374 ptrAss(idrDirRangePtr, dirRange);
375 idrDirRangePtr.p->dirArray[0] = RNIL;
376 cfirstfreeDirrange = 0;
383 void Dbacc::initialiseFragRec(
Signal* signal)
385 FragmentrecPtr regFragPtr;
386 ndbrequire(cfragmentsize > 0);
387 for (regFragPtr.i = 0; regFragPtr.i < cfragmentsize; regFragPtr.i++) {
390 ptrAss(regFragPtr, fragmentrec);
391 initFragGeneral(regFragPtr);
392 regFragPtr.p->nextfreefrag = regFragPtr.i + 1;
394 regFragPtr.i = cfragmentsize - 1;
395 ptrAss(regFragPtr, fragmentrec);
396 regFragPtr.p->nextfreefrag = RNIL;
404 void Dbacc::initialiseOperationRec(
Signal* signal)
406 ndbrequire(coprecsize > 0);
407 for (operationRecPtr.i = 0; operationRecPtr.i < coprecsize; operationRecPtr.i++) {
409 ptrAss(operationRecPtr, operationrec);
410 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
411 operationRecPtr.p->nextOp = operationRecPtr.i + 1;
413 operationRecPtr.i = coprecsize - 1;
414 ptrAss(operationRecPtr, operationrec);
415 operationRecPtr.p->nextOp = RNIL;
423 void Dbacc::initialiseOverflowRec(
Signal* signal)
425 OverflowRecordPtr iorOverflowRecPtr;
427 ndbrequire(coverflowrecsize > 0);
428 for (iorOverflowRecPtr.i = 0; iorOverflowRecPtr.i < coverflowrecsize; iorOverflowRecPtr.i++) {
430 ptrAss(iorOverflowRecPtr, overflowRecord);
431 iorOverflowRecPtr.p->nextfreeoverrec = iorOverflowRecPtr.i + 1;
433 iorOverflowRecPtr.i = coverflowrecsize - 1;
434 ptrAss(iorOverflowRecPtr, overflowRecord);
435 iorOverflowRecPtr.p->nextfreeoverrec = RNIL;
436 cfirstfreeoverrec = 0;
443 void Dbacc::initialisePageRec(
Signal* signal)
445 ndbrequire(cpagesize > 0);
446 cnoOfAllocatedPages = 0;
447 cnoOfAllocatedPagesMax = 0;
459 void Dbacc::initialiseScanRec(
Signal* signal)
461 ndbrequire(cscanRecSize > 0);
462 for (scanPtr.i = 0; scanPtr.i < cscanRecSize; scanPtr.i++) {
463 ptrAss(scanPtr, scanRec);
464 scanPtr.p->scanNextfreerec = scanPtr.i + 1;
465 scanPtr.p->scanState = ScanRec::SCAN_DISCONNECT;
467 scanPtr.i = cscanRecSize - 1;
468 ptrAss(scanPtr, scanRec);
469 scanPtr.p->scanNextfreerec = RNIL;
470 cfirstFreeScanRec = 0;
478 void Dbacc::initialiseTableRec(
Signal* signal)
480 ndbrequire(ctablesize > 0);
481 for (tabptr.i = 0; tabptr.i < ctablesize; tabptr.i++) {
483 ptrAss(tabptr, tabrec);
484 for (Uint32
i = 0;
i < MAX_FRAG_PER_NODE;
i++) {
485 tabptr.p->fragholder[
i] = RNIL;
486 tabptr.p->fragptrholder[
i] = RNIL;
509 void Dbacc::execACCFRAGREQ(
Signal* signal)
513 if (ERROR_INSERTED(3001)) {
515 addFragRefuse(signal, 1);
516 CLEAR_ERROR_INSERT_VALUE;
519 tabptr.i = req->tableId;
522 if (tabptr.i >= ctablesize) {
524 addFragRefuse(signal, 640);
528 ptrCheckGuard(tabptr, ctablesize, tabrec);
529 ndbrequire((req->reqInfo & 0xF) == ZADDFRAG);
530 ndbrequire(!getfragmentrec(signal, fragrecptr, req->fragId));
531 if (cfirstfreefrag == RNIL) {
533 addFragRefuse(signal, ZFULL_FRAGRECORD_ERROR);
537 seizeFragrec(signal);
538 initFragGeneral(fragrecptr);
539 initFragAdd(signal, fragrecptr);
541 if (!addfragtotab(signal, fragrecptr.i, req->fragId)) {
543 releaseFragRecord(signal, fragrecptr);
544 addFragRefuse(signal, ZFULL_FRAGRECORD_ERROR);
547 if (cfirstfreeDirrange == RNIL) {
549 releaseFragRecord(signal, fragrecptr);
550 addFragRefuse(signal, ZDIR_RANGE_ERROR);
554 seizeDirrange(signal);
557 fragrecptr.p->directory = newDirRangePtr.i;
558 seizeDirectory(signal);
559 if (tresult < ZLIMIT_OF_ERROR) {
561 newDirRangePtr.p->dirArray[0] = sdDirptr.i;
564 addFragRefuse(signal, tresult);
569 if (tresult > ZLIMIT_OF_ERROR) {
571 addFragRefuse(signal, tresult);
574 sdDirptr.p->pagep[0] = spPageptr.i;
576 inpPageptr = spPageptr;
578 if (cfirstfreeDirrange == RNIL) {
580 addFragRefuse(signal, ZDIR_RANGE_ERROR);
584 seizeDirrange(signal);
586 fragrecptr.p->overflowdir = newDirRangePtr.i;
587 seizeDirectory(signal);
588 if (tresult < ZLIMIT_OF_ERROR) {
590 newDirRangePtr.p->dirArray[0] = sdDirptr.i;
593 addFragRefuse(signal, tresult);
597 Uint32 userPtr = req->userPtr;
598 BlockReference retRef = req->userRef;
599 fragrecptr.p->rootState = ACTIVEROOT;
602 conf->userPtr = userPtr;
603 conf->rootFragPtr = RNIL;
604 conf->fragId[0] = fragrecptr.p->fragmentid;
605 conf->fragId[1] = RNIL;
606 conf->fragPtr[0] = fragrecptr.i;
607 conf->fragPtr[1] = RNIL;
608 conf->rootHashCheck = fragrecptr.p->roothashcheck;
609 sendSignal(retRef, GSN_ACCFRAGCONF, signal, AccFragConf::SignalLength, JBB);
612 void Dbacc::addFragRefuse(
Signal* signal, Uint32 errorCode)
616 Uint32 userPtr = req->userPtr;
617 BlockReference retRef = req->userRef;
619 ref->userPtr = userPtr;
620 ref->errorCode = errorCode;
621 sendSignal(retRef, GSN_ACCFRAGREF, signal, AccFragRef::SignalLength, JBB);
626 Dbacc::execDROP_TAB_REQ(
Signal* signal){
631 tabPtr.i = req->tableId;
632 ptrCheckGuard(tabPtr, ctablesize, tabrec);
634 tabPtr.p->tabUserRef = req->senderRef;
635 tabPtr.p->tabUserPtr = req->senderData;
636 tabPtr.p->tabUserGsn = GSN_DROP_TAB_REQ;
638 signal->theData[0] = ZREL_ROOT_FRAG;
639 signal->theData[1] = tabPtr.i;
640 sendSignal(cownBlockref, GSN_CONTINUEB, signal, 2, JBB);
644 Dbacc::execDROP_FRAG_REQ(
Signal* signal){
649 tabPtr.i = req->tableId;
650 ptrCheckGuard(tabPtr, ctablesize, tabrec);
652 tabPtr.p->tabUserRef = req->senderRef;
653 tabPtr.p->tabUserPtr = req->senderData;
654 tabPtr.p->tabUserGsn = GSN_DROP_FRAG_REQ;
656 for (Uint32
i = 0;
i < MAX_FRAG_PER_NODE;
i++)
659 if (tabPtr.p->fragholder[
i] == req->fragId)
662 tabPtr.p->fragholder[
i] = RNIL;
663 releaseFragResources(signal, tabPtr.p->fragptrholder[
i]);
668 releaseRootFragResources(signal, req->tableId);
671 void Dbacc::releaseRootFragResources(
Signal* signal, Uint32 tableId)
675 ptrCheckGuard(tabPtr, ctablesize, tabrec);
677 if (tabPtr.p->tabUserGsn == GSN_DROP_TAB_REQ)
680 for (Uint32
i = 0;
i < MAX_FRAG_PER_NODE;
i++)
683 if (tabPtr.p->fragholder[
i] != RNIL)
686 tabPtr.p->fragholder[
i] = RNIL;
687 releaseFragResources(signal, tabPtr.p->fragptrholder[
i]);
696 dropConf->senderRef = reference();
697 dropConf->senderData = tabPtr.p->tabUserPtr;
698 dropConf->tableId = tabPtr.i;
699 sendSignal(tabPtr.p->tabUserRef, GSN_DROP_TAB_CONF,
700 signal, DropTabConf::SignalLength, JBB);
704 ndbrequire(tabPtr.p->tabUserGsn == GSN_DROP_FRAG_REQ);
707 conf->senderRef = reference();
708 conf->senderData = tabPtr.p->tabUserPtr;
709 conf->tableId = tabPtr.i;
710 sendSignal(tabPtr.p->tabUserRef, GSN_DROP_FRAG_CONF,
711 signal, DropFragConf::SignalLength, JBB);
714 tabPtr.p->tabUserPtr = RNIL;
715 tabPtr.p->tabUserRef = 0;
716 tabPtr.p->tabUserGsn = 0;
719 void Dbacc::releaseFragResources(
Signal* signal, Uint32 fragIndex)
721 FragmentrecPtr regFragPtr;
722 regFragPtr.i = fragIndex;
723 ptrCheckGuard(regFragPtr, cfragmentsize, fragmentrec);
724 verifyFragCorrect(regFragPtr);
725 if (regFragPtr.p->directory != RNIL) {
727 releaseDirResources(signal, regFragPtr.i, regFragPtr.p->directory, 0);
728 regFragPtr.p->directory = RNIL;
729 }
else if (regFragPtr.p->overflowdir != RNIL) {
731 releaseDirResources(signal, regFragPtr.i, regFragPtr.p->overflowdir, 0);
732 regFragPtr.p->overflowdir = RNIL;
733 }
else if (regFragPtr.p->firstOverflowRec != RNIL) {
735 releaseOverflowResources(signal, regFragPtr);
736 }
else if (regFragPtr.p->firstFreeDirindexRec != RNIL) {
738 releaseDirIndexResources(signal, regFragPtr);
741 Uint32 tab = regFragPtr.p->mytabptr;
742 releaseFragRecord(signal, regFragPtr);
743 signal->theData[0] = ZREL_ROOT_FRAG;
744 signal->theData[1] = tab;
745 sendSignal(cownBlockref, GSN_CONTINUEB, signal, 2, JBB);
749 void Dbacc::verifyFragCorrect(FragmentrecPtr regFragPtr)
751 ndbrequire(regFragPtr.p->lockOwnersList == RNIL);
754 void Dbacc::releaseDirResources(
Signal* signal,
759 DirRangePtr regDirRangePtr;
760 regDirRangePtr.i = dirIndex;
761 ptrCheckGuard(regDirRangePtr, cdirrangesize, dirRange);
762 for (Uint32
i = startIndex;
i < 256;
i++) {
764 if (regDirRangePtr.p->dirArray[
i] != RNIL) {
766 Uint32 directoryIndex = regDirRangePtr.p->dirArray[
i];
767 regDirRangePtr.p->dirArray[
i] = RNIL;
768 releaseDirectoryResources(signal, fragIndex, dirIndex, (
i + 1), directoryIndex);
772 rdDirRangePtr = regDirRangePtr;
773 releaseDirrange(signal);
774 signal->theData[0] = ZREL_FRAG;
775 signal->theData[1] = fragIndex;
776 sendSignal(cownBlockref, GSN_CONTINUEB, signal, 2, JBB);
779 void Dbacc::releaseDirectoryResources(
Signal* signal,
783 Uint32 directoryIndex)
785 DirectoryarrayPtr regDirPtr;
786 regDirPtr.i = directoryIndex;
787 ptrCheckGuard(regDirPtr, cdirarraysize, directoryarray);
788 for (Uint32
i = 0;
i < 256;
i++) {
790 if (regDirPtr.p->pagep[
i] != RNIL) {
792 rpPageptr.i = regDirPtr.p->pagep[
i];
793 ptrCheckGuard(rpPageptr, cpagesize, page8);
795 regDirPtr.p->pagep[
i] = RNIL;
798 rdDirptr = regDirPtr;
799 releaseDirectory(signal);
800 signal->theData[0] = ZREL_DIR;
801 signal->theData[1] = fragIndex;
802 signal->theData[2] = dirIndex;
803 signal->theData[3] = startIndex;
804 sendSignal(cownBlockref, GSN_CONTINUEB, signal, 4, JBB);
807 void Dbacc::releaseOverflowResources(
Signal* signal, FragmentrecPtr regFragPtr)
809 Uint32 loopCount = 0;
810 OverflowRecordPtr regOverflowRecPtr;
811 while ((regFragPtr.p->firstOverflowRec != RNIL) &&
814 regOverflowRecPtr.i = regFragPtr.p->firstOverflowRec;
815 ptrCheckGuard(regOverflowRecPtr, coverflowrecsize, overflowRecord);
816 regFragPtr.p->firstOverflowRec = regOverflowRecPtr.p->nextOverRec;
817 rorOverflowRecPtr = regOverflowRecPtr;
818 releaseOverflowRec(signal);
821 signal->theData[0] = ZREL_FRAG;
822 signal->theData[1] = regFragPtr.i;
823 sendSignal(cownBlockref, GSN_CONTINUEB, signal, 2, JBB);
826 void Dbacc::releaseDirIndexResources(
Signal* signal, FragmentrecPtr regFragPtr)
828 Uint32 loopCount = 0;
829 OverflowRecordPtr regOverflowRecPtr;
830 while ((regFragPtr.p->firstFreeDirindexRec != RNIL) &&
833 regOverflowRecPtr.i = regFragPtr.p->firstFreeDirindexRec;
834 ptrCheckGuard(regOverflowRecPtr, coverflowrecsize, overflowRecord);
835 regFragPtr.p->firstFreeDirindexRec = regOverflowRecPtr.p->nextOverList;
836 rorOverflowRecPtr = regOverflowRecPtr;
837 releaseOverflowRec(signal);
840 signal->theData[0] = ZREL_FRAG;
841 signal->theData[1] = regFragPtr.i;
842 sendSignal(cownBlockref, GSN_CONTINUEB, signal, 2, JBB);
845 void Dbacc::releaseFragRecord(
Signal* signal, FragmentrecPtr regFragPtr)
847 regFragPtr.p->nextfreefrag = cfirstfreefrag;
848 cfirstfreefrag = regFragPtr.i;
849 initFragGeneral(regFragPtr);
850 RSS_OP_FREE(cnoOfFreeFragrec);
858 bool Dbacc::addfragtotab(
Signal* signal, Uint32 rootIndex, Uint32 fid)
860 for (Uint32
i = 0;
i < MAX_FRAG_PER_NODE;
i++) {
862 if (tabptr.p->fragholder[
i] == RNIL) {
864 tabptr.p->fragholder[
i] = fid;
865 tabptr.p->fragptrholder[
i] = rootIndex;
899 void Dbacc::execACCSEIZEREQ(
Signal* signal)
902 tuserptr = signal->theData[0];
904 tuserblockref = signal->theData[1];
907 if (cfreeopRec == RNIL) {
909 refaccConnectLab(signal);
913 ptrGuard(operationRecPtr);
914 operationRecPtr.p->userptr = tuserptr;
915 operationRecPtr.p->userblockref = tuserblockref;
916 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
920 signal->theData[0] = tuserptr;
921 signal->theData[1] = operationRecPtr.i;
922 sendSignal(tuserblockref, GSN_ACCSEIZECONF, signal, 2, JBB);
926 void Dbacc::refaccConnectLab(
Signal* signal)
928 tresult = ZCONNECT_SIZE_ERROR;
932 signal->theData[0] = tuserptr;
933 signal->theData[1] = tresult;
934 sendSignal(tuserblockref, GSN_ACCSEIZEREF, signal, 2, JBB);
959 void Dbacc::initOpRec(
Signal* signal)
961 register Uint32 Treqinfo;
963 Treqinfo = signal->theData[2];
965 operationRecPtr.p->hashValue = signal->theData[3];
966 operationRecPtr.p->tupkeylen = signal->theData[4];
967 operationRecPtr.p->xfrmtupkeylen = signal->theData[4];
968 operationRecPtr.p->transId1 = signal->theData[5];
969 operationRecPtr.p->transId2 = signal->theData[6];
971 Uint32 readFlag = (((Treqinfo >> 4) & 0x3) == 0);
972 Uint32 dirtyFlag = (((Treqinfo >> 6) & 0x1) == 1);
973 Uint32 dirtyReadFlag = readFlag & dirtyFlag;
974 Uint32 operation = Treqinfo & 0xf;
975 if (operation == ZREFRESH)
980 opbits |= ((Treqinfo >> 4) & 0x3) ? (Uint32) Operationrec::OP_LOCK_MODE : 0;
981 opbits |= ((Treqinfo >> 4) & 0x3) ? (Uint32) Operationrec::OP_ACC_LOCK_MODE : 0;
982 opbits |= (dirtyReadFlag) ? (Uint32) Operationrec::OP_DIRTY_READ : 0;
983 if ((Treqinfo >> 31) & 0x1)
985 opbits |= Operationrec::OP_LOCK_REQ;
992 opbits |= Operationrec::OP_COMMIT_DELETE_CHECK;
1001 operationRecPtr.p->fid = fragrecptr.p->myfid;
1002 operationRecPtr.p->fragptr = fragrecptr.i;
1003 operationRecPtr.p->nextParallelQue = RNIL;
1004 operationRecPtr.p->prevParallelQue = RNIL;
1005 operationRecPtr.p->nextSerialQue = RNIL;
1006 operationRecPtr.p->prevSerialQue = RNIL;
1007 operationRecPtr.p->elementPage = RNIL;
1008 operationRecPtr.p->scanRecPtr = RNIL;
1009 operationRecPtr.p->m_op_bits = opbits;
1014 if (operationRecPtr.p->tupkeylen == 0)
1016 ndbassert(signal->getLength() == 9);
1023 void Dbacc::sendAcckeyconf(
Signal* signal)
1025 signal->theData[0] = operationRecPtr.p->userptr;
1026 signal->theData[1] = operationRecPtr.p->m_op_bits & Operationrec::OP_MASK;
1027 signal->theData[2] = operationRecPtr.p->fid;
1028 signal->theData[3] = operationRecPtr.p->localdata[0];
1029 signal->theData[4] = operationRecPtr.p->localdata[1];
1033 Dbacc::ACCKEY_error(Uint32 fromWhere)
1075 void Dbacc::execACCKEYREQ(
Signal* signal)
1078 operationRecPtr.i = signal->theData[0];
1079 fragrecptr.i = signal->theData[1];
1080 if (!((operationRecPtr.i < coprecsize) ||
1081 (fragrecptr.i < cfragmentsize))) {
1085 ptrAss(operationRecPtr, operationrec);
1086 ptrAss(fragrecptr, fragmentrec);
1088 ndbrequire(operationRecPtr.p->m_op_bits == Operationrec::OP_INITIAL);
1092 if (operationRecPtr.p->tupkeylen && fragrecptr.p->hasCharAttr)
1093 xfrmKeyData(signal);
1102 OperationrecPtr lockOwnerPtr;
1103 const Uint32 found = getElement(signal, lockOwnerPtr);
1105 Uint32 opbits = operationRecPtr.p->m_op_bits;
1106 Uint32 op = opbits & Operationrec::OP_MASK;
1115 if (!lockOwnerPtr.p)
1120 opbits &= ~(Uint32)Operationrec::OP_MASK;
1121 opbits |= (op = ZUPDATE);
1122 operationRecPtr.p->m_op_bits = opbits;
1124 opbits |= Operationrec::OP_STATE_RUNNING;
1125 opbits |= Operationrec::OP_RUN_QUEUE;
1126 sendAcckeyconf(signal);
1127 if (! (opbits & Operationrec::OP_DIRTY_READ)) {
1132 Uint32 eh = gePageptr.p->word32[tgeElementptr];
1133 operationRecPtr.p->scanBits = ElementHeader::getScanBits(eh);
1134 operationRecPtr.p->hashvaluePart = ElementHeader::getHashValuePart(eh);
1135 operationRecPtr.p->elementPage = gePageptr.i;
1136 operationRecPtr.p->elementContainer = tgeContainerptr;
1137 operationRecPtr.p->elementPointer = tgeElementptr;
1138 operationRecPtr.p->elementIsforward = tgeForward;
1140 eh = ElementHeader::setLocked(operationRecPtr.i);
1141 dbgWord32(gePageptr, tgeElementptr, eh);
1142 gePageptr.p->word32[tgeElementptr] = eh;
1144 opbits |= Operationrec::OP_LOCK_OWNER;
1145 insertLockOwnersList(signal, operationRecPtr);
1152 opbits = Operationrec::OP_EXECUTED_DIRTY_READ;
1154 operationRecPtr.p->m_op_bits = opbits;
1158 accIsLockedLab(signal, lockOwnerPtr);
1164 insertExistElemLab(signal, lockOwnerPtr);
1171 }
else if (found == ZFALSE) {
1174 opbits &= ~(Uint32)Operationrec::OP_MASK;
1175 opbits |= (op = ZINSERT);
1178 opbits |= Operationrec::OP_INSERT_IS_DONE;
1179 opbits |= Operationrec::OP_STATE_RUNNING;
1180 opbits |= Operationrec::OP_RUN_QUEUE;
1181 operationRecPtr.p->m_op_bits = opbits;
1182 insertelementLab(signal);
1190 acckeyref1Lab(signal, ZREAD_ERROR);
1199 acckeyref1Lab(signal, found);
1206 Dbacc::execACCKEY_ORD(
Signal* signal, Uint32 opPtrI)
1209 OperationrecPtr lastOp;
1211 ptrCheckGuard(lastOp, coprecsize, operationrec);
1212 Uint32 opbits = lastOp.p->m_op_bits;
1213 Uint32 opstate = opbits & Operationrec::OP_STATE_MASK;
1215 if (likely(opbits == Operationrec::OP_EXECUTED_DIRTY_READ))
1218 lastOp.p->m_op_bits = Operationrec::OP_INITIAL;
1221 else if (likely(opstate == Operationrec::OP_STATE_RUNNING))
1223 opbits |= Operationrec::OP_STATE_EXECUTED;
1224 lastOp.p->m_op_bits = opbits;
1232 ndbout_c(
"bits: %.8x state: %.8x", opbits, opstate);
1242 nextOp.i = lastOp.p->nextParallelQue;
1243 loPtr.i = lastOp.p->m_lock_owner_ptr_i;
1244 Uint32 opbits = lastOp.p->m_op_bits;
1246 if ((opbits & Operationrec::OP_STATE_MASK)!= Operationrec::OP_STATE_EXECUTED)
1253 if (nextOp.i != RNIL)
1256 ptrCheckGuard(nextOp, coprecsize, operationrec);
1257 nextbits = nextOp.p->m_op_bits;
1261 if ((opbits & Operationrec::OP_LOCK_OWNER) == 0)
1264 ptrCheckGuard(loPtr, coprecsize, operationrec);
1272 nextOp.i = loPtr.p->nextSerialQue;
1273 ndbassert(loPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER);
1275 if (nextOp.i == RNIL)
1285 ptrCheckGuard(nextOp, coprecsize, operationrec);
1286 nextbits = nextOp.p->m_op_bits;
1289 const bool same = nextOp.p->is_same_trans(lastOp.p);
1291 if (!same && ((opbits & Operationrec::OP_ACC_LOCK_MODE) ||
1292 (nextbits & Operationrec::OP_LOCK_MODE)))
1306 if (same && (opbits & Operationrec::OP_ACC_LOCK_MODE))
1316 if ((opbits & Operationrec::OP_ACC_LOCK_MODE) == 0 &&
1317 (nextbits & Operationrec::OP_LOCK_MODE) == 0)
1326 ndbassert((opbits & Operationrec::OP_ACC_LOCK_MODE) == 0 &&
1327 (nextbits & Operationrec::OP_LOCK_MODE));
1334 while (tmp.i != RNIL)
1336 ptrCheckGuard(tmp, coprecsize, operationrec);
1337 if (!nextOp.p->is_same_trans(tmp.p))
1345 tmp.i = tmp.p->nextParallelQue;
1353 tmp.i = loPtr.p->nextSerialQue = nextOp.p->nextSerialQue;
1354 loPtr.p->m_lo_last_parallel_op_ptr_i = nextOp.i;
1355 nextOp.p->nextSerialQue = RNIL;
1356 nextOp.p->prevSerialQue = RNIL;
1357 nextOp.p->m_lock_owner_ptr_i = loPtr.i;
1358 nextOp.p->prevParallelQue = lastOp.i;
1359 lastOp.p->nextParallelQue = nextOp.i;
1364 ptrCheckGuard(tmp, coprecsize, operationrec);
1365 tmp.p->prevSerialQue = loPtr.i;
1370 loPtr.p->m_lo_last_serial_op_ptr_i = RNIL;
1373 nextbits |= Operationrec::OP_RUN_QUEUE;
1378 ndbrequire(nextOp.p->nextParallelQue == RNIL);
1383 operationRecPtr = nextOp;
1385 Uint32 lastop = opbits & Operationrec::OP_MASK;
1386 Uint32 nextop = nextbits & Operationrec::OP_MASK;
1388 nextbits &= nextbits & ~(Uint32)Operationrec::OP_STATE_MASK;
1389 nextbits |= Operationrec::OP_STATE_RUNNING;
1391 if (lastop == ZDELETE)
1394 if (nextop != ZINSERT && nextop != ZWRITE)
1396 errCode = ZREAD_ERROR;
1400 nextbits &= ~(Uint32)Operationrec::OP_MASK;
1401 nextbits &= ~(Uint32)Operationrec::OP_ELEMENT_DISAPPEARED;
1402 nextbits |= (nextop = ZINSERT);
1405 else if (nextop == ZINSERT)
1408 errCode = ZWRITE_ERROR;
1411 else if (nextop == ZWRITE)
1414 nextbits &= ~(Uint32)Operationrec::OP_MASK;
1415 nextbits |= (nextop = ZUPDATE);
1424 nextOp.p->m_op_bits = nextbits;
1425 nextOp.p->localdata[0] = lastOp.p->localdata[0];
1426 nextOp.p->localdata[1] = lastOp.p->localdata[1];
1428 if (nextop == ZSCAN_OP && (nextbits & Operationrec::OP_LOCK_REQ) == 0)
1431 takeOutScanLockQueue(nextOp.p->scanRecPtr);
1432 putReadyScanQueue(signal, nextOp.p->scanRecPtr);
1437 fragrecptr.i = nextOp.p->fragptr;
1438 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
1440 sendAcckeyconf(signal);
1441 sendSignal(nextOp.p->userblockref, GSN_ACCKEYCONF,
1445 operationRecPtr = save;
1449 nextOp.p->m_op_bits = nextbits;
1451 if (nextop == ZSCAN_OP && (nextbits & Operationrec::OP_LOCK_REQ) == 0)
1454 nextOp.p->m_op_bits |= Operationrec::OP_ELEMENT_DISAPPEARED;
1455 takeOutScanLockQueue(nextOp.p->scanRecPtr);
1456 putReadyScanQueue(signal, nextOp.p->scanRecPtr);
1461 signal->theData[0] = nextOp.p->userptr;
1462 signal->theData[1] = errCode;
1463 sendSignal(nextOp.p->userblockref, GSN_ACCKEYREF, signal,
1467 operationRecPtr = save;
1474 Dbacc::execACCKEY_REP_REF(
Signal* signal, Uint32 opPtrI)
1480 Dbacc::xfrmKeyData(
Signal* signal)
1482 Uint32
table = fragrecptr.p->myTableId;
1483 Uint32 dst[MAX_KEY_SIZE_IN_WORDS * MAX_XFRM_MULTIPLY];
1484 Uint32 keyPartLen[MAX_ATTRIBUTES_IN_INDEX];
1485 Uint32* src = &signal->theData[7];
1486 Uint32 len =
xfrm_key(table, src, dst,
sizeof(dst) >> 2, keyPartLen);
1488 memcpy(src, dst, len << 2);
1489 operationRecPtr.p->xfrmtupkeylen = len;
1493 Dbacc::accIsLockedLab(
Signal* signal, OperationrecPtr lockOwnerPtr)
1495 Uint32 bits = operationRecPtr.p->m_op_bits;
1496 validate_lock_queue(lockOwnerPtr);
1498 if ((bits & Operationrec::OP_DIRTY_READ) == 0){
1499 Uint32 return_result;
1500 if ((bits & Operationrec::OP_LOCK_MODE) == ZREADLOCK) {
1502 return_result = placeReadInLockQueue(lockOwnerPtr);
1505 return_result = placeWriteInLockQueue(lockOwnerPtr);
1507 if (return_result == ZPARALLEL_QUEUE) {
1509 sendAcckeyconf(signal);
1511 }
else if (return_result == ZSERIAL_QUEUE) {
1513 signal->theData[0] = RNIL;
1517 acckeyref1Lab(signal, return_result);
1524 if (! (lockOwnerPtr.p->m_op_bits & Operationrec::OP_ELEMENT_DISAPPEARED) &&
1525 ! Local_key::isInvalid(lockOwnerPtr.p->localdata[0],
1526 lockOwnerPtr.p->localdata[1]))
1533 sendAcckeyconf(signal);
1534 operationRecPtr.p->m_op_bits = Operationrec::OP_EXECUTED_DIRTY_READ;
1544 acckeyref1Lab(signal, ZREAD_ERROR);
1553 void Dbacc::insertExistElemLab(
Signal* signal, OperationrecPtr lockOwnerPtr)
1555 if (!lockOwnerPtr.p)
1558 acckeyref1Lab(signal, ZWRITE_ERROR);
1561 accIsLockedLab(signal, lockOwnerPtr);
1567 void Dbacc::insertelementLab(
Signal* signal)
1569 if (unlikely(fragrecptr.p->dirRangeFull))
1572 acckeyref1Lab(signal, ZDIR_RANGE_FULL_ERROR);
1575 if (fragrecptr.p->firstOverflowRec == RNIL) {
1577 allocOverflowPage(signal);
1578 if (tresult > ZLIMIT_OF_ERROR) {
1580 acckeyref1Lab(signal, tresult);
1584 ndbrequire(operationRecPtr.p->tupkeylen <= fragrecptr.p->keyLength);
1585 ndbassert(!(operationRecPtr.p->m_op_bits & Operationrec::OP_LOCK_REQ));
1586 Uint32 localKey = ~(Uint32)0;
1588 insertLockOwnersList(signal, operationRecPtr);
1590 const Uint32 tmp = fragrecptr.p->k + fragrecptr.p->lhfragbits;
1591 operationRecPtr.p->hashvaluePart =
1592 (operationRecPtr.p->hashValue >> tmp) & 0xFFFF;
1593 operationRecPtr.p->scanBits = 0;
1594 tidrElemhead = ElementHeader::setLocked(operationRecPtr.i);
1595 idrPageptr = gdiPageptr;
1596 tidrPageindex = tgdiPageindex;
1597 tidrForward = ZTRUE;
1598 idrOperationRecPtr = operationRecPtr;
1599 clocalkey[0] = localKey;
1600 clocalkey[1] = localKey;
1601 operationRecPtr.p->localdata[0] = localKey;
1602 operationRecPtr.p->localdata[1] = localKey;
1606 insertElement(signal);
1607 sendAcckeyconf(signal);
1616 Dbacc::getNoParallelTransaction(
const Operationrec * op)
1618 OperationrecPtr tmp;
1620 tmp.i= op->nextParallelQue;
1621 Uint32 transId[2] = { op->transId1, op->transId2 };
1622 while (tmp.i != RNIL)
1625 ptrCheckGuard(tmp, coprecsize, operationrec);
1626 if (tmp.p->transId1 == transId[0] && tmp.p->transId2 == transId[1])
1627 tmp.i = tmp.p->nextParallelQue;
1636 Dbacc::getNoParallelTransactionFull(
const Operationrec * op)
1641 while ((tmp.p->m_op_bits & Operationrec::OP_LOCK_OWNER) == 0)
1643 tmp.i = tmp.p->prevParallelQue;
1646 ptrCheckGuard(tmp, coprecsize, operationrec);
1654 return getNoParallelTransaction(tmp.p);
1658 #ifdef ACC_SAFE_QUEUE
1661 Dbacc::get_parallel_head(OperationrecPtr opPtr)
1663 while ((opPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER) == 0 &&
1664 opPtr.p->prevParallelQue != RNIL)
1666 opPtr.i = opPtr.p->prevParallelQue;
1667 ptrCheckGuard(opPtr, coprecsize, operationrec);
1674 Dbacc::validate_lock_queue(OperationrecPtr opPtr)
1676 OperationrecPtr loPtr;
1677 loPtr.i = get_parallel_head(opPtr);
1678 ptrCheckGuard(loPtr, coprecsize, operationrec);
1680 while((loPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER) == 0 &&
1681 loPtr.p->prevSerialQue != RNIL)
1683 loPtr.i = loPtr.p->prevSerialQue;
1684 ptrCheckGuard(loPtr, coprecsize, operationrec);
1688 vlqrequire(loPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER);
1689 vlqrequire(loPtr.p->m_op_bits & Operationrec::OP_RUN_QUEUE);
1694 pagePtr.i = loPtr.p->elementPage;
1695 ptrCheckGuard(pagePtr, cpagesize, page8);
1696 arrGuard(loPtr.p->elementPointer, 2048);
1697 Uint32 eh = pagePtr.p->word32[loPtr.p->elementPointer];
1698 vlqrequire(ElementHeader::getLocked(eh));
1699 vlqrequire(ElementHeader::getOpPtrI(eh) == loPtr.i);
1703 if (loPtr.p->m_op_bits & Operationrec::OP_LOCK_MODE)
1705 vlqrequire(loPtr.p->m_op_bits & Operationrec::OP_ACC_LOCK_MODE);
1709 vlqrequire((loPtr.p->m_op_bits & Operationrec::OP_ACC_LOCK_MODE) == 0);
1713 bool running =
false;
1715 Uint32 opstate = loPtr.p->m_op_bits & Operationrec::OP_STATE_MASK;
1716 if (opstate == Operationrec::OP_STATE_RUNNING)
1720 vlqrequire(opstate == Operationrec::OP_STATE_EXECUTED);
1727 bool orlockmode = loPtr.p->m_op_bits & Operationrec::OP_LOCK_MODE;
1728 OperationrecPtr lastP = loPtr;
1730 while (lastP.p->nextParallelQue != RNIL)
1732 Uint32 prev = lastP.i;
1733 lastP.i = lastP.p->nextParallelQue;
1734 ptrCheckGuard(lastP, coprecsize, operationrec);
1736 vlqrequire(lastP.p->prevParallelQue == prev);
1738 Uint32 opbits = lastP.p->m_op_bits;
1739 many |= loPtr.p->is_same_trans(lastP.p) ? 0 : 1;
1740 orlockmode |= !!(opbits & Operationrec::OP_LOCK_MODE);
1742 vlqrequire(opbits & Operationrec::OP_RUN_QUEUE);
1743 vlqrequire((opbits & Operationrec::OP_LOCK_OWNER) == 0);
1745 Uint32 opstate = opbits & Operationrec::OP_STATE_MASK;
1750 vlqrequire(opstate == Operationrec::OP_STATE_WAITING);
1754 if (opstate == Operationrec::OP_STATE_RUNNING)
1757 vlqrequire(opstate == Operationrec::OP_STATE_EXECUTED);
1760 if (lastP.p->m_op_bits & Operationrec::OP_LOCK_MODE)
1762 vlqrequire(lastP.p->m_op_bits & Operationrec::OP_ACC_LOCK_MODE);
1766 vlqrequire((lastP.p->m_op_bits && orlockmode) == orlockmode);
1767 vlqrequire((lastP.p->m_op_bits & Operationrec::OP_MASK) == ZREAD ||
1768 (lastP.p->m_op_bits & Operationrec::OP_MASK) == ZSCAN_OP);
1773 vlqrequire(orlockmode == 0);
1777 if (lastP.i != loPtr.i)
1779 vlqrequire(loPtr.p->m_lo_last_parallel_op_ptr_i == lastP.i);
1780 vlqrequire(lastP.p->m_lock_owner_ptr_i == loPtr.i);
1784 vlqrequire(loPtr.p->m_lo_last_parallel_op_ptr_i == RNIL);
1789 if (loPtr.p->nextSerialQue != RNIL)
1791 Uint32 prev = loPtr.i;
1792 OperationrecPtr lastS;
1793 lastS.i = loPtr.p->nextSerialQue;
1796 ptrCheckGuard(lastS, coprecsize, operationrec);
1797 vlqrequire(lastS.p->prevSerialQue == prev);
1798 vlqrequire(getNoParallelTransaction(lastS.p) == 1);
1799 vlqrequire((lastS.p->m_op_bits & Operationrec::OP_LOCK_OWNER) == 0);
1800 vlqrequire((lastS.p->m_op_bits & Operationrec::OP_RUN_QUEUE) == 0);
1801 vlqrequire((lastS.p->m_op_bits & Operationrec::OP_STATE_MASK) == Operationrec::OP_STATE_WAITING);
1802 if (lastS.p->nextSerialQue == RNIL)
1805 lastS.i = lastS.p->nextSerialQue;
1808 vlqrequire(loPtr.p->m_lo_last_serial_op_ptr_i == lastS.i);
1812 vlqrequire(loPtr.p->m_lo_last_serial_op_ptr_i == RNIL);
1820 Uint32 opbits = ptr.p->m_op_bits;
1821 out <<
"[ " << dec << ptr.i
1822 <<
" [ " << hex << ptr.p->transId1
1823 <<
" " << hex << ptr.p->transId2 <<
"] "
1824 <<
" bits: H'" << hex << opbits <<
" ";
1827 switch(opbits & Dbacc::Operationrec::OP_MASK){
1828 case ZREAD: out <<
"READ "; read =
true;
break;
1829 case ZINSERT: out <<
"INSERT ";
break;
1830 case ZUPDATE: out <<
"UPDATE ";
break;
1831 case ZDELETE: out <<
"DELETE ";
break;
1832 case ZWRITE: out <<
"WRITE ";
break;
1833 case ZSCAN_OP: out <<
"SCAN "; read =
true;
break;
1835 out <<
"<Unknown: H'"
1836 << hex << (opbits & Dbacc::Operationrec::OP_MASK)
1842 if (opbits & Dbacc::Operationrec::OP_LOCK_MODE)
1846 if (opbits & Dbacc::Operationrec::OP_ACC_LOCK_MODE)
1857 switch(opbits & Dbacc::Operationrec::OP_STATE_MASK){
1858 case Dbacc::Operationrec::OP_STATE_WAITING:
1859 out <<
" WAITING ";
break;
1860 case Dbacc::Operationrec::OP_STATE_RUNNING:
1861 out <<
" RUNNING ";
break;
1862 case Dbacc::Operationrec::OP_STATE_EXECUTED:
1863 out <<
" EXECUTED ";
break;
1864 case Dbacc::Operationrec::OP_STATE_IDLE:
1865 out <<
" IDLE ";
break;
1867 out <<
" <Unknown: H'"
1868 << hex << (opbits & Dbacc::Operationrec::OP_STATE_MASK)
1891 if (opbits & Dbacc::Operationrec::OP_LOCK_OWNER)
1894 if (opbits & Dbacc::Operationrec::OP_DIRTY_READ)
1897 if (opbits & Dbacc::Operationrec::OP_LOCK_REQ)
1900 if (opbits & Dbacc::Operationrec::OP_COMMIT_DELETE_CHECK)
1901 out <<
"COMMIT_DELETE_CHECK ";
1903 if (opbits & Dbacc::Operationrec::OP_INSERT_IS_DONE)
1904 out <<
"INSERT_IS_DONE ";
1906 if (opbits & Dbacc::Operationrec::OP_ELEMENT_DISAPPEARED)
1907 out <<
"ELEMENT_DISAPPEARED ";
1909 if (opbits & Dbacc::Operationrec::OP_LOCK_OWNER)
1911 out <<
"last_parallel: " << dec << ptr.p->m_lo_last_parallel_op_ptr_i <<
" ";
1912 out <<
"last_serial: " << dec << ptr.p->m_lo_last_serial_op_ptr_i <<
" ";
1920 Dbacc::dump_lock_queue(OperationrecPtr loPtr)
1922 if ((loPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER) == 0)
1924 while ((loPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER) == 0 &&
1925 loPtr.p->prevParallelQue != RNIL)
1927 loPtr.i = loPtr.p->prevParallelQue;
1928 ptrCheckGuard(loPtr, coprecsize, operationrec);
1931 while ((loPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER) == 0 &&
1932 loPtr.p->prevSerialQue != RNIL)
1934 loPtr.i = loPtr.p->prevSerialQue;
1935 ptrCheckGuard(loPtr, coprecsize, operationrec);
1938 ndbassert(loPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER);
1941 ndbout <<
"-- HEAD --" << endl;
1942 OperationrecPtr tmp = loPtr;
1943 while (tmp.i != RNIL)
1945 ptrCheckGuard(tmp, coprecsize, operationrec);
1946 ndbout << tmp <<
" ";
1947 tmp.i = tmp.p->nextParallelQue;
1949 if (tmp.i == loPtr.i)
1951 ndbout <<
" <LOOP>";
1957 tmp.i = loPtr.p->nextSerialQue;
1958 while (tmp.i != RNIL)
1960 ptrCheckGuard(tmp, coprecsize, operationrec);
1961 OperationrecPtr tmp2 = tmp;
1963 if (tmp.i == loPtr.i)
1965 ndbout <<
"<LOOP S>" << endl;
1969 while (tmp2.i != RNIL)
1971 ptrCheckGuard(tmp2, coprecsize, operationrec);
1972 ndbout << tmp2 <<
" ";
1973 tmp2.i = tmp2.p->nextParallelQue;
1975 if (tmp2.i == tmp.i)
1977 ndbout <<
"<LOOP 3>";
1982 tmp.i = tmp.p->nextSerialQue;
2000 Dbacc::placeWriteInLockQueue(OperationrecPtr lockOwnerPtr)
2002 OperationrecPtr lastOpPtr;
2003 lastOpPtr.i = lockOwnerPtr.p->m_lo_last_parallel_op_ptr_i;
2004 Uint32 opbits = operationRecPtr.p->m_op_bits;
2006 if (lastOpPtr.i == RNIL)
2008 lastOpPtr = lockOwnerPtr;
2012 ptrCheckGuard(lastOpPtr, coprecsize, operationrec);
2015 ndbassert(get_parallel_head(lastOpPtr) == lockOwnerPtr.i);
2017 Uint32 lastbits = lastOpPtr.p->m_op_bits;
2018 if (lastbits & Operationrec::OP_ACC_LOCK_MODE)
2020 if(operationRecPtr.p->is_same_trans(lastOpPtr.p))
2036 OperationrecPtr loopPtr = lockOwnerPtr;
2039 ptrCheckGuard(loopPtr, coprecsize, operationrec);
2040 if (!loopPtr.p->is_same_trans(operationRecPtr.p))
2044 loopPtr.i = loopPtr.p->nextParallelQue;
2045 }
while (loopPtr.i != RNIL);
2052 placeSerialQueue(lockOwnerPtr, operationRecPtr);
2054 validate_lock_queue(lockOwnerPtr);
2056 return ZSERIAL_QUEUE;
2067 Uint32 lstate = lastbits & Operationrec::OP_STATE_MASK;
2069 Uint32 retValue = ZSERIAL_QUEUE;
2070 if (lstate == Operationrec::OP_STATE_EXECUTED)
2078 Uint32 op = opbits & Operationrec::OP_MASK;
2079 Uint32 lop = lastbits & Operationrec::OP_MASK;
2080 if (op == ZINSERT && lop != ZDELETE)
2083 return ZWRITE_ERROR;
2091 if (lop == ZDELETE && (op != ZINSERT && op != ZWRITE))
2097 if (lop == ZDELETE && (op == ZUPDATE && op == ZDELETE))
2106 opbits &= ~(Uint32)Operationrec::OP_MASK;
2107 opbits |= (lop == ZDELETE) ? ZINSERT : ZUPDATE;
2110 opbits |= Operationrec::OP_STATE_RUNNING;
2111 operationRecPtr.p->localdata[0] = lastOpPtr.p->localdata[0];
2112 operationRecPtr.p->localdata[1] = lastOpPtr.p->localdata[1];
2113 retValue = ZPARALLEL_QUEUE;
2116 opbits |= Operationrec::OP_RUN_QUEUE;
2117 operationRecPtr.p->m_op_bits = opbits;
2118 operationRecPtr.p->prevParallelQue = lastOpPtr.i;
2119 operationRecPtr.p->m_lock_owner_ptr_i = lockOwnerPtr.i;
2120 lastOpPtr.p->nextParallelQue = operationRecPtr.i;
2121 lockOwnerPtr.p->m_lo_last_parallel_op_ptr_i = operationRecPtr.i;
2123 validate_lock_queue(lockOwnerPtr);
2129 Dbacc::placeReadInLockQueue(OperationrecPtr lockOwnerPtr)
2131 OperationrecPtr lastOpPtr;
2132 OperationrecPtr loopPtr = lockOwnerPtr;
2133 lastOpPtr.i = lockOwnerPtr.p->m_lo_last_parallel_op_ptr_i;
2134 Uint32 opbits = operationRecPtr.p->m_op_bits;
2136 if (lastOpPtr.i == RNIL)
2138 lastOpPtr = lockOwnerPtr;
2142 ptrCheckGuard(lastOpPtr, coprecsize, operationrec);
2145 ndbassert(get_parallel_head(lastOpPtr) == lockOwnerPtr.i);
2151 Uint32 lastbits = lastOpPtr.p->m_op_bits;
2152 bool same = operationRecPtr.p->is_same_trans(lastOpPtr.p);
2153 if (same && (lastbits & Operationrec::OP_ACC_LOCK_MODE))
2156 opbits |= Operationrec::OP_LOCK_MODE;
2160 if ((lastbits & Operationrec::OP_ACC_LOCK_MODE) && !same)
2169 if (lockOwnerPtr.p->nextSerialQue == RNIL)
2180 ptrCheckGuard(loopPtr, coprecsize, operationrec);
2181 if (loopPtr.p->is_same_trans(operationRecPtr.p))
2183 loopPtr.i = loopPtr.p->nextParallelQue;
2184 }
while (loopPtr.i != RNIL);
2187 placeSerialQueue(lockOwnerPtr, operationRecPtr);
2189 validate_lock_queue(lockOwnerPtr);
2191 return ZSERIAL_QUEUE;
2194 Uint32 lstate = lastbits & Operationrec::OP_STATE_MASK;
2196 Uint32 retValue = ZSERIAL_QUEUE;
2197 if (lstate == Operationrec::OP_STATE_EXECUTED)
2218 opbits |= Operationrec::OP_STATE_RUNNING;
2219 operationRecPtr.p->localdata[0] = lastOpPtr.p->localdata[0];
2220 operationRecPtr.p->localdata[1] = lastOpPtr.p->localdata[1];
2221 retValue = ZPARALLEL_QUEUE;
2223 opbits |= (lastbits & Operationrec::OP_ACC_LOCK_MODE);
2224 opbits |= Operationrec::OP_RUN_QUEUE;
2225 operationRecPtr.p->m_op_bits = opbits;
2227 operationRecPtr.p->prevParallelQue = lastOpPtr.i;
2228 operationRecPtr.p->m_lock_owner_ptr_i = lockOwnerPtr.i;
2229 lastOpPtr.p->nextParallelQue = operationRecPtr.i;
2230 lockOwnerPtr.p->m_lo_last_parallel_op_ptr_i = operationRecPtr.i;
2232 validate_lock_queue(lockOwnerPtr);
2237 void Dbacc::placeSerialQueue(OperationrecPtr lockOwnerPtr,
2238 OperationrecPtr opPtr)
2240 OperationrecPtr lastOpPtr;
2241 lastOpPtr.i = lockOwnerPtr.p->m_lo_last_serial_op_ptr_i;
2243 if (lastOpPtr.i == RNIL)
2246 ndbrequire(lockOwnerPtr.p->nextSerialQue == RNIL);
2247 lastOpPtr = lockOwnerPtr;
2251 ptrCheckGuard(lastOpPtr, coprecsize, operationrec);
2254 operationRecPtr.p->prevSerialQue = lastOpPtr.i;
2255 lastOpPtr.p->nextSerialQue = opPtr.i;
2256 lockOwnerPtr.p->m_lo_last_serial_op_ptr_i = opPtr.i;
2262 void Dbacc::acckeyref1Lab(
Signal* signal, Uint32 result_code)
2264 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
2268 signal->theData[0] = cminusOne;
2269 signal->theData[1] = result_code;
2282 void Dbacc::execACCMINUPDATE(
Signal* signal)
2284 Page8Ptr ulkPageidptr;
2285 Uint32 tulkLocalPtr;
2286 Uint32 tlocalkey1, tlocalkey2;
2289 operationRecPtr.i = signal->theData[0];
2290 tlocalkey1 = signal->theData[1];
2291 tlocalkey2 = signal->theData[2];
2292 Uint32 localref = Local_key::ref(tlocalkey1, tlocalkey2);
2293 ptrCheckGuard(operationRecPtr, coprecsize, operationrec);
2294 Uint32 opbits = operationRecPtr.p->m_op_bits;
2295 fragrecptr.i = operationRecPtr.p->fragptr;
2296 ulkPageidptr.i = operationRecPtr.p->elementPage;
2297 tulkLocalPtr = operationRecPtr.p->elementPointer +
2298 operationRecPtr.p->elementIsforward;
2300 if ((opbits & Operationrec::OP_STATE_MASK) == Operationrec::OP_STATE_RUNNING)
2302 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
2303 ptrCheckGuard(ulkPageidptr, cpagesize, page8);
2304 dbgWord32(ulkPageidptr, tulkLocalPtr, tlocalkey1);
2305 arrGuard(tulkLocalPtr, 2048);
2306 operationRecPtr.p->localdata[0] = tlocalkey1;
2307 operationRecPtr.p->localdata[1] = tlocalkey2;
2308 if (likely(fragrecptr.p->localkeylen == 1))
2310 ulkPageidptr.p->word32[tulkLocalPtr] = localref;
2313 else if (fragrecptr.p->localkeylen == 2)
2316 ulkPageidptr.p->word32[tulkLocalPtr] = tlocalkey1;
2317 tulkLocalPtr = tulkLocalPtr + operationRecPtr.p->elementIsforward;
2318 dbgWord32(ulkPageidptr, tulkLocalPtr, tlocalkey2);
2319 arrGuard(tulkLocalPtr, 2048);
2320 ulkPageidptr.p->word32[tulkLocalPtr] = tlocalkey2;
2330 Dbacc::removerow(Uint32 opPtrI,
const Local_key* key)
2333 operationRecPtr.i = opPtrI;
2334 ptrCheckGuard(operationRecPtr, coprecsize, operationrec);
2335 Uint32 opbits = operationRecPtr.p->m_op_bits;
2336 fragrecptr.i = operationRecPtr.p->fragptr;
2339 opbits |= Operationrec::OP_ELEMENT_DISAPPEARED;
2340 opbits &= ~Uint32(Operationrec::OP_COMMIT_DELETE_CHECK);
2341 operationRecPtr.p->m_op_bits = opbits;
2344 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
2345 ndbrequire(operationRecPtr.p->localdata[0] == key->m_page_no);
2346 ndbrequire(operationRecPtr.p->localdata[1] == key->m_page_idx);
2355 void Dbacc::execACC_COMMITREQ(
Signal* signal)
2359 Uint32 tmp = operationRecPtr.i = signal->theData[0];
2360 ptrCheckGuard(operationRecPtr, coprecsize, operationrec);
2361 void* ptr = operationRecPtr.p;
2362 Uint32 opbits = operationRecPtr.p->m_op_bits;
2363 fragrecptr.i = operationRecPtr.p->fragptr;
2364 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
2365 Toperation = opbits & Operationrec::OP_MASK;
2366 commitOperation(signal);
2367 ndbassert(operationRecPtr.i == tmp);
2368 ndbassert(operationRecPtr.p == ptr);
2369 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
2370 if((Toperation != ZREAD) &&
2371 (Toperation != ZSCAN_OP))
2373 fragrecptr.p->m_commit_count++;
2374 if (Toperation != ZINSERT) {
2375 if (Toperation != ZDELETE) {
2379 fragrecptr.p->noOfElements--;
2380 fragrecptr.p->slack += fragrecptr.p->elementLength;
2381 if (fragrecptr.p->slack > fragrecptr.p->slackCheck) {
2383 if (fragrecptr.p->expandCounter > 0) {
2384 if (fragrecptr.p->expandFlag < 2) {
2386 signal->theData[0] = fragrecptr.i;
2387 signal->theData[1] = fragrecptr.p->p;
2388 signal->theData[2] = fragrecptr.p->maxp;
2389 signal->theData[3] = fragrecptr.p->expandFlag;
2390 fragrecptr.p->expandFlag = 2;
2391 sendSignal(cownBlockref, GSN_SHRINKCHECK2, signal, 4, JBB);
2398 if (unlikely(opbits & Operationrec::OP_ELEMENT_DISAPPEARED))
2405 ndbrequire((opbits & Operationrec::OP_MASK) == ZINSERT);
2408 fragrecptr.p->noOfElements++;
2409 fragrecptr.p->slack -= fragrecptr.p->elementLength;
2410 if (fragrecptr.p->slack >= (1u << 31)) {
2412 if (fragrecptr.p->expandFlag == 0) {
2414 fragrecptr.p->expandFlag = 2;
2415 signal->theData[0] = fragrecptr.i;
2416 signal->theData[1] = fragrecptr.p->p;
2417 signal->theData[2] = fragrecptr.p->maxp;
2418 sendSignal(cownBlockref, GSN_EXPANDCHECK2, signal, 3, JBB);
2434 void Dbacc::execACC_ABORTREQ(
Signal* signal)
2437 operationRecPtr.i = signal->theData[0];
2438 Uint32 sendConf = signal->theData[1];
2439 ptrCheckGuard(operationRecPtr, coprecsize, operationrec);
2440 fragrecptr.i = operationRecPtr.p->fragptr;
2441 Uint32 opbits = operationRecPtr.p->m_op_bits;
2442 Uint32 opstate = opbits & Operationrec::OP_STATE_MASK;
2445 if (opbits == Operationrec::OP_EXECUTED_DIRTY_READ)
2449 else if (opstate == Operationrec::OP_STATE_EXECUTED ||
2450 opstate == Operationrec::OP_STATE_WAITING ||
2451 opstate == Operationrec::OP_STATE_RUNNING)
2454 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
2455 abortOperation(signal);
2458 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
2460 signal->theData[0] = operationRecPtr.p->userptr;
2461 signal->theData[1] = 0;
2466 if (opstate != Operationrec::OP_STATE_RUNNING)
2471 sendSignal(operationRecPtr.p->userblockref, GSN_ACC_ABORTCONF,
2475 signal->theData[1] = RNIL;
2481 void Dbacc::execACC_LOCKREQ(
Signal* signal)
2487 Uint32 lockOp = (req->requestInfo & 0xFF);
2488 if (lockOp == AccLockReq::LockShared ||
2489 lockOp == AccLockReq::LockExclusive) {
2492 tabptr.i = req->tableId;
2493 ptrCheckGuard(tabptr, ctablesize, tabrec);
2495 if (req->fragPtrI == RNIL) {
2496 for (Uint32
i = 0;
i < MAX_FRAG_PER_NODE;
i++) {
2498 if (tabptr.p->fragholder[
i] == req->fragId){
2500 req->fragPtrI = tabptr.p->fragptrholder[
i];
2505 fragrecptr.i = req->fragPtrI;
2506 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
2507 ndbrequire(req->fragId == fragrecptr.p->myfid);
2509 ndbrequire(req->accOpPtr == RNIL);
2511 if (cfreeopRec != RNIL) {
2515 operationRecPtr.p->userptr = req->userPtr;
2516 operationRecPtr.p->userblockref = req->userRef;
2517 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
2518 operationRecPtr.p->scanRecPtr = RNIL;
2520 Uint32 lockMode = (lockOp == AccLockReq::LockShared) ? 0 : 1;
2521 Uint32 opCode = ZSCAN_OP;
2522 signal->theData[0] = operationRecPtr.i;
2523 signal->theData[1] = fragrecptr.i;
2524 signal->theData[2] = opCode | (lockMode << 4) | (1u << 31);
2525 signal->theData[3] = req->hashValue;
2526 signal->theData[4] = 0;
2527 signal->theData[5] = req->transId1;
2528 signal->theData[6] = req->transId2;
2530 signal->theData[7] = req->page_id;
2531 signal->theData[8] = req->page_idx;
2534 if (signal->theData[0] < RNIL) {
2536 req->returnCode = AccLockReq::Success;
2537 req->accOpPtr = operationRecPtr.i;
2538 }
else if (signal->theData[0] == RNIL) {
2540 req->returnCode = AccLockReq::IsBlocked;
2541 req->accOpPtr = operationRecPtr.i;
2543 ndbrequire(signal->theData[0] == (UintR)-1);
2544 releaseOpRec(signal);
2545 req->returnCode = AccLockReq::Refused;
2546 req->accOpPtr = RNIL;
2550 req->returnCode = AccLockReq::NoFreeOp;
2555 if (lockOp == AccLockReq::Unlock) {
2558 signal->theData[0] = req->accOpPtr;
2560 releaseOpRec(signal);
2561 req->returnCode = AccLockReq::Success;
2565 if (lockOp == AccLockReq::Abort) {
2568 signal->theData[0] = req->accOpPtr;
2569 signal->theData[1] = 0;
2570 execACC_ABORTREQ(signal);
2571 releaseOpRec(signal);
2572 req->returnCode = AccLockReq::Success;
2576 if (lockOp == AccLockReq::AbortWithConf) {
2579 signal->theData[0] = req->accOpPtr;
2580 signal->theData[1] = 1;
2581 execACC_ABORTREQ(signal);
2582 releaseOpRec(signal);
2583 req->returnCode = AccLockReq::Success;
2650 void Dbacc::insertElement(
Signal* signal)
2652 DirRangePtr inrOverflowrangeptr;
2653 DirectoryarrayPtr inrOverflowDirptr;
2654 OverflowRecordPtr inrOverflowRecPtr;
2655 Page8Ptr inrNewPageptr;
2656 Uint32 tinrNextSamePage;
2660 insertContainer(signal);
2661 if (tidrResult != ZFALSE) {
2667 if (((tidrContainerhead >> 7) & 0x3) != 0) {
2668 tinrNextSamePage = (tidrContainerhead >> 9) & 0x1;
2670 tidrPageindex = tidrContainerhead & 0x7f;
2671 if (((tidrContainerhead >> 7) & 3) == ZLEFT) {
2673 tidrForward = ZTRUE;
2674 }
else if (((tidrContainerhead >> 7) & 3) == ZRIGHT) {
2676 tidrForward = cminusOne;
2681 if (tinrNextSamePage == ZFALSE) {
2683 tinrTmp = idrPageptr.p->word32[tidrContainerptr + 1];
2684 inrOverflowrangeptr.i = fragrecptr.p->overflowdir;
2685 ptrCheckGuard(inrOverflowrangeptr, cdirrangesize, dirRange);
2686 arrGuard((tinrTmp >> 8), 256);
2687 inrOverflowDirptr.i = inrOverflowrangeptr.p->dirArray[tinrTmp >> 8];
2688 ptrCheckGuard(inrOverflowDirptr, cdirarraysize, directoryarray);
2689 idrPageptr.i = inrOverflowDirptr.p->pagep[tinrTmp & 0xff];
2690 ptrCheckGuard(idrPageptr, cpagesize, page8);
2692 ndbrequire(tidrPageindex < ZEMPTYLIST);
2697 gflPageptr.p = idrPageptr.p;
2698 getfreelist(signal);
2699 if (tgflPageindex == ZEMPTYLIST) {
2702 if (fragrecptr.p->firstOverflowRec == RNIL) {
2704 allocOverflowPage(signal);
2705 ndbrequire(tresult <= ZLIMIT_OF_ERROR);
2707 inrOverflowRecPtr.i = fragrecptr.p->firstOverflowRec;
2708 ptrCheckGuard(inrOverflowRecPtr, coverflowrecsize, overflowRecord);
2709 inrNewPageptr.i = inrOverflowRecPtr.p->overpage;
2710 ptrCheckGuard(inrNewPageptr, cpagesize, page8);
2711 gflPageptr.p = inrNewPageptr.p;
2712 getfreelist(signal);
2713 ndbrequire(tgflPageindex != ZEMPTYLIST);
2717 inrNewPageptr = idrPageptr;
2720 tslUpdateHeader = ZTRUE;
2721 tslPageindex = tgflPageindex;
2722 slPageptr.p = inrNewPageptr.p;
2723 if (tgflBufType == ZLEFT) {
2724 seizeLeftlist(signal);
2725 tidrForward = ZTRUE;
2727 seizeRightlist(signal);
2728 tidrForward = cminusOne;
2730 tancPageindex = tgflPageindex;
2731 tancPageid = inrNewPageptr.p->word32[ZPOS_PAGE_ID];
2732 tancBufType = tgflBufType;
2733 tancContainerptr = tidrContainerptr;
2734 ancPageptr.p = idrPageptr.p;
2735 addnewcontainer(signal);
2737 idrPageptr = inrNewPageptr;
2738 tidrPageindex = tgflPageindex;
2739 insertContainer(signal);
2740 ndbrequire(tidrResult == ZTRUE);
2769 void Dbacc::insertContainer(
Signal* signal)
2771 Uint32 tidrContainerlen;
2772 Uint32 tidrConfreelen;
2773 Uint32 tidrNextSide;
2774 Uint32 tidrNextConLen;
2776 Uint32 tidrInputIndex;
2780 tidrResult = ZFALSE;
2781 tidrContainerptr = (tidrPageindex << ZSHIFT_PLUS) - (tidrPageindex << ZSHIFT_MINUS);
2782 tidrContainerptr = tidrContainerptr + ZHEAD_SIZE;
2787 if (tidrForward == ZTRUE) {
2789 tidrNextSide = tidrContainerptr + (ZBUF_SIZE - ZCON_HEAD_SIZE);
2790 arrGuard(tidrNextSide + 1, 2048);
2791 tidrContainerhead = idrPageptr.p->word32[tidrContainerptr];
2792 tidrContainerlen = tidrContainerhead >> 26;
2793 tidrIndex = tidrContainerptr + tidrContainerlen;
2796 tidrNextSide = tidrContainerptr;
2797 tidrContainerptr = tidrContainerptr + (ZBUF_SIZE - ZCON_HEAD_SIZE);
2798 arrGuard(tidrContainerptr + 1, 2048);
2799 tidrContainerhead = idrPageptr.p->word32[tidrContainerptr];
2800 tidrContainerlen = tidrContainerhead >> 26;
2801 tidrIndex = (tidrContainerptr - tidrContainerlen) + (ZCON_HEAD_SIZE - 1);
2803 if (tidrContainerlen > (ZBUF_SIZE - 3)) {
2806 tidrConfreelen = ZBUF_SIZE - tidrContainerlen;
2811 if (((tidrContainerhead >> 10) & 1) == 0) {
2817 tidrNextConLen = idrPageptr.p->word32[tidrNextSide] >> 26;
2818 tidrConfreelen = tidrConfreelen - tidrNextConLen;
2819 if (tidrConfreelen > ZBUF_SIZE) {
2830 if (tidrConfreelen < fragrecptr.p->elementLength) {
2838 tidrContainerlen = tidrContainerlen + fragrecptr.p->elementLength;
2839 if (tidrNextConLen == 0) {
2842 if (tidrContainerlen > ZUP_LIMIT) {
2843 dbgWord32(idrPageptr, tidrContainerptr, idrPageptr.p->word32[tidrContainerptr] | (1 << 10));
2844 idrPageptr.p->word32[tidrContainerptr] = idrPageptr.p->word32[tidrContainerptr] | (1 << 10);
2845 tslUpdateHeader = ZFALSE;
2846 tslPageindex = tidrPageindex;
2847 slPageptr.p = idrPageptr.p;
2848 if (tidrForward == ZTRUE) {
2850 seizeRightlist(signal);
2854 seizeLeftlist(signal);
2868 if (idrOperationRecPtr.i != RNIL) {
2870 idrOperationRecPtr.p->elementIsforward = tidrForward;
2871 idrOperationRecPtr.p->elementPage = idrPageptr.i;
2872 idrOperationRecPtr.p->elementContainer = tidrContainerptr;
2873 idrOperationRecPtr.p->elementPointer = tidrIndex;
2883 dbgWord32(idrPageptr, tidrIndex, tidrElemhead);
2884 idrPageptr.p->word32[tidrIndex] = tidrElemhead;
2885 tidrIndex += tidrForward;
2886 guard26 = fragrecptr.p->localkeylen - 1;
2887 arrGuard(guard26, 2);
2888 for (tidrInputIndex = 0; tidrInputIndex <= guard26; tidrInputIndex++) {
2889 dbgWord32(idrPageptr, tidrIndex, clocalkey[tidrInputIndex]);
2890 arrGuard(tidrIndex, 2048);
2891 idrPageptr.p->word32[tidrIndex] = clocalkey[tidrInputIndex];
2892 tidrIndex += tidrForward;
2894 tidrContLen = idrPageptr.p->word32[tidrContainerptr] << 6;
2895 tidrContLen = tidrContLen >> 6;
2896 dbgWord32(idrPageptr, tidrContainerptr, (tidrContainerlen << 26) | tidrContLen);
2897 idrPageptr.p->word32[tidrContainerptr] = (tidrContainerlen << 26) | tidrContLen;
2914 void Dbacc::addnewcontainer(
Signal* signal)
2926 tancTmp1 = ancPageptr.p->word32[tancContainerptr] >> 10;
2927 tancTmp1 = tancTmp1 << 1;
2928 tancTmp1 = tancTmp1 | tancNext;
2929 tancTmp1 = tancTmp1 << 2;
2930 tancTmp1 = tancTmp1 | tancBufType;
2931 tancTmp1 = tancTmp1 << 7;
2932 tancTmp1 = tancTmp1 | tancPageindex;
2933 dbgWord32(ancPageptr, tancContainerptr, tancTmp1);
2934 ancPageptr.p->word32[tancContainerptr] = tancTmp1;
2935 dbgWord32(ancPageptr, tancContainerptr + 1, tancPageid);
2936 ancPageptr.p->word32[tancContainerptr + 1] = tancPageid;
2951 void Dbacc::getfreelist(
Signal* signal)
2955 tgflTmp = gflPageptr.p->word32[ZPOS_EMPTY_LIST];
2956 tgflPageindex = (tgflTmp >> 7) & 0x7f;
2957 tgflBufType = ZLEFT;
2958 if (tgflPageindex == ZEMPTYLIST) {
2960 tgflPageindex = tgflTmp & 0x7f;
2961 tgflBufType = ZRIGHT;
2963 ndbrequire(tgflPageindex <= ZEMPTYLIST);
2975 void Dbacc::increaselistcont(
Signal* signal)
2977 OverflowRecordPtr ilcOverflowRecPtr;
2979 dbgWord32(ilcPageptr, ZPOS_ALLOC_CONTAINERS, ilcPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] + 1);
2980 ilcPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] = ilcPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] + 1;
2981 if (ilcPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] > ZFREE_LIMIT) {
2982 if (ilcPageptr.p->word32[ZPOS_OVERFLOWREC] != RNIL) {
2984 ilcOverflowRecPtr.i = ilcPageptr.p->word32[ZPOS_OVERFLOWREC];
2985 dbgWord32(ilcPageptr, ZPOS_OVERFLOWREC, RNIL);
2986 ilcPageptr.p->word32[ZPOS_OVERFLOWREC] = RNIL;
2987 ptrCheckGuard(ilcOverflowRecPtr, coverflowrecsize, overflowRecord);
2988 tfoOverflowRecPtr = ilcOverflowRecPtr;
2989 takeRecOutOfFreeOverpage(signal);
2990 rorOverflowRecPtr = ilcOverflowRecPtr;
2991 releaseOverflowRec(signal);
3010 void Dbacc::seizeLeftlist(
Signal* signal)
3014 Uint32 tsllHeadIndex;
3017 tsllHeadIndex = ((tslPageindex << ZSHIFT_PLUS) - (tslPageindex << ZSHIFT_MINUS)) + ZHEAD_SIZE;
3018 arrGuard(tsllHeadIndex + 1, 2048);
3019 tslNextfree = slPageptr.p->word32[tsllHeadIndex];
3020 tslPrevfree = slPageptr.p->word32[tsllHeadIndex + 1];
3021 if (tslPrevfree == ZEMPTYLIST) {
3024 tsllTmp1 = slPageptr.p->word32[ZPOS_EMPTY_LIST];
3025 tsllTmp = tsllTmp1 & 0x7f;
3026 tsllTmp1 = (tsllTmp1 >> 14) << 14;
3027 tsllTmp1 = (tsllTmp1 | (tslNextfree << 7)) | tsllTmp;
3028 dbgWord32(slPageptr, ZPOS_EMPTY_LIST, tsllTmp1);
3029 slPageptr.p->word32[ZPOS_EMPTY_LIST] = tsllTmp1;
3031 ndbrequire(tslPrevfree < ZEMPTYLIST);
3033 tsllTmp = ((tslPrevfree << ZSHIFT_PLUS) - (tslPrevfree << ZSHIFT_MINUS)) + ZHEAD_SIZE;
3034 dbgWord32(slPageptr, tsllTmp, tslNextfree);
3035 slPageptr.p->word32[tsllTmp] = tslNextfree;
3037 if (tslNextfree < ZEMPTYLIST) {
3039 tsllTmp = (((tslNextfree << ZSHIFT_PLUS) - (tslNextfree << ZSHIFT_MINUS)) + ZHEAD_SIZE) + 1;
3040 dbgWord32(slPageptr, tsllTmp, tslPrevfree);
3041 slPageptr.p->word32[tsllTmp] = tslPrevfree;
3043 ndbrequire(tslNextfree == ZEMPTYLIST);
3059 if (tslUpdateHeader == ZTRUE) {
3061 tslNextfree = (slPageptr.p->word32[ZPOS_EMPTY_LIST] >> 23) & 0x7f;
3062 tsllNewHead = ZCON_HEAD_SIZE;
3063 tsllNewHead = ((tsllNewHead << 8) + ZEMPTYLIST) + (1 << 7);
3064 tsllNewHead = (tsllNewHead << 7) + tslNextfree;
3065 tsllNewHead = tsllNewHead << 11;
3066 dbgWord32(slPageptr, tsllHeadIndex, tsllNewHead);
3067 slPageptr.p->word32[tsllHeadIndex] = tsllNewHead;
3068 tsllTmp = slPageptr.p->word32[ZPOS_EMPTY_LIST] & 0xc07fffff;
3069 tsllTmp = tsllTmp | (tslPageindex << 23);
3070 dbgWord32(slPageptr, ZPOS_EMPTY_LIST, tsllTmp);
3071 slPageptr.p->word32[ZPOS_EMPTY_LIST] = tsllTmp;
3072 if (tslNextfree < ZEMPTYLIST) {
3074 tsllTmp = ((tslNextfree << ZSHIFT_PLUS) - (tslNextfree << ZSHIFT_MINUS)) + ZHEAD_SIZE;
3075 tsllTmp1 = slPageptr.p->word32[tsllTmp] & 0xfe03ffff;
3076 tsllTmp1 = tsllTmp1 | (tslPageindex << 18);
3077 dbgWord32(slPageptr, tsllTmp, tsllTmp1);
3078 slPageptr.p->word32[tsllTmp] = tsllTmp1;
3080 ndbrequire(tslNextfree == ZEMPTYLIST);
3084 ilcPageptr.p = slPageptr.p;
3085 increaselistcont(signal);
3095 void Dbacc::seizeRightlist(
Signal* signal)
3099 Uint32 tsrlHeadIndex;
3102 tsrlHeadIndex = ((tslPageindex << ZSHIFT_PLUS) - (tslPageindex << ZSHIFT_MINUS)) + ((ZHEAD_SIZE + ZBUF_SIZE) - ZCON_HEAD_SIZE);
3103 arrGuard(tsrlHeadIndex + 1, 2048);
3104 tslNextfree = slPageptr.p->word32[tsrlHeadIndex];
3105 tslPrevfree = slPageptr.p->word32[tsrlHeadIndex + 1];
3106 if (tslPrevfree == ZEMPTYLIST) {
3108 tsrlTmp = slPageptr.p->word32[ZPOS_EMPTY_LIST];
3109 dbgWord32(slPageptr, ZPOS_EMPTY_LIST, ((tsrlTmp >> 7) << 7) | tslNextfree);
3110 slPageptr.p->word32[ZPOS_EMPTY_LIST] = ((tsrlTmp >> 7) << 7) | tslNextfree;
3112 ndbrequire(tslPrevfree < ZEMPTYLIST);
3114 tsrlTmp = ((tslPrevfree << ZSHIFT_PLUS) - (tslPrevfree << ZSHIFT_MINUS)) + ((ZHEAD_SIZE + ZBUF_SIZE) - ZCON_HEAD_SIZE);
3115 dbgWord32(slPageptr, tsrlTmp, tslNextfree);
3116 slPageptr.p->word32[tsrlTmp] = tslNextfree;
3118 if (tslNextfree < ZEMPTYLIST) {
3120 tsrlTmp = ((tslNextfree << ZSHIFT_PLUS) - (tslNextfree << ZSHIFT_MINUS)) + ((ZHEAD_SIZE + ZBUF_SIZE) - (ZCON_HEAD_SIZE - 1));
3121 dbgWord32(slPageptr, tsrlTmp, tslPrevfree);
3122 slPageptr.p->word32[tsrlTmp] = tslPrevfree;
3124 ndbrequire(tslNextfree == ZEMPTYLIST);
3139 if (tslUpdateHeader == ZTRUE) {
3141 tslNextfree = (slPageptr.p->word32[ZPOS_EMPTY_LIST] >> 16) & 0x7f;
3142 tsrlNewHead = ZCON_HEAD_SIZE;
3143 tsrlNewHead = ((tsrlNewHead << 8) + ZEMPTYLIST) + (1 << 7);
3144 tsrlNewHead = (tsrlNewHead << 7) + tslNextfree;
3145 tsrlNewHead = tsrlNewHead << 11;
3146 dbgWord32(slPageptr, tsrlHeadIndex, tsrlNewHead);
3147 slPageptr.p->word32[tsrlHeadIndex] = tsrlNewHead;
3148 tsrlTmp = slPageptr.p->word32[ZPOS_EMPTY_LIST] & 0xff80ffff;
3149 dbgWord32(slPageptr, ZPOS_EMPTY_LIST, tsrlTmp | (tslPageindex << 16));
3150 slPageptr.p->word32[ZPOS_EMPTY_LIST] = tsrlTmp | (tslPageindex << 16);
3151 if (tslNextfree < ZEMPTYLIST) {
3153 tsrlTmp = ((tslNextfree << ZSHIFT_PLUS) - (tslNextfree << ZSHIFT_MINUS)) + ((ZHEAD_SIZE + ZBUF_SIZE) - ZCON_HEAD_SIZE);
3154 tsrlTmp1 = slPageptr.p->word32[tsrlTmp] & 0xfe03ffff;
3155 dbgWord32(slPageptr, tsrlTmp, tsrlTmp1 | (tslPageindex << 18));
3156 slPageptr.p->word32[tsrlTmp] = tsrlTmp1 | (tslPageindex << 18);
3158 ndbrequire(tslNextfree == ZEMPTYLIST);
3162 ilcPageptr.p = slPageptr.p;
3163 increaselistcont(signal);
3213 void Dbacc::getdirindex(
Signal* signal)
3215 DirRangePtr gdiDirRangePtr;
3216 DirectoryarrayPtr gdiDirptr;
3220 tgdiTmp = fragrecptr.p->k + fragrecptr.p->lhfragbits;
3221 tgdiPageindex = operationRecPtr.p->hashValue & ((1 << fragrecptr.p->k) - 1);
3222 tgdiTmp = operationRecPtr.p->hashValue >> tgdiTmp;
3223 tgdiTmp = (tgdiTmp << fragrecptr.p->k) | tgdiPageindex;
3224 tgdiAddress = tgdiTmp & fragrecptr.p->maxp;
3225 gdiDirRangePtr.i = fragrecptr.p->directory;
3226 ptrCheckGuard(gdiDirRangePtr, cdirrangesize, dirRange);
3227 if (tgdiAddress < fragrecptr.p->p) {
3229 tgdiAddress = tgdiTmp & ((fragrecptr.p->maxp << 1) | 1);
3231 tgdiTmp = tgdiAddress >> fragrecptr.p->k;
3232 arrGuard((tgdiTmp >> 8), 256);
3233 gdiDirptr.i = gdiDirRangePtr.p->dirArray[tgdiTmp >> 8];
3234 ptrCheckGuard(gdiDirptr, cdirarraysize, directoryarray);
3235 gdiPageptr.i = gdiDirptr.p->pagep[tgdiTmp & 0xff];
3236 ptrCheckGuard(gdiPageptr, cpagesize, page8);
3240 Dbacc::readTablePk(Uint32 localkey1, Uint32 localkey2,
3244 Uint32 tableId = fragrecptr.p->myTableId;
3245 Uint32 fragId = fragrecptr.p->myfid;
3246 bool xfrm = fragrecptr.p->hasCharAttr;
3249 memset(ckeys, 0x1f, (fragrecptr.p->keyLength * MAX_XFRM_MULTIPLY) << 2);
3252 if (likely(! Local_key::isInvalid(localkey1, localkey2)))
3254 ret = c_tup->accReadPk(tableId, fragId, localkey1, localkey2,
3259 ndbrequire(ElementHeader::getLocked(eh));
3260 if (unlikely((opPtr.p->m_op_bits & Operationrec::OP_MASK) == ZSCAN_OP))
3262 dump_lock_queue(opPtr);
3263 ndbrequire(opPtr.p->nextParallelQue == RNIL);
3264 ndbrequire(opPtr.p->m_op_bits & Operationrec::OP_ELEMENT_DISAPPEARED);
3265 ndbrequire(opPtr.p->m_op_bits & Operationrec::OP_COMMIT_DELETE_CHECK);
3266 ndbrequire((opPtr.p->m_op_bits & Operationrec::OP_STATE_MASK) == Operationrec::OP_STATE_RUNNING);
3269 ret = c_lqh->readPrimaryKeys(opPtr.p->userptr, ckeys, xfrm);
3272 ndbrequire(ret >= 0);
3295 #if __INTEL_COMPILER == 810
3296 int ndb_acc_ia64_icc810_dummy_var = 0;
3297 void ndb_acc_ia64_icc810_dummy_func()
3299 ndb_acc_ia64_icc810_dummy_var++;
3305 Dbacc::getElement(
Signal* signal, OperationrecPtr& lockOwnerPtr)
3308 DirRangePtr geOverflowrangeptr;
3309 DirectoryarrayPtr geOverflowDirptr;
3310 Uint32 tgeElementHeader;
3312 Uint32 tgeContainerhead;
3313 Uint32 tgePageindex;
3314 Uint32 tgeActivePageDir;
3315 Uint32 tgeNextptrtype;
3316 register Uint32 tgeKeyptr;
3317 register Uint32 tgeRemLen;
3318 register Uint32 TelemLen = fragrecptr.p->elementLength;
3319 register Uint32* Tkeydata = (Uint32*)&signal->theData[7];
3320 const Uint32 localkeylen = fragrecptr.p->localkeylen;
3322 getdirindex(signal);
3323 tgePageindex = tgdiPageindex;
3324 gePageptr = gdiPageptr;
3330 const bool searchLocalKey = operationRecPtr.p->tupkeylen == 0;
3332 ndbrequire(TelemLen == ZELEM_HEAD_SIZE + localkeylen);
3333 tgeNextptrtype = ZLEFT;
3335 const Uint32 tmp = fragrecptr.p->k + fragrecptr.p->lhfragbits;
3336 const Uint32 opHashValuePart = (operationRecPtr.p->hashValue >> tmp) &0xFFFF;
3338 tgeContainerptr = (tgePageindex << ZSHIFT_PLUS) - (tgePageindex << ZSHIFT_MINUS);
3339 if (tgeNextptrtype == ZLEFT) {
3341 tgeContainerptr = tgeContainerptr + ZHEAD_SIZE;
3342 tgeElementptr = tgeContainerptr + ZCON_HEAD_SIZE;
3343 tgeKeyptr = (tgeElementptr + ZELEM_HEAD_SIZE) + localkeylen;
3344 tgeElemStep = TelemLen;
3346 if (unlikely(tgeContainerptr >= 2048))
3351 tgeRemLen = gePageptr.p->word32[tgeContainerptr] >> 26;
3352 if (unlikely(((tgeContainerptr + tgeRemLen - 1) >= 2048)))
3357 }
else if (tgeNextptrtype == ZRIGHT) {
3359 tgeContainerptr = tgeContainerptr + ((ZHEAD_SIZE + ZBUF_SIZE) - ZCON_HEAD_SIZE);
3360 tgeElementptr = tgeContainerptr - 1;
3361 tgeKeyptr = (tgeElementptr - ZELEM_HEAD_SIZE) - localkeylen;
3362 tgeElemStep = 0 - TelemLen;
3363 tgeForward = (Uint32)-1;
3364 if (unlikely(tgeContainerptr >= 2048))
3369 tgeRemLen = gePageptr.p->word32[tgeContainerptr] >> 26;
3370 if (unlikely((tgeContainerptr - tgeRemLen) >= 2048))
3379 if (tgeRemLen >= ZCON_HEAD_SIZE + TelemLen) {
3380 if (unlikely(tgeRemLen > ZBUF_SIZE))
3390 tgeElementHeader = gePageptr.p->word32[tgeElementptr];
3391 tgeRemLen = tgeRemLen - TelemLen;
3392 Uint32 hashValuePart;
3393 Uint32 localkey1, localkey2;
3394 lockOwnerPtr.i = RNIL;
3395 lockOwnerPtr.p = NULL;
3396 if (ElementHeader::getLocked(tgeElementHeader)) {
3398 lockOwnerPtr.i = ElementHeader::getOpPtrI(tgeElementHeader);
3399 ptrCheckGuard(lockOwnerPtr, coprecsize, operationrec);
3400 hashValuePart = lockOwnerPtr.p->hashvaluePart;
3401 localkey1 = lockOwnerPtr.p->localdata[0];
3402 localkey2 = lockOwnerPtr.p->localdata[1];
3405 Uint32 pos = tgeElementptr + tgeForward;
3406 hashValuePart = ElementHeader::getHashValuePart(tgeElementHeader);
3407 localkey1 = gePageptr.p->word32[pos];
3408 if (likely(localkeylen == 1))
3410 localkey2 = Local_key::ref2page_idx(localkey1);
3411 localkey1 = Local_key::ref2page_id(localkey1);
3415 localkey2 = gePageptr.p->word32[pos + tgeForward];
3418 if (hashValuePart == opHashValuePart) {
3421 if (! searchLocalKey)
3423 Uint32 len = readTablePk(localkey1, localkey2, tgeElementHeader,
3425 found = (len == operationRecPtr.p->xfrmtupkeylen) &&
3426 (memcmp(Tkeydata, ckeys, len << 2) == 0);
3429 found = (localkey1 == Tkeydata[0] && localkey2 == Tkeydata[1]);
3434 operationRecPtr.p->localdata[0] = localkey1;
3435 operationRecPtr.p->localdata[1] = localkey2;
3439 if (tgeRemLen <= ZCON_HEAD_SIZE) {
3442 tgeElementptr = tgeElementptr + tgeElemStep;
3445 if (unlikely(tgeRemLen != ZCON_HEAD_SIZE))
3450 tgeContainerhead = gePageptr.p->word32[tgeContainerptr];
3451 tgeNextptrtype = (tgeContainerhead >> 7) & 0x3;
3452 if (tgeNextptrtype == 0) {
3456 tgePageindex = tgeContainerhead & 0x7f;
3457 if (unlikely(tgePageindex > ZEMPTYLIST))
3462 if (((tgeContainerhead >> 9) & 1) == ZFALSE) {
3464 tgeActivePageDir = gePageptr.p->word32[tgeContainerptr + 1];
3465 geOverflowrangeptr.i = fragrecptr.p->overflowdir;
3466 ptrCheckGuard(geOverflowrangeptr, cdirrangesize, dirRange);
3467 arrGuard((tgeActivePageDir >> 8), 256);
3468 geOverflowDirptr.i = geOverflowrangeptr.p->dirArray[tgeActivePageDir >> 8];
3469 ptrCheckGuard(geOverflowDirptr, cdirarraysize, directoryarray);
3470 gePageptr.i = geOverflowDirptr.p->pagep[tgeActivePageDir & 0xff];
3471 ptrCheckGuard(gePageptr, cpagesize, page8);
3478 ACCKEY_error(errcode);
3512 Dbacc::report_dealloc(
Signal* signal,
const Operationrec* opPtrP)
3514 Uint32 localKey1 = opPtrP->localdata[0];
3515 Uint32 localKey2 = opPtrP->localdata[1];
3516 Uint32 opbits = opPtrP->m_op_bits;
3517 Uint32 userptr= opPtrP->userptr;
3519 ((opbits & Operationrec::OP_MASK) == ZSCAN_OP) ||
3520 (opbits & Operationrec::OP_LOCK_REQ);
3522 if (! Local_key::isInvalid(localKey1, localKey2))
3524 signal->theData[0] = fragrecptr.p->myfid;
3525 signal->theData[1] = fragrecptr.p->myTableId;
3526 signal->theData[2] = localKey1;
3527 signal->theData[3] = localKey2;
3528 signal->theData[4] = userptr;
3529 signal->theData[5] = scanInd;
3535 void Dbacc::commitdelete(
Signal* signal)
3538 report_dealloc(signal, operationRecPtr.p);
3540 getdirindex(signal);
3541 tlastPageindex = tgdiPageindex;
3542 lastPageptr.i = gdiPageptr.i;
3543 lastPageptr.p = gdiPageptr.p;
3544 tlastForward = ZTRUE;
3545 tlastContainerptr = (tlastPageindex << ZSHIFT_PLUS) - (tlastPageindex << ZSHIFT_MINUS);
3546 tlastContainerptr = tlastContainerptr + ZHEAD_SIZE;
3547 arrGuard(tlastContainerptr, 2048);
3548 tlastContainerhead = lastPageptr.p->word32[tlastContainerptr];
3549 tlastContainerlen = tlastContainerhead >> 26;
3550 lastPrevpageptr.i = RNIL;
3551 ptrNull(lastPrevpageptr);
3552 tlastPrevconptr = 0;
3553 getLastAndRemove(signal);
3555 delPageptr.i = operationRecPtr.p->elementPage;
3556 ptrCheckGuard(delPageptr, cpagesize, page8);
3557 tdelElementptr = operationRecPtr.p->elementPointer;
3564 const Uint32 hv = operationRecPtr.p->hashvaluePart;
3565 const Uint32 eh = ElementHeader::setUnlocked(hv, 0);
3566 delPageptr.p->word32[tdelElementptr] = eh;
3567 if (operationRecPtr.p->elementPage == lastPageptr.i) {
3568 if (operationRecPtr.p->elementPointer == tlastElementptr) {
3580 tdelContainerptr = operationRecPtr.p->elementContainer;
3581 tdelForward = operationRecPtr.p->elementIsforward;
3582 deleteElement(signal);
3598 void Dbacc::deleteElement(
Signal* signal)
3600 OperationrecPtr deOperationRecPtr;
3602 Uint32 tlastMoveElemptr;
3603 Uint32 tdelMoveElemptr;
3606 if (tlastElementptr >= 2048)
3607 goto deleteElement_index_error1;
3609 const Uint32 tdeElemhead = lastPageptr.p->word32[tlastElementptr];
3610 tlastMoveElemptr = tlastElementptr;
3611 tdelMoveElemptr = tdelElementptr;
3612 guard31 = fragrecptr.p->elementLength - 1;
3613 for (tdeIndex = 0; tdeIndex <= guard31; tdeIndex++) {
3614 dbgWord32(delPageptr, tdelMoveElemptr, lastPageptr.p->word32[tlastMoveElemptr]);
3615 if ((tlastMoveElemptr >= 2048) ||
3616 (tdelMoveElemptr >= 2048))
3617 goto deleteElement_index_error2;
3618 delPageptr.p->word32[tdelMoveElemptr] = lastPageptr.p->word32[tlastMoveElemptr];
3619 tdelMoveElemptr = tdelMoveElemptr + tdelForward;
3620 tlastMoveElemptr = tlastMoveElemptr + tlastForward;
3622 if (ElementHeader::getLocked(tdeElemhead)) {
3627 deOperationRecPtr.i = ElementHeader::getOpPtrI(tdeElemhead);
3628 ptrCheckGuard(deOperationRecPtr, coprecsize, operationrec);
3629 deOperationRecPtr.p->elementPage = delPageptr.i;
3630 deOperationRecPtr.p->elementContainer = tdelContainerptr;
3631 deOperationRecPtr.p->elementPointer = tdelElementptr;
3632 deOperationRecPtr.p->elementIsforward = tdelForward;
3638 Uint32 eh = ElementHeader::setUnlocked(deOperationRecPtr.p->hashvaluePart,
3640 lastPageptr.p->word32[tlastElementptr] = eh;
3645 deleteElement_index_error1:
3646 arrGuard(tlastElementptr, 2048);
3649 deleteElement_index_error2:
3650 arrGuard(tdelMoveElemptr + guard31, 2048);
3651 arrGuard(tlastMoveElemptr, 2048);
3673 void Dbacc::getLastAndRemove(
Signal* signal)
3675 DirRangePtr glrOverflowrangeptr;
3676 DirectoryarrayPtr glrOverflowDirptr;
3681 if (((tlastContainerhead >> 7) & 0x3) != 0) {
3683 lastPrevpageptr.i = lastPageptr.i;
3684 lastPrevpageptr.p = lastPageptr.p;
3685 tlastPrevconptr = tlastContainerptr;
3686 tlastPageindex = tlastContainerhead & 0x7f;
3687 if (((tlastContainerhead >> 9) & 0x1) == ZFALSE) {
3689 arrGuard(tlastContainerptr + 1, 2048);
3690 tglrTmp = lastPageptr.p->word32[tlastContainerptr + 1];
3691 glrOverflowrangeptr.i = fragrecptr.p->overflowdir;
3692 ptrCheckGuard(glrOverflowrangeptr, cdirrangesize, dirRange);
3693 arrGuard((tglrTmp >> 8), 256);
3694 glrOverflowDirptr.i = glrOverflowrangeptr.p->dirArray[tglrTmp >> 8];
3695 ptrCheckGuard(glrOverflowDirptr, cdirarraysize, directoryarray);
3696 lastPageptr.i = glrOverflowDirptr.p->pagep[tglrTmp & 0xff];
3697 ptrCheckGuard(lastPageptr, cpagesize, page8);
3699 tlastContainerptr = (tlastPageindex << ZSHIFT_PLUS) - (tlastPageindex << ZSHIFT_MINUS);
3700 if (((tlastContainerhead >> 7) & 3) == ZLEFT) {
3702 tlastForward = ZTRUE;
3703 tlastContainerptr = tlastContainerptr + ZHEAD_SIZE;
3704 }
else if (((tlastContainerhead >> 7) & 3) == ZRIGHT) {
3706 tlastForward = cminusOne;
3707 tlastContainerptr = ((tlastContainerptr + ZHEAD_SIZE) + ZBUF_SIZE) - ZCON_HEAD_SIZE;
3712 arrGuard(tlastContainerptr, 2048);
3713 tlastContainerhead = lastPageptr.p->word32[tlastContainerptr];
3714 tlastContainerlen = tlastContainerhead >> 26;
3715 ndbrequire(tlastContainerlen >= ((Uint32)ZCON_HEAD_SIZE + fragrecptr.p->elementLength));
3718 tlastContainerlen = tlastContainerlen - fragrecptr.p->elementLength;
3719 if (tlastForward == ZTRUE) {
3721 tlastElementptr = tlastContainerptr + tlastContainerlen;
3724 tlastElementptr = (tlastContainerptr + (ZCON_HEAD_SIZE - 1)) - tlastContainerlen;
3726 rlPageptr.i = lastPageptr.i;
3727 rlPageptr.p = lastPageptr.p;
3728 trlPageindex = tlastPageindex;
3729 if (((tlastContainerhead >> 10) & 1) == 1) {
3733 if (tlastContainerlen < ZDOWN_LIMIT) {
3738 tlastContainerhead = tlastContainerhead ^ (1 << 10);
3740 if (tlastForward == ZTRUE) {
3742 turlIndex = tlastContainerptr + (ZBUF_SIZE - ZCON_HEAD_SIZE);
3743 releaseRightlist(signal);
3746 tullIndex = tlastContainerptr - (ZBUF_SIZE - ZCON_HEAD_SIZE);
3747 releaseLeftlist(signal);
3751 if (tlastContainerlen <= 2) {
3752 ndbrequire(tlastContainerlen == 2);
3753 if (lastPrevpageptr.i != RNIL) {
3760 ndbrequire(tlastPrevconptr < 2048);
3761 tglrTmp = lastPrevpageptr.p->word32[tlastPrevconptr] >> 9;
3762 dbgWord32(lastPrevpageptr, tlastPrevconptr, tglrTmp << 9);
3763 lastPrevpageptr.p->word32[tlastPrevconptr] = tglrTmp << 9;
3765 if (tlastForward == ZTRUE) {
3767 tullIndex = tlastContainerptr;
3768 releaseLeftlist(signal);
3771 turlIndex = tlastContainerptr;
3772 releaseRightlist(signal);
3777 tglrHead = tlastContainerhead << 6;
3778 tglrHead = tglrHead >> 6;
3779 tglrHead = tglrHead | (tlastContainerlen << 26);
3780 dbgWord32(lastPageptr, tlastContainerptr, tglrHead);
3781 arrGuard(tlastContainerptr, 2048);
3782 lastPageptr.p->word32[tlastContainerptr] = tglrHead;
3800 void Dbacc::releaseLeftlist(
Signal* signal)
3810 if (trlRelCon == ZTRUE) {
3811 arrGuard(tullIndex, 2048);
3812 trlHead = rlPageptr.p->word32[tullIndex];
3813 trlNextused = (trlHead >> 11) & 0x7f;
3814 trlPrevused = (trlHead >> 18) & 0x7f;
3815 if (trlNextused < ZEMPTYLIST) {
3817 tullTmp1 = (trlNextused << ZSHIFT_PLUS) - (trlNextused << ZSHIFT_MINUS);
3818 tullTmp1 = tullTmp1 + ZHEAD_SIZE;
3819 tullTmp = rlPageptr.p->word32[tullTmp1] & 0xfe03ffff;
3820 dbgWord32(rlPageptr, tullTmp1, tullTmp | (trlPrevused << 18));
3821 rlPageptr.p->word32[tullTmp1] = tullTmp | (trlPrevused << 18);
3823 ndbrequire(trlNextused == ZEMPTYLIST);
3826 if (trlPrevused < ZEMPTYLIST) {
3828 tullTmp1 = (trlPrevused << ZSHIFT_PLUS) - (trlPrevused << ZSHIFT_MINUS);
3829 tullTmp1 = tullTmp1 + ZHEAD_SIZE;
3830 tullTmp = rlPageptr.p->word32[tullTmp1] & 0xfffc07ff;
3831 dbgWord32(rlPageptr, tullTmp1, tullTmp | (trlNextused << 11));
3832 rlPageptr.p->word32[tullTmp1] = tullTmp | (trlNextused << 11);
3834 ndbrequire(trlPrevused == ZEMPTYLIST);
3839 tullTmp = rlPageptr.p->word32[ZPOS_EMPTY_LIST] & 0xc07fffff;
3840 dbgWord32(rlPageptr, ZPOS_EMPTY_LIST, tullTmp | (trlNextused << 23));
3841 rlPageptr.p->word32[ZPOS_EMPTY_LIST] = tullTmp | (trlNextused << 23);
3844 dbgWord32(rlPageptr, tullIndex + 1, ZEMPTYLIST);
3845 arrGuard(tullIndex + 1, 2048);
3846 rlPageptr.p->word32[tullIndex + 1] = ZEMPTYLIST;
3847 tullTmp1 = (rlPageptr.p->word32[ZPOS_EMPTY_LIST] >> 7) & 0x7f;
3848 dbgWord32(rlPageptr, tullIndex, tullTmp1);
3849 arrGuard(tullIndex, 2048);
3850 rlPageptr.p->word32[tullIndex] = tullTmp1;
3851 if (tullTmp1 < ZEMPTYLIST) {
3853 tullTmp1 = (tullTmp1 << ZSHIFT_PLUS) - (tullTmp1 << ZSHIFT_MINUS);
3854 tullTmp1 = (tullTmp1 + ZHEAD_SIZE) + 1;
3855 dbgWord32(rlPageptr, tullTmp1, trlPageindex);
3856 rlPageptr.p->word32[tullTmp1] = trlPageindex;
3858 ndbrequire(tullTmp1 == ZEMPTYLIST);
3860 tullTmp = rlPageptr.p->word32[ZPOS_EMPTY_LIST];
3861 tullTmp = (((tullTmp >> 14) << 14) | (trlPageindex << 7)) | (tullTmp & 0x7f);
3862 dbgWord32(rlPageptr, ZPOS_EMPTY_LIST, tullTmp);
3863 rlPageptr.p->word32[ZPOS_EMPTY_LIST] = tullTmp;
3864 dbgWord32(rlPageptr, ZPOS_ALLOC_CONTAINERS, rlPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] - 1);
3865 rlPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] = rlPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] - 1;
3866 ndbrequire(rlPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] <= ZNIL);
3867 if (((rlPageptr.p->word32[ZPOS_EMPTY_LIST] >> ZPOS_PAGE_TYPE_BIT) & 3) == 1) {
3869 colPageptr.i = rlPageptr.i;
3870 colPageptr.p = rlPageptr.p;
3871 ptrCheck(colPageptr, cpagesize, page8);
3872 checkoverfreelist(signal);
3892 void Dbacc::releaseRightlist(
Signal* signal)
3902 if (trlRelCon == ZTRUE) {
3904 arrGuard(turlIndex, 2048);
3905 trlHead = rlPageptr.p->word32[turlIndex];
3906 trlNextused = (trlHead >> 11) & 0x7f;
3907 trlPrevused = (trlHead >> 18) & 0x7f;
3908 if (trlNextused < ZEMPTYLIST) {
3910 turlTmp1 = (trlNextused << ZSHIFT_PLUS) - (trlNextused << ZSHIFT_MINUS);
3911 turlTmp1 = turlTmp1 + ((ZHEAD_SIZE + ZBUF_SIZE) - ZCON_HEAD_SIZE);
3912 turlTmp = rlPageptr.p->word32[turlTmp1] & 0xfe03ffff;
3913 dbgWord32(rlPageptr, turlTmp1, turlTmp | (trlPrevused << 18));
3914 rlPageptr.p->word32[turlTmp1] = turlTmp | (trlPrevused << 18);
3916 ndbrequire(trlNextused == ZEMPTYLIST);
3919 if (trlPrevused < ZEMPTYLIST) {
3921 turlTmp1 = (trlPrevused << ZSHIFT_PLUS) - (trlPrevused << ZSHIFT_MINUS);
3922 turlTmp1 = turlTmp1 + ((ZHEAD_SIZE + ZBUF_SIZE) - ZCON_HEAD_SIZE);
3923 turlTmp = rlPageptr.p->word32[turlTmp1] & 0xfffc07ff;
3924 dbgWord32(rlPageptr, turlTmp1, turlTmp | (trlNextused << 11));
3925 rlPageptr.p->word32[turlTmp1] = turlTmp | (trlNextused << 11);
3927 ndbrequire(trlPrevused == ZEMPTYLIST);
3933 turlTmp = rlPageptr.p->word32[ZPOS_EMPTY_LIST] & 0xff80ffff;
3934 dbgWord32(rlPageptr, ZPOS_EMPTY_LIST, turlTmp | (trlNextused << 16));
3935 rlPageptr.p->word32[ZPOS_EMPTY_LIST] = turlTmp | (trlNextused << 16);
3938 dbgWord32(rlPageptr, turlIndex + 1, ZEMPTYLIST);
3939 arrGuard(turlIndex + 1, 2048);
3940 rlPageptr.p->word32[turlIndex + 1] = ZEMPTYLIST;
3941 turlTmp1 = rlPageptr.p->word32[ZPOS_EMPTY_LIST] & 0x7f;
3942 dbgWord32(rlPageptr, turlIndex, turlTmp1);
3943 arrGuard(turlIndex, 2048);
3944 rlPageptr.p->word32[turlIndex] = turlTmp1;
3945 if (turlTmp1 < ZEMPTYLIST) {
3947 turlTmp = (turlTmp1 << ZSHIFT_PLUS) - (turlTmp1 << ZSHIFT_MINUS);
3948 turlTmp = turlTmp + ((ZHEAD_SIZE + ZBUF_SIZE) - (ZCON_HEAD_SIZE - 1));
3949 dbgWord32(rlPageptr, turlTmp, trlPageindex);
3950 rlPageptr.p->word32[turlTmp] = trlPageindex;
3952 ndbrequire(turlTmp1 == ZEMPTYLIST);
3954 turlTmp = rlPageptr.p->word32[ZPOS_EMPTY_LIST];
3955 dbgWord32(rlPageptr, ZPOS_EMPTY_LIST, ((turlTmp >> 7) << 7) | trlPageindex);
3956 rlPageptr.p->word32[ZPOS_EMPTY_LIST] = ((turlTmp >> 7) << 7) | trlPageindex;
3957 dbgWord32(rlPageptr, ZPOS_ALLOC_CONTAINERS, rlPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] - 1);
3958 rlPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] = rlPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] - 1;
3959 ndbrequire(rlPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] <= ZNIL);
3960 if (((rlPageptr.p->word32[ZPOS_EMPTY_LIST] >> ZPOS_PAGE_TYPE_BIT) & 3) == 1) {
3962 colPageptr.i = rlPageptr.i;
3963 colPageptr.p = rlPageptr.p;
3964 checkoverfreelist(signal);
3975 void Dbacc::checkoverfreelist(
Signal* signal)
3979 tcolTmp = colPageptr.p->word32[ZPOS_ALLOC_CONTAINERS];
3980 if (tcolTmp <= ZFREE_LIMIT) {
3983 ropPageptr = colPageptr;
3984 releaseOverpage(signal);
3987 if (colPageptr.p->word32[ZPOS_OVERFLOWREC] == RNIL) {
3988 ndbrequire(cfirstfreeoverrec != RNIL);
3990 seizeOverRec(signal);
3991 sorOverflowRecPtr.p->dirindex = colPageptr.p->word32[ZPOS_PAGE_ID];
3992 sorOverflowRecPtr.p->overpage = colPageptr.i;
3993 dbgWord32(colPageptr, ZPOS_OVERFLOWREC, sorOverflowRecPtr.i);
3994 colPageptr.p->word32[ZPOS_OVERFLOWREC] = sorOverflowRecPtr.i;
3995 porOverflowRecPtr = sorOverflowRecPtr;
3996 putOverflowRecInFrag(signal);
4036 Dbacc::abortParallelQueueOperation(
Signal* signal, OperationrecPtr opPtr)
4039 OperationrecPtr nextP;
4040 OperationrecPtr prevP;
4041 OperationrecPtr loPtr;
4043 Uint32 opbits = opPtr.p->m_op_bits;
4044 Uint32 opstate = opbits & Operationrec::OP_STATE_MASK;
4045 nextP.i = opPtr.p->nextParallelQue;
4046 prevP.i = opPtr.p->prevParallelQue;
4047 loPtr.i = opPtr.p->m_lock_owner_ptr_i;
4049 ndbassert(! (opbits & Operationrec::OP_LOCK_OWNER));
4050 ndbassert(opbits & Operationrec::OP_RUN_QUEUE);
4052 ptrCheckGuard(prevP, coprecsize, operationrec);
4053 ndbassert(prevP.p->nextParallelQue == opPtr.i);
4054 prevP.p->nextParallelQue = nextP.i;
4056 if (nextP.i != RNIL)
4058 ptrCheckGuard(nextP, coprecsize, operationrec);
4059 ndbassert(nextP.p->prevParallelQue == opPtr.i);
4060 nextP.p->prevParallelQue = prevP.i;
4062 else if (prevP.i != loPtr.i)
4065 ptrCheckGuard(loPtr, coprecsize, operationrec);
4066 ndbassert(loPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER);
4067 ndbassert(loPtr.p->m_lo_last_parallel_op_ptr_i == opPtr.i);
4068 loPtr.p->m_lo_last_parallel_op_ptr_i = prevP.i;
4069 prevP.p->m_lock_owner_ptr_i = loPtr.i;
4075 validate_lock_queue(prevP);
4086 ndbassert(prevP.p->m_op_bits & Operationrec::OP_LOCK_OWNER);
4087 prevP.p->m_lo_last_parallel_op_ptr_i = RNIL;
4089 validate_lock_queue(prevP);
4096 if (opbits & Operationrec::OP_LOCK_MODE)
4098 Uint32 nextbits = nextP.p->m_op_bits;
4099 while ((nextbits & Operationrec::OP_LOCK_MODE) == 0)
4101 ndbassert(nextbits & Operationrec::OP_ACC_LOCK_MODE);
4102 nextbits &= ~(Uint32)Operationrec::OP_ACC_LOCK_MODE;
4103 nextP.p->m_op_bits = nextbits;
4105 if (nextP.p->nextParallelQue != RNIL)
4107 nextP.i = nextP.p->nextParallelQue;
4108 ptrCheckGuard(nextP, coprecsize, operationrec);
4109 nextbits = nextP.p->m_op_bits;
4121 if (opstate == Operationrec::OP_STATE_RUNNING)
4125 validate_lock_queue(prevP);
4129 ndbassert(opstate == Operationrec::OP_STATE_EXECUTED ||
4130 opstate == Operationrec::OP_STATE_WAITING);
4135 while (nextP.p->nextParallelQue != RNIL)
4138 nextP.i = nextP.p->nextParallelQue;
4139 ptrCheckGuard(nextP, coprecsize, operationrec);
4143 loPtr.i = nextP.p->m_lock_owner_ptr_i;
4144 ptrCheckGuard(loPtr, coprecsize, operationrec);
4145 ndbassert(loPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER);
4146 ndbassert(loPtr.p->m_lo_last_parallel_op_ptr_i == nextP.i);
4149 validate_lock_queue(nextP);
4155 Dbacc::abortSerieQueueOperation(
Signal* signal, OperationrecPtr opPtr)
4158 OperationrecPtr prevS, nextS;
4159 OperationrecPtr prevP, nextP;
4160 OperationrecPtr loPtr;
4162 Uint32 opbits = opPtr.p->m_op_bits;
4164 prevS.i = opPtr.p->prevSerialQue;
4165 nextS.i = opPtr.p->nextSerialQue;
4167 prevP.i = opPtr.p->prevParallelQue;
4168 nextP.i = opPtr.p->nextParallelQue;
4170 ndbassert((opbits & Operationrec::OP_LOCK_OWNER) == 0);
4171 ndbassert((opbits & Operationrec::OP_RUN_QUEUE) == 0);
4173 if (prevP.i != RNIL)
4178 ptrCheckGuard(prevP, coprecsize, operationrec);
4179 ndbassert(prevP.p->nextParallelQue == opPtr.i);
4180 prevP.p->nextParallelQue = nextP.i;
4182 if (nextP.i != RNIL)
4184 ptrCheckGuard(nextP, coprecsize, operationrec);
4185 ndbassert(nextP.p->prevParallelQue == opPtr.i);
4186 ndbassert((nextP.p->m_op_bits & Operationrec::OP_STATE_MASK) ==
4187 Operationrec::OP_STATE_WAITING);
4188 nextP.p->prevParallelQue = prevP.i;
4190 if ((prevP.p->m_op_bits & Operationrec::OP_ACC_LOCK_MODE) == 0 &&
4191 opbits & Operationrec::OP_LOCK_MODE)
4196 while ((nextP.p->m_op_bits & Operationrec::OP_LOCK_MODE) == 0)
4198 ndbassert(nextP.p->m_op_bits & Operationrec::OP_ACC_LOCK_MODE);
4199 nextP.p->m_op_bits &= ~(Uint32)Operationrec::OP_ACC_LOCK_MODE;
4200 nextP.i = nextP.p->nextParallelQue;
4201 if (nextP.i == RNIL)
4203 ptrCheckGuard(nextP, coprecsize, operationrec);
4207 validate_lock_queue(prevP);
4215 ptrCheckGuard(prevS, coprecsize, operationrec);
4216 ndbassert(prevS.p->nextSerialQue == opPtr.i);
4218 if (nextP.i != RNIL)
4223 ptrCheckGuard(nextP, coprecsize, operationrec);
4224 ndbassert(nextP.p->prevParallelQue == opPtr.i);
4225 prevS.p->nextSerialQue = nextP.i;
4226 nextP.p->prevParallelQue = RNIL;
4227 nextP.p->nextSerialQue = nextS.i;
4228 if (nextS.i != RNIL)
4231 ptrCheckGuard(nextS, coprecsize, operationrec);
4232 ndbassert(nextS.p->prevSerialQue == opPtr.i);
4233 nextS.p->prevSerialQue = nextP.i;
4234 validate_lock_queue(prevS);
4242 while ((loPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER) == 0)
4244 loPtr.i = loPtr.p->prevSerialQue;
4245 ptrCheckGuard(loPtr, coprecsize, operationrec);
4247 ndbassert(loPtr.p->m_lo_last_serial_op_ptr_i == opPtr.i);
4248 loPtr.p->m_lo_last_serial_op_ptr_i = nextP.i;
4249 validate_lock_queue(loPtr);
4254 if (nextS.i == RNIL)
4263 prevS.p->nextSerialQue = RNIL;
4266 while ((loPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER) == 0)
4268 loPtr.i = loPtr.p->prevSerialQue;
4269 ptrCheckGuard(loPtr, coprecsize, operationrec);
4271 ndbassert(loPtr.p->m_lo_last_serial_op_ptr_i == opPtr.i);
4272 if (prevS.i != loPtr.i)
4275 loPtr.p->m_lo_last_serial_op_ptr_i = prevS.i;
4279 loPtr.p->m_lo_last_serial_op_ptr_i = RNIL;
4281 validate_lock_queue(loPtr);
4283 else if (nextP.i == RNIL)
4285 ptrCheckGuard(nextS, coprecsize, operationrec);
4286 ndbassert(nextS.p->prevSerialQue == opPtr.i);
4287 prevS.p->nextSerialQue = nextS.i;
4288 nextS.p->prevSerialQue = prevS.i;
4290 if (prevS.p->m_op_bits & Operationrec::OP_LOCK_OWNER)
4295 OperationrecPtr lastOp;
4296 lastOp.i = prevS.p->m_lo_last_parallel_op_ptr_i;
4297 if (lastOp.i != RNIL)
4300 ptrCheckGuard(lastOp, coprecsize, operationrec);
4301 ndbassert(lastOp.p->m_lock_owner_ptr_i == prevS.i);
4309 validate_lock_queue(lastOp);
4313 validate_lock_queue(prevS);
4320 void Dbacc::abortOperation(
Signal* signal)
4322 Uint32 opbits = operationRecPtr.p->m_op_bits;
4324 validate_lock_queue(operationRecPtr);
4326 if (opbits & Operationrec::OP_LOCK_OWNER)
4328 takeOutLockOwnersList(signal, operationRecPtr);
4329 opbits &= ~(Uint32)Operationrec::OP_LOCK_OWNER;
4330 if (opbits & Operationrec::OP_INSERT_IS_DONE)
4333 opbits |= Operationrec::OP_ELEMENT_DISAPPEARED;
4335 operationRecPtr.p->m_op_bits = opbits;
4336 const bool queue = (operationRecPtr.p->nextParallelQue != RNIL ||
4337 operationRecPtr.p->nextSerialQue != RNIL);
4342 release_lockowner(signal, operationRecPtr,
false);
4351 if ((opbits & Operationrec::OP_ELEMENT_DISAPPEARED) == 0)
4354 Page8Ptr aboPageidptr;
4355 Uint32 taboElementptr;
4358 taboElementptr = operationRecPtr.p->elementPointer;
4359 aboPageidptr.i = operationRecPtr.p->elementPage;
4360 tmp2Olq = ElementHeader::setUnlocked(operationRecPtr.p->hashvaluePart,
4361 operationRecPtr.p->scanBits);
4362 ptrCheckGuard(aboPageidptr, cpagesize, page8);
4363 dbgWord32(aboPageidptr, taboElementptr, tmp2Olq);
4364 arrGuard(taboElementptr, 2048);
4365 aboPageidptr.p->word32[taboElementptr] = tmp2Olq;
4371 commitdelete(signal);
4375 else if (opbits & Operationrec::OP_RUN_QUEUE)
4377 abortParallelQueueOperation(signal, operationRecPtr);
4381 abortSerieQueueOperation(signal, operationRecPtr);
4386 Dbacc::commitDeleteCheck()
4388 OperationrecPtr opPtr;
4389 OperationrecPtr lastOpPtr;
4390 OperationrecPtr deleteOpPtr;
4391 Uint32 elementDeleted = 0;
4392 bool deleteCheckOngoing =
true;
4393 Uint32 hashValue = 0;
4394 lastOpPtr = operationRecPtr;
4395 opPtr.i = operationRecPtr.p->nextParallelQue;
4396 while (opPtr.i != RNIL) {
4398 ptrCheckGuard(opPtr, coprecsize, operationrec);
4400 opPtr.i = opPtr.p->nextParallelQue;
4402 deleteOpPtr = lastOpPtr;
4404 Uint32 opbits = deleteOpPtr.p->m_op_bits;
4405 Uint32 op = opbits & Operationrec::OP_MASK;
4406 if (op == ZDELETE) {
4419 hashValue = deleteOpPtr.p->hashValue;
4420 elementDeleted = Operationrec::OP_ELEMENT_DISAPPEARED;
4421 deleteCheckOngoing =
false;
4422 }
else if (op == ZREAD || op == ZSCAN_OP) {
4432 deleteOpPtr.i = deleteOpPtr.p->prevParallelQue;
4433 if (opbits & Operationrec::OP_LOCK_OWNER) {
4435 deleteCheckOngoing =
false;
4438 ptrCheckGuard(deleteOpPtr, coprecsize, operationrec);
4446 deleteCheckOngoing =
false;
4448 }
while (deleteCheckOngoing);
4452 opPtr.p->m_op_bits |= Operationrec::OP_COMMIT_DELETE_CHECK;
4453 if (elementDeleted) {
4455 opPtr.p->m_op_bits |= elementDeleted;
4456 opPtr.p->hashValue = hashValue;
4458 opPtr.i = opPtr.p->prevParallelQue;
4459 if (opPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER) {
4463 ptrCheckGuard(opPtr, coprecsize, operationrec);
4473 void Dbacc::commitOperation(
Signal* signal)
4475 validate_lock_queue(operationRecPtr);
4477 Uint32 opbits = operationRecPtr.p->m_op_bits;
4478 Uint32 op = opbits & Operationrec::OP_MASK;
4479 ndbrequire((opbits & Operationrec::OP_STATE_MASK) == Operationrec::OP_STATE_EXECUTED);
4480 if ((opbits & Operationrec::OP_COMMIT_DELETE_CHECK) == 0 &&
4481 (op != ZREAD && op != ZSCAN_OP))
4493 commitDeleteCheck();
4494 opbits = operationRecPtr.p->m_op_bits;
4497 ndbassert(opbits & Operationrec::OP_RUN_QUEUE);
4499 if (opbits & Operationrec::OP_LOCK_OWNER)
4501 takeOutLockOwnersList(signal, operationRecPtr);
4502 opbits &= ~(Uint32)Operationrec::OP_LOCK_OWNER;
4503 operationRecPtr.p->m_op_bits = opbits;
4505 const bool queue = (operationRecPtr.p->nextParallelQue != RNIL ||
4506 operationRecPtr.p->nextSerialQue != RNIL);
4508 if (!queue && (opbits & Operationrec::OP_ELEMENT_DISAPPEARED) == 0)
4514 Page8Ptr coPageidptr;
4515 Uint32 tcoElementptr;
4518 coPageidptr.i = operationRecPtr.p->elementPage;
4519 tcoElementptr = operationRecPtr.p->elementPointer;
4520 tmp2Olq = ElementHeader::setUnlocked(operationRecPtr.p->hashvaluePart,
4521 operationRecPtr.p->scanBits);
4522 ptrCheckGuard(coPageidptr, cpagesize, page8);
4523 dbgWord32(coPageidptr, tcoElementptr, tmp2Olq);
4524 arrGuard(tcoElementptr, 2048);
4525 coPageidptr.p->word32[tcoElementptr] = tmp2Olq;
4535 release_lockowner(signal, operationRecPtr,
true);
4545 commitdelete(signal);
4556 OperationrecPtr prev, next, lockOwner;
4557 prev.i = operationRecPtr.p->prevParallelQue;
4558 next.i = operationRecPtr.p->nextParallelQue;
4559 lockOwner.i = operationRecPtr.p->m_lock_owner_ptr_i;
4560 ptrCheckGuard(prev, coprecsize, operationrec);
4562 prev.p->nextParallelQue = next.i;
4566 ptrCheckGuard(next, coprecsize, operationrec);
4567 next.p->prevParallelQue = prev.i;
4569 else if (prev.p->m_op_bits & Operationrec::OP_LOCK_OWNER)
4572 ndbassert(lockOwner.i == prev.i);
4573 prev.p->m_lo_last_parallel_op_ptr_i = RNIL;
4582 ndbassert(prev.i != lockOwner.i);
4583 ptrCheckGuard(lockOwner, coprecsize, operationrec);
4584 ndbassert(lockOwner.p->m_op_bits & Operationrec::OP_LOCK_OWNER);
4585 lockOwner.p->m_lo_last_parallel_op_ptr_i = prev.i;
4586 prev.p->m_lock_owner_ptr_i = lockOwner.i;
4593 if(opbits & Operationrec::OP_ACC_LOCK_MODE)
4614 validate_lock_queue(prev);
4622 while(next.p->nextParallelQue != RNIL)
4625 next.i = next.p->nextParallelQue;
4626 ptrCheckGuard(next, coprecsize, operationrec);
4628 if ((next.p->m_op_bits & Operationrec::OP_STATE_MASK) !=
4629 Operationrec::OP_STATE_EXECUTED)
4638 validate_lock_queue(prev);
4643 Dbacc::release_lockowner(
Signal* signal, OperationrecPtr opPtr,
bool commit)
4645 OperationrecPtr nextP;
4646 OperationrecPtr nextS;
4647 OperationrecPtr newOwner;
4648 OperationrecPtr lastP;
4650 Uint32 opbits = opPtr.p->m_op_bits;
4651 nextP.i = opPtr.p->nextParallelQue;
4652 nextS.i = opPtr.p->nextSerialQue;
4653 lastP.i = opPtr.p->m_lo_last_parallel_op_ptr_i;
4654 Uint32 lastS = opPtr.p->m_lo_last_serial_op_ptr_i;
4656 ndbassert(lastP.i != RNIL || lastS != RNIL);
4657 ndbassert(nextP.i != RNIL || nextS.i != RNIL);
4665 if (nextP.i != RNIL)
4668 ptrCheckGuard(nextP, coprecsize, operationrec);
4671 if (lastP.i == newOwner.i)
4673 newOwner.p->m_lo_last_parallel_op_ptr_i = RNIL;
4678 ptrCheckGuard(lastP, coprecsize, operationrec);
4679 newOwner.p->m_lo_last_parallel_op_ptr_i = lastP.i;
4680 lastP.p->m_lock_owner_ptr_i = newOwner.i;
4683 newOwner.p->m_lo_last_serial_op_ptr_i = lastS;
4684 newOwner.p->nextSerialQue = nextS.i;
4686 if (nextS.i != RNIL)
4689 ptrCheckGuard(nextS, coprecsize, operationrec);
4690 ndbassert(nextS.p->prevSerialQue == opPtr.i);
4691 nextS.p->prevSerialQue = newOwner.i;
4696 if ((opbits & Operationrec::OP_ACC_LOCK_MODE) == ZREADLOCK)
4716 action = CHECK_LOCK_UPGRADE;
4721 newOwner.p->m_op_bits |= Operationrec::OP_LOCK_MODE;
4729 action = CHECK_LOCK_UPGRADE;
4730 Uint32 opstate = opbits & Operationrec::OP_STATE_MASK;
4731 if (opstate != Operationrec::OP_STATE_EXECUTED)
4733 ndbassert(opstate == Operationrec::OP_STATE_RUNNING);
4734 if (opbits & Operationrec::OP_ELEMENT_DISAPPEARED)
4737 report_dealloc(signal, opPtr.p);
4738 newOwner.p->localdata[0] = ~(Uint32)0;
4739 newOwner.p->localdata[1] = ~(Uint32)0;
4744 newOwner.p->localdata[0] = opPtr.p->localdata[0];
4745 newOwner.p->localdata[1] = opPtr.p->localdata[1];
4753 if (opbits & Operationrec::OP_LOCK_MODE)
4755 Uint32 nextbits = nextP.p->m_op_bits;
4756 while ((nextbits & Operationrec::OP_LOCK_MODE) == 0)
4758 ndbassert(nextbits & Operationrec::OP_ACC_LOCK_MODE);
4759 nextbits &= ~(Uint32)Operationrec::OP_ACC_LOCK_MODE;
4760 nextP.p->m_op_bits = nextbits;
4762 if (nextP.p->nextParallelQue != RNIL)
4764 nextP.i = nextP.p->nextParallelQue;
4765 ptrCheckGuard(nextP, coprecsize, operationrec);
4766 nextbits = nextP.p->m_op_bits;
4779 ptrCheckGuard(nextS, coprecsize, operationrec);
4782 newOwner.p->m_op_bits |= Operationrec::OP_RUN_QUEUE;
4784 if (opbits & Operationrec::OP_ELEMENT_DISAPPEARED)
4786 report_dealloc(signal, opPtr.p);
4787 newOwner.p->localdata[0] = ~(Uint32)0;
4788 newOwner.p->localdata[1] = ~(Uint32)0;
4793 newOwner.p->localdata[0] = opPtr.p->localdata[0];
4794 newOwner.p->localdata[1] = opPtr.p->localdata[1];
4798 while (lastP.p->nextParallelQue != RNIL)
4800 lastP.i = lastP.p->nextParallelQue;
4801 ptrCheckGuard(lastP, coprecsize, operationrec);
4802 lastP.p->m_op_bits |= Operationrec::OP_RUN_QUEUE;
4805 if (newOwner.i != lastP.i)
4808 newOwner.p->m_lo_last_parallel_op_ptr_i = lastP.i;
4813 newOwner.p->m_lo_last_parallel_op_ptr_i = RNIL;
4816 if (newOwner.i != lastS)
4819 newOwner.p->m_lo_last_serial_op_ptr_i = lastS;
4824 newOwner.p->m_lo_last_serial_op_ptr_i = RNIL;
4830 insertLockOwnersList(signal, newOwner);
4837 newOwner.p->elementPage = opPtr.p->elementPage;
4838 newOwner.p->elementIsforward = opPtr.p->elementIsforward;
4839 newOwner.p->elementPointer = opPtr.p->elementPointer;
4840 newOwner.p->elementContainer = opPtr.p->elementContainer;
4841 newOwner.p->scanBits = opPtr.p->scanBits;
4842 newOwner.p->hashvaluePart = opPtr.p->hashvaluePart;
4843 newOwner.p->m_op_bits |= (opbits & Operationrec::OP_ELEMENT_DISAPPEARED);
4844 if (opbits & Operationrec::OP_ELEMENT_DISAPPEARED)
4855 newOwner.p->hashValue = opPtr.p->hashValue;
4859 pagePtr.i = newOwner.p->elementPage;
4860 ptrCheckGuard(pagePtr, cpagesize, page8);
4861 const Uint32 tmp = ElementHeader::setLocked(newOwner.i);
4862 arrGuard(newOwner.p->elementPointer, 2048);
4863 pagePtr.p->word32[newOwner.p->elementPointer] = tmp;
4868 validate_lock_queue(newOwner);
4871 startNew(signal, newOwner);
4872 validate_lock_queue(newOwner);
4874 case CHECK_LOCK_UPGRADE:
4876 validate_lock_queue(lastP);
4883 Dbacc::startNew(
Signal* signal, OperationrecPtr newOwner)
4885 OperationrecPtr save = operationRecPtr;
4886 operationRecPtr = newOwner;
4888 Uint32 opbits = newOwner.p->m_op_bits;
4889 Uint32 op = opbits & Operationrec::OP_MASK;
4890 Uint32 opstate = (opbits & Operationrec::OP_STATE_MASK);
4891 ndbassert(opstate == Operationrec::OP_STATE_WAITING);
4892 ndbassert(opbits & Operationrec::OP_LOCK_OWNER);
4893 const bool deleted = opbits & Operationrec::OP_ELEMENT_DISAPPEARED;
4896 opbits &= opbits & ~(Uint32)Operationrec::OP_STATE_MASK;
4897 opbits |= Operationrec::OP_STATE_RUNNING;
4899 if (op == ZSCAN_OP && (opbits & Operationrec::OP_LOCK_REQ) == 0)
4905 if (op != ZINSERT && op != ZWRITE)
4907 errCode = ZREAD_ERROR;
4911 opbits &= ~(Uint32)Operationrec::OP_MASK;
4912 opbits &= ~(Uint32)Operationrec::OP_ELEMENT_DISAPPEARED;
4913 opbits |= (op = ZINSERT);
4914 opbits |= Operationrec::OP_INSERT_IS_DONE;
4917 else if (op == ZINSERT)
4920 errCode = ZWRITE_ERROR;
4923 else if (op == ZWRITE)
4926 opbits &= ~(Uint32)Operationrec::OP_MASK;
4927 opbits |= (op = ZUPDATE);
4932 newOwner.p->m_op_bits = opbits;
4934 sendAcckeyconf(signal);
4935 sendSignal(newOwner.p->userblockref, GSN_ACCKEYCONF,
4938 operationRecPtr = save;
4943 newOwner.p->m_op_bits = opbits;
4945 takeOutScanLockQueue(newOwner.p->scanRecPtr);
4946 putReadyScanQueue(signal, newOwner.p->scanRecPtr);
4948 operationRecPtr = save;
4952 newOwner.p->m_op_bits = opbits;
4954 signal->theData[0] = newOwner.p->userptr;
4955 signal->theData[1] = errCode;
4956 sendSignal(newOwner.p->userblockref, GSN_ACCKEYREF, signal,
4959 operationRecPtr = save;
4970 void Dbacc::takeOutLockOwnersList(
Signal* signal,
4971 const OperationrecPtr& outOperPtr)
4973 const Uint32 Tprev = outOperPtr.p->prevLockOwnerOp;
4974 const Uint32 Tnext = outOperPtr.p->nextLockOwnerOp;
4977 OperationrecPtr tmpOperPtr;
4978 bool inList =
false;
4979 tmpOperPtr.i = fragrecptr.p->lockOwnersList;
4980 while (tmpOperPtr.i != RNIL){
4981 ptrCheckGuard(tmpOperPtr, coprecsize, operationrec);
4982 if (tmpOperPtr.i == outOperPtr.i)
4984 tmpOperPtr.i = tmpOperPtr.p->nextLockOwnerOp;
4986 ndbrequire(inList ==
true);
4989 ndbassert(outOperPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER);
4992 if ((Tprev == RNIL) && (Tnext == RNIL)) {
4993 ndbrequire(fragrecptr.p->lockOwnersList == outOperPtr.i);
4994 fragrecptr.p->lockOwnersList = RNIL;
4999 if (Tprev != RNIL) {
5001 arrGuard(Tprev, coprecsize);
5002 operationrec[Tprev].nextLockOwnerOp = Tnext;
5004 fragrecptr.p->lockOwnersList = Tnext;
5008 if (Tnext == RNIL) {
5012 arrGuard(Tnext, coprecsize);
5013 operationrec[Tnext].prevLockOwnerOp = Tprev;
5026 void Dbacc::insertLockOwnersList(
Signal* signal,
5027 const OperationrecPtr& insOperPtr)
5029 OperationrecPtr tmpOperPtr;
5032 tmpOperPtr.i = fragrecptr.p->lockOwnersList;
5033 while(tmpOperPtr.i != RNIL){
5034 ptrCheckGuard(tmpOperPtr, coprecsize, operationrec);
5035 ndbrequire(tmpOperPtr.i != insOperPtr.i);
5036 tmpOperPtr.i = tmpOperPtr.p->nextLockOwnerOp;
5039 tmpOperPtr.i = fragrecptr.p->lockOwnersList;
5041 ndbrequire(! (insOperPtr.p->m_op_bits & Operationrec::OP_LOCK_OWNER));
5043 insOperPtr.p->m_op_bits |= Operationrec::OP_LOCK_OWNER;
5044 insOperPtr.p->prevLockOwnerOp = RNIL;
5045 insOperPtr.p->nextLockOwnerOp = tmpOperPtr.i;
5047 fragrecptr.p->lockOwnersList = insOperPtr.i;
5048 if (tmpOperPtr.i == RNIL) {
5052 ptrCheckGuard(tmpOperPtr, coprecsize, operationrec);
5053 tmpOperPtr.p->prevLockOwnerOp = insOperPtr.i;
5072 void Dbacc::allocOverflowPage(
Signal* signal)
5074 DirRangePtr aopDirRangePtr;
5075 DirectoryarrayPtr aopOverflowDirptr;
5076 OverflowRecordPtr aopOverflowRecPtr;
5082 if (cfirstfreepage == RNIL)
5085 zpagesize_error(
"Dbacc::allocOverflowPage");
5086 tresult = ZPAGESIZE_ERROR;
5089 if (fragrecptr.p->firstFreeDirindexRec != RNIL) {
5094 aopOverflowRecPtr.i = fragrecptr.p->firstFreeDirindexRec;
5095 ptrCheckGuard(aopOverflowRecPtr, coverflowrecsize, overflowRecord);
5096 troOverflowRecPtr.p = aopOverflowRecPtr.p;
5097 takeRecOutOfFreeOverdir(signal);
5098 }
else if (cfirstfreeoverrec == RNIL) {
5100 tresult = ZOVER_REC_ERROR;
5102 }
else if ((cfirstfreedir == RNIL) &&
5103 (cdirarraysize <= cdirmemory)) {
5105 tresult = ZDIRSIZE_ERROR;
5109 seizeOverRec(signal);
5110 aopOverflowRecPtr = sorOverflowRecPtr;
5111 aopOverflowRecPtr.p->dirindex = fragrecptr.p->lastOverIndex;
5113 aopOverflowRecPtr.p->nextOverRec = RNIL;
5114 aopOverflowRecPtr.p->prevOverRec = RNIL;
5115 fragrecptr.p->firstOverflowRec = aopOverflowRecPtr.i;
5116 fragrecptr.p->lastOverflowRec = aopOverflowRecPtr.i;
5117 taopTmp1 = aopOverflowRecPtr.p->dirindex;
5118 aopDirRangePtr.i = fragrecptr.p->overflowdir;
5119 taopTmp2 = taopTmp1 >> 8;
5120 taopTmp3 = taopTmp1 & 0xff;
5121 ptrCheckGuard(aopDirRangePtr, cdirrangesize, dirRange);
5122 arrGuard(taopTmp2, 256);
5123 if (aopDirRangePtr.p->dirArray[taopTmp2] == RNIL) {
5125 seizeDirectory(signal);
5126 ndbrequire(tresult <= ZLIMIT_OF_ERROR);
5127 aopDirRangePtr.p->dirArray[taopTmp2] = sdDirptr.i;
5129 aopOverflowDirptr.i = aopDirRangePtr.p->dirArray[taopTmp2];
5131 ndbrequire(tresult <= ZLIMIT_OF_ERROR);
5132 ptrCheckGuard(aopOverflowDirptr, cdirarraysize, directoryarray);
5133 aopOverflowDirptr.p->pagep[taopTmp3] = spPageptr.i;
5134 tiopPageId = aopOverflowRecPtr.p->dirindex;
5135 iopOverflowRecPtr = aopOverflowRecPtr;
5136 iopPageptr = spPageptr;
5137 initOverpage(signal);
5138 aopOverflowRecPtr.p->overpage = spPageptr.i;
5139 if (fragrecptr.p->lastOverIndex <= aopOverflowRecPtr.p->dirindex) {
5141 ndbrequire(fragrecptr.p->lastOverIndex == aopOverflowRecPtr.p->dirindex);
5142 fragrecptr.p->lastOverIndex++;
5169 Uint32 Dbacc::checkScanExpand(
Signal* signal)
5172 Uint32 TreturnCode = 0;
5176 Uint32 TreleaseInd = 0;
5177 Uint32 TreleaseScanBucket;
5178 Uint32 TreleaseScanIndicator[MAX_PARALLEL_SCANS_PER_FRAG];
5179 DirectoryarrayPtr TDirptr;
5180 DirRangePtr TDirRangePtr;
5182 ScanRecPtr TscanPtr;
5184 TSplit = fragrecptr.p->p;
5185 for (Ti = 0; Ti < MAX_PARALLEL_SCANS_PER_FRAG; Ti++) {
5186 TreleaseScanIndicator[Ti] = 0;
5187 if (fragrecptr.p->scan[Ti] != RNIL) {
5192 TscanPtr.i = fragrecptr.p->scan[Ti];
5193 ptrCheckGuard(TscanPtr, cscanRecSize, scanRec);
5194 if (TscanPtr.p->activeLocalFrag == fragrecptr.i) {
5195 if (TscanPtr.p->scanBucketState == ScanRec::FIRST_LAP) {
5196 if (TSplit == TscanPtr.p->nextBucketIndex) {
5205 }
else if (TSplit > TscanPtr.p->nextBucketIndex) {
5211 TreleaseScanIndicator[Ti] = 1;
5216 }
else if (TscanPtr.p->scanBucketState == ScanRec::SECOND_LAP) {
5226 ndbrequire(TscanPtr.p->scanBucketState == ScanRec::SCAN_COMPLETED);
5236 if (TreleaseInd == 1) {
5237 TreleaseScanBucket = TSplit;
5238 TDirRangePtr.i = fragrecptr.p->directory;
5239 TPageIndex = TreleaseScanBucket & ((1 << fragrecptr.p->k) - 1);
5240 TDirInd = TreleaseScanBucket >> fragrecptr.p->k;
5241 ptrCheckGuard(TDirRangePtr, cdirrangesize, dirRange);
5242 arrGuard((TDirInd >> 8), 256);
5243 TDirptr.i = TDirRangePtr.p->dirArray[TDirInd >> 8];
5244 ptrCheckGuard(TDirptr, cdirarraysize, directoryarray);
5245 TPageptr.i = TDirptr.p->pagep[TDirInd & 0xff];
5246 ptrCheckGuard(TPageptr, cpagesize, page8);
5247 for (Ti = 0; Ti < MAX_PARALLEL_SCANS_PER_FRAG; Ti++) {
5248 if (TreleaseScanIndicator[Ti] == 1) {
5250 scanPtr.i = fragrecptr.p->scan[Ti];
5251 ptrCheckGuard(scanPtr, cscanRecSize, scanRec);
5252 rsbPageidptr = TPageptr;
5253 trsbPageindex = TPageIndex;
5254 releaseScanBucket(signal);
5261 void Dbacc::execEXPANDCHECK2(
Signal* signal)
5265 if(refToBlock(signal->getSendersBlockRef()) == DBLQH)
5271 DirectoryarrayPtr newDirptr;
5273 fragrecptr.i = signal->theData[0];
5277 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
5278 fragrecptr.p->expandFlag = 0;
5279 if (fragrecptr.p->slack < tmp) {
5286 if (ERROR_INSERTED(3002))
5287 debug_lh_vars(
"SLK");
5288 if (fragrecptr.p->dirRangeFull == ZTRUE) {
5290 fragrecptr.p->dirRangeFull = ZFALSE;
5294 if (fragrecptr.p->firstOverflowRec == RNIL) {
5296 allocOverflowPage(signal);
5297 if (tresult > ZLIMIT_OF_ERROR) {
5306 if (cfirstfreepage == RNIL)
5315 if (checkScanExpand(signal) == 1) {
5330 expDirRangePtr.i = fragrecptr.p->directory;
5331 texpReceivedBucket = (fragrecptr.p->maxp + fragrecptr.p->p) + 1;
5332 texpDirInd = texpReceivedBucket >> fragrecptr.p->k;
5335 texpDirRangeIndex = texpDirInd >> 8;
5336 ptrCheckGuard(expDirRangePtr, cdirrangesize, dirRange);
5337 Uint32 max_dir_range_size = 256;
5338 if (ERROR_INSERTED(3002)) {
5339 debug_lh_vars(
"EXP");
5340 max_dir_range_size = 2;
5342 if (texpDirRangeIndex >= max_dir_range_size) {
5344 ndbrequire(texpDirRangeIndex == max_dir_range_size);
5345 if (fragrecptr.p->dirRangeFull == ZFALSE) {
5347 fragrecptr.p->dirRangeFull = ZTRUE;
5351 expDirptr.i = expDirRangePtr.p->dirArray[texpDirRangeIndex];
5352 if (expDirptr.i == RNIL) {
5354 seizeDirectory(signal);
5355 if (tresult > ZLIMIT_OF_ERROR) {
5360 newDirptr = sdDirptr;
5361 expDirptr = sdDirptr;
5362 expDirRangePtr.p->dirArray[texpDirRangeIndex] = sdDirptr.i;
5365 ptrCheckGuard(expDirptr, cdirarraysize, directoryarray);
5367 texpDirPageIndex = texpDirInd & 0xff;
5368 expPageptr.i = expDirptr.p->pagep[texpDirPageIndex];
5369 if (expPageptr.i == RNIL) {
5372 if (tresult > ZLIMIT_OF_ERROR) {
5374 if (newDirptr.i != RNIL) {
5376 rdDirptr.i = newDirptr.i;
5377 releaseDirectory(signal);
5381 expDirptr.p->pagep[texpDirPageIndex] = spPageptr.i;
5382 tipPageId = texpDirInd;
5383 inpPageptr = spPageptr;
5385 fragrecptr.p->dirsize++;
5386 expPageptr = spPageptr;
5388 ptrCheckGuard(expPageptr, cpagesize, page8);
5391 fragrecptr.p->expReceivePageptr = expPageptr.i;
5392 fragrecptr.p->expReceiveIndex = texpReceivedBucket & ((1 << fragrecptr.p->k) - 1);
5397 expDirRangePtr.i = fragrecptr.p->directory;
5398 cexcPageindex = fragrecptr.p->p & ((1 << fragrecptr.p->k) - 1);
5399 texpDirInd = fragrecptr.p->p >> fragrecptr.p->k;
5400 ptrCheckGuard(expDirRangePtr, cdirrangesize, dirRange);
5401 arrGuard((texpDirInd >> 8), 256);
5402 expDirptr.i = expDirRangePtr.p->dirArray[texpDirInd >> 8];
5403 ptrCheckGuard(expDirptr, cdirarraysize, directoryarray);
5404 excPageptr.i = expDirptr.p->pagep[texpDirInd & 0xff];
5405 fragrecptr.p->expSenderIndex = cexcPageindex;
5406 fragrecptr.p->expSenderPageptr = excPageptr.i;
5407 if (excPageptr.i == RNIL) {
5409 endofexpLab(signal);
5412 fragrecptr.p->expReceiveForward = ZTRUE;
5413 ptrCheckGuard(excPageptr, cpagesize, page8);
5414 expandcontainer(signal);
5415 endofexpLab(signal);
5419 void Dbacc::endofexpLab(
Signal* signal)
5422 fragrecptr.p->slack += fragrecptr.p->maxloadfactor;
5423 fragrecptr.p->expandCounter++;
5424 if (fragrecptr.p->p > fragrecptr.p->maxp) {
5426 fragrecptr.p->maxp = (fragrecptr.p->maxp << 1) | 1;
5427 fragrecptr.p->lhdirbits++;
5428 fragrecptr.p->hashcheckbit++;
5429 fragrecptr.p->p = 0;
5431 Uint32 noOfBuckets = (fragrecptr.p->maxp + 1) + fragrecptr.p->p;
5432 Uint32 Thysteres = fragrecptr.p->maxloadfactor - fragrecptr.p->minloadfactor;
5433 fragrecptr.p->slackCheck = noOfBuckets * Thysteres;
5434 if (fragrecptr.p->slack > (1u << 31)) {
5441 fragrecptr.p->expandFlag = 2;
5442 signal->theData[0] = fragrecptr.i;
5443 signal->theData[1] = fragrecptr.p->p;
5444 signal->theData[2] = fragrecptr.p->maxp;
5445 sendSignal(cownBlockref, GSN_EXPANDCHECK2, signal, 3, JBB);
5450 void Dbacc::reenable_expand_after_redo_log_exection_complete(
Signal* signal){
5452 tabptr.i = signal->theData[0];
5453 Uint32 fragId = signal->theData[1];
5455 ptrCheckGuard(tabptr, ctablesize, tabrec);
5456 ndbrequire(getfragmentrec(signal, fragrecptr, fragId));
5458 ndbout_c(
"reenable expand check for table %d fragment: %d",
5462 switch(fragrecptr.p->expandFlag){
5467 fragrecptr.p->expandFlag = 1;
5478 fragrecptr.p->expandFlag = 2;
5479 signal->theData[0] = fragrecptr.i;
5480 signal->theData[1] = fragrecptr.p->p;
5481 signal->theData[2] = fragrecptr.p->maxp;
5482 sendSignal(cownBlockref, GSN_EXPANDCHECK2, signal, 3, JBB);
5487 void Dbacc::execDEBUG_SIG(
Signal* signal)
5490 expPageptr.i = signal->theData[0];
5492 progError(__LINE__, NDBD_EXIT_SR_UNDOLOG);
5504 void Dbacc::expandcontainer(
Signal* signal)
5506 Uint32 texcHashvalue;
5511 cexcPrevpageptr = RNIL;
5513 cexcForward = ZTRUE;
5515 cexcContainerptr = (cexcPageindex << ZSHIFT_PLUS) - (cexcPageindex << ZSHIFT_MINUS);
5516 if (cexcForward == ZTRUE) {
5518 cexcContainerptr = cexcContainerptr + ZHEAD_SIZE;
5519 cexcElementptr = cexcContainerptr + ZCON_HEAD_SIZE;
5522 cexcContainerptr = ((cexcContainerptr + ZHEAD_SIZE) + ZBUF_SIZE) - ZCON_HEAD_SIZE;
5523 cexcElementptr = cexcContainerptr - 1;
5525 arrGuard(cexcContainerptr, 2048);
5526 cexcContainerhead = excPageptr.p->word32[cexcContainerptr];
5527 cexcContainerlen = cexcContainerhead >> 26;
5528 cexcMovedLen = ZCON_HEAD_SIZE;
5529 if (cexcContainerlen <= ZCON_HEAD_SIZE) {
5530 ndbrequire(cexcContainerlen >= ZCON_HEAD_SIZE);
5535 idrOperationRecPtr.i = RNIL;
5536 ptrNull(idrOperationRecPtr);
5546 arrGuard(cexcElementptr, 2048);
5547 tidrElemhead = excPageptr.p->word32[cexcElementptr];
5548 if (ElementHeader::getUnlocked(tidrElemhead)){
5550 texcHashvalue = ElementHeader::getHashValuePart(tidrElemhead);
5553 idrOperationRecPtr.i = ElementHeader::getOpPtrI(tidrElemhead);
5554 ptrCheckGuard(idrOperationRecPtr, coprecsize, operationrec);
5555 texcHashvalue = idrOperationRecPtr.p->hashvaluePart;
5557 if (((texcHashvalue >> fragrecptr.p->hashcheckbit) & 1) == 0) {
5575 texcTmp = cexcElementptr + cexcForward;
5576 guard20 = fragrecptr.p->localkeylen - 1;
5577 for (texcIndex = 0; texcIndex <= guard20; texcIndex++) {
5578 arrGuard(texcIndex, 2);
5579 arrGuard(texcTmp, 2048);
5580 clocalkey[texcIndex] = excPageptr.p->word32[texcTmp];
5581 texcTmp = texcTmp + cexcForward;
5583 tidrPageindex = fragrecptr.p->expReceiveIndex;
5584 idrPageptr.i = fragrecptr.p->expReceivePageptr;
5585 ptrCheckGuard(idrPageptr, cpagesize, page8);
5586 tidrForward = fragrecptr.p->expReceiveForward;
5587 insertElement(signal);
5588 fragrecptr.p->expReceiveIndex = tidrPageindex;
5589 fragrecptr.p->expReceivePageptr = idrPageptr.i;
5590 fragrecptr.p->expReceiveForward = tidrForward;
5593 lastPageptr.i = excPageptr.i;
5594 lastPageptr.p = excPageptr.p;
5595 tlastContainerptr = cexcContainerptr;
5596 lastPrevpageptr.i = cexcPrevpageptr;
5597 ptrCheck(lastPrevpageptr, cpagesize, page8);
5598 tlastPrevconptr = cexcPrevconptr;
5599 arrGuard(tlastContainerptr, 2048);
5600 tlastContainerhead = lastPageptr.p->word32[tlastContainerptr];
5601 tlastContainerlen = tlastContainerhead >> 26;
5602 tlastForward = cexcForward;
5603 tlastPageindex = cexcPageindex;
5604 getLastAndRemove(signal);
5605 if (excPageptr.i == lastPageptr.i) {
5606 if (cexcElementptr == tlastElementptr) {
5619 idrOperationRecPtr.i = RNIL;
5620 ptrNull(idrOperationRecPtr);
5621 arrGuard(tlastElementptr, 2048);
5622 tidrElemhead = lastPageptr.p->word32[tlastElementptr];
5623 if (ElementHeader::getUnlocked(tidrElemhead)) {
5625 texcHashvalue = ElementHeader::getHashValuePart(tidrElemhead);
5628 idrOperationRecPtr.i = ElementHeader::getOpPtrI(tidrElemhead);
5629 ptrCheckGuard(idrOperationRecPtr, coprecsize, operationrec);
5630 texcHashvalue = idrOperationRecPtr.p->hashvaluePart;
5632 if (((texcHashvalue >> fragrecptr.p->hashcheckbit) & 1) == 0) {
5637 delPageptr = excPageptr;
5638 tdelContainerptr = cexcContainerptr;
5639 tdelForward = cexcForward;
5640 tdelElementptr = cexcElementptr;
5641 deleteElement(signal);
5647 texcTmp = tlastElementptr + tlastForward;
5648 for (texcIndex = 0; texcIndex < fragrecptr.p->localkeylen; texcIndex++) {
5649 arrGuard(texcIndex, 2);
5650 arrGuard(texcTmp, 2048);
5651 clocalkey[texcIndex] = lastPageptr.p->word32[texcTmp];
5652 texcTmp = texcTmp + tlastForward;
5654 tidrPageindex = fragrecptr.p->expReceiveIndex;
5655 idrPageptr.i = fragrecptr.p->expReceivePageptr;
5656 ptrCheckGuard(idrPageptr, cpagesize, page8);
5657 tidrForward = fragrecptr.p->expReceiveForward;
5658 insertElement(signal);
5659 fragrecptr.p->expReceiveIndex = tidrPageindex;
5660 fragrecptr.p->expReceivePageptr = idrPageptr.i;
5661 fragrecptr.p->expReceiveForward = tidrForward;
5662 goto REMOVE_LAST_LOOP;
5665 arrGuard(cexcContainerptr, 2048);
5666 cexcContainerhead = excPageptr.p->word32[cexcContainerptr];
5667 cexcMovedLen = cexcMovedLen + fragrecptr.p->elementLength;
5668 if ((cexcContainerhead >> 26) > cexcMovedLen) {
5676 cexcElementptr = cexcElementptr + (cexcForward * fragrecptr.p->elementLength);
5677 goto NEXT_ELEMENT_LOOP;
5679 if (((cexcContainerhead >> 7) & 3) != 0) {
5684 cexcPrevpageptr = excPageptr.i;
5685 cexcPrevconptr = cexcContainerptr;
5686 nextcontainerinfoExp(signal);
5687 goto EXP_CONTAINER_LOOP;
5706 Uint32 Dbacc::checkScanShrink(
Signal* signal)
5709 Uint32 TreturnCode = 0;
5713 Uint32 TmergeSource;
5714 Uint32 TreleaseScanBucket;
5715 Uint32 TreleaseInd = 0;
5716 Uint32 TreleaseScanIndicator[MAX_PARALLEL_SCANS_PER_FRAG];
5717 DirectoryarrayPtr TDirptr;
5718 DirRangePtr TDirRangePtr;
5720 ScanRecPtr TscanPtr;
5722 if (fragrecptr.p->p == 0) {
5724 TmergeDest = fragrecptr.p->maxp >> 1;
5727 TmergeDest = fragrecptr.p->p - 1;
5729 TmergeSource = fragrecptr.p->maxp + fragrecptr.p->p;
5730 for (Ti = 0; Ti < MAX_PARALLEL_SCANS_PER_FRAG; Ti++) {
5731 TreleaseScanIndicator[Ti] = 0;
5732 if (fragrecptr.p->scan[Ti] != RNIL) {
5733 TscanPtr.i = fragrecptr.p->scan[Ti];
5734 ptrCheckGuard(TscanPtr, cscanRecSize, scanRec);
5735 if (TscanPtr.p->activeLocalFrag == fragrecptr.i) {
5740 if (TscanPtr.p->scanBucketState == ScanRec::FIRST_LAP) {
5742 if ((TmergeDest == TscanPtr.p->nextBucketIndex) ||
5743 (TmergeSource == TscanPtr.p->nextBucketIndex)) {
5752 }
else if (TmergeDest < TscanPtr.p->nextBucketIndex) {
5754 TreleaseScanIndicator[Ti] = 1;
5757 }
else if (TscanPtr.p->scanBucketState == ScanRec::SECOND_LAP) {
5766 }
else if (TscanPtr.p->scanBucketState == ScanRec::SCAN_COMPLETED) {
5774 sendSystemerror(signal, __LINE__);
5780 if (TreleaseInd == 1) {
5782 TreleaseScanBucket = TmergeSource;
5783 TDirRangePtr.i = fragrecptr.p->directory;
5784 TPageIndex = TreleaseScanBucket & ((1 << fragrecptr.p->k) - 1);
5785 TDirInd = TreleaseScanBucket >> fragrecptr.p->k;
5786 ptrCheckGuard(TDirRangePtr, cdirrangesize, dirRange);
5787 arrGuard((TDirInd >> 8), 256);
5788 TDirptr.i = TDirRangePtr.p->dirArray[TDirInd >> 8];
5789 ptrCheckGuard(TDirptr, cdirarraysize, directoryarray);
5790 TPageptr.i = TDirptr.p->pagep[TDirInd & 0xff];
5791 ptrCheckGuard(TPageptr, cpagesize, page8);
5792 for (Ti = 0; Ti < MAX_PARALLEL_SCANS_PER_FRAG; Ti++) {
5793 if (TreleaseScanIndicator[Ti] == 1) {
5795 scanPtr.i = fragrecptr.p->scan[Ti];
5796 ptrCheckGuard(scanPtr, cscanRecSize, scanRec);
5797 rsbPageidptr.i = TPageptr.i;
5798 rsbPageidptr.p = TPageptr.p;
5799 trsbPageindex = TPageIndex;
5800 releaseScanBucket(signal);
5801 if (TmergeDest < scanPtr.p->minBucketIndexToRescan) {
5807 scanPtr.p->minBucketIndexToRescan = TmergeDest;
5809 if (TmergeDest > scanPtr.p->maxBucketIndexToRescan) {
5815 scanPtr.p->maxBucketIndexToRescan = TmergeDest;
5823 void Dbacc::execSHRINKCHECK2(
Signal* signal)
5828 fragrecptr.i = signal->theData[0];
5829 Uint32 oldFlag = signal->theData[3];
5830 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
5831 fragrecptr.p->expandFlag = oldFlag;
5833 if (fragrecptr.p->slack <= fragrecptr.p->slackCheck) {
5841 if (fragrecptr.p->slack > (1u << 31)) {
5849 texpDirInd = (fragrecptr.p->maxp + fragrecptr.p->p) >> fragrecptr.p->k;
5850 if (fragrecptr.p->firstOverflowRec == RNIL) {
5852 allocOverflowPage(signal);
5853 if (tresult > ZLIMIT_OF_ERROR) {
5858 if (cfirstfreepage == RNIL)
5868 if (checkScanShrink(signal) == 1) {
5876 if (fragrecptr.p->p == 0) {
5878 fragrecptr.p->maxp = fragrecptr.p->maxp >> 1;
5879 fragrecptr.p->p = fragrecptr.p->maxp;
5880 fragrecptr.p->lhdirbits--;
5881 fragrecptr.p->hashcheckbit--;
5887 if (ERROR_INSERTED(3002))
5888 debug_lh_vars(
"SHR");
5889 if (fragrecptr.p->dirRangeFull == ZTRUE) {
5891 fragrecptr.p->dirRangeFull = ZFALSE;
5898 expDirRangePtr.i = fragrecptr.p->directory;
5899 cexcPageindex = ((fragrecptr.p->maxp + fragrecptr.p->p) + 1) & ((1 << fragrecptr.p->k) - 1);
5900 texpDirInd = ((fragrecptr.p->maxp + fragrecptr.p->p) + 1) >> fragrecptr.p->k;
5901 texpDirRangeIndex = texpDirInd >> 8;
5902 texpDirPageIndex = texpDirInd & 0xff;
5903 ptrCheckGuard(expDirRangePtr, cdirrangesize, dirRange);
5904 arrGuard(texpDirRangeIndex, 256);
5905 expDirptr.i = expDirRangePtr.p->dirArray[texpDirRangeIndex];
5906 ptrCheckGuard(expDirptr, cdirarraysize, directoryarray);
5907 excPageptr.i = expDirptr.p->pagep[texpDirPageIndex];
5908 fragrecptr.p->expSenderDirptr = expDirptr.i;
5909 fragrecptr.p->expSenderIndex = cexcPageindex;
5910 fragrecptr.p->expSenderPageptr = excPageptr.i;
5911 fragrecptr.p->expSenderDirIndex = texpDirInd;
5916 expDirRangePtr.i = fragrecptr.p->directory;
5917 texpReceivedBucket = fragrecptr.p->p >> fragrecptr.p->k;
5918 ptrCheckGuard(expDirRangePtr, cdirrangesize, dirRange);
5919 arrGuard((texpReceivedBucket >> 8), 256);
5920 expDirptr.i = expDirRangePtr.p->dirArray[texpReceivedBucket >> 8];
5921 ptrCheckGuard(expDirptr, cdirarraysize, directoryarray);
5922 fragrecptr.p->expReceivePageptr = expDirptr.p->pagep[texpReceivedBucket & 0xff];
5923 fragrecptr.p->expReceiveIndex = fragrecptr.p->p & ((1 << fragrecptr.p->k) - 1);
5924 fragrecptr.p->expReceiveForward = ZTRUE;
5925 if (excPageptr.i == RNIL) {
5927 endofshrinkbucketLab(signal);
5933 ptrCheckGuard(excPageptr, cpagesize, page8);
5934 cexcForward = ZTRUE;
5935 cexcContainerptr = (cexcPageindex << ZSHIFT_PLUS) - (cexcPageindex << ZSHIFT_MINUS);
5936 cexcContainerptr = cexcContainerptr + ZHEAD_SIZE;
5937 arrGuard(cexcContainerptr, 2048);
5938 cexcContainerhead = excPageptr.p->word32[cexcContainerptr];
5939 cexcContainerlen = cexcContainerhead >> 26;
5940 if (cexcContainerlen <= ZCON_HEAD_SIZE) {
5941 ndbrequire(cexcContainerlen == ZCON_HEAD_SIZE);
5944 shrinkcontainer(signal);
5949 if (((cexcContainerhead >> 10) & 1) == 1) {
5951 rlPageptr = excPageptr;
5952 trlPageindex = cexcPageindex;
5954 turlIndex = cexcContainerptr + (ZBUF_SIZE - ZCON_HEAD_SIZE);
5955 releaseRightlist(signal);
5957 tshrTmp1 = ZCON_HEAD_SIZE;
5958 tshrTmp1 = tshrTmp1 << 26;
5959 dbgWord32(excPageptr, cexcContainerptr, tshrTmp1);
5960 arrGuard(cexcContainerptr, 2048);
5961 excPageptr.p->word32[cexcContainerptr] = tshrTmp1;
5962 if (((cexcContainerhead >> 7) & 0x3) == 0) {
5964 endofshrinkbucketLab(signal);
5967 nextcontainerinfoExp(signal);
5969 cexcContainerptr = (cexcPageindex << ZSHIFT_PLUS) - (cexcPageindex << ZSHIFT_MINUS);
5970 if (cexcForward == ZTRUE) {
5972 cexcContainerptr = cexcContainerptr + ZHEAD_SIZE;
5975 cexcContainerptr = ((cexcContainerptr + ZHEAD_SIZE) + ZBUF_SIZE) - ZCON_HEAD_SIZE;
5977 arrGuard(cexcContainerptr, 2048);
5978 cexcContainerhead = excPageptr.p->word32[cexcContainerptr];
5979 cexcContainerlen = cexcContainerhead >> 26;
5980 ndbrequire(cexcContainerlen > ZCON_HEAD_SIZE);
5984 shrinkcontainer(signal);
5985 cexcPrevpageptr = excPageptr.i;
5986 cexcPrevpageindex = cexcPageindex;
5987 cexcPrevforward = cexcForward;
5988 if (((cexcContainerhead >> 7) & 0x3) != 0) {
5994 nextcontainerinfoExp(signal);
5996 rlPageptr.i = cexcPrevpageptr;
5997 ptrCheckGuard(rlPageptr, cpagesize, page8);
5998 trlPageindex = cexcPrevpageindex;
5999 if (cexcPrevforward == ZTRUE) {
6001 if (((cexcContainerhead >> 10) & 1) == 1) {
6004 turlIndex = cexcContainerptr + (ZBUF_SIZE - ZCON_HEAD_SIZE);
6005 releaseRightlist(signal);
6008 tullIndex = cexcContainerptr;
6009 releaseLeftlist(signal);
6012 if (((cexcContainerhead >> 10) & 1) == 1) {
6015 tullIndex = cexcContainerptr - (ZBUF_SIZE - ZCON_HEAD_SIZE);
6016 releaseLeftlist(signal);
6019 turlIndex = cexcContainerptr;
6020 releaseRightlist(signal);
6022 }
while (((cexcContainerhead >> 7) & 0x3) != 0);
6023 endofshrinkbucketLab(signal);
6027 void Dbacc::endofshrinkbucketLab(
Signal* signal)
6029 fragrecptr.p->expandCounter--;
6030 fragrecptr.p->slack -= fragrecptr.p->maxloadfactor;
6031 if (fragrecptr.p->expSenderIndex == 0) {
6033 fragrecptr.p->dirsize--;
6034 if (fragrecptr.p->expSenderPageptr != RNIL) {
6036 rpPageptr.i = fragrecptr.p->expSenderPageptr;
6037 ptrCheckGuard(rpPageptr, cpagesize, page8);
6038 releasePage(signal);
6039 expDirptr.i = fragrecptr.p->expSenderDirptr;
6040 ptrCheckGuard(expDirptr, cdirarraysize, directoryarray);
6041 expDirptr.p->pagep[fragrecptr.p->expSenderDirIndex & 0xff] = RNIL;
6043 if (((((fragrecptr.p->p + fragrecptr.p->maxp) + 1) >> fragrecptr.p->k) & 0xff) == 0) {
6045 rdDirptr.i = fragrecptr.p->expSenderDirptr;
6046 releaseDirectory(signal);
6047 expDirRangePtr.i = fragrecptr.p->directory;
6048 ptrCheckGuard(expDirRangePtr, cdirrangesize, dirRange);
6049 arrGuard((fragrecptr.p->expSenderDirIndex >> 8), 256);
6050 expDirRangePtr.p->dirArray[fragrecptr.p->expSenderDirIndex >> 8] = RNIL;
6053 if (fragrecptr.p->slack < (1u << 31)) {
6059 Uint32 noOfBuckets = (fragrecptr.p->maxp + 1) + fragrecptr.p->p;
6060 Uint32 Thysteresis = fragrecptr.p->maxloadfactor - fragrecptr.p->minloadfactor;
6061 fragrecptr.p->slackCheck = noOfBuckets * Thysteresis;
6062 if (fragrecptr.p->slack > Thysteresis) {
6070 if (fragrecptr.p->expandCounter > 0) {
6079 signal->theData[0] = fragrecptr.i;
6080 signal->theData[1] = fragrecptr.p->p;
6081 signal->theData[2] = fragrecptr.p->maxp;
6082 signal->theData[3] = fragrecptr.p->expandFlag;
6083 ndbrequire(fragrecptr.p->expandFlag < 2);
6084 fragrecptr.p->expandFlag = 2;
6085 sendSignal(cownBlockref, GSN_SHRINKCHECK2, signal, 4, JBB);
6089 ndbrequire(fragrecptr.p->maxp >= (Uint32)((1 << fragrecptr.p->k) - 1));
6103 void Dbacc::shrinkcontainer(
Signal* signal)
6105 Uint32 tshrElementptr;
6112 tshrRemLen = cexcContainerlen - ZCON_HEAD_SIZE;
6113 tshrInc = fragrecptr.p->elementLength;
6114 if (cexcForward == ZTRUE) {
6116 tshrElementptr = cexcContainerptr + ZCON_HEAD_SIZE;
6119 tshrElementptr = cexcContainerptr - 1;
6122 idrOperationRecPtr.i = RNIL;
6123 ptrNull(idrOperationRecPtr);
6129 arrGuard(tshrElementptr, 2048);
6130 tidrElemhead = excPageptr.p->word32[tshrElementptr];
6131 if (ElementHeader::getLocked(tidrElemhead)) {
6138 idrOperationRecPtr.i = ElementHeader::getOpPtrI(tidrElemhead);
6139 ptrCheckGuard(idrOperationRecPtr, coprecsize, operationrec);
6141 tshrTmp = tshrElementptr + cexcForward;
6142 guard21 = fragrecptr.p->localkeylen - 1;
6143 for (tshrIndex = 0; tshrIndex <= guard21; tshrIndex++) {
6144 arrGuard(tshrIndex, 2);
6145 arrGuard(tshrTmp, 2048);
6146 clocalkey[tshrIndex] = excPageptr.p->word32[tshrTmp];
6147 tshrTmp = tshrTmp + cexcForward;
6149 tidrPageindex = fragrecptr.p->expReceiveIndex;
6150 idrPageptr.i = fragrecptr.p->expReceivePageptr;
6151 ptrCheckGuard(idrPageptr, cpagesize, page8);
6152 tidrForward = fragrecptr.p->expReceiveForward;
6153 insertElement(signal);
6157 fragrecptr.p->expReceiveIndex = tidrPageindex;
6158 fragrecptr.p->expReceivePageptr = idrPageptr.i;
6159 fragrecptr.p->expReceiveForward = tidrForward;
6160 if (tshrRemLen < tshrInc) {
6162 sendSystemerror(signal, __LINE__);
6164 tshrRemLen = tshrRemLen - tshrInc;
6165 if (tshrRemLen != 0) {
6167 tshrElementptr = tshrTmp;
6184 void Dbacc::nextcontainerinfoExp(
Signal* signal)
6186 tnciNextSamePage = (cexcContainerhead >> 9) & 0x1;
6188 cexcPageindex = cexcContainerhead & 0x7f;
6189 if (((cexcContainerhead >> 7) & 3) == ZLEFT) {
6191 cexcForward = ZTRUE;
6192 }
else if (((cexcContainerhead >> 7) & 3) == ZRIGHT) {
6194 cexcForward = cminusOne;
6197 sendSystemerror(signal, __LINE__);
6200 if (tnciNextSamePage == ZFALSE) {
6203 arrGuard(cexcContainerptr + 1, 2048);
6204 tnciTmp = excPageptr.p->word32[cexcContainerptr + 1];
6205 nciOverflowrangeptr.i = fragrecptr.p->overflowdir;
6206 ptrCheckGuard(nciOverflowrangeptr, cdirrangesize, dirRange);
6207 arrGuard((tnciTmp >> 8), 256);
6208 nciOverflowDirptr.i = nciOverflowrangeptr.p->dirArray[tnciTmp >> 8];
6209 ptrCheckGuard(nciOverflowDirptr, cdirarraysize, directoryarray);
6210 excPageptr.i = nciOverflowDirptr.p->pagep[tnciTmp & 0xff];
6211 ptrCheckGuard(excPageptr, cpagesize, page8);
6215 void Dbacc::initFragAdd(
Signal* signal,
6216 FragmentrecPtr regFragPtr)
6219 Uint32 lhFragBits = req->lhFragBits + 1;
6220 Uint32 minLoadFactor = (req->minLoadFactor * ZBUF_SIZE) / 100;
6221 Uint32 maxLoadFactor = (req->maxLoadFactor * ZBUF_SIZE) / 100;
6222 if (minLoadFactor >= maxLoadFactor) {
6224 minLoadFactor = maxLoadFactor - 1;
6226 regFragPtr.p->fragState = ACTIVEFRAG;
6228 regFragPtr.p->myfid = req->fragId;
6229 regFragPtr.p->myTableId = req->tableId;
6230 ndbrequire(req->kValue == 6);
6231 regFragPtr.p->k = req->kValue;
6232 regFragPtr.p->expandCounter = 0;
6240 regFragPtr.p->expandFlag = 0;
6241 regFragPtr.p->p = 0;
6242 regFragPtr.p->maxp = (1 << req->kValue) - 1;
6243 regFragPtr.p->minloadfactor = minLoadFactor;
6244 regFragPtr.p->maxloadfactor = maxLoadFactor;
6245 regFragPtr.p->slack = (regFragPtr.p->maxp + 1) * maxLoadFactor;
6246 regFragPtr.p->lhfragbits = lhFragBits;
6247 regFragPtr.p->lhdirbits = 0;
6248 regFragPtr.p->hashcheckbit = 0;
6249 regFragPtr.p->localkeylen = req->localKeyLen;
6250 regFragPtr.p->nodetype = (req->reqInfo >> 4) & 0x3;
6251 regFragPtr.p->lastOverIndex = 0;
6252 regFragPtr.p->dirsize = 1;
6253 regFragPtr.p->keyLength = req->keyLength;
6254 ndbrequire(req->keyLength != 0);
6255 regFragPtr.p->elementLength = ZELEM_HEAD_SIZE + regFragPtr.p->localkeylen;
6256 Uint32 Tmp1 = (regFragPtr.p->maxp + 1) + regFragPtr.p->p;
6257 Uint32 Tmp2 = regFragPtr.p->maxloadfactor - regFragPtr.p->minloadfactor;
6259 regFragPtr.p->slackCheck = Tmp2;
6260 regFragPtr.p->mytabptr = req->tableId;
6261 regFragPtr.p->roothashcheck = req->kValue + req->lhFragBits;
6262 regFragPtr.p->noOfElements = 0;
6263 regFragPtr.p->m_commit_count = 0;
6264 for (Uint32
i = 0;
i < MAX_PARALLEL_SCANS_PER_FRAG;
i++) {
6265 regFragPtr.p->scan[
i] = RNIL;
6268 Uint32 hasCharAttr = g_key_descriptor_pool.getPtr(req->tableId)->hasCharAttr;
6269 regFragPtr.p->hasCharAttr = hasCharAttr;
6272 void Dbacc::initFragGeneral(FragmentrecPtr regFragPtr)
6274 regFragPtr.p->directory = RNIL;
6275 regFragPtr.p->overflowdir = RNIL;
6276 regFragPtr.p->firstOverflowRec = RNIL;
6277 regFragPtr.p->lastOverflowRec = RNIL;
6278 regFragPtr.p->lockOwnersList = RNIL;
6279 regFragPtr.p->firstFreeDirindexRec = RNIL;
6281 regFragPtr.p->activeDataPage = 0;
6282 regFragPtr.p->hasCharAttr = ZFALSE;
6283 regFragPtr.p->dirRangeFull = ZFALSE;
6284 regFragPtr.p->nextAllocPage = 0;
6285 regFragPtr.p->fragState = FREEFRAG;
6290 Dbacc::releaseLogicalPage(Fragmentrec * fragP, Uint32 logicalPageId){
6292 dirRangePtr.i = fragP->directory;
6293 ptrCheckGuard(dirRangePtr, cdirrangesize, dirRange);
6295 const Uint32 lp1 = logicalPageId >> 8;
6296 const Uint32 lp2 = logicalPageId & 0xFF;
6297 ndbrequire(lp1 < 256);
6300 dirArrPtr.i = dirRangePtr.p->dirArray[lp1];
6301 ptrCheckGuard(dirArrPtr, cdirarraysize, directoryarray);
6303 const Uint32 physicalPageId = dirArrPtr.p->pagep[lp2];
6305 rpPageptr.i = physicalPageId;
6306 ptrCheckGuard(rpPageptr, cpagesize, page8);
6309 dirArrPtr.p->pagep[lp2] = RNIL;
6312 void Dbacc::execACC_SCANREQ(
Signal* signal)
6316 tuserptr = req->senderData;
6317 tuserblockref = req->senderRef;
6318 tabptr.i = req->tableId;
6319 tfid = req->fragmentNo;
6320 tscanFlag = req->requestInfo;
6321 tscanTrid1 = req->transId1;
6322 tscanTrid2 = req->transId2;
6325 ptrCheckGuard(tabptr, ctablesize, tabrec);
6326 ndbrequire(getfragmentrec(signal, fragrecptr, tfid));
6329 for (i = 0; i < MAX_PARALLEL_SCANS_PER_FRAG; i++) {
6331 if (fragrecptr.p->scan[i] == RNIL) {
6336 ndbrequire(i != MAX_PARALLEL_SCANS_PER_FRAG);
6337 ndbrequire(cfirstFreeScanRec != RNIL);
6338 seizeScanRec(signal);
6340 fragrecptr.p->scan[
i] = scanPtr.i;
6341 scanPtr.p->scanBucketState = ScanRec::FIRST_LAP;
6342 scanPtr.p->scanLockMode = AccScanReq::getLockMode(tscanFlag);
6343 scanPtr.p->scanReadCommittedFlag = AccScanReq::getReadCommittedFlag(tscanFlag);
6348 scanPtr.p->scanMask = 1 <<
i;
6349 scanPtr.p->scanUserptr = tuserptr;
6350 scanPtr.p->scanUserblockref = tuserblockref;
6351 scanPtr.p->scanTrid1 = tscanTrid1;
6352 scanPtr.p->scanTrid2 = tscanTrid2;
6353 scanPtr.p->scanLockHeld = 0;
6354 scanPtr.p->scanOpsAllocated = 0;
6355 scanPtr.p->scanFirstActiveOp = RNIL;
6356 scanPtr.p->scanFirstQueuedOp = RNIL;
6357 scanPtr.p->scanLastQueuedOp = RNIL;
6358 scanPtr.p->scanFirstLockedOp = RNIL;
6359 scanPtr.p->scanLastLockedOp = RNIL;
6360 scanPtr.p->scanState = ScanRec::WAIT_NEXT;
6361 initScanFragmentPart(signal);
6366 signal->theData[0] = scanPtr.p->scanUserptr;
6367 signal->theData[1] = scanPtr.i;
6368 signal->theData[2] = 1;
6369 signal->theData[3] = fragrecptr.p->fragmentid;
6370 signal->theData[4] = RNIL;
6371 signal->theData[7] = AccScanConf::ZNOT_EMPTY_FRAGMENT;
6372 sendSignal(scanPtr.p->scanUserblockref, GSN_ACC_SCANCONF, signal, 8, JBB);
6381 void Dbacc::execNEXT_SCANREQ(
Signal* signal)
6383 Uint32 tscanNextFlag;
6385 scanPtr.i = signal->theData[0];
6386 operationRecPtr.i = signal->theData[1];
6387 tscanNextFlag = signal->theData[2];
6398 ptrCheckGuard(scanPtr, cscanRecSize, scanRec);
6399 ndbrequire(scanPtr.p->scanState == ScanRec::WAIT_NEXT);
6401 switch (tscanNextFlag) {
6402 case NextScanReq::ZSCAN_NEXT:
6406 case NextScanReq::ZSCAN_NEXT_COMMIT:
6407 case NextScanReq::ZSCAN_COMMIT:
6413 ptrCheckGuard(operationRecPtr, coprecsize, operationrec);
6414 fragrecptr.i = operationRecPtr.p->fragptr;
6415 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
6416 if (!scanPtr.p->scanReadCommittedFlag) {
6417 commitOperation(signal);
6419 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
6420 takeOutActiveScanOp(signal);
6421 releaseOpRec(signal);
6422 scanPtr.p->scanOpsAllocated--;
6423 if (tscanNextFlag == NextScanReq::ZSCAN_COMMIT) {
6425 signal->theData[0] = scanPtr.p->scanUserptr;
6426 Uint32 blockNo = refToMain(scanPtr.p->scanUserblockref);
6431 case NextScanReq::ZSCAN_CLOSE:
6433 fragrecptr.i = scanPtr.p->activeLocalFrag;
6434 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
6439 releaseScanLab(signal);
6446 signal->theData[0] = scanPtr.i;
6447 signal->theData[1] = AccCheckScan::ZNOT_CHECK_LCP_STOP;
6448 execACC_CHECK_SCAN(signal);
6452 void Dbacc::checkNextBucketLab(
Signal* signal)
6454 DirRangePtr cscDirRangePtr;
6455 DirectoryarrayPtr cscDirptr;
6456 DirectoryarrayPtr tnsDirptr;
6458 Page8Ptr cscPageidptr;
6459 Page8Ptr gnsPageidptr;
6460 Page8Ptr tnsPageidptr;
6461 Uint32 tnsElementptr;
6462 Uint32 tnsContainerptr;
6466 Uint32 tnsCopyIndex1;
6467 Uint32 tnsCopyIndex2;
6470 tnsCopyDir = scanPtr.p->nextBucketIndex >> fragrecptr.p->k;
6471 tnsCopyIndex1 = tnsCopyDir >> 8;
6472 tnsCopyIndex2 = tnsCopyDir & 0xff;
6473 arrGuard(tnsCopyIndex1, 256);
6474 tnsDirptr.i = gnsDirRangePtr.p->dirArray[tnsCopyIndex1];
6475 ptrCheckGuard(tnsDirptr, cdirarraysize, directoryarray);
6476 tnsPageidptr.i = tnsDirptr.p->pagep[tnsCopyIndex2];
6477 ptrCheckGuard(tnsPageidptr, cpagesize, page8);
6478 gnsPageidptr.i = tnsPageidptr.i;
6479 gnsPageidptr.p = tnsPageidptr.p;
6480 tnsTmp1 = (1 << fragrecptr.p->k) - 1;
6481 tgsePageindex = scanPtr.p->nextBucketIndex & tnsTmp1;
6482 gsePageidptr.i = gnsPageidptr.i;
6483 gsePageidptr.p = gnsPageidptr.p;
6484 if (!getScanElement(signal)) {
6485 scanPtr.p->nextBucketIndex++;
6486 if (scanPtr.p->scanBucketState == ScanRec::SECOND_LAP) {
6487 if (scanPtr.p->nextBucketIndex > scanPtr.p->maxBucketIndexToRescan) {
6493 checkNextFragmentLab(signal);
6496 }
else if (scanPtr.p->scanBucketState == ScanRec::FIRST_LAP) {
6497 if ((fragrecptr.p->p + fragrecptr.p->maxp) < scanPtr.p->nextBucketIndex) {
6501 if (scanPtr.p->minBucketIndexToRescan == 0xFFFFFFFF) {
6508 checkNextFragmentLab(signal);
6517 scanPtr.p->nextBucketIndex = scanPtr.p->minBucketIndexToRescan;
6518 scanPtr.p->scanBucketState = ScanRec::SECOND_LAP;
6519 if (scanPtr.p->maxBucketIndexToRescan > (fragrecptr.p->p + fragrecptr.p->maxp)) {
6527 if (scanPtr.p->minBucketIndexToRescan != 0) {
6529 sendSystemerror(signal, __LINE__);
6532 scanPtr.p->maxBucketIndexToRescan = fragrecptr.p->p + fragrecptr.p->maxp;
6537 if ((scanPtr.p->scanBucketState == ScanRec::FIRST_LAP) &&
6538 (scanPtr.p->nextBucketIndex <= scanPtr.p->startNoOfBuckets)) {
6543 tnsTmp2 = (1 << fragrecptr.p->k) - 1;
6544 trsbPageindex = scanPtr.p->nextBucketIndex & tnsTmp2;
6545 if (trsbPageindex != 0) {
6547 rsbPageidptr.i = gnsPageidptr.i;
6548 rsbPageidptr.p = gnsPageidptr.p;
6551 cscDirRangePtr.i = fragrecptr.p->directory;
6552 tmpP = scanPtr.p->nextBucketIndex >> fragrecptr.p->k;
6555 ptrCheckGuard(cscDirRangePtr, cdirrangesize, dirRange);
6556 arrGuard(tmpP2, 256);
6557 cscDirptr.i = cscDirRangePtr.p->dirArray[tmpP2];
6558 ptrCheckGuard(cscDirptr, cdirarraysize, directoryarray);
6559 cscPageidptr.i = cscDirptr.p->pagep[tmpP];
6560 ptrCheckGuard(cscPageidptr, cpagesize, page8);
6561 tmp1 = (1 << fragrecptr.p->k) - 1;
6562 trsbPageindex = scanPtr.p->nextBucketIndex & tmp1;
6563 rsbPageidptr.i = cscPageidptr.i;
6564 rsbPageidptr.p = cscPageidptr.p;
6566 releaseScanBucket(signal);
6568 signal->theData[0] = scanPtr.i;
6569 signal->theData[1] = AccCheckScan::ZCHECK_LCP_STOP;
6570 sendSignal(cownBlockref, GSN_ACC_CHECK_SCAN, signal, 2, JBB);
6579 tnsIsLocked = tgseIsLocked;
6580 tnsElementptr = tgseElementptr;
6581 tnsContainerptr = tgseContainerptr;
6582 nsPageptr.i = gsePageidptr.i;
6583 nsPageptr.p = gsePageidptr.p;
6585 tisoIsforward = tgseIsforward;
6586 tisoContainerptr = tnsContainerptr;
6587 tisoElementptr = tnsElementptr;
6588 isoPageptr.i = nsPageptr.i;
6589 isoPageptr.p = nsPageptr.p;
6590 initScanOpRec(signal);
6593 if (!scanPtr.p->scanReadCommittedFlag) {
6595 slPageidptr = nsPageptr;
6596 tslElementptr = tnsElementptr;
6598 insertLockOwnersList(signal, operationRecPtr);
6599 operationRecPtr.p->m_op_bits |=
6600 Operationrec::OP_STATE_RUNNING | Operationrec::OP_RUN_QUEUE;
6603 arrGuard(tnsElementptr, 2048);
6605 ElementHeader::getOpPtrI(nsPageptr.p->word32[tnsElementptr]);
6606 ptrCheckGuard(queOperPtr, coprecsize, operationrec);
6607 if (queOperPtr.p->m_op_bits & Operationrec::OP_ELEMENT_DISAPPEARED ||
6608 Local_key::isInvalid(queOperPtr.p->localdata[0],
6609 queOperPtr.p->localdata[1]))
6616 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
6617 releaseOpRec(signal);
6618 scanPtr.p->scanOpsAllocated--;
6619 signal->theData[0] = scanPtr.i;
6620 signal->theData[1] = AccCheckScan::ZCHECK_LCP_STOP;
6621 sendSignal(cownBlockref, GSN_ACC_CHECK_SCAN, signal, 2, JBB);
6624 if (!scanPtr.p->scanReadCommittedFlag) {
6625 Uint32 return_result;
6626 if (scanPtr.p->scanLockMode == ZREADLOCK) {
6628 return_result = placeReadInLockQueue(queOperPtr);
6631 return_result = placeWriteInLockQueue(queOperPtr);
6633 if (return_result == ZSERIAL_QUEUE) {
6639 signal->theData[0] = scanPtr.i;
6640 signal->theData[1] = AccCheckScan::ZCHECK_LCP_STOP;
6641 sendSignal(cownBlockref, GSN_ACC_CHECK_SCAN, signal, 2, JBB);
6643 }
else if (return_result != ZPARALLEL_QUEUE) {
6650 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
6651 releaseOpRec(signal);
6652 scanPtr.p->scanOpsAllocated--;
6653 signal->theData[0] = scanPtr.i;
6654 signal->theData[1] = AccCheckScan::ZCHECK_LCP_STOP;
6655 sendSignal(cownBlockref, GSN_ACC_CHECK_SCAN, signal, 2, JBB);
6658 ndbassert(return_result == ZPARALLEL_QUEUE);
6666 putActiveScanOp(signal);
6667 sendNextScanConf(signal);
6672 void Dbacc::checkNextFragmentLab(
Signal* signal)
6674 scanPtr.p->scanBucketState = ScanRec::SCAN_COMPLETED;
6678 signal->theData[0] = scanPtr.i;
6679 signal->theData[1] = AccCheckScan::ZCHECK_LCP_STOP;
6680 execACC_CHECK_SCAN(signal);
6684 void Dbacc::initScanFragmentPart(
Signal* signal)
6686 DirRangePtr cnfDirRangePtr;
6687 DirectoryarrayPtr cnfDirptr;
6688 Page8Ptr cnfPageidptr;
6698 scanPtr.p->activeLocalFrag = fragrecptr.i;
6699 scanPtr.p->nextBucketIndex = 0;
6700 scanPtr.p->scanBucketState = ScanRec::FIRST_LAP;
6701 scanPtr.p->startNoOfBuckets = fragrecptr.p->p + fragrecptr.p->maxp;
6702 scanPtr.p->minBucketIndexToRescan = 0xFFFFFFFF;
6703 scanPtr.p->maxBucketIndexToRescan = 0;
6704 cnfDirRangePtr.i = fragrecptr.p->directory;
6705 ptrCheckGuard(cnfDirRangePtr, cdirrangesize, dirRange);
6706 cnfDirptr.i = cnfDirRangePtr.p->dirArray[0];
6707 ptrCheckGuard(cnfDirptr, cdirarraysize, directoryarray);
6708 cnfPageidptr.i = cnfDirptr.p->pagep[0];
6709 ptrCheckGuard(cnfPageidptr, cpagesize, page8);
6710 trsbPageindex = scanPtr.p->nextBucketIndex & ((1 << fragrecptr.p->k) - 1);
6711 rsbPageidptr.i = cnfPageidptr.i;
6712 rsbPageidptr.p = cnfPageidptr.p;
6713 releaseScanBucket(signal);
6721 void Dbacc::releaseScanLab(
Signal* signal)
6723 releaseAndCommitActiveOps(signal);
6724 releaseAndCommitQueuedOps(signal);
6725 releaseAndAbortLockedOps(signal);
6727 fragrecptr.i = scanPtr.p->activeLocalFrag;
6728 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
6729 for (tmp = 0; tmp < MAX_PARALLEL_SCANS_PER_FRAG; tmp++) {
6731 if (fragrecptr.p->scan[tmp] == scanPtr.i) {
6733 fragrecptr.p->scan[tmp] = RNIL;
6737 signal->theData[0] = scanPtr.p->scanUserptr;
6738 signal->theData[1] = RNIL;
6739 signal->theData[2] = RNIL;
6740 sendSignal(scanPtr.p->scanUserblockref, GSN_NEXT_SCANCONF, signal, 3, JBB);
6741 releaseScanRec(signal);
6746 void Dbacc::releaseAndCommitActiveOps(
Signal* signal)
6748 OperationrecPtr trsoOperPtr;
6749 operationRecPtr.i = scanPtr.p->scanFirstActiveOp;
6750 while (operationRecPtr.i != RNIL) {
6752 ptrCheckGuard(operationRecPtr, coprecsize, operationrec);
6753 trsoOperPtr.i = operationRecPtr.p->nextOp;
6754 fragrecptr.i = operationRecPtr.p->fragptr;
6755 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
6756 if (!scanPtr.p->scanReadCommittedFlag) {
6758 if ((operationRecPtr.p->m_op_bits & Operationrec::OP_STATE_MASK) ==
6759 Operationrec::OP_STATE_EXECUTED)
6761 commitOperation(signal);
6765 abortOperation(signal);
6768 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
6769 takeOutActiveScanOp(signal);
6770 releaseOpRec(signal);
6771 scanPtr.p->scanOpsAllocated--;
6772 operationRecPtr.i = trsoOperPtr.i;
6777 void Dbacc::releaseAndCommitQueuedOps(
Signal* signal)
6779 OperationrecPtr trsoOperPtr;
6780 operationRecPtr.i = scanPtr.p->scanFirstQueuedOp;
6781 while (operationRecPtr.i != RNIL) {
6783 ptrCheckGuard(operationRecPtr, coprecsize, operationrec);
6784 trsoOperPtr.i = operationRecPtr.p->nextOp;
6785 fragrecptr.i = operationRecPtr.p->fragptr;
6786 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
6787 if (!scanPtr.p->scanReadCommittedFlag) {
6789 if ((operationRecPtr.p->m_op_bits & Operationrec::OP_STATE_MASK) ==
6790 Operationrec::OP_STATE_EXECUTED)
6792 commitOperation(signal);
6796 abortOperation(signal);
6799 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
6800 takeOutReadyScanQueue(signal);
6801 releaseOpRec(signal);
6802 scanPtr.p->scanOpsAllocated--;
6803 operationRecPtr.i = trsoOperPtr.i;
6807 void Dbacc::releaseAndAbortLockedOps(
Signal* signal) {
6809 OperationrecPtr trsoOperPtr;
6810 operationRecPtr.i = scanPtr.p->scanFirstLockedOp;
6811 while (operationRecPtr.i != RNIL) {
6813 ptrCheckGuard(operationRecPtr, coprecsize, operationrec);
6814 trsoOperPtr.i = operationRecPtr.p->nextOp;
6815 fragrecptr.i = operationRecPtr.p->fragptr;
6816 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
6817 if (!scanPtr.p->scanReadCommittedFlag) {
6819 abortOperation(signal);
6821 takeOutScanLockQueue(scanPtr.i);
6822 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
6823 releaseOpRec(signal);
6824 scanPtr.p->scanOpsAllocated--;
6825 operationRecPtr.i = trsoOperPtr.i;
6838 void Dbacc::execACC_CHECK_SCAN(
Signal* signal)
6840 Uint32 TcheckLcpStop;
6842 scanPtr.i = signal->theData[0];
6843 TcheckLcpStop = signal->theData[1];
6844 ptrCheckGuard(scanPtr, cscanRecSize, scanRec);
6845 while (scanPtr.p->scanFirstQueuedOp != RNIL) {
6852 operationRecPtr.i = scanPtr.p->scanFirstQueuedOp;
6853 ptrCheckGuard(operationRecPtr, coprecsize, operationrec);
6854 takeOutReadyScanQueue(signal);
6855 fragrecptr.i = operationRecPtr.p->fragptr;
6856 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
6857 if (operationRecPtr.p->m_op_bits & Operationrec::OP_ELEMENT_DISAPPEARED)
6860 abortOperation(signal);
6861 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
6862 releaseOpRec(signal);
6863 scanPtr.p->scanOpsAllocated--;
6866 putActiveScanOp(signal);
6867 sendNextScanConf(signal);
6872 if ((scanPtr.p->scanBucketState == ScanRec::SCAN_COMPLETED) &&
6873 (scanPtr.p->scanLockHeld == 0)) {
6879 signal->theData[0] = scanPtr.p->scanUserptr;
6880 signal->theData[1] = RNIL;
6881 signal->theData[2] = RNIL;
6882 sendSignal(scanPtr.p->scanUserblockref, GSN_NEXT_SCANCONF, signal, 3, JBB);
6885 if (TcheckLcpStop == AccCheckScan::ZCHECK_LCP_STOP) {
6892 signal->theData[0] = scanPtr.p->scanUserptr;
6893 signal->theData[1] =
6894 ((scanPtr.p->scanLockHeld >= ZSCAN_MAX_LOCK) ||
6895 (scanPtr.p->scanBucketState == ScanRec::SCAN_COMPLETED));
6898 if (signal->theData[0] == RNIL) {
6908 if ((scanPtr.p->scanLockHeld >= ZSCAN_MAX_LOCK) ||
6909 (cfreeopRec == RNIL) ||
6910 ((scanPtr.p->scanBucketState == ScanRec::SCAN_COMPLETED) &&
6911 (scanPtr.p->scanLockHeld > 0))) {
6913 signal->theData[0] = scanPtr.p->scanUserptr;
6914 signal->theData[1] = RNIL;
6915 signal->theData[2] = 512;
6916 sendSignal(scanPtr.p->scanUserblockref, GSN_NEXT_SCANCONF, signal, 3, JBB);
6919 if (scanPtr.p->scanBucketState == ScanRec::SCAN_COMPLETED) {
6921 signal->theData[0] = scanPtr.i;
6922 signal->theData[1] = AccCheckScan::ZCHECK_LCP_STOP;
6923 execACC_CHECK_SCAN(signal);
6927 fragrecptr.i = scanPtr.p->activeLocalFrag;
6928 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
6929 gnsDirRangePtr.i = fragrecptr.p->directory;
6930 ptrCheckGuard(gnsDirRangePtr, cdirrangesize, dirRange);
6931 checkNextBucketLab(signal);
6939 void Dbacc::execACC_TO_REQ(
Signal* signal)
6941 OperationrecPtr tatrOpPtr;
6944 tatrOpPtr.i = signal->theData[1];
6945 ptrCheckGuard(tatrOpPtr, coprecsize, operationrec);
6946 if ((tatrOpPtr.p->m_op_bits & Operationrec::OP_MASK) == ZSCAN_OP)
6948 tatrOpPtr.p->transId1 = signal->theData[2];
6949 tatrOpPtr.p->transId2 = signal->theData[3];
6950 validate_lock_queue(tatrOpPtr);
6953 signal->theData[0] = cminusOne;
6954 signal->theData[1] = ZTO_OP_STATE_ERROR;
6974 void Dbacc::containerinfo(
Signal* signal)
6976 tciContainerptr = (tciPageindex << ZSHIFT_PLUS) - (tciPageindex << ZSHIFT_MINUS);
6977 if (tciIsforward == ZTRUE) {
6979 tciContainerptr = tciContainerptr + ZHEAD_SIZE;
6982 tciContainerptr = ((tciContainerptr + ZHEAD_SIZE) + ZBUF_SIZE) - ZCON_HEAD_SIZE;
6984 arrGuard(tciContainerptr, 2048);
6985 tciContainerhead = ciPageidptr.p->word32[tciContainerptr];
6986 tciContainerlen = tciContainerhead >> 26;
6997 bool Dbacc::getScanElement(
Signal* signal)
6999 tgseIsforward = ZTRUE;
7000 NEXTSEARCH_SCAN_LOOP:
7001 ciPageidptr.i = gsePageidptr.i;
7002 ciPageidptr.p = gsePageidptr.p;
7003 tciPageindex = tgsePageindex;
7004 tciIsforward = tgseIsforward;
7005 containerinfo(signal);
7006 sscPageidptr.i = gsePageidptr.i;
7007 sscPageidptr.p = gsePageidptr.p;
7008 tsscContainerlen = tciContainerlen;
7009 tsscContainerptr = tciContainerptr;
7010 tsscIsforward = tciIsforward;
7011 if (searchScanContainer(signal)) {
7013 tgseIsLocked = tsscIsLocked;
7014 tgseElementptr = tsscElementptr;
7015 tgseContainerptr = tsscContainerptr;
7018 if (((tciContainerhead >> 7) & 0x3) != 0) {
7020 nciPageidptr.i = gsePageidptr.i;
7021 nciPageidptr.p = gsePageidptr.p;
7022 tnciContainerhead = tciContainerhead;
7023 tnciContainerptr = tciContainerptr;
7024 nextcontainerinfo(signal);
7025 tgsePageindex = tnciPageindex;
7026 gsePageidptr.i = nciPageidptr.i;
7027 gsePageidptr.p = nciPageidptr.p;
7028 tgseIsforward = tnciIsforward;
7029 goto NEXTSEARCH_SCAN_LOOP;
7037 void Dbacc::initScanOpRec(
Signal* signal)
7039 Uint32 tisoLocalPtr;
7040 Uint32 localkeylen = fragrecptr.p->localkeylen;
7042 scanPtr.p->scanOpsAllocated++;
7046 opbits |= scanPtr.p->scanLockMode ? (Uint32) Operationrec::OP_LOCK_MODE : 0;
7047 opbits |= scanPtr.p->scanLockMode ? (Uint32) Operationrec::OP_ACC_LOCK_MODE : 0;
7048 opbits |= (scanPtr.p->scanReadCommittedFlag ?
7049 (Uint32) Operationrec::OP_EXECUTED_DIRTY_READ : 0);
7050 opbits |= Operationrec::OP_COMMIT_DELETE_CHECK;
7051 operationRecPtr.p->userptr = RNIL;
7052 operationRecPtr.p->scanRecPtr = scanPtr.i;
7053 operationRecPtr.p->fid = fragrecptr.p->myfid;
7054 operationRecPtr.p->fragptr = fragrecptr.i;
7055 operationRecPtr.p->nextParallelQue = RNIL;
7056 operationRecPtr.p->prevParallelQue = RNIL;
7057 operationRecPtr.p->nextSerialQue = RNIL;
7058 operationRecPtr.p->prevSerialQue = RNIL;
7059 operationRecPtr.p->transId1 = scanPtr.p->scanTrid1;
7060 operationRecPtr.p->transId2 = scanPtr.p->scanTrid2;
7061 operationRecPtr.p->elementIsforward = tisoIsforward;
7062 operationRecPtr.p->elementContainer = tisoContainerptr;
7063 operationRecPtr.p->elementPointer = tisoElementptr;
7064 operationRecPtr.p->elementPage = isoPageptr.i;
7065 operationRecPtr.p->m_op_bits = opbits;
7066 tisoLocalPtr = tisoElementptr + tisoIsforward;
7068 arrGuard(tisoLocalPtr, 2048);
7069 Uint32 Tkey1 = isoPageptr.p->word32[tisoLocalPtr];
7070 tisoLocalPtr = tisoLocalPtr + tisoIsforward;
7071 if (localkeylen == 1)
7073 operationRecPtr.p->localdata[0] = Local_key::ref2page_id(Tkey1);
7074 operationRecPtr.p->localdata[1] = Local_key::ref2page_idx(Tkey1);
7078 arrGuard(tisoLocalPtr, 2048);
7079 operationRecPtr.p->localdata[0] = Tkey1;
7080 operationRecPtr.p->localdata[1] = isoPageptr.p->word32[tisoLocalPtr];
7082 operationRecPtr.p->tupkeylen = fragrecptr.p->keyLength;
7083 operationRecPtr.p->xfrmtupkeylen = 0;
7098 void Dbacc::nextcontainerinfo(
Signal* signal)
7100 tnciNextSamePage = (tnciContainerhead >> 9) & 0x1;
7102 tnciPageindex = tnciContainerhead & 0x7f;
7103 if (((tnciContainerhead >> 7) & 3) == ZLEFT) {
7105 tnciIsforward = ZTRUE;
7108 tnciIsforward = cminusOne;
7110 if (tnciNextSamePage == ZFALSE) {
7113 arrGuard(tnciContainerptr + 1, 2048);
7114 tnciTmp = nciPageidptr.p->word32[tnciContainerptr + 1];
7115 nciOverflowrangeptr.i = fragrecptr.p->overflowdir;
7116 ptrCheckGuard(nciOverflowrangeptr, cdirrangesize, dirRange);
7117 arrGuard((tnciTmp >> 8), 256);
7118 nciOverflowDirptr.i = nciOverflowrangeptr.p->dirArray[tnciTmp >> 8];
7119 ptrCheckGuard(nciOverflowDirptr, cdirarraysize, directoryarray);
7120 nciPageidptr.i = nciOverflowDirptr.p->pagep[tnciTmp & 0xff];
7121 ptrCheckGuard(nciPageidptr, cpagesize, page8);
7128 void Dbacc::putActiveScanOp(
Signal* signal)
7130 OperationrecPtr pasOperationRecPtr;
7131 pasOperationRecPtr.i = scanPtr.p->scanFirstActiveOp;
7132 if (pasOperationRecPtr.i != RNIL) {
7134 ptrCheckGuard(pasOperationRecPtr, coprecsize, operationrec);
7135 pasOperationRecPtr.p->prevOp = operationRecPtr.i;
7137 operationRecPtr.p->nextOp = pasOperationRecPtr.i;
7138 operationRecPtr.p->prevOp = RNIL;
7139 scanPtr.p->scanFirstActiveOp = operationRecPtr.i;
7155 void Dbacc::putOpScanLockQue()
7162 OperationrecPtr tmpOp;
7163 int numLockedOpsBefore = 0;
7164 tmpOp.i = scanPtr.p->scanFirstLockedOp;
7165 while(tmpOp.i != RNIL){
7166 numLockedOpsBefore++;
7167 ptrCheckGuard(tmpOp, coprecsize, operationrec);
7168 if (tmpOp.p->nextOp == RNIL)
7170 ndbrequire(tmpOp.i == scanPtr.p->scanLastLockedOp);
7172 tmpOp.i = tmpOp.p->nextOp;
7174 ndbrequire(numLockedOpsBefore==scanPtr.p->scanLockHeld);
7177 OperationrecPtr pslOperationRecPtr;
7179 theScanRec = *scanPtr.p;
7181 pslOperationRecPtr.i = scanPtr.p->scanLastLockedOp;
7182 operationRecPtr.p->prevOp = pslOperationRecPtr.i;
7183 operationRecPtr.p->nextOp = RNIL;
7184 if (pslOperationRecPtr.i != RNIL) {
7186 ptrCheckGuard(pslOperationRecPtr, coprecsize, operationrec);
7187 pslOperationRecPtr.p->nextOp = operationRecPtr.i;
7190 scanPtr.p->scanFirstLockedOp = operationRecPtr.i;
7192 scanPtr.p->scanLastLockedOp = operationRecPtr.i;
7193 scanPtr.p->scanLockHeld++;
7200 void Dbacc::putReadyScanQueue(
Signal* signal, Uint32 scanRecIndex)
7202 OperationrecPtr prsOperationRecPtr;
7203 ScanRecPtr TscanPtr;
7205 TscanPtr.i = scanRecIndex;
7206 ptrCheckGuard(TscanPtr, cscanRecSize, scanRec);
7208 prsOperationRecPtr.i = TscanPtr.p->scanLastQueuedOp;
7209 operationRecPtr.p->prevOp = prsOperationRecPtr.i;
7210 operationRecPtr.p->nextOp = RNIL;
7211 TscanPtr.p->scanLastQueuedOp = operationRecPtr.i;
7212 if (prsOperationRecPtr.i != RNIL) {
7214 ptrCheckGuard(prsOperationRecPtr, coprecsize, operationrec);
7215 prsOperationRecPtr.p->nextOp = operationRecPtr.i;
7218 TscanPtr.p->scanFirstQueuedOp = operationRecPtr.i;
7229 void Dbacc::releaseScanBucket(
Signal* signal)
7231 Uint32 trsbIsforward;
7233 trsbIsforward = ZTRUE;
7234 NEXTRELEASESCANLOOP:
7235 ciPageidptr.i = rsbPageidptr.i;
7236 ciPageidptr.p = rsbPageidptr.p;
7237 tciPageindex = trsbPageindex;
7238 tciIsforward = trsbIsforward;
7239 containerinfo(signal);
7240 rscPageidptr.i = rsbPageidptr.i;
7241 rscPageidptr.p = rsbPageidptr.p;
7242 trscContainerlen = tciContainerlen;
7243 trscContainerptr = tciContainerptr;
7244 trscIsforward = trsbIsforward;
7245 releaseScanContainer(signal);
7246 if (((tciContainerhead >> 7) & 0x3) != 0) {
7248 nciPageidptr.i = rsbPageidptr.i;
7249 nciPageidptr.p = rsbPageidptr.p;
7250 tnciContainerhead = tciContainerhead;
7251 tnciContainerptr = tciContainerptr;
7252 nextcontainerinfo(signal);
7253 rsbPageidptr.i = nciPageidptr.i;
7254 rsbPageidptr.p = nciPageidptr.p;
7255 trsbPageindex = tnciPageindex;
7256 trsbIsforward = tnciIsforward;
7257 goto NEXTRELEASESCANLOOP;
7272 void Dbacc::releaseScanContainer(
Signal* signal)
7274 OperationrecPtr rscOperPtr;
7275 Uint32 trscElemStep;
7276 Uint32 trscElementptr;
7277 Uint32 trscElemlens;
7280 if (trscContainerlen < 4) {
7281 if (trscContainerlen != ZCON_HEAD_SIZE) {
7283 sendSystemerror(signal, __LINE__);
7287 trscElemlens = trscContainerlen - ZCON_HEAD_SIZE;
7288 trscElemlen = fragrecptr.p->elementLength;
7289 if (trscIsforward == 1) {
7291 trscElementptr = trscContainerptr + ZCON_HEAD_SIZE;
7292 trscElemStep = trscElemlen;
7295 trscElementptr = trscContainerptr - 1;
7296 trscElemStep = 0 - trscElemlen;
7299 arrGuard(trscElementptr, 2048);
7300 const Uint32 eh = rscPageidptr.p->word32[trscElementptr];
7301 const Uint32 scanMask = scanPtr.p->scanMask;
7302 if (ElementHeader::getUnlocked(eh)) {
7304 const Uint32 tmp = ElementHeader::clearScanBit(eh, scanMask);
7305 dbgWord32(rscPageidptr, trscElementptr, tmp);
7306 rscPageidptr.p->word32[trscElementptr] = tmp;
7309 rscOperPtr.i = ElementHeader::getOpPtrI(eh);
7310 ptrCheckGuard(rscOperPtr, coprecsize, operationrec);
7311 rscOperPtr.p->scanBits &= ~scanMask;
7313 trscElemlens = trscElemlens - trscElemlen;
7314 trscElementptr = trscElementptr + trscElemStep;
7315 }
while (trscElemlens > 1);
7316 if (trscElemlens != 0) {
7318 sendSystemerror(signal, __LINE__);
7325 void Dbacc::releaseScanRec(
Signal* signal)
7329 ndbrequire(scanPtr.p->scanOpsAllocated==0);
7333 ndbrequire(scanPtr.p->scanLockHeld == 0);
7334 ndbrequire(scanPtr.p->scanFirstLockedOp == RNIL);
7335 ndbrequire(scanPtr.p->scanLastLockedOp == RNIL);
7339 ndbrequire(scanPtr.p->scanFirstActiveOp == RNIL);
7343 ndbrequire(scanPtr.p->scanFirstQueuedOp == RNIL);
7344 ndbrequire(scanPtr.p->scanLastQueuedOp == RNIL);
7347 scanPtr.p->scanNextfreerec = cfirstFreeScanRec;
7348 scanPtr.p->scanState = ScanRec::SCAN_DISCONNECT;
7349 cfirstFreeScanRec = scanPtr.i;
7366 bool Dbacc::searchScanContainer(
Signal* signal)
7368 OperationrecPtr sscOperPtr;
7369 Uint32 tsscScanBits;
7370 Uint32 tsscElemlens;
7372 Uint32 tsscElemStep;
7374 if (tsscContainerlen < 4) {
7378 tsscElemlens = tsscContainerlen - ZCON_HEAD_SIZE;
7379 tsscElemlen = fragrecptr.p->elementLength;
7381 if (tsscIsforward == 1) {
7383 tsscElementptr = tsscContainerptr + ZCON_HEAD_SIZE;
7384 tsscElemStep = tsscElemlen;
7387 tsscElementptr = tsscContainerptr - 1;
7388 tsscElemStep = 0 - tsscElemlen;
7391 arrGuard(tsscElementptr, 2048);
7392 const Uint32 eh = sscPageidptr.p->word32[tsscElementptr];
7393 tsscIsLocked = ElementHeader::getLocked(eh);
7396 tsscScanBits = ElementHeader::getScanBits(eh);
7397 if ((scanPtr.p->scanMask & tsscScanBits) == 0) {
7399 const Uint32 tmp = ElementHeader::setScanBit(eh, scanPtr.p->scanMask);
7400 dbgWord32(sscPageidptr, tsscElementptr, tmp);
7401 sscPageidptr.p->word32[tsscElementptr] = tmp;
7406 sscOperPtr.i = ElementHeader::getOpPtrI(eh);
7407 ptrCheckGuard(sscOperPtr, coprecsize, operationrec);
7408 if ((sscOperPtr.p->scanBits & scanPtr.p->scanMask) == 0) {
7410 sscOperPtr.p->scanBits |= scanPtr.p->scanMask;
7416 tsscElemlens = tsscElemlens - tsscElemlen;
7417 if (tsscElemlens > 1) {
7419 tsscElementptr = tsscElementptr + tsscElemStep;
7420 goto SCANELEMENTLOOP001;
7428 void Dbacc::sendNextScanConf(
Signal* signal)
7430 Uint32 blockNo = refToMain(scanPtr.p->scanUserblockref);
7437 signal->theData[0] = scanPtr.p->scanUserptr;
7438 signal->theData[1] = operationRecPtr.i;
7439 signal->theData[2] = operationRecPtr.p->fid;
7440 signal->theData[3] = operationRecPtr.p->localdata[0];
7441 signal->theData[4] = operationRecPtr.p->localdata[1];
7453 void Dbacc::setlock(
Signal* signal)
7457 arrGuard(tslElementptr, 2048);
7458 tselTmp1 = slPageidptr.p->word32[tslElementptr];
7459 operationRecPtr.p->scanBits = ElementHeader::getScanBits(tselTmp1);
7460 operationRecPtr.p->hashvaluePart = ElementHeader::getHashValuePart(tselTmp1);
7462 tselTmp1 = ElementHeader::setLocked(operationRecPtr.i);
7463 dbgWord32(slPageidptr, tslElementptr, tselTmp1);
7464 slPageidptr.p->word32[tslElementptr] = tselTmp1;
7472 void Dbacc::takeOutActiveScanOp(
Signal* signal)
7474 OperationrecPtr tasOperationRecPtr;
7476 if (operationRecPtr.p->prevOp != RNIL) {
7478 tasOperationRecPtr.i = operationRecPtr.p->prevOp;
7479 ptrCheckGuard(tasOperationRecPtr, coprecsize, operationrec);
7480 tasOperationRecPtr.p->nextOp = operationRecPtr.p->nextOp;
7483 scanPtr.p->scanFirstActiveOp = operationRecPtr.p->nextOp;
7485 if (operationRecPtr.p->nextOp != RNIL) {
7487 tasOperationRecPtr.i = operationRecPtr.p->nextOp;
7488 ptrCheckGuard(tasOperationRecPtr, coprecsize, operationrec);
7489 tasOperationRecPtr.p->prevOp = operationRecPtr.p->prevOp;
7503 void Dbacc::takeOutScanLockQueue(Uint32 scanRecIndex)
7505 OperationrecPtr tslOperationRecPtr;
7506 ScanRecPtr TscanPtr;
7508 TscanPtr.i = scanRecIndex;
7509 ptrCheckGuard(TscanPtr, cscanRecSize, scanRec);
7511 if (operationRecPtr.p->prevOp != RNIL) {
7513 tslOperationRecPtr.i = operationRecPtr.p->prevOp;
7514 ptrCheckGuard(tslOperationRecPtr, coprecsize, operationrec);
7515 tslOperationRecPtr.p->nextOp = operationRecPtr.p->nextOp;
7519 ndbrequire(TscanPtr.p->scanFirstLockedOp==operationRecPtr.i);
7520 TscanPtr.p->scanFirstLockedOp = operationRecPtr.p->nextOp;
7522 if (operationRecPtr.p->nextOp != RNIL) {
7524 tslOperationRecPtr.i = operationRecPtr.p->nextOp;
7525 ptrCheckGuard(tslOperationRecPtr, coprecsize, operationrec);
7526 tslOperationRecPtr.p->prevOp = operationRecPtr.p->prevOp;
7530 ndbrequire(TscanPtr.p->scanLastLockedOp==operationRecPtr.i);
7531 TscanPtr.p->scanLastLockedOp = operationRecPtr.p->prevOp;
7533 TscanPtr.p->scanLockHeld--;
7539 OperationrecPtr tmpOp;
7540 int numLockedOps = 0;
7541 tmpOp.i = TscanPtr.p->scanFirstLockedOp;
7542 while(tmpOp.i != RNIL){
7544 ptrCheckGuard(tmpOp, coprecsize, operationrec);
7545 if (tmpOp.p->nextOp == RNIL)
7547 ndbrequire(tmpOp.i == TscanPtr.p->scanLastLockedOp);
7549 tmpOp.i = tmpOp.p->nextOp;
7551 ndbrequire(numLockedOps==TscanPtr.p->scanLockHeld);
7558 void Dbacc::takeOutReadyScanQueue(
Signal* signal)
7560 OperationrecPtr trsOperationRecPtr;
7562 if (operationRecPtr.p->prevOp != RNIL) {
7564 trsOperationRecPtr.i = operationRecPtr.p->prevOp;
7565 ptrCheckGuard(trsOperationRecPtr, coprecsize, operationrec);
7566 trsOperationRecPtr.p->nextOp = operationRecPtr.p->nextOp;
7569 scanPtr.p->scanFirstQueuedOp = operationRecPtr.p->nextOp;
7571 if (operationRecPtr.p->nextOp != RNIL) {
7573 trsOperationRecPtr.i = operationRecPtr.p->nextOp;
7574 ptrCheckGuard(trsOperationRecPtr, coprecsize, operationrec);
7575 trsOperationRecPtr.p->prevOp = operationRecPtr.p->prevOp;
7578 scanPtr.p->scanLastQueuedOp = operationRecPtr.p->nextOp;
7591 bool Dbacc::getfragmentrec(
Signal* signal, FragmentrecPtr& rootPtr, Uint32 fid)
7593 for (Uint32 i = 0; i < MAX_FRAG_PER_NODE; i++) {
7595 if (tabptr.p->fragholder[i] == fid) {
7597 fragrecptr.i = tabptr.p->fragptrholder[
i];
7598 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
7611 void Dbacc::initOverpage(
Signal* signal)
7614 Uint32 tiopPrevFree;
7615 Uint32 tiopNextFree;
7617 for (tiopIndex = 0; tiopIndex <= 2047; tiopIndex++) {
7618 iopPageptr.p->word32[tiopIndex] = 0;
7620 iopPageptr.p->word32[ZPOS_OVERFLOWREC] = iopOverflowRecPtr.i;
7621 iopPageptr.p->word32[ZPOS_CHECKSUM] = 0;
7622 iopPageptr.p->word32[ZPOS_PAGE_ID] = tiopPageId;
7623 iopPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] = 0;
7624 tiopTmp = ZEMPTYLIST;
7625 tiopTmp = (tiopTmp << 16) + (tiopTmp << 23);
7626 iopPageptr.p->word32[ZPOS_EMPTY_LIST] = tiopTmp + (1 << ZPOS_PAGE_TYPE_BIT);
7630 tiopIndex = ZHEAD_SIZE + 1;
7631 iopPageptr.p->word32[tiopIndex] = ZEMPTYLIST;
7632 for (tiopPrevFree = 0; tiopPrevFree <= ZEMPTYLIST - 2; tiopPrevFree++) {
7633 tiopIndex = tiopIndex + ZBUF_SIZE;
7634 iopPageptr.p->word32[tiopIndex] = tiopPrevFree;
7639 tiopIndex = ZHEAD_SIZE;
7640 for (tiopNextFree = 1; tiopNextFree <= ZEMPTYLIST - 1; tiopNextFree++) {
7641 iopPageptr.p->word32[tiopIndex] = tiopNextFree;
7642 tiopIndex = tiopIndex + ZBUF_SIZE;
7644 iopPageptr.p->word32[tiopIndex] = ZEMPTYLIST;
7648 tiopIndex = (ZBUF_SIZE + ZHEAD_SIZE) - 1;
7649 iopPageptr.p->word32[tiopIndex] = ZEMPTYLIST;
7650 for (tiopPrevFree = 0; tiopPrevFree <= ZEMPTYLIST - 2; tiopPrevFree++) {
7651 tiopIndex = tiopIndex + ZBUF_SIZE;
7652 iopPageptr.p->word32[tiopIndex] = tiopPrevFree;
7657 tiopIndex = (ZBUF_SIZE + ZHEAD_SIZE) - 2;
7658 for (tiopNextFree = 1; tiopNextFree <= ZEMPTYLIST - 1; tiopNextFree++) {
7659 iopPageptr.p->word32[tiopIndex] = tiopNextFree;
7660 tiopIndex = tiopIndex + ZBUF_SIZE;
7662 iopPageptr.p->word32[tiopIndex] = ZEMPTYLIST;
7671 void Dbacc::initPage(
Signal* signal)
7676 Uint32 tinpPrevFree;
7677 Uint32 tinpNextFree;
7679 for (tiopIndex = 0; tiopIndex <= 2047; tiopIndex++) {
7680 inpPageptr.p->word32[tiopIndex] = 0;
7686 inpPageptr.p->word32[ZPOS_PAGE_ID] = tipPageId;
7687 tinpTmp1 = ZCON_HEAD_SIZE;
7688 tinpTmp1 = tinpTmp1 << 26;
7692 tinpIndex = ZHEAD_SIZE;
7693 for (tinpTmp = 0; tinpTmp <= ZNO_CONTAINERS - 1; tinpTmp++) {
7694 inpPageptr.p->word32[tinpIndex] = tinpTmp1;
7695 tinpIndex = tinpIndex + ZBUF_SIZE;
7709 tinpTmp = ZEMPTYLIST;
7710 tinpTmp = (tinpTmp << 16) + (tinpTmp << 23);
7711 tinpTmp = tinpTmp + (ZNO_CONTAINERS << 7);
7712 inpPageptr.p->word32[ZPOS_EMPTY_LIST] = tinpTmp;
7716 tinpIndex = (ZHEAD_SIZE + ZBUF_SIZE) - 1;
7717 inpPageptr.p->word32[tinpIndex] = ZEMPTYLIST;
7718 for (tinpPrevFree = 0; tinpPrevFree <= ZEMPTYLIST - 2; tinpPrevFree++) {
7719 tinpIndex = tinpIndex + ZBUF_SIZE;
7720 inpPageptr.p->word32[tinpIndex] = tinpPrevFree;
7725 tinpIndex = (ZHEAD_SIZE + ZBUF_SIZE) - 2;
7726 for (tinpNextFree = 1; tinpNextFree <= ZEMPTYLIST - 1; tinpNextFree++) {
7727 inpPageptr.p->word32[tinpIndex] = tinpNextFree;
7728 tinpIndex = tinpIndex + ZBUF_SIZE;
7730 inpPageptr.p->word32[tinpIndex] = ZEMPTYLIST;
7736 tinpIndex = (ZNO_CONTAINERS * ZBUF_SIZE) + ZHEAD_SIZE;
7737 for (tinpNextFree = ZNO_CONTAINERS + 1; tinpNextFree <= ZEMPTYLIST - 1; tinpNextFree++) {
7738 inpPageptr.p->word32[tinpIndex] = tinpNextFree;
7739 tinpIndex = tinpIndex + ZBUF_SIZE;
7741 inpPageptr.p->word32[tinpIndex] = ZEMPTYLIST;
7747 tinpIndex = ((ZNO_CONTAINERS * ZBUF_SIZE) + ZHEAD_SIZE) + 1;
7748 inpPageptr.p->word32[tinpIndex] = ZEMPTYLIST;
7749 for (tinpPrevFree = ZNO_CONTAINERS; tinpPrevFree <= ZEMPTYLIST - 2; tinpPrevFree++) {
7750 tinpIndex = tinpIndex + ZBUF_SIZE;
7751 inpPageptr.p->word32[tinpIndex] = tinpPrevFree;
7757 inpPageptr.p->word32[ZPOS_CHECKSUM] = 0;
7758 inpPageptr.p->word32[ZPOS_ALLOC_CONTAINERS] = 0;
7759 inpPageptr.p->word32[ZPOS_OVERFLOWREC] = RNIL;
7768 void Dbacc::putOverflowRecInFrag(
Signal* signal)
7770 OverflowRecordPtr tpifNextOverrecPtr;
7771 OverflowRecordPtr tpifPrevOverrecPtr;
7773 tpifNextOverrecPtr.i = fragrecptr.p->firstOverflowRec;
7774 LINT_INIT(tpifPrevOverrecPtr.p);
7775 tpifPrevOverrecPtr.i = RNIL;
7776 while (tpifNextOverrecPtr.i != RNIL) {
7777 ptrCheckGuard(tpifNextOverrecPtr, coverflowrecsize, overflowRecord);
7778 if (tpifNextOverrecPtr.p->dirindex < porOverflowRecPtr.p->dirindex) {
7786 tpifPrevOverrecPtr = tpifNextOverrecPtr;
7787 tpifNextOverrecPtr.i = tpifNextOverrecPtr.p->nextOverRec;
7790 ndbrequire(tpifNextOverrecPtr.p->dirindex != porOverflowRecPtr.p->dirindex);
7797 if (tpifNextOverrecPtr.i == RNIL) {
7799 fragrecptr.p->lastOverflowRec = porOverflowRecPtr.i;
7802 tpifNextOverrecPtr.p->prevOverRec = porOverflowRecPtr.i;
7804 if (tpifPrevOverrecPtr.i == RNIL) {
7806 fragrecptr.p->firstOverflowRec = porOverflowRecPtr.i;
7809 tpifPrevOverrecPtr.p->nextOverRec = porOverflowRecPtr.i;
7811 porOverflowRecPtr.p->prevOverRec = tpifPrevOverrecPtr.i;
7812 porOverflowRecPtr.p->nextOverRec = tpifNextOverrecPtr.i;
7818 void Dbacc::putRecInFreeOverdir(
Signal* signal)
7820 OverflowRecordPtr tpfoNextOverrecPtr;
7821 OverflowRecordPtr tpfoPrevOverrecPtr;
7823 tpfoNextOverrecPtr.i = fragrecptr.p->firstFreeDirindexRec;
7824 LINT_INIT(tpfoPrevOverrecPtr.p);
7825 tpfoPrevOverrecPtr.i = RNIL;
7826 while (tpfoNextOverrecPtr.i != RNIL) {
7827 ptrCheckGuard(tpfoNextOverrecPtr, coverflowrecsize, overflowRecord);
7828 if (tpfoNextOverrecPtr.p->dirindex < priOverflowRecPtr.p->dirindex) {
7836 tpfoPrevOverrecPtr = tpfoNextOverrecPtr;
7837 tpfoNextOverrecPtr.i = tpfoNextOverrecPtr.p->nextOverList;
7840 ndbrequire(tpfoNextOverrecPtr.p->dirindex != priOverflowRecPtr.p->dirindex);
7847 if (tpfoNextOverrecPtr.i != RNIL) {
7849 tpfoNextOverrecPtr.p->prevOverList = priOverflowRecPtr.i;
7851 if (tpfoPrevOverrecPtr.i == RNIL) {
7853 fragrecptr.p->firstFreeDirindexRec = priOverflowRecPtr.i;
7856 tpfoPrevOverrecPtr.p->nextOverList = priOverflowRecPtr.i;
7858 priOverflowRecPtr.p->prevOverList = tpfoPrevOverrecPtr.i;
7859 priOverflowRecPtr.p->nextOverList = tpfoNextOverrecPtr.i;
7865 void Dbacc::releaseDirectory(
Signal* signal)
7867 ptrCheckGuard(rdDirptr, cdirarraysize, directoryarray);
7868 rdDirptr.p->pagep[0] = cfirstfreedir;
7869 cfirstfreedir = rdDirptr.i;
7875 void Dbacc::releaseDirrange(
Signal* signal)
7877 ptrCheckGuard(rdDirRangePtr, cdirrangesize, dirRange);
7878 rdDirRangePtr.p->dirArray[0] = cfirstfreeDirrange;
7879 cfirstfreeDirrange = rdDirRangePtr.i;
7886 void Dbacc::releaseOpRec(
Signal* signal)
7894 OperationrecPtr opRecPtr;
7895 bool opInList =
false;
7896 opRecPtr.i = cfreeopRec;
7897 while (opRecPtr.i != RNIL){
7898 if (opRecPtr.i == operationRecPtr.i){
7902 ptrCheckGuard(opRecPtr, coprecsize, operationrec);
7903 opRecPtr.i = opRecPtr.p->nextOp;
7905 ndbrequire(opInList ==
false);
7907 ndbrequire(operationRecPtr.p->m_op_bits == Operationrec::OP_INITIAL);
7909 operationRecPtr.p->nextOp = cfreeopRec;
7910 cfreeopRec = operationRecPtr.i;
7911 operationRecPtr.p->prevOp = RNIL;
7912 operationRecPtr.p->m_op_bits = Operationrec::OP_INITIAL;
7919 void Dbacc::releaseOverflowRec(
Signal* signal)
7921 rorOverflowRecPtr.p->nextfreeoverrec = cfirstfreeoverrec;
7922 cfirstfreeoverrec = rorOverflowRecPtr.i;
7928 void Dbacc::releaseOverpage(
Signal* signal)
7930 DirRangePtr ropOverflowrangeptr;
7931 DirectoryarrayPtr ropOverflowDirptr;
7932 OverflowRecordPtr ropOverflowRecPtr;
7933 OverflowRecordPtr tuodOverflowRecPtr;
7938 ropOverflowRecPtr.i = ropPageptr.p->word32[ZPOS_OVERFLOWREC];
7939 ndbrequire(ropOverflowRecPtr.i != RNIL);
7944 if ((fragrecptr.p->lastOverflowRec == ropOverflowRecPtr.i) &&
7945 (fragrecptr.p->firstOverflowRec == ropOverflowRecPtr.i)) {
7952 i = fragrecptr.p->directory;
7953 p = dirRange.getPtr(i);
7955 i1 = logicalPage >> 8;
7956 i2 = logicalPage & 0xFF;
7958 ndbrequire(i1 < 256);
7960 i = p->dirArray[i1];
7961 p = directoryarray.getPtr(i);
7963 physicPageId = p->pagep[i2];
7964 physicPageP = page8.getPtr(physicPageId);
7966 p->pagep[i2] = RNIL;
7967 rpPageptr = { physicPageId, physicPageP };
7968 releasePage(signal);
7975 ptrCheckGuard(ropOverflowRecPtr, coverflowrecsize, overflowRecord);
7976 tfoOverflowRecPtr = ropOverflowRecPtr;
7977 takeRecOutOfFreeOverpage(signal);
7978 ropOverflowRecPtr.p->overpage = RNIL;
7979 priOverflowRecPtr = ropOverflowRecPtr;
7980 putRecInFreeOverdir(signal);
7981 tropTmp = ropPageptr.p->word32[ZPOS_PAGE_ID];
7982 ropOverflowrangeptr.i = fragrecptr.p->overflowdir;
7983 tropTmp1 = tropTmp >> 8;
7984 tropTmp2 = tropTmp & 0xff;
7985 ptrCheckGuard(ropOverflowrangeptr, cdirrangesize, dirRange);
7986 arrGuard(tropTmp1, 256);
7987 ropOverflowDirptr.i = ropOverflowrangeptr.p->dirArray[tropTmp1];
7988 ptrCheckGuard(ropOverflowDirptr, cdirarraysize, directoryarray);
7989 ropOverflowDirptr.p->pagep[tropTmp2] = RNIL;
7990 rpPageptr = ropPageptr;
7991 releasePage(signal);
7992 if (ropOverflowRecPtr.p->dirindex != (fragrecptr.p->lastOverIndex - 1)) {
8001 fragrecptr.p->lastOverIndex--;
8002 if (tropTmp2 == 0) {
8004 ndbrequire(tropTmp1 != 0);
8005 ropOverflowrangeptr.p->dirArray[tropTmp1] = RNIL;
8006 rdDirptr.i = ropOverflowDirptr.i;
8007 releaseDirectory(signal);
8014 ropOverflowDirptr.i = ropOverflowrangeptr.p->dirArray[tropTmp1];
8015 ptrCheckGuard(ropOverflowDirptr, cdirarraysize, directoryarray);
8016 }
while (ropOverflowDirptr.p->pagep[tropTmp2] == RNIL);
8021 tuodOverflowRecPtr.i = fragrecptr.p->firstFreeDirindexRec;
8023 while (tuodOverflowRecPtr.i != RNIL) {
8025 ptrCheckGuard(tuodOverflowRecPtr, coverflowrecsize, overflowRecord);
8026 if (tuodOverflowRecPtr.p->dirindex >= fragrecptr.p->lastOverIndex) {
8028 rorOverflowRecPtr = tuodOverflowRecPtr;
8029 troOverflowRecPtr.p = tuodOverflowRecPtr.p;
8030 tuodOverflowRecPtr.i = troOverflowRecPtr.p->nextOverList;
8031 takeRecOutOfFreeOverdir(signal);
8032 releaseOverflowRec(signal);
8035 tuodOverflowRecPtr.i = tuodOverflowRecPtr.p->nextOverList;
8041 extern Uint32 g_acc_pages_used[MAX_NDBMT_LQH_WORKERS];
8046 void Dbacc::releasePage(
Signal* signal)
8049 bool inList =
false;
8050 Uint32 numInList = 0;
8051 Page8Ptr tmpPagePtr;
8052 tmpPagePtr.i = cfirstfreepage;
8053 while (tmpPagePtr.i != RNIL){
8054 ptrCheckGuard(tmpPagePtr, cpagesize, page8);
8055 if (tmpPagePtr.i == rpPageptr.i){
8056 jam(); inList =
true;
8060 tmpPagePtr.i = tmpPagePtr.p->word32[0];
8062 ndbrequire(inList ==
false);
8065 rpPageptr.p->word32[0] = cfirstfreepage;
8066 cfirstfreepage = rpPageptr.i;
8067 cnoOfAllocatedPages--;
8069 g_acc_pages_used[instance()] = cnoOfAllocatedPages;
8080 void Dbacc::seizeDirectory(
Signal* signal)
8084 if (cfirstfreedir == RNIL) {
8086 if (cdirarraysize <= cdirmemory) {
8088 tresult = ZDIRSIZE_ERROR;
8092 sdDirptr.i = cdirmemory;
8093 ptrCheckGuard(sdDirptr, cdirarraysize, directoryarray);
8094 cdirmemory = cdirmemory + 1;
8098 sdDirptr.i = cfirstfreedir;
8099 ptrCheckGuard(sdDirptr, cdirarraysize, directoryarray);
8100 cfirstfreedir = sdDirptr.p->pagep[0];
8101 sdDirptr.p->pagep[0] = RNIL;
8103 for (tsdyIndex = 0; tsdyIndex <= 255; tsdyIndex++) {
8104 sdDirptr.p->pagep[tsdyIndex] = RNIL;
8111 void Dbacc::seizeDirrange(
Signal* signal)
8115 newDirRangePtr.i = cfirstfreeDirrange;
8116 ptrCheckGuard(newDirRangePtr, cdirrangesize, dirRange);
8117 cfirstfreeDirrange = newDirRangePtr.p->dirArray[0];
8118 for (tsdeIndex = 0; tsdeIndex <= 255; tsdeIndex++) {
8119 newDirRangePtr.p->dirArray[tsdeIndex] = RNIL;
8126 void Dbacc::seizeFragrec(
Signal* signal)
8128 RSS_OP_ALLOC(cnoOfFreeFragrec);
8129 fragrecptr.i = cfirstfreefrag;
8130 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
8131 cfirstfreefrag = fragrecptr.p->nextfreefrag;
8132 fragrecptr.p->nextfreefrag = RNIL;
8138 void Dbacc::seizeOpRec(
Signal* signal)
8140 operationRecPtr.i = cfreeopRec;
8141 ptrCheckGuard(operationRecPtr, coprecsize, operationrec);
8142 cfreeopRec = operationRecPtr.p->nextOp;
8145 operationRecPtr.p->nextOp = RNIL;
8151 void Dbacc::seizeOverRec(
Signal* signal) {
8152 sorOverflowRecPtr.i = cfirstfreeoverrec;
8153 ptrCheckGuard(sorOverflowRecPtr, coverflowrecsize, overflowRecord);
8154 cfirstfreeoverrec = sorOverflowRecPtr.p->nextfreeoverrec;
8155 sorOverflowRecPtr.p->nextfreeoverrec = RNIL;
8156 sorOverflowRecPtr.p->prevOverRec = RNIL;
8157 sorOverflowRecPtr.p->nextOverRec = RNIL;
8165 void Dbacc::zpagesize_error(
const char* where){
8167 <<
" ZPAGESIZE_ERROR" << endl
8168 <<
" cfirstfreepage=" << cfirstfreepage << endl
8169 <<
" cpagesize=" <<cpagesize<<endl
8170 <<
" cnoOfAllocatedPages="<<cnoOfAllocatedPages);
8177 void Dbacc::seizePage(
Signal* signal)
8180 if (cfirstfreepage == RNIL)
8183 zpagesize_error(
"Dbacc::seizePage");
8184 tresult = ZPAGESIZE_ERROR;
8189 spPageptr.i = cfirstfreepage;
8190 ptrCheckGuard(spPageptr, cpagesize, page8);
8191 cfirstfreepage = spPageptr.p->word32[0];
8192 cnoOfAllocatedPages++;
8194 if (cnoOfAllocatedPages > cnoOfAllocatedPagesMax)
8195 cnoOfAllocatedPagesMax = cnoOfAllocatedPages;
8197 g_acc_pages_used[instance()] = cnoOfAllocatedPages;
8210 void Dbacc::seizeScanRec(
Signal* signal)
8212 scanPtr.i = cfirstFreeScanRec;
8213 ptrCheckGuard(scanPtr, cscanRecSize, scanRec);
8214 ndbrequire(scanPtr.p->scanState == ScanRec::SCAN_DISCONNECT);
8215 cfirstFreeScanRec = scanPtr.p->scanNextfreerec;
8224 void Dbacc::sendSystemerror(
Signal* signal,
int line)
8232 void Dbacc::takeRecOutOfFreeOverdir(
Signal* signal)
8234 OverflowRecordPtr tofoOverrecPtr;
8235 if (troOverflowRecPtr.p->nextOverList != RNIL) {
8237 tofoOverrecPtr.i = troOverflowRecPtr.p->nextOverList;
8238 ptrCheckGuard(tofoOverrecPtr, coverflowrecsize, overflowRecord);
8239 tofoOverrecPtr.p->prevOverList = troOverflowRecPtr.p->prevOverList;
8241 if (troOverflowRecPtr.p->prevOverList != RNIL) {
8243 tofoOverrecPtr.i = troOverflowRecPtr.p->prevOverList;
8244 ptrCheckGuard(tofoOverrecPtr, coverflowrecsize, overflowRecord);
8245 tofoOverrecPtr.p->nextOverList = troOverflowRecPtr.p->nextOverList;
8248 fragrecptr.p->firstFreeDirindexRec = troOverflowRecPtr.p->nextOverList;
8258 void Dbacc::takeRecOutOfFreeOverpage(
Signal* signal)
8260 OverflowRecordPtr tfoNextOverflowRecPtr;
8261 OverflowRecordPtr tfoPrevOverflowRecPtr;
8263 if (tfoOverflowRecPtr.p->nextOverRec != RNIL) {
8265 tfoNextOverflowRecPtr.i = tfoOverflowRecPtr.p->nextOverRec;
8266 ptrCheckGuard(tfoNextOverflowRecPtr, coverflowrecsize, overflowRecord);
8267 tfoNextOverflowRecPtr.p->prevOverRec = tfoOverflowRecPtr.p->prevOverRec;
8269 ndbrequire(fragrecptr.p->lastOverflowRec == tfoOverflowRecPtr.i);
8271 fragrecptr.p->lastOverflowRec = tfoOverflowRecPtr.p->prevOverRec;
8273 if (tfoOverflowRecPtr.p->prevOverRec != RNIL) {
8275 tfoPrevOverflowRecPtr.i = tfoOverflowRecPtr.p->prevOverRec;
8276 ptrCheckGuard(tfoPrevOverflowRecPtr, coverflowrecsize, overflowRecord);
8277 tfoPrevOverflowRecPtr.p->nextOverRec = tfoOverflowRecPtr.p->nextOverRec;
8279 ndbrequire(fragrecptr.p->firstOverflowRec == tfoOverflowRecPtr.i);
8281 fragrecptr.p->firstOverflowRec = tfoOverflowRecPtr.p->nextOverRec;
8286 void Dbacc::execDBINFO_SCANREQ(
Signal *signal)
8295 switch(req.tableId){
8296 case Ndbinfo::POOLS_TABLEID:
8303 cnoOfAllocatedPages,
8306 cnoOfAllocatedPagesMax,
8307 { CFG_DB_INDEX_MEM,0,0,0 }},
8308 { NULL, 0,0,0,0,{ 0,0,0,0 }}
8311 static const size_t num_config_params =
8312 sizeof(pools[0].config_params)/
sizeof(pools[0].config_params[0]);
8313 Uint32 pool =
cursor->data[0];
8314 BlockNumber bn = blockToMain(number());
8315 while(pools[pool].poolname)
8319 row.write_uint32(getOwnNodeId());
8320 row.write_uint32(bn);
8321 row.write_uint32(instance());
8322 row.write_string(pools[pool].poolname);
8324 row.write_uint64(pools[pool].used);
8325 row.write_uint64(pools[pool].total);
8326 row.write_uint64(pools[pool].used_hi);
8327 row.write_uint64(pools[pool].entry_size);
8328 for (
size_t i = 0; i < num_config_params; i++)
8329 row.write_uint32(pools[pool].config_params[i]);
8330 ndbinfo_send_row(signal, req, row, rl);
8332 if (rl.need_break(req))
8335 ndbinfo_send_scan_break(signal, req, rl, pool);
8344 ndbinfo_send_scan_conf(signal, req, rl);
8348 Dbacc::execDUMP_STATE_ORD(
Signal* signal)
8351 if (dumpState->args[0] == DumpStateOrd::AccDumpOneScanRec){
8352 Uint32 recordNo = RNIL;
8353 if (signal->
length() == 2)
8354 recordNo = dumpState->args[1];
8358 if (recordNo >= cscanRecSize)
8361 scanPtr.i = recordNo;
8362 ptrAss(scanPtr, scanRec);
8363 infoEvent(
"Dbacc::ScanRec[%d]: state=%d, transid(0x%x, 0x%x)",
8364 scanPtr.i, scanPtr.p->scanState,scanPtr.p->scanTrid1,
8365 scanPtr.p->scanTrid2);
8366 infoEvent(
" activeLocalFrag=%d, nextBucketIndex=%d",
8367 scanPtr.p->activeLocalFrag,
8368 scanPtr.p->nextBucketIndex);
8369 infoEvent(
" scanNextfreerec=%d firstActOp=%d firstLockedOp=%d, "
8370 "scanLastLockedOp=%d firstQOp=%d lastQOp=%d",
8371 scanPtr.p->scanNextfreerec,
8372 scanPtr.p->scanFirstActiveOp,
8373 scanPtr.p->scanFirstLockedOp,
8374 scanPtr.p->scanLastLockedOp,
8375 scanPtr.p->scanFirstQueuedOp,
8376 scanPtr.p->scanLastQueuedOp);
8377 infoEvent(
" scanUserP=%d, startNoBuck=%d, minBucketIndexToRescan=%d, "
8378 "maxBucketIndexToRescan=%d",
8379 scanPtr.p->scanUserptr,
8380 scanPtr.p->startNoOfBuckets,
8381 scanPtr.p->minBucketIndexToRescan,
8382 scanPtr.p->maxBucketIndexToRescan);
8383 infoEvent(
" scanBucketState=%d, scanLockHeld=%d, userBlockRef=%d, "
8384 "scanMask=%d scanLockMode=%d",
8385 scanPtr.p->scanBucketState,
8386 scanPtr.p->scanLockHeld,
8387 scanPtr.p->scanUserblockref,
8388 scanPtr.p->scanMask,
8389 scanPtr.p->scanLockMode);
8394 if (dumpState->args[0] == DumpStateOrd::AccDumpAllScanRec){
8395 Uint32 recordNo = 0;
8396 if (signal->
length() == 1)
8397 infoEvent(
"ACC: Dump all ScanRec - size: %d",
8399 else if (signal->
length() == 2)
8400 recordNo = dumpState->args[1];
8404 dumpState->args[0] = DumpStateOrd::AccDumpOneScanRec;
8405 dumpState->args[1] = recordNo;
8406 execDUMP_STATE_ORD(signal);
8408 if (recordNo < cscanRecSize-1){
8409 dumpState->args[0] = DumpStateOrd::AccDumpAllScanRec;
8410 dumpState->args[1] = recordNo+1;
8411 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 2, JBB);
8417 if (dumpState->args[0] == DumpStateOrd::AccDumpAllActiveScanRec){
8418 Uint32 recordNo = 0;
8419 if (signal->
length() == 1)
8420 infoEvent(
"ACC: Dump active ScanRec - size: %d",
8422 else if (signal->
length() == 2)
8423 recordNo = dumpState->args[1];
8429 ptrAss(sp, scanRec);
8430 if (sp.p->scanState != ScanRec::SCAN_DISCONNECT){
8431 dumpState->args[0] = DumpStateOrd::AccDumpOneScanRec;
8432 dumpState->args[1] = recordNo;
8433 execDUMP_STATE_ORD(signal);
8436 if (recordNo < cscanRecSize-1){
8437 dumpState->args[0] = DumpStateOrd::AccDumpAllActiveScanRec;
8438 dumpState->args[1] = recordNo+1;
8439 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 2, JBB);
8444 if(dumpState->args[0] == DumpStateOrd::EnableUndoDelayDataWrite){
8445 ndbout <<
"Dbacc:: delay write of datapages for table = "
8446 << dumpState->args[1]<< endl;
8447 c_errorInsert3000_TableId = dumpState->args[1];
8448 SET_ERROR_INSERT_VALUE(3000);
8452 if(dumpState->args[0] == DumpStateOrd::AccDumpOneOperationRec){
8453 Uint32 recordNo = RNIL;
8454 if (signal->
length() == 2)
8455 recordNo = dumpState->args[1];
8459 if (recordNo >= coprecsize)
8462 OperationrecPtr tmpOpPtr;
8463 tmpOpPtr.i = recordNo;
8464 ptrAss(tmpOpPtr, operationrec);
8465 infoEvent(
"Dbacc::operationrec[%d]: transid(0x%x, 0x%x)",
8466 tmpOpPtr.i, tmpOpPtr.p->transId1,
8467 tmpOpPtr.p->transId2);
8468 infoEvent(
"elementIsforward=%d, elementPage=%d, elementPointer=%d ",
8469 tmpOpPtr.p->elementIsforward, tmpOpPtr.p->elementPage,
8470 tmpOpPtr.p->elementPointer);
8471 infoEvent(
"fid=%d, fragptr=%d, hashvaluePart=%d ",
8472 tmpOpPtr.p->fid, tmpOpPtr.p->fragptr,
8473 tmpOpPtr.p->hashvaluePart);
8474 infoEvent(
"hashValue=%d", tmpOpPtr.p->hashValue);
8475 infoEvent(
"nextLockOwnerOp=%d, nextOp=%d, nextParallelQue=%d ",
8476 tmpOpPtr.p->nextLockOwnerOp, tmpOpPtr.p->nextOp,
8477 tmpOpPtr.p->nextParallelQue);
8478 infoEvent(
"nextSerialQue=%d, prevOp=%d ",
8479 tmpOpPtr.p->nextSerialQue,
8480 tmpOpPtr.p->prevOp);
8481 infoEvent(
"prevLockOwnerOp=%d, prevParallelQue=%d",
8482 tmpOpPtr.p->prevLockOwnerOp, tmpOpPtr.p->nextParallelQue);
8483 infoEvent(
"prevSerialQue=%d, scanRecPtr=%d",
8484 tmpOpPtr.p->prevSerialQue, tmpOpPtr.p->scanRecPtr);
8485 infoEvent(
"m_op_bits=0x%x, scanBits=%d ",
8486 tmpOpPtr.p->m_op_bits, tmpOpPtr.p->scanBits);
8490 if(dumpState->args[0] == DumpStateOrd::AccDumpNumOpRecs){
8492 Uint32 freeOpRecs = 0;
8493 OperationrecPtr opRecPtr;
8494 opRecPtr.i = cfreeopRec;
8495 while (opRecPtr.i != RNIL){
8497 ptrCheckGuard(opRecPtr, coprecsize, operationrec);
8498 opRecPtr.i = opRecPtr.p->nextOp;
8501 infoEvent(
"Dbacc::OperationRecords: num=%d, free=%d",
8502 coprecsize, freeOpRecs);
8506 if(dumpState->args[0] == DumpStateOrd::AccDumpFreeOpRecs){
8508 OperationrecPtr opRecPtr;
8509 opRecPtr.i = cfreeopRec;
8510 while (opRecPtr.i != RNIL){
8512 dumpState->args[0] = DumpStateOrd::AccDumpOneOperationRec;
8513 dumpState->args[1] = opRecPtr.i;
8514 execDUMP_STATE_ORD(signal);
8516 ptrCheckGuard(opRecPtr, coprecsize, operationrec);
8517 opRecPtr.i = opRecPtr.p->nextOp;
8524 if(dumpState->args[0] == DumpStateOrd::AccDumpNotFreeOpRecs){
8525 Uint32 recordStart = RNIL;
8526 if (signal->
length() == 2)
8527 recordStart = dumpState->args[1];
8531 if (recordStart >= coprecsize)
8534 for (Uint32 i = recordStart; i < coprecsize; i++){
8536 bool inFreeList =
false;
8537 OperationrecPtr opRecPtr;
8538 opRecPtr.i = cfreeopRec;
8539 while (opRecPtr.i != RNIL){
8540 if (opRecPtr.i == i){
8544 ptrCheckGuard(opRecPtr, coprecsize, operationrec);
8545 opRecPtr.i = opRecPtr.p->nextOp;
8547 if (inFreeList ==
false){
8548 dumpState->args[0] = DumpStateOrd::AccDumpOneOperationRec;
8549 dumpState->args[1] =
i;
8550 execDUMP_STATE_ORD(signal);
8559 req->primaryTableId = 2;
8560 req->secondaryTableId = RNIL;
8562 req->userRef = DBDICT_REF;
8563 sendSignal(cownBlockref, GSN_REL_TABMEMREQ, signal,
8564 RelTabMemReq::SignalLength, JBB);
8569 req->primaryTableId = 4;
8570 req->secondaryTableId = 5;
8572 req->userRef = DBDICT_REF;
8573 sendSignal(cownBlockref, GSN_REL_TABMEMREQ, signal,
8574 RelTabMemReq::SignalLength, JBB);
8579 req->primaryTableId = 6;
8580 req->secondaryTableId = 8;
8582 req->userRef = DBDICT_REF;
8583 sendSignal(cownBlockref, GSN_REL_TABMEMREQ, signal,
8584 RelTabMemReq::SignalLength, JBB);
8589 req->primaryTableId = 2;
8590 req->secondaryTableId = RNIL;
8592 req->userRef = DBDICT_REF;
8593 sendSignal(cownBlockref, GSN_DROP_TABFILEREQ, signal,
8594 DropTabFileReq::SignalLength, JBB);
8599 req->primaryTableId = 4;
8600 req->secondaryTableId = 5;
8602 req->userRef = DBDICT_REF;
8603 sendSignal(cownBlockref, GSN_DROP_TABFILEREQ, signal,
8604 DropTabFileReq::SignalLength, JBB);
8609 req->primaryTableId = 6;
8610 req->secondaryTableId = 8;
8612 req->userRef = DBDICT_REF;
8613 sendSignal(cownBlockref, GSN_DROP_TABFILEREQ, signal,
8614 DropTabFileReq::SignalLength, JBB);
8619 if (signal->theData[0] == DumpStateOrd::SchemaResourceSnapshot)
8621 RSS_OP_SNAPSHOT_SAVE(cnoOfFreeFragrec);
8625 if (signal->theData[0] == DumpStateOrd::SchemaResourceCheckLeak)
8627 RSS_OP_SNAPSHOT_CHECK(cnoOfFreeFragrec);
8633 Dbacc::execREAD_PSEUDO_REQ(
Signal* signal){
8635 fragrecptr.i = signal->theData[0];
8636 Uint32 attrId = signal->theData[1];
8637 ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec);
8640 case AttributeHeader::ROW_COUNT:
8641 tmp = fragrecptr.p->noOfElements;
8643 case AttributeHeader::COMMIT_COUNT:
8644 tmp = fragrecptr.p->m_commit_count;
8649 memcpy(signal->theData, &tmp, 8);
8660 Dbacc::debug_lh_vars(
const char* where)
8662 Uint32 b = fragrecptr.p->maxp + fragrecptr.p->p;
8663 Uint32 di = b >> fragrecptr.p->k;
8664 Uint32 ri = di >> 8;
8666 <<
"DBACC: " << where <<
":"
8667 <<
" frag:" << fragrecptr.p->myTableId
8668 <<
"/" << fragrecptr.p->myfid
8669 <<
" slack:" << (Int32)fragrecptr.p->slack
8670 <<
"/" << fragrecptr.p->slackCheck
8671 <<
" maxp:" << fragrecptr.p->maxp
8672 <<
" p:" << fragrecptr.p->p
8675 <<
" full:" << fragrecptr.p->dirRangeFull