21 #include "md5_hash.hpp"
22 #include <RefConvert.hpp>
23 #include <ndb_limits.h>
26 #include <signaldata/DiGetNodes.hpp>
27 #include <signaldata/EventReport.hpp>
28 #include <signaldata/TcKeyReq.hpp>
29 #include <signaldata/TcKeyConf.hpp>
30 #include <signaldata/TcKeyRef.hpp>
31 #include <signaldata/KeyInfo.hpp>
32 #include <signaldata/AttrInfo.hpp>
33 #include <signaldata/TransIdAI.hpp>
34 #include <signaldata/TcRollbackRep.hpp>
35 #include <signaldata/NodeFailRep.hpp>
36 #include <signaldata/ReadNodesConf.hpp>
37 #include <signaldata/NFCompleteRep.hpp>
38 #include <signaldata/LqhKey.hpp>
39 #include <signaldata/TcCommit.hpp>
40 #include <signaldata/TcContinueB.hpp>
41 #include <signaldata/TcKeyFailConf.hpp>
42 #include <signaldata/AbortAll.hpp>
43 #include <signaldata/DihScanTab.hpp>
44 #include <signaldata/ScanFrag.hpp>
45 #include <signaldata/ScanTab.hpp>
46 #include <signaldata/PrepDropTab.hpp>
47 #include <signaldata/DropTab.hpp>
48 #include <signaldata/AlterTab.hpp>
49 #include <signaldata/CreateTrig.hpp>
50 #include <signaldata/CreateTrigImpl.hpp>
51 #include <signaldata/DropTrig.hpp>
52 #include <signaldata/DropTrigImpl.hpp>
53 #include <signaldata/FireTrigOrd.hpp>
54 #include <signaldata/TrigAttrInfo.hpp>
55 #include <signaldata/CreateIndx.hpp>
56 #include <signaldata/CreateIndxImpl.hpp>
57 #include <signaldata/DropIndx.hpp>
58 #include <signaldata/DropIndxImpl.hpp>
59 #include <signaldata/AlterIndx.hpp>
60 #include <signaldata/AlterIndxImpl.hpp>
61 #include <signaldata/ScanTab.hpp>
62 #include <signaldata/SystemError.hpp>
63 #include <signaldata/DumpStateOrd.hpp>
64 #include <signaldata/DisconnectRep.hpp>
65 #include <signaldata/TcHbRep.hpp>
67 #include <signaldata/PrepDropTab.hpp>
68 #include <signaldata/DropTab.hpp>
69 #include <signaldata/TcIndx.hpp>
70 #include <signaldata/IndxKeyInfo.hpp>
71 #include <signaldata/IndxAttrInfo.hpp>
72 #include <signaldata/PackedSignal.hpp>
73 #include <signaldata/SignalDroppedRep.hpp>
74 #include <AttributeHeader.hpp>
75 #include <signaldata/DictTabInfo.hpp>
76 #include <AttributeDescriptor.hpp>
77 #include <SectionReader.hpp>
78 #include <KeyDescriptor.hpp>
81 #include <DebuggerNames.hpp>
82 #include <signaldata/CheckNodeGroups.hpp>
84 #include <signaldata/RouteOrd.hpp>
85 #include <signaldata/GCP.hpp>
87 #include <signaldata/DbinfoScan.hpp>
88 #include <signaldata/TransIdAI.hpp>
89 #include <signaldata/CreateTab.hpp>
94 #define DEBUG(x) ndbout << "DBTC: "<< x << endl;
99 #define INTERNAL_TRIGGER_TCKEYREQ_JBA 0
105 case Dbtc::CS_CONNECTED: out <<
"CS_CONNECTED";
break;
106 case Dbtc::CS_DISCONNECTED: out <<
"CS_DISCONNECTED";
break;
107 case Dbtc::CS_STARTED: out <<
"CS_STARTED";
break;
108 case Dbtc::CS_RECEIVING: out <<
"CS_RECEIVING";
break;
109 case Dbtc::CS_PREPARED: out <<
"CS_PREPARED";
break;
110 case Dbtc::CS_START_PREPARING: out <<
"CS_START_PREPARING";
break;
111 case Dbtc::CS_REC_PREPARING: out <<
"CS_REC_PREPARING";
break;
112 case Dbtc::CS_RESTART: out <<
"CS_RESTART";
break;
113 case Dbtc::CS_ABORTING: out <<
"CS_ABORTING";
break;
114 case Dbtc::CS_COMPLETING: out <<
"CS_COMPLETING";
break;
115 case Dbtc::CS_COMPLETE_SENT: out <<
"CS_COMPLETE_SENT";
break;
116 case Dbtc::CS_PREPARE_TO_COMMIT: out <<
"CS_PREPARE_TO_COMMIT";
break;
117 case Dbtc::CS_COMMIT_SENT: out <<
"CS_COMMIT_SENT";
break;
118 case Dbtc::CS_START_COMMITTING: out <<
"CS_START_COMMITTING";
break;
119 case Dbtc::CS_COMMITTING: out <<
"CS_COMMITTING";
break;
120 case Dbtc::CS_REC_COMMITTING: out <<
"CS_REC_COMMITTING";
break;
121 case Dbtc::CS_WAIT_ABORT_CONF: out <<
"CS_WAIT_ABORT_CONF";
break;
122 case Dbtc::CS_WAIT_COMPLETE_CONF: out <<
"CS_WAIT_COMPLETE_CONF";
break;
123 case Dbtc::CS_WAIT_COMMIT_CONF: out <<
"CS_WAIT_COMMIT_CONF";
break;
124 case Dbtc::CS_FAIL_ABORTING: out <<
"CS_FAIL_ABORTING";
break;
125 case Dbtc::CS_FAIL_ABORTED: out <<
"CS_FAIL_ABORTED";
break;
126 case Dbtc::CS_FAIL_PREPARED: out <<
"CS_FAIL_PREPARED";
break;
127 case Dbtc::CS_FAIL_COMMITTING: out <<
"CS_FAIL_COMMITTING";
break;
128 case Dbtc::CS_FAIL_COMMITTED: out <<
"CS_FAIL_COMMITTED";
break;
129 case Dbtc::CS_FAIL_COMPLETED: out <<
"CS_FAIL_COMPLETED";
break;
130 case Dbtc::CS_START_SCAN: out <<
"CS_START_SCAN";
break;
132 out <<
"Unknown: " << (int)state;
break;
137 operator<<(NdbOut& out, Dbtc::OperationState state){
142 operator<<(NdbOut& out, Dbtc::AbortState state){
147 operator<<(NdbOut& out, Dbtc::ReturnSignal state){
163 extern int ErrorSignalReceive;
164 extern int ErrorMaxSegmentsToSeize;
167 Dbtc::updateBuddyTimer(ApiConnectRecordPtr apiPtr)
169 if (apiPtr.p->buddyPtr != RNIL) {
171 ApiConnectRecordPtr buddyApiPtr;
172 buddyApiPtr.i = apiPtr.p->buddyPtr;
173 ptrCheckGuard(buddyApiPtr, capiConnectFilesize, apiConnectRecord);
174 if (getApiConTimer(buddyApiPtr.i) != 0) {
175 if ((apiPtr.p->transid[0] == buddyApiPtr.p->transid[0]) &&
176 (apiPtr.p->transid[1] == buddyApiPtr.p->transid[1])) {
178 setApiConTimer(buddyApiPtr.i, ctcTimer, __LINE__);
182 apiPtr.p->buddyPtr = RNIL;
191 tc_testbit(Uint32
flags, Uint32 flag)
193 return (flags & flag) != 0;
199 tc_clearbit(Uint32 & flags, Uint32 flag)
201 flags &= ~(Uint32)flag;
204 void Dbtc::execCONTINUEB(
Signal* signal)
209 tcase = signal->theData[0];
210 UintR Tdata0 = signal->theData[1];
211 UintR Tdata1 = signal->theData[2];
212 UintR Tdata2 = signal->theData[3];
214 case TcContinueB::ZRETURN_FROM_QUEUED_DELIVERY:
218 case TcContinueB::ZCOMPLETE_TRANS_AT_TAKE_OVER:
220 tcNodeFailptr.i = Tdata0;
221 ptrCheckGuard(tcNodeFailptr, 1, tcFailRecord);
222 completeTransAtTakeOverLab(signal, Tdata1);
224 case TcContinueB::ZCONTINUE_TIME_OUT_CONTROL:
226 timeOutLoopStartLab(signal, Tdata0);
228 case TcContinueB::ZNODE_TAKE_OVER_COMPLETED:
232 ptrAss(tcNodeFailptr, tcFailRecord);
233 nodeTakeOverCompletedLab(signal);
235 case TcContinueB::ZINITIALISE_RECORDS:
237 initialiseRecordsLab(signal, Tdata0, Tdata2, signal->theData[4]);
239 case TcContinueB::ZSEND_COMMIT_LOOP:
241 apiConnectptr.i = Tdata0;
242 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
243 tcConnectptr.i = Tdata1;
244 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
245 commit020Lab(signal);
247 case TcContinueB::ZSEND_COMPLETE_LOOP:
249 apiConnectptr.i = Tdata0;
250 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
251 tcConnectptr.i = Tdata1;
252 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
253 complete010Lab(signal);
255 case TcContinueB::ZHANDLE_FAILED_API_NODE:
257 handleFailedApiNode(signal, Tdata0, Tdata1);
259 case TcContinueB::ZTRANS_EVENT_REP:
263 const Uint32 len = c_counters.build_event_rep(signal);
264 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, len, JBB);
268 const Uint32 report_interval = 5000;
269 const Uint32 len = c_counters.build_continueB(signal);
270 signal->theData[0] = TcContinueB::ZTRANS_EVENT_REP;
271 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, report_interval, len);
274 case TcContinueB::ZCONTINUE_TIME_OUT_FRAG_CONTROL:
276 timeOutLoopStartFragLab(signal, Tdata0);
278 case TcContinueB::ZABORT_BREAK:
280 tcConnectptr.i = Tdata0;
281 apiConnectptr.i = Tdata1;
282 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
283 apiConnectptr.p->counter--;
286 case TcContinueB::ZABORT_TIMEOUT_BREAK:
288 tcConnectptr.i = Tdata0;
289 apiConnectptr.i = Tdata1;
290 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
291 apiConnectptr.p->counter--;
292 sendAbortedAfterTimeout(signal, 1);
294 case TcContinueB::ZHANDLE_FAILED_API_NODE_REMOVE_MARKERS:
296 removeMarkerForFailedAPI(signal, Tdata0, Tdata1);
298 case TcContinueB::ZWAIT_ABORT_ALL:
300 checkAbortAllTimeout(signal, Tdata0);
302 case TcContinueB::ZCHECK_SCAN_ACTIVE_FAILED_LQH:
304 checkScanActiveInFailedLqh(signal, Tdata0, Tdata1);
306 case TcContinueB::ZNF_CHECK_TRANSACTIONS:
308 nodeFailCheckTransactions(signal, Tdata0, Tdata1);
310 case TcContinueB::TRIGGER_PENDING:
312 ApiConnectRecordPtr transPtr;
314 ptrCheckGuard(transPtr, capiConnectFilesize, apiConnectRecord);
316 if (ERROR_INSERTED(8082))
322 if (++transPtr.p->continueBCount > 100000)
329 if (likely((transPtr.p->transid[0] == Tdata1) &&
330 (transPtr.p->transid[1] == Tdata2)))
332 ndbrequire(tc_testbit(transPtr.p->m_flags,
333 ApiConnectRecord::TF_TRIGGER_PENDING));
334 tc_clearbit(transPtr.p->m_flags, ApiConnectRecord::TF_TRIGGER_PENDING);
336 executeTriggers(signal, &transPtr);
339 case TcContinueB::DelayTCKEYCONF:
341 apiConnectptr.i = Tdata0;
342 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
343 sendtckeyconf(signal, Tdata1);
345 case TcContinueB::ZSEND_FIRE_TRIG_REQ:
347 apiConnectptr.i = Tdata0;
348 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
349 if (unlikely(! (apiConnectptr.p->transid[0] == Tdata1 &&
350 apiConnectptr.p->transid[1] == Tdata2 &&
353 warningReport(signal, 29);
356 sendFireTrigReq(signal, apiConnectptr, signal->theData[4]);
363 void Dbtc::execDIGETNODESREF(
Signal* signal)
366 terrorCode = signal->theData[1];
367 releaseAtErrorLab(signal);
370 void Dbtc::execINCL_NODEREQ(
Signal* signal)
373 tblockref = signal->theData[0];
374 hostptr.i = signal->theData[1];
375 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
376 hostptr.p->hostStatus = HS_ALIVE;
377 c_alive_nodes.
set(hostptr.i);
379 signal->theData[0] = hostptr.i;
380 signal->theData[1] = cownref;
382 if (ERROR_INSERTED(8039))
384 CLEAR_ERROR_INSERT_VALUE;
385 Uint32 save = signal->theData[0];
386 signal->theData[0] = 9999;
387 sendSignal(numberToRef(CMVMI, hostptr.i),
388 GSN_NDB_TAMPER, signal, 1, JBB);
389 signal->theData[0] = save;
390 sendSignalWithDelay(tblockref, GSN_INCL_NODECONF, signal, 5000, 2);
394 Uint32 Tnode = hostptr.i;
399 hostptr.p->hostLqhBlockRef = numberToRef(DBLQH, 1, Tnode);
404 hostptr.p->hostLqhBlockRef = numberToRef(DBLQH, Tnode);
407 sendSignal(tblockref, GSN_INCL_NODECONF, signal, 2, JBB);
409 if (m_deferred_enabled)
412 if (!ndbd_deferred_unique_constraints(
getNodeInfo(Tnode).m_version))
415 m_deferred_enabled = 0;
420 void Dbtc::execREAD_NODESREF(
Signal* signal)
427 void Dbtc::execTC_SCHVERREQ(
Signal* signal)
435 tabptr.i = req->tableId;
436 ptrCheckGuard(tabptr, ctabrecFilesize, tableRecord);
437 tabptr.p->currentSchemaVersion = req->tableVersion;
438 tabptr.p->m_flags = 0;
439 tabptr.p->set_storedTable((
bool)req->tableLogged);
440 BlockReference retRef = req->senderRef;
441 tabptr.p->tableType = (Uint8)req->tableType;
442 BlockReference retPtr = req->senderData;
443 Uint32 noOfKeyAttr = req->noOfPrimaryKeys;
444 tabptr.p->singleUserMode = (Uint8)req->singleUserMode;
445 Uint32 userDefinedPartitioning = (Uint8)req->userDefinedPartition;
446 ndbrequire(noOfKeyAttr <= MAX_ATTRIBUTES_IN_INDEX);
448 const KeyDescriptor* desc = g_key_descriptor_pool.getPtr(tabptr.i);
449 ndbrequire(noOfKeyAttr == desc->noOfKeyAttr);
451 ndbrequire(tabptr.p->get_prepared() ==
false);
452 ndbrequire(tabptr.p->get_enabled() ==
false);
453 tabptr.p->set_prepared(
true);
454 tabptr.p->set_enabled(
false);
455 tabptr.p->set_dropping(
false);
456 tabptr.p->noOfKeyAttr = desc->noOfKeyAttr;
457 tabptr.p->hasCharAttr = desc->hasCharAttr;
458 tabptr.p->noOfDistrKeys = desc->noOfDistrKeys;
459 tabptr.p->hasVarKeys = desc->noOfVarKeys > 0;
460 tabptr.p->set_user_defined_partitioning(userDefinedPartitioning);
463 conf->senderRef = reference();
464 conf->senderData = retPtr;
465 sendSignal(retRef, GSN_TC_SCHVERCONF, signal,
466 TcSchVerConf::SignalLength, JBB);
470 void Dbtc::execTAB_COMMITREQ(
Signal* signal)
473 Uint32 senderData = signal->theData[0];
474 Uint32 senderRef = signal->theData[1];
475 tabptr.i = signal->theData[2];
476 ptrCheckGuard(tabptr, ctabrecFilesize, tableRecord);
478 ndbrequire(tabptr.p->get_prepared() ==
true);
479 ndbrequire(tabptr.p->get_enabled() ==
false);
480 tabptr.p->set_enabled(
true);
481 tabptr.p->set_prepared(
false);
482 tabptr.p->set_dropping(
false);
484 signal->theData[0] = senderData;
485 signal->theData[1] = reference();
486 signal->theData[2] = tabptr.i;
487 sendSignal(senderRef, GSN_TAB_COMMITCONF, signal, 3, JBB);
491 Dbtc::execPREP_DROP_TAB_REQ(
Signal* signal)
497 TableRecordPtr tabPtr;
498 tabPtr.i = req->tableId;
499 ptrCheckGuard(tabPtr, ctabrecFilesize, tableRecord);
501 Uint32 senderRef = req->senderRef;
502 Uint32 senderData = req->senderData;
504 if(!tabPtr.p->get_enabled())
508 ref->senderRef = reference();
509 ref->senderData = senderData;
510 ref->tableId = tabPtr.i;
511 ref->errorCode = PrepDropTabRef::NoSuchTable;
512 sendSignal(senderRef, GSN_PREP_DROP_TAB_REF, signal,
513 PrepDropTabRef::SignalLength, JBB);
517 if(tabPtr.p->get_dropping())
521 ref->senderRef = reference();
522 ref->senderData = senderData;
523 ref->tableId = tabPtr.i;
524 ref->errorCode = PrepDropTabRef::DropInProgress;
525 sendSignal(senderRef, GSN_PREP_DROP_TAB_REF, signal,
526 PrepDropTabRef::SignalLength, JBB);
530 tabPtr.p->set_dropping(
true);
531 tabPtr.p->set_prepared(
false);
534 conf->tableId = tabPtr.i;
535 conf->senderRef = reference();
536 conf->senderData = senderData;
537 sendSignal(senderRef, GSN_PREP_DROP_TAB_CONF, signal,
538 PrepDropTabConf::SignalLength, JBB);
542 Dbtc::execDROP_TAB_REQ(
Signal* signal)
548 TableRecordPtr tabPtr;
549 tabPtr.i = req->tableId;
550 ptrCheckGuard(tabPtr, ctabrecFilesize, tableRecord);
552 Uint32 senderRef = req->senderRef;
553 Uint32 senderData = req->senderData;
554 DropTabReq::RequestType rt = (DropTabReq::RequestType)req->requestType;
556 if(!tabPtr.p->get_enabled() && rt == DropTabReq::OnlineDropTab){
559 ref->senderRef = reference();
560 ref->senderData = senderData;
561 ref->tableId = tabPtr.i;
562 ref->errorCode = DropTabRef::NoSuchTable;
563 sendSignal(senderRef, GSN_DROP_TAB_REF, signal,
564 DropTabRef::SignalLength, JBB);
568 if(!tabPtr.p->get_dropping() && rt == DropTabReq::OnlineDropTab){
571 ref->senderRef = reference();
572 ref->senderData = senderData;
573 ref->tableId = tabPtr.i;
574 ref->errorCode = DropTabRef::DropWoPrep;
575 sendSignal(senderRef, GSN_DROP_TAB_REF, signal,
576 DropTabRef::SignalLength, JBB);
580 tabPtr.p->set_enabled(
false);
581 tabPtr.p->set_prepared(
false);
582 tabPtr.p->set_dropping(
false);
585 conf->tableId = tabPtr.i;
586 conf->senderRef = reference();
587 conf->senderData = senderData;
588 sendSignal(senderRef, GSN_DROP_TAB_CONF, signal,
589 PrepDropTabConf::SignalLength, JBB);
592 void Dbtc::execALTER_TAB_REQ(
Signal * signal)
595 const Uint32 senderRef = req->senderRef;
596 const Uint32 senderData = req->senderData;
597 const Uint32 tableVersion = req->tableVersion;
598 const Uint32 newTableVersion = req->newTableVersion;
599 AlterTabReq::RequestType requestType =
600 (AlterTabReq::RequestType) req->requestType;
602 TableRecordPtr tabPtr;
603 tabPtr.i = req->tableId;
604 ptrCheckGuard(tabPtr, ctabrecFilesize, tableRecord);
606 switch (requestType) {
607 case AlterTabReq::AlterTablePrepare:
610 case AlterTabReq::AlterTableRevert:
612 tabPtr.p->currentSchemaVersion = tableVersion;
614 case AlterTabReq::AlterTableCommit:
616 tabPtr.p->currentSchemaVersion = newTableVersion;
625 conf->senderRef = reference();
626 conf->senderData = senderData;
627 conf->connectPtr = RNIL;
628 sendSignal(senderRef, GSN_ALTER_TAB_CONF, signal,
629 AlterTabConf::SignalLength, JBB);
635 void Dbtc::execREAD_CONFIG_REQ(
Signal* signal)
638 Uint32 ref = req->senderRef;
639 Uint32 senderData = req->senderData;
640 ndbrequire(req->noOfParameters == 0);
645 m_ctx.m_config.getOwnConfigIterator();
656 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TC_API_CONNECT, &apiConnect));
657 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TC_TC_CONNECT, &tcConnect));
658 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TC_TABLE, &tables));
659 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TC_LOCAL_SCAN, &localScan));
660 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TC_SCAN, &tcScan));
662 ccacheFilesize = (apiConnect/3) + 1;
663 capiConnectFilesize = apiConnect;
664 ctcConnectFilesize = tcConnect;
665 ctabrecFilesize = tables;
666 cscanrecFileSize = tcScan;
667 cscanFragrecFileSize = localScan;
670 initialiseRecordsLab(signal, 0, ref, senderData);
673 ndb_mgm_get_int_parameter(p, CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT, &val);
674 set_timeout_value(val);
677 ndb_mgm_get_int_parameter(p, CFG_DB_HEARTBEAT_INTERVAL, &val);
678 cDbHbInterval = (val < 10) ? 10 : val;
681 ndb_mgm_get_int_parameter(p, CFG_DB_TRANSACTION_INACTIVE_TIMEOUT, &val);
682 set_appl_timeout_value(val);
686 set_no_parallel_takeover(val);
689 ndb_mgm_get_int_parameter(p, CFG_DB_MAX_DML_OPERATIONS_PER_TRANSACTION, &val);
690 m_max_writes_per_trans = val;
692 ctimeOutCheckDelay = 50;
695 void Dbtc::execSTTOR(
Signal* signal)
701 tphase = signal->theData[1];
702 csignalKey = signal->theData[6];
703 c_sttor_ref = signal->getSendersBlockRef();
707 startphase1x010Lab(signal);
716 void Dbtc::sttorryLab(
Signal* signal)
718 signal->theData[0] = csignalKey;
719 signal->theData[1] = 3;
720 signal->theData[2] = 2;
721 signal->theData[3] = ZSPH1;
722 signal->theData[4] = 255;
723 sendSignal(c_sttor_ref, GSN_STTORRY, signal, 5, JBB);
729 void Dbtc::execNDB_STTOR(
Signal* signal)
731 Uint16 tndbstartphase;
735 tusersblkref = signal->theData[0];
736 tnodeid = signal->theData[1];
737 tndbstartphase = signal->theData[2];
738 tstarttype = signal->theData[3];
739 c_sttor_ref = signal->getSendersBlockRef();
740 switch (tndbstartphase) {
743 intstartphase1x010Lab(signal);
747 ndbsttorry010Lab(signal);
752 intstartphase3x010Lab(signal);
755 const Uint32 len = c_counters.build_continueB(signal);
756 signal->theData[0] = TcContinueB::ZTRANS_EVENT_REP;
757 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 10, len);
762 csystemStart = SSS_TRUE;
768 ndbsttorry010Lab(signal);
772 void Dbtc::ndbsttorry010Lab(
Signal* signal)
774 signal->theData[0] = cownref;
775 sendSignal(c_sttor_ref, GSN_NDB_STTORRY, signal, 1, JBB);
779 Dbtc::set_timeout_value(Uint32 timeOut)
781 timeOut = timeOut / 10;
786 ctimeOutValue = timeOut;
790 Dbtc::set_appl_timeout_value(Uint32 timeOut)
795 if (timeOut < ctimeOutValue) {
797 c_appl_timeout_value = ctimeOutValue;
800 c_appl_timeout_value = timeOut;
804 Dbtc::set_no_parallel_takeover(Uint32 noParallelTakeOver)
806 if (noParallelTakeOver == 0) {
808 noParallelTakeOver = 1;
809 }
else if (noParallelTakeOver > MAX_NDB_NODES) {
811 noParallelTakeOver = MAX_NDB_NODES;
813 cnoParallelTakeOver = noParallelTakeOver;
820 void Dbtc::startphase1x010Lab(
Signal* signal)
822 csystemStart = SSS_FALSE;
823 ctimeOutCheckCounter = 0;
824 ctimeOutCheckFragCounter = 0;
825 ctimeOutMissedHeartbeats = 0;
826 ctimeOutCheckHeartbeat = 0;
827 ctimeOutCheckLastHeartbeat = 0;
828 ctimeOutCheckActive = TOCS_FALSE;
829 ctimeOutCheckFragActive = TOCS_FALSE;
837 void Dbtc::intstartphase1x010Lab(
Signal* signal)
839 cownNodeid = tnodeid;
840 cownref = reference();
841 clqhblockref = calcLqhBlockRef(cownNodeid);
842 cdihblockref = calcDihBlockRef(cownNodeid);
843 cdictblockref = calcDictBlockRef(cownNodeid);
844 cndbcntrblockref = calcNdbCntrBlockRef(cownNodeid);
845 cerrorBlockref = calcNdbCntrBlockRef(cownNodeid);
848 ndbsttorry010Lab(signal);
855 void Dbtc::intstartphase3x010Lab(
Signal* signal)
857 signal->theData[0] = cownref;
858 sendSignal(cndbcntrblockref, GSN_READ_NODESREQ, signal, 1, JBB);
861 void Dbtc::execREAD_NODESCONF(
Signal* signal)
869 csystemnodes = readNodes->noOfNodes;
870 cmasterNodeId = readNodes->masterNodeId;
873 arrGuard(csystemnodes, MAX_NDB_NODES);
874 guard0 = csystemnodes - 1;
875 arrGuard(guard0, MAX_NDB_NODES);
877 for (
unsigned i = 1;
i < MAX_NDB_NODES;
i++) {
881 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
885 hostptr.p->hostStatus = HS_DEAD;
889 hostptr.p->hostStatus = HS_ALIVE;
890 c_alive_nodes.
set(
i);
894 hostptr.p->hostLqhBlockRef = numberToRef(DBLQH, 1,
i);
899 hostptr.p->hostLqhBlockRef = numberToRef(DBLQH,
i);
901 if (!ndbd_deferred_unique_constraints(
getNodeInfo(
i).m_version))
904 m_deferred_enabled = 0;
909 ndbsttorry010Lab(signal);
917 void Dbtc::execAPI_FAILREQ(
Signal* signal)
927 if (ERROR_INSERTED(8056))
929 CLEAR_ERROR_INSERT_VALUE;
933 if (ERROR_INSERTED(8078))
935 c_lastFailedApi = signal->theData[0];
936 SET_ERROR_INSERT_VALUE(8079);
940 capiFailRef = signal->theData[1];
941 arrGuard(signal->theData[0], MAX_NODES);
942 capiConnectClosing[signal->theData[0]] = 1;
943 handleFailedApiNode(signal, signal->theData[0], (UintR)0);
947 Dbtc::handleFailedApiNode(
Signal* signal,
948 UintR TapiFailedNode,
949 UintR TapiConnectPtr)
951 UintR TloopCount = 0;
952 arrGuard(TapiFailedNode, MAX_NODES);
953 apiConnectptr.i = TapiConnectPtr;
955 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
956 const UintR TapiNode = refToNode(apiConnectptr.p->ndbapiBlockref);
957 if (TapiNode == TapiFailedNode) {
959 if (apiConnectptr.p->apiFailState != ZFALSE) {
960 ndbout <<
"Error in previous API fail handling discovered" << endl
961 <<
" apiConnectptr.i = " << apiConnectptr.i << endl
962 <<
" apiConnectstate = " << apiConnectptr.p->apiConnectstate
964 <<
" ndbapiBlockref = " << hex
965 << apiConnectptr.p->ndbapiBlockref << endl
966 <<
" apiNode = " << refToNode(apiConnectptr.p->ndbapiBlockref)
968 if (apiConnectptr.p->lastTcConnect != RNIL){
970 tcConnectptr.i = apiConnectptr.p->lastTcConnect;
971 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
972 ndbout <<
" tcConnectptr.i = " << tcConnectptr.i << endl
973 <<
" tcConnectstate = " << tcConnectptr.p->tcConnectstate
979 apiConnectptr.p->returnsignal = RS_NO_RETURN;
983 switch(apiConnectptr.p->apiConnectstate) {
984 case CS_DISCONNECTED:
996 if (apiConnectptr.p->abortState == AS_IDLE) {
998 releaseApiCon(signal, apiConnectptr.i);
1001 capiConnectClosing[TapiFailedNode]++;
1002 apiConnectptr.p->apiFailState = ZTRUE;
1005 case CS_WAIT_ABORT_CONF:
1006 case CS_WAIT_COMMIT_CONF:
1007 case CS_START_COMMITTING:
1008 case CS_PREPARE_TO_COMMIT:
1010 case CS_COMMIT_SENT:
1019 capiConnectClosing[TapiFailedNode]++;
1020 apiConnectptr.p->apiFailState = ZTRUE;
1030 apiConnectptr.p->apiFailState = ZTRUE;
1031 capiConnectClosing[TapiFailedNode]++;
1033 ScanRecordPtr scanPtr;
1034 scanPtr.i = apiConnectptr.p->apiScanRec;
1035 ptrCheckGuard(scanPtr, cscanrecFileSize, scanRecord);
1036 close_scan_req(signal, scanPtr,
true);
1041 case CS_REC_COMMITTING:
1053 apiConnectptr.p->apiFailState = ZTRUE;
1054 capiConnectClosing[TapiFailedNode]++;
1055 abort010Lab(signal);
1060 case CS_REC_PREPARING:
1062 case CS_START_PREPARING:
1067 systemErrorLab(signal, __LINE__);
1073 case CS_COMPLETE_SENT:
1075 case CS_WAIT_COMPLETE_CONF:
1077 case CS_FAIL_ABORTING:
1079 case CS_FAIL_ABORTED:
1081 case CS_FAIL_PREPARED:
1083 case CS_FAIL_COMMITTING:
1085 case CS_FAIL_COMMITTED:
1091 systemErrorLab(signal, __LINE__);
1098 if (apiConnectptr.i > ((capiConnectFilesize / 3) - 1)) {
1105 removeMarkerForFailedAPI(signal, TapiFailedNode, 0);
1108 }
while (TloopCount++ < 256);
1109 signal->theData[0] = TcContinueB::ZHANDLE_FAILED_API_NODE;
1110 signal->theData[1] = TapiFailedNode;
1111 signal->theData[2] = apiConnectptr.i;
1112 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
1116 Dbtc::removeMarkerForFailedAPI(
Signal* signal,
1120 TcFailRecordPtr node_fail_ptr;
1121 node_fail_ptr.i = 0;
1122 ptrAss(node_fail_ptr, tcFailRecord);
1123 if(node_fail_ptr.p->failStatus != FS_IDLE) {
1125 DEBUG(
"Restarting removeMarkerForFailedAPI");
1131 signal->theData[0] = TcContinueB::ZHANDLE_FAILED_API_NODE_REMOVE_MARKERS;
1132 signal->theData[1] = nodeId;
1133 signal->theData[2] = 0;
1134 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 500, 3);
1138 CommitAckMarkerIterator iter;
1139 m_commitAckMarkerHash.
next(startBucket, iter);
1141 const Uint32 RT_BREAK = 256;
1142 for(Uint32
i = 0;
i<RT_BREAK || iter.bucket == startBucket;
i++){
1145 if(iter.curr.i == RNIL){
1150 capiConnectClosing[nodeId]--;
1151 if (capiConnectClosing[nodeId] == 0) {
1159 Callback cb = {safe_cast(&Dbtc::apiFailBlockCleanupCallback),
1166 if(iter.curr.p->apiNodeId == nodeId){
1173 ApiConnectRecordPtr apiConnectPtr;
1174 apiConnectPtr.i = iter.curr.p->apiConnectPtr;
1175 ptrCheckGuard(apiConnectPtr, capiConnectFilesize, apiConnectRecord);
1176 if(apiConnectPtr.p->commitAckMarker == iter.curr.i){
1185 sendRemoveMarkers(signal, iter.curr.p);
1186 m_commitAckMarkerHash.
release(iter.curr);
1190 m_commitAckMarkerHash.
next(iter);
1193 signal->theData[0] = TcContinueB::ZHANDLE_FAILED_API_NODE_REMOVE_MARKERS;
1194 signal->theData[1] = nodeId;
1195 signal->theData[2] = iter.bucket;
1196 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
1199 void Dbtc::handleApiFailState(
Signal* signal, UintR TapiConnectptr)
1201 ApiConnectRecordPtr TlocalApiConnectptr;
1202 UintR TfailedApiNode;
1204 TlocalApiConnectptr.i = TapiConnectptr;
1205 ptrCheckGuard(TlocalApiConnectptr, capiConnectFilesize, apiConnectRecord);
1206 TfailedApiNode = refToNode(TlocalApiConnectptr.p->ndbapiBlockref);
1207 arrGuard(TfailedApiNode, MAX_NODES);
1208 capiConnectClosing[TfailedApiNode]--;
1209 releaseApiCon(signal, TapiConnectptr);
1210 TlocalApiConnectptr.p->apiFailState = ZFALSE;
1211 if (capiConnectClosing[TfailedApiNode] == 0)
1218 Callback cb = {safe_cast(&Dbtc::apiFailBlockCleanupCallback),
1231 void Dbtc::execTCSEIZEREQ(
Signal* signal)
1234 BlockReference tapiBlockref;
1237 tapiPointer = signal->theData[0];
1238 tapiBlockref = signal->theData[1];
1240 if (signal->getLength() > 2)
1242 ndbassert(instance() == signal->theData[2]);
1248 const NodeId senderNodeId = refToNode(tapiBlockref);
1249 const bool local = senderNodeId == getOwnNodeId() || senderNodeId == 0;
1262 errCode = ZSYSTEM_NOT_STARTED_ERROR;
1271 errCode = ZCLUSTER_SHUTDOWN_IN_PROGRESS;
1273 errCode = ZNODE_SHUTDOWN_IN_PROGRESS;
1275 case NodeState::SL_SINGLEUSER:
1278 errCode = ZWRONG_STATE;
1283 signal->theData[0] = tapiPointer;
1284 signal->theData[1] = errCode;
1285 sendSignal(tapiBlockref, GSN_TCSEIZEREF, signal, 2, JBB);
1293 if (ERROR_INSERTED(8078) || ERROR_INSERTED(8079))
1296 CLEAR_ERROR_INSERT_VALUE;
1299 seizeApiConnect(signal);
1300 if (terrorCode == ZOK) {
1302 apiConnectptr.p->ndbapiConnect = tapiPointer;
1303 apiConnectptr.p->ndbapiBlockref = tapiBlockref;
1304 signal->theData[0] = apiConnectptr.p->ndbapiConnect;
1305 signal->theData[1] = apiConnectptr.i;
1306 signal->theData[2] = reference();
1307 sendSignal(tapiBlockref, GSN_TCSEIZECONF, signal, 3, JBB);
1311 signal->theData[0] = tapiPointer;
1312 signal->theData[1] = terrorCode;
1313 sendSignal(tapiBlockref, GSN_TCSEIZEREF, signal, 2, JBB);
1320 void Dbtc::execTCRELEASEREQ(
Signal* signal)
1323 BlockReference tapiBlockref;
1326 tapiPointer = signal->theData[0];
1327 tapiBlockref = signal->theData[1];
1328 tuserpointer = signal->theData[2];
1329 if (tapiPointer >= capiConnectFilesize) {
1331 signal->theData[0] = tuserpointer;
1332 signal->theData[1] = ZINVALID_CONNECTION;
1333 signal->theData[2] = __LINE__;
1334 sendSignal(tapiBlockref, GSN_TCRELEASEREF, signal, 3, JBB);
1338 apiConnectptr.i = tapiPointer;
1340 ptrAss(apiConnectptr, apiConnectRecord);
1341 if (apiConnectptr.p->apiConnectstate == CS_DISCONNECTED) {
1343 signal->theData[0] = tuserpointer;
1344 sendSignal(tapiBlockref, GSN_TCRELEASECONF, signal, 1, JBB);
1346 if (tapiBlockref == apiConnectptr.p->ndbapiBlockref) {
1347 if (apiConnectptr.p->apiConnectstate == CS_CONNECTED ||
1348 (apiConnectptr.p->apiConnectstate == CS_ABORTING &&
1349 apiConnectptr.p->abortState == AS_IDLE) ||
1350 (apiConnectptr.p->apiConnectstate == CS_STARTED &&
1351 apiConnectptr.p->firstTcConnect == RNIL))
1354 apiConnectptr.p->m_transaction_nodes.
clear();
1355 releaseApiCon(signal, apiConnectptr.i);
1356 signal->theData[0] = tuserpointer;
1357 sendSignal(tapiBlockref,
1358 GSN_TCRELEASECONF, signal, 1, JBB);
1361 signal->theData[0] = tuserpointer;
1362 signal->theData[1] = ZINVALID_CONNECTION;
1363 signal->theData[2] = __LINE__;
1364 signal->theData[3] = apiConnectptr.p->apiConnectstate;
1365 sendSignal(tapiBlockref,
1366 GSN_TCRELEASEREF, signal, 4, JBB);
1370 signal->theData[0] = tuserpointer;
1371 signal->theData[1] = ZINVALID_CONNECTION;
1372 signal->theData[2] = __LINE__;
1373 signal->theData[3] = tapiBlockref;
1374 signal->theData[4] = apiConnectptr.p->ndbapiBlockref;
1375 sendSignal(tapiBlockref, GSN_TCRELEASEREF, signal, 5, JBB);
1383 void Dbtc::signalErrorRefuseLab(
Signal* signal)
1385 ptrGuard(apiConnectptr);
1386 if (apiConnectptr.p->apiConnectstate != CS_DISCONNECTED) {
1388 apiConnectptr.p->abortState = AS_IDLE;
1389 apiConnectptr.p->apiConnectstate = CS_ABORTING;
1391 sendSignalErrorRefuseLab(signal);
1394 void Dbtc::sendSignalErrorRefuseLab(
Signal* signal)
1397 ptrGuard(apiConnectptr);
1398 if (apiConnectptr.p->apiConnectstate != CS_DISCONNECTED) {
1401 signal->theData[0] = apiConnectptr.p->ndbapiConnect;
1402 signal->theData[1] = signal->theData[ttransid_ptr];
1403 signal->theData[2] = signal->theData[ttransid_ptr + 1];
1404 signal->theData[3] = ZSIGNAL_ERROR;
1405 sendSignal(apiConnectptr.p->ndbapiBlockref, GSN_TCROLLBACKREP,
1410 void Dbtc::abortBeginErrorLab(
Signal* signal)
1412 apiConnectptr.p->transid[0] = signal->theData[ttransid_ptr];
1413 apiConnectptr.p->transid[1] = signal->theData[ttransid_ptr + 1];
1414 abortErrorLab(signal);
1417 void Dbtc::printState(
Signal* signal,
int place)
1419 #ifdef VM_TRACE // Change to if 0 to disable these printouts
1420 ndbout <<
"-- Dbtc::printState -- " << endl;
1421 ndbout <<
"Received from place = " << place
1422 <<
" apiConnectptr.i = " << apiConnectptr.i
1423 <<
" apiConnectstate = " << apiConnectptr.p->apiConnectstate << endl;
1424 ndbout <<
"ctcTimer = " << ctcTimer
1425 <<
" ndbapiBlockref = " << hex <<apiConnectptr.p->ndbapiBlockref
1426 <<
" Transid = " << apiConnectptr.p->transid[0]
1427 <<
" " << apiConnectptr.p->transid[1] << endl;
1428 ndbout <<
" apiTimer = " << getApiConTimer(apiConnectptr.i)
1429 <<
" counter = " << apiConnectptr.p->counter
1430 <<
" lqhkeyconfrec = " << apiConnectptr.p->lqhkeyconfrec
1431 <<
" lqhkeyreqrec = " << apiConnectptr.p->lqhkeyreqrec << endl;
1432 ndbout <<
"abortState = " << apiConnectptr.p->abortState
1433 <<
" apiScanRec = " << apiConnectptr.p->apiScanRec
1434 <<
" returncode = " << apiConnectptr.p->returncode << endl;
1435 ndbout <<
"tckeyrec = " << apiConnectptr.p->tckeyrec
1436 <<
" returnsignal = " << apiConnectptr.p->returnsignal
1437 <<
" apiFailState = " << apiConnectptr.p->apiFailState << endl;
1438 if (apiConnectptr.p->cachePtr != RNIL) {
1440 CacheRecord *localCacheRecord = cacheRecord;
1441 UintR TcacheFilesize = ccacheFilesize;
1442 UintR TcachePtr = apiConnectptr.p->cachePtr;
1443 if (TcachePtr < TcacheFilesize) {
1445 CacheRecord *
const regCachePtr = &localCacheRecord[TcachePtr];
1446 ndbout <<
"currReclenAi = " << regCachePtr->currReclenAi
1447 <<
" attrlength = " << regCachePtr->attrlength
1448 <<
" tableref = " << regCachePtr->tableref
1449 <<
" keylen = " << regCachePtr->keylen << endl;
1452 systemErrorLab(signal, __LINE__);
1460 Dbtc::TCKEY_abort(
Signal* signal,
int place)
1465 terrorCode = ZSTATE_ERROR;
1466 apiConnectptr.p->firstTcConnect = RNIL;
1467 printState(signal, 4);
1468 abortBeginErrorLab(signal);
1472 printState(signal, 3);
1473 sendSignalErrorRefuseLab(signal);
1476 printState(signal, 6);
1478 const Uint32 t1 = tcKeyReq->transId1;
1479 const Uint32 t2 = tcKeyReq->transId2;
1480 signal->theData[0] = apiConnectptr.p->ndbapiConnect;
1481 signal->theData[1] = t1;
1482 signal->theData[2] = t2;
1483 signal->theData[3] = ZABORT_ERROR;
1485 sendSignal(apiConnectptr.p->ndbapiBlockref, GSN_TCROLLBACKREP,
1491 printState(signal, 7);
1492 noFreeConnectionErrorLab(signal);
1496 terrorCode = ZERO_KEYLEN_ERROR;
1497 releaseAtErrorLab(signal);
1501 terrorCode = ZNO_AI_WITH_UPDATE;
1502 releaseAtErrorLab(signal);
1506 warningHandlerLab(signal, __LINE__);
1511 tabStateErrorLab(signal);
1516 wrongSchemaVersionErrorLab(signal);
1521 terrorCode = ZSTATE_ERROR;
1522 releaseAtErrorLab(signal);
1527 systemErrorLab(signal, __LINE__);
1532 terrorCode = ZMORE_AI_IN_TCKEYREQ_ERROR;
1533 releaseAtErrorLab(signal);
1538 terrorCode = ZSIMPLE_READ_WITHOUT_AI;
1539 releaseAtErrorLab(signal);
1544 switch (tcConnectptr.p->tcConnectstate) {
1545 case OS_WAIT_KEYINFO:
1547 printState(signal, 8);
1548 terrorCode = ZSTATE_ERROR;
1549 abortErrorLab(signal);
1558 systemErrorLab(signal, __LINE__);
1565 terrorCode = ZSCAN_NODE_ERROR;
1566 releaseAtErrorLab(signal);
1571 systemErrorLab(signal, __LINE__);
1576 systemErrorLab(signal, __LINE__);
1581 warningHandlerLab(signal, __LINE__);
1590 warningHandlerLab(signal, __LINE__);
1595 systemErrorLab(signal, __LINE__);
1600 systemErrorLab(signal, __LINE__);
1605 systemErrorLab(signal, __LINE__);
1610 appendToSectionErrorLab(signal);
1615 warningHandlerLab(signal, __LINE__);
1623 systemErrorLab(signal, __LINE__);
1634 systemErrorLab(signal, __LINE__);
1639 systemErrorLab(signal, __LINE__);
1644 systemErrorLab(signal, __LINE__);
1649 systemErrorLab(signal, __LINE__);
1654 systemErrorLab(signal, __LINE__);
1659 systemErrorLab(signal, __LINE__);
1664 systemErrorLab(signal, __LINE__);
1669 systemErrorLab(signal, __LINE__);
1674 systemErrorLab(signal, __LINE__);
1679 systemErrorLab(signal, __LINE__);
1684 systemErrorLab(signal, __LINE__);
1689 systemErrorLab(signal, __LINE__);
1694 systemErrorLab(signal, __LINE__);
1699 systemErrorLab(signal, __LINE__);
1704 systemErrorLab(signal, __LINE__);
1709 systemErrorLab(signal, __LINE__);
1714 systemErrorLab(signal, __LINE__);
1719 systemErrorLab(signal, __LINE__);
1724 terrorCode = apiConnectptr.p->returncode;
1725 releaseAtErrorLab(signal);
1730 terrorCode = ZCOMMIT_TYPE_ERROR;
1731 releaseAtErrorLab(signal);
1736 abortErrorLab(signal);
1741 systemErrorLab(signal, __LINE__);
1746 abortErrorLab(signal);
1751 abortErrorLab(signal);
1756 abortErrorLab(signal);
1761 abortErrorLab(signal);
1766 printState(signal, 5);
1767 sendSignalErrorRefuseLab(signal);
1772 terrorCode = ZNO_FREE_TC_MARKER;
1773 abortErrorLab(signal);
1781 initApiConnectRec(signal, apiConnectptr.p,
true);
1787 terrorCode = ZCLUSTER_IN_SINGLEUSER_MODE;
1793 terrorCode = ZCLUSTER_SHUTDOWN_IN_PROGRESS;
1795 terrorCode = ZNODE_SHUTDOWN_IN_PROGRESS;
1797 case NodeState::SL_SINGLEUSER:
1798 terrorCode = ZCLUSTER_IN_SINGLEUSER_MODE;
1803 terrorCode = ZCLUSTER_IN_SINGLEUSER_MODE;
1807 terrorCode = ZWRONG_STATE;
1810 abortErrorLab(signal);
1816 releaseAtErrorLab(signal);
1822 terrorCode = ZABORTINPROGRESS;
1823 abortErrorLab(signal);
1830 initApiConnectRec(signal, apiConnectptr.p,
true);
1831 apiConnectptr.p->m_flags |= ApiConnectRecord::TF_EXEC_FLAG;
1837 terrorCode = ZUNLOCKED_IVAL_TOO_HIGH;
1838 abortErrorLab(signal);
1844 terrorCode = ZUNLOCKED_OP_HAS_BAD_STATE;
1845 abortErrorLab(signal);
1853 abortErrorLab(signal);
1860 terrorCode = ZBAD_DIST_KEY;
1861 abortErrorLab(signal);
1867 terrorCode = ZTRANS_TOO_BIG;
1868 abortErrorLab(signal);
1873 systemErrorLab(signal, __LINE__);
1881 compare_transid(Uint32* val0, Uint32* val1)
1883 Uint32 tmp0 = val0[0] ^ val1[0];
1884 Uint32 tmp1 = val0[1] ^ val1[1];
1885 return (tmp0 | tmp1) == 0;
1888 void Dbtc::execKEYINFO(
Signal* signal)
1891 apiConnectptr.i = signal->theData[0];
1893 if (apiConnectptr.i >= capiConnectFilesize) {
1894 TCKEY_abort(signal, 18);
1897 ptrAss(apiConnectptr, apiConnectRecord);
1899 if (compare_transid(apiConnectptr.p->transid, signal->theData+1) ==
false)
1901 TCKEY_abort(signal, 19);
1904 switch (apiConnectptr.p->apiConnectstate) {
1906 case CS_REC_COMMITTING:
1921 printState(signal, 11);
1922 signalErrorRefuseLab(signal);
1931 terrorCode = ZSIGNAL_ERROR;
1932 printState(signal, 2);
1933 abortErrorLab(signal);
1937 warningHandlerLab(signal, __LINE__);
1941 CacheRecord *localCacheRecord = cacheRecord;
1942 UintR TcacheFilesize = ccacheFilesize;
1943 UintR TcachePtr = apiConnectptr.p->cachePtr;
1944 UintR TtcTimer = ctcTimer;
1945 CacheRecord *
const regCachePtr = &localCacheRecord[TcachePtr];
1946 if (TcachePtr >= TcacheFilesize) {
1947 TCKEY_abort(signal, 42);
1950 setApiConTimer(apiConnectptr.i, TtcTimer, __LINE__);
1951 cachePtr.i = TcachePtr;
1952 cachePtr.p = regCachePtr;
1954 tcConnectptr.i = apiConnectptr.p->lastTcConnect;
1955 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
1956 switch (tcConnectptr.p->tcConnectstate) {
1957 case OS_WAIT_KEYINFO:
1959 tckeyreq020Lab(signal);
1963 scanKeyinfoLab(signal);
1967 terrorCode = ZSTATE_ERROR;
1968 abortErrorLab(signal);
1980 void Dbtc::sendKeyInfoTrain(
Signal* signal,
1981 BlockReference TBRef,
1988 signal->theData[0] = connectPtr;
1989 signal->theData[1] = apiConnectptr.p->transid[0];
1990 signal->theData[2] = apiConnectptr.p->transid[1];
1991 Uint32 * dst = signal->theData + KeyInfo::HeaderLength;
1993 ndbassert( sectionIVal != RNIL );
1994 SectionReader keyInfoReader(sectionIVal, getSectionSegmentPool());
1996 Uint32 totalLen= keyInfoReader.getSize();
1998 ndbassert( offset < totalLen );
2000 keyInfoReader.step(offset);
2003 while(totalLen != 0)
2005 Uint32 dataInSignal= MIN(KeyInfo::DataLength, totalLen);
2006 keyInfoReader.getWords(dst, dataInSignal);
2007 totalLen-= dataInSignal;
2009 sendSignal(TBRef, GSN_KEYINFO, signal,
2010 KeyInfo::HeaderLength + dataInSignal, JBB);
2018 void Dbtc::tckeyreq020Lab(
Signal* signal)
2020 CacheRecord *
const regCachePtr = cachePtr.p;
2021 UintR TkeyLen = regCachePtr->keylen;
2022 UintR Tlen = regCachePtr->save1;
2023 UintR wordsInSignal= MIN(KeyInfo::DataLength,
2026 ndbassert(! regCachePtr->isLongTcKeyReq );
2027 ndbassert( regCachePtr->keyInfoSectionI != RNIL );
2030 if (! appendToSection(regCachePtr->keyInfoSectionI,
2031 &signal->theData[KeyInfo::HeaderLength],
2035 appendToSectionErrorLab(signal);
2038 Tlen+= wordsInSignal;
2046 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
2047 regCachePtr->save1 = Tlen;
2048 tcConnectptr.p->tcConnectstate = OS_WAIT_KEYINFO;
2057 tckeyreq050Lab(signal);
2062 void Dbtc::execATTRINFO(
Signal* signal)
2064 UintR Tdata1 = signal->theData[0];
2065 UintR Tlength = signal->
length();
2066 UintR TapiConnectFilesize = capiConnectFilesize;
2067 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
2070 apiConnectptr.i = Tdata1;
2072 if (Tdata1 >= TapiConnectFilesize) {
2073 DEBUG(
"Drop ATTRINFO, wrong apiConnectptr");
2074 TCKEY_abort(signal, 18);
2078 ApiConnectRecord *
const regApiPtr = &localApiConnectRecord[Tdata1];
2079 apiConnectptr.p = regApiPtr;
2081 if (compare_transid(regApiPtr->transid, signal->theData+1) ==
false)
2083 DEBUG(
"Drop ATTRINFO, wrong transid, lenght="<<Tlength
2084 <<
" transid("<<hex<<signal->theData[1]<<
", "<<signal->theData[2]);
2085 TCKEY_abort(signal, 19);
2089 DEBUG(
"Drop ATTRINFO, wrong length = " << Tlength);
2090 TCKEY_abort(signal, 20);
2093 Tlength -= AttrInfo::HeaderLength;
2094 UintR TcompREC_COMMIT = (regApiPtr->apiConnectstate == CS_REC_COMMITTING);
2095 UintR TcompRECEIVING = (regApiPtr->apiConnectstate == CS_RECEIVING);
2096 UintR TcompBOTH = TcompREC_COMMIT | TcompRECEIVING;
2100 if (ERROR_INSERTED(8015)) {
2101 CLEAR_ERROR_INSERT_VALUE;
2104 if (ERROR_INSERTED(8016)) {
2105 CLEAR_ERROR_INSERT_VALUE;
2108 CacheRecord *localCacheRecord = cacheRecord;
2109 UintR TcacheFilesize = ccacheFilesize;
2110 UintR TcachePtr = regApiPtr->cachePtr;
2111 UintR TtcTimer = ctcTimer;
2112 CacheRecord *
const regCachePtr = &localCacheRecord[TcachePtr];
2113 if (TcachePtr >= TcacheFilesize) {
2114 TCKEY_abort(signal, 43);
2119 cachePtr.i= TcachePtr;
2120 cachePtr.p= regCachePtr;
2122 regCachePtr->currReclenAi+= Tlength;
2123 int TattrlengthRemain = regCachePtr->attrlength -
2124 regCachePtr->currReclenAi;
2129 tcConnectptr.i = regApiPtr->lastTcConnect;
2130 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
2136 if (! appendToSection(regCachePtr->attrInfoSectionI,
2137 &signal->theData[AttrInfo::HeaderLength],
2140 DEBUG(
"No more section segments available");
2141 appendToSectionErrorLab(signal);
2145 setApiConTimer(apiConnectptr.i, TtcTimer, __LINE__);
2147 if (TattrlengthRemain == 0) {
2155 if (TcompRECEIVING) {
2157 regApiPtr->apiConnectstate = CS_STARTED;
2160 regApiPtr->apiConnectstate = CS_START_COMMITTING;
2162 attrinfoDihReceivedLab(signal);
2163 }
else if (TattrlengthRemain < 0) {
2165 DEBUG(
"ATTRINFO wrong total length="<<Tlength
2166 <<
", TattrlengthRemain="<<TattrlengthRemain
2167 <<
", TattrLen="<< regCachePtr->attrlength
2168 <<
", TcurrReclenAi="<< regCachePtr->currReclenAi);
2169 tcConnectptr.i = regApiPtr->lastTcConnect;
2170 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
2174 }
else if (regApiPtr->apiConnectstate == CS_START_SCAN) {
2176 scanAttrinfoLab(signal, Tlength);
2179 switch (regApiPtr->apiConnectstate) {
2197 terrorCode = ZSIGNAL_ERROR;
2198 printState(signal, 1);
2199 abortErrorLab(signal);
2207 DEBUG(
"Drop ATTRINFO, illegal state="<<regApiPtr->apiConnectstate);
2208 printState(signal, 9);
2219 void Dbtc::hash(
Signal* signal)
2223 CacheRecord *
const regCachePtr = cachePtr.p;
2225 UintR keylen = (UintR)regCachePtr->keylen;
2226 Uint32 distKey = regCachePtr->distributionKeyIndicator;
2228 getSection(keyInfoSection, regCachePtr->keyInfoSectionI);
2230 ndbassert( keyInfoSection.sz <= MAX_KEY_SIZE_IN_WORDS );
2231 ndbassert( keyInfoSection.sz == keylen );
2235 if (keylen <= SectionSegment::DataLength)
2241 ndbassert( keyInfoSection.p != NULL );
2243 Tdata32= &keyInfoSection.p->theData[0];
2248 Tdata32= signal->theData;
2249 copy(Tdata32, keyInfoSection);
2253 if(!regCachePtr->m_special_hash)
2255 md5_hash(tmp, (Uint64*)&Tdata32[0], keylen);
2259 if (regCachePtr->m_no_hash)
2263 Uint32 zero[4] = {0, 0, 0, 0};
2268 handle_special_hash(tmp, Tdata32, keylen, regCachePtr->tableref, !distKey);
2276 thashValue = tmp[0];
2279 tdistrHashValue = regCachePtr->distributionKey;
2282 tdistrHashValue = tmp[1];
2287 Dbtc::handle_special_hash(Uint32 dstHash[4],
2288 const Uint32* src, Uint32 srcLen,
2292 const Uint32 MAX_KEY_SIZE_IN_LONG_WORDS=
2293 (MAX_KEY_SIZE_IN_WORDS + 1) / 2;
2294 Uint64 alignedWorkspace[MAX_KEY_SIZE_IN_LONG_WORDS * MAX_XFRM_MULTIPLY];
2295 Uint32* workspace= (Uint32*)alignedWorkspace;
2296 const TableRecord* tabPtrP = &tableRecord[tabPtrI];
2297 const bool hasVarKeys = tabPtrP->hasVarKeys;
2298 const bool hasCharAttr = tabPtrP->hasCharAttr;
2299 const bool compute_distkey = distr && (tabPtrP->noOfDistrKeys > 0);
2301 const Uint32 *hashInput = workspace;
2302 Uint32 inputLen = 0;
2303 Uint32 keyPartLen[MAX_ATTRIBUTES_IN_INDEX];
2304 Uint32 * keyPartLenPtr;
2307 if(hasCharAttr || (compute_distkey && hasVarKeys))
2309 keyPartLenPtr = keyPartLen;
2313 sizeof(alignedWorkspace) >> 2,
2315 if (unlikely(inputLen == 0))
2329 md5_hash(dstHash, (Uint64*)hashInput, inputLen);
2339 Uint32 distrKeyHash[4];
2341 Uint32 len = create_distr_key(tabPtrI, hashInput, workspace, keyPartLenPtr);
2343 md5_hash(distrKeyHash, (Uint64*) workspace, len);
2346 dstHash[1] = distrKeyHash[1];
2351 terrorCode = ZINVALID_KEY;
2363 void Dbtc::initApiConnectRec(
Signal* signal,
2364 ApiConnectRecord *
const regApiPtr,
2365 bool releaseIndexOperations)
2368 UintR TfailureNr = cfailure_nr;
2369 UintR Ttransid0 = tcKeyReq->transId1;
2370 UintR Ttransid1 = tcKeyReq->transId2;
2372 tc_clearbit(regApiPtr->m_flags, ApiConnectRecord::TF_EXEC_FLAG);
2373 regApiPtr->returncode = 0;
2374 regApiPtr->returnsignal = RS_TCKEYCONF;
2375 ndbassert(regApiPtr->firstTcConnect == RNIL);
2376 regApiPtr->firstTcConnect = RNIL;
2377 regApiPtr->lastTcConnect = RNIL;
2378 regApiPtr->globalcheckpointid = 0;
2379 regApiPtr->lqhkeyconfrec = 0;
2380 regApiPtr->lqhkeyreqrec = 0;
2381 regApiPtr->tckeyrec = 0;
2382 regApiPtr->tcindxrec = 0;
2383 tc_clearbit(regApiPtr->m_flags,
2384 ApiConnectRecord::TF_COMMIT_ACK_MARKER_RECEIVED);
2385 regApiPtr->no_commit_ack_markers = 0;
2386 regApiPtr->failureNr = TfailureNr;
2387 regApiPtr->transid[0] = Ttransid0;
2388 regApiPtr->transid[1] = Ttransid1;
2389 regApiPtr->commitAckMarker = RNIL;
2390 regApiPtr->buddyPtr = RNIL;
2391 regApiPtr->currSavePointId = 0;
2392 regApiPtr->m_transaction_nodes.clear();
2393 regApiPtr->singleUserMode = 0;
2394 regApiPtr->m_pre_commit_pass = 0;
2396 releaseFiredTriggerData(®ApiPtr->theFiredTriggers);
2398 tc_clearbit(regApiPtr->m_flags,
2399 ApiConnectRecord::TF_INDEX_OP_RETURN);
2400 regApiPtr->noIndexOp = 0;
2401 if(releaseIndexOperations)
2402 releaseAllSeizedIndexOperations(regApiPtr);
2403 regApiPtr->immediateTriggerId = RNIL;
2405 tc_clearbit(regApiPtr->m_flags,
2406 ApiConnectRecord::TF_DEFERRED_CONSTRAINTS);
2407 c_counters.ctransCount++;
2410 regApiPtr->continueBCount = 0;
2413 regApiPtr->m_write_count = 0;
2417 Dbtc::seizeTcRecord(
Signal* signal)
2419 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
2420 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
2421 UintR TfirstfreeTcConnect = cfirstfreeTcConnect;
2422 UintR TtcConnectFilesize = ctcConnectFilesize;
2423 tcConnectptr.i = TfirstfreeTcConnect;
2424 if (TfirstfreeTcConnect >= TtcConnectFilesize) {
2426 if (TfirstfreeTcConnect != RNIL) {
2429 TCKEY_abort(signal, place);
2435 TcConnectRecord *
const regTcPtr =
2436 &localTcConnectRecord[TfirstfreeTcConnect];
2438 UintR TlastTcConnect = regApiPtr->lastTcConnect;
2439 UintR TtcConnectptrIndex = tcConnectptr.i;
2440 TcConnectRecordPtr tmpTcConnectptr;
2442 cfirstfreeTcConnect = regTcPtr->nextTcConnect;
2443 tcConnectptr.p = regTcPtr;
2445 c_counters.cconcurrentOp++;
2447 regTcPtr->prevTcConnect = TlastTcConnect;
2448 regTcPtr->nextTcConnect = RNIL;
2449 regTcPtr->noFiredTriggers = 0;
2450 regTcPtr->noReceivedTriggers = 0;
2451 regTcPtr->triggerExecutionCount = 0;
2452 regTcPtr->triggeringOperation = RNIL;
2453 regTcPtr->m_special_op_flags = 0;
2454 regTcPtr->indexOp = RNIL;
2455 regTcPtr->currentTriggerId = RNIL;
2456 regTcPtr->tcConnectstate = OS_ABORTING;
2457 regTcPtr->noOfNodes = 0;
2459 regApiPtr->lastTcConnect = TtcConnectptrIndex;
2461 if (TlastTcConnect == RNIL) {
2463 regApiPtr->firstTcConnect = TtcConnectptrIndex;
2465 tmpTcConnectptr.i = TlastTcConnect;
2467 ptrCheckGuard(tmpTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
2468 tmpTcConnectptr.p->nextTcConnect = TtcConnectptrIndex;
2474 Dbtc::seizeCacheRecord(
Signal* signal)
2476 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
2477 UintR TfirstfreeCacheRec = cfirstfreeCacheRec;
2478 UintR TcacheFilesize = ccacheFilesize;
2479 CacheRecord *localCacheRecord = cacheRecord;
2480 if (TfirstfreeCacheRec >= TcacheFilesize) {
2481 TCKEY_abort(signal, 41);
2484 CacheRecord *
const regCachePtr = &localCacheRecord[TfirstfreeCacheRec];
2486 regApiPtr->cachePtr = TfirstfreeCacheRec;
2487 cfirstfreeCacheRec = regCachePtr->nextCacheRec;
2488 cachePtr.i = TfirstfreeCacheRec;
2489 cachePtr.p = regCachePtr;
2491 regCachePtr->currReclenAi = 0;
2492 regCachePtr->keyInfoSectionI = RNIL;
2493 regCachePtr->attrInfoSectionI = RNIL;
2504 void Dbtc::execTCKEYREQ(
Signal* signal)
2506 Uint32 sendersNodeId = refToNode(signal->getSendersBlockRef());
2507 UintR compare_transid1, compare_transid2;
2517 const UintR TapiIndex = tcKeyReq->apiConnectPtr;
2518 const UintR TapiMaxIndex = capiConnectFilesize;
2519 const UintR TtabIndex = tcKeyReq->tableId;
2520 const UintR TtabMaxIndex = ctabrecFilesize;
2521 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
2524 apiConnectptr.i = TapiIndex;
2525 if (TapiIndex >= TapiMaxIndex) {
2526 releaseSections(handle);
2527 TCKEY_abort(signal, 6);
2530 if (TtabIndex >= TtabMaxIndex) {
2531 releaseSections(handle);
2532 TCKEY_abort(signal, 7);
2537 if (ERROR_INSERTED(8079))
2540 if (sendersNodeId == c_lastFailedApi)
2548 Treqinfo = tcKeyReq->requestInfo;
2553 ApiConnectRecord *
const regApiPtr = &localApiConnectRecord[TapiIndex];
2554 apiConnectptr.p = regApiPtr;
2556 Uint32 TstartFlag = TcKeyReq::getStartFlag(Treqinfo);
2558 TcKeyReq::getExecuteFlag(Treqinfo) ? ApiConnectRecord::TF_EXEC_FLAG : 0;
2560 Uint8 Tspecial_op_flags = regApiPtr->m_special_op_flags;
2561 bool isIndexOpReturn = tc_testbit(regApiPtr->m_flags,
2562 ApiConnectRecord::TF_INDEX_OP_RETURN);
2563 bool isExecutingTrigger = Tspecial_op_flags & TcConnectRecord::SOF_TRIGGER;
2564 regApiPtr->m_special_op_flags = 0;
2565 regApiPtr->m_flags |= TexecFlag;
2566 TableRecordPtr localTabptr;
2567 localTabptr.i = TtabIndex;
2568 localTabptr.p = &tableRecord[TtabIndex];
2569 switch (regApiPtr->apiConnectstate) {
2571 if (TstartFlag == 1 && getAllowStartTransaction(sendersNodeId, localTabptr.p->singleUserMode) ==
true){
2576 initApiConnectRec(signal, regApiPtr);
2577 regApiPtr->m_flags |= TexecFlag;
2579 releaseSections(handle);
2580 if(getAllowStartTransaction(sendersNodeId, localTabptr.p->singleUserMode) ==
true){
2586 TCKEY_abort(signal, 0);
2592 TCKEY_abort(signal, TexecFlag ? 60 : 57);
2599 if(TstartFlag == 1 && regApiPtr->firstTcConnect == RNIL)
2609 !localTabptr.p->singleUserMode)
2611 releaseSections(handle);
2612 TCKEY_abort(signal, TexecFlag ? 60 : 57);
2615 initApiConnectRec(signal, regApiPtr);
2616 regApiPtr->m_flags |= TexecFlag;
2622 compare_transid1 = regApiPtr->transid[0] ^ tcKeyReq->transId1;
2623 compare_transid2 = regApiPtr->transid[1] ^ tcKeyReq->transId2;
2625 compare_transid1 = compare_transid1 | compare_transid2;
2626 if (compare_transid1 != 0) {
2627 releaseSections(handle);
2628 TCKEY_abort(signal, 1);
2634 if (regApiPtr->abortState == AS_IDLE) {
2635 if (TstartFlag == 1) {
2636 if(getAllowStartTransaction(sendersNodeId, localTabptr.p->singleUserMode) ==
false){
2637 releaseSections(handle);
2638 TCKEY_abort(signal, TexecFlag ? 60 : 57);
2646 initApiConnectRec(signal, regApiPtr);
2647 regApiPtr->m_flags |= TexecFlag;
2648 }
else if(TexecFlag) {
2649 releaseSections(handle);
2650 TCKEY_abort(signal, 59);
2659 DEBUG(
"Drop TCKEYREQ - apiConnectState=CS_ABORTING, ==AS_IDLE");
2660 releaseSections(handle);
2668 releaseSections(handle);
2669 if (TstartFlag == 1) {
2674 TCKEY_abort(signal, 2);
2676 }
else if(TexecFlag) {
2677 TCKEY_abort(signal, 59);
2683 DEBUG(
"Drop TCKEYREQ - apiConnectState=CS_ABORTING, !=AS_IDLE");
2687 case CS_START_COMMITTING:
2691 if(isIndexOpReturn || isExecutingTrigger){
2705 releaseSections(handle);
2706 TCKEY_abort(signal, 55);
2710 if (localTabptr.p->checkTable(tcKeyReq->tableSchemaVersion)) {
2717 releaseSections(handle);
2718 TCKEY_abort(signal, 8);
2726 if (ERROR_INSERTED(8032)) {
2727 releaseSections(handle);
2728 TCKEY_abort(signal, 3);
2732 if (seizeTcRecord(signal) != 0) {
2733 releaseSections(handle);
2737 if (seizeCacheRecord(signal) != 0) {
2738 releaseSections(handle);
2742 CRASH_INSERTION(8063);
2744 TcConnectRecord *
const regTcPtr = tcConnectptr.p;
2745 CacheRecord *
const regCachePtr = cachePtr.p;
2756 UintR TapiVersionNo = TcKeyReq::getAPIVersion(tcKeyReq->attrLen);
2757 UintR Tlqhkeyreqrec = regApiPtr->lqhkeyreqrec;
2758 regApiPtr->lqhkeyreqrec = Tlqhkeyreqrec + 1;
2759 regCachePtr->apiVersionNo = TapiVersionNo;
2762 regCachePtr->isLongTcKeyReq= ( handle.m_cnt != 0 );
2764 UintR TapiConnectptrIndex = apiConnectptr.i;
2765 UintR TsenderData = tcKeyReq->senderData;
2767 if (ERROR_INSERTED(8065))
2769 ErrorSignalReceive= 1;
2770 ErrorMaxSegmentsToSeize= 10;
2772 if (ERROR_INSERTED(8066))
2774 ErrorSignalReceive= 1;
2775 ErrorMaxSegmentsToSeize= 1;
2777 if (ERROR_INSERTED(8067))
2779 ErrorSignalReceive= 1;
2780 ErrorMaxSegmentsToSeize= 0;
2782 if (ERROR_INSERTED(8068))
2784 ErrorSignalReceive= 0;
2785 ErrorMaxSegmentsToSeize= 0;
2786 CLEAR_ERROR_INSERT_VALUE;
2787 DEBUG(
"Max segments to seize cleared");
2790 if (ErrorSignalReceive)
2791 DEBUG(
"Max segments to seize : "
2792 << ErrorMaxSegmentsToSeize);
2799 UintR TkeyLength = 0;
2801 UintR titcLenAiInTckeyreq = 0;
2803 if (regCachePtr->isLongTcKeyReq)
2806 if (handle.getSection(keyInfoSec, TcKeyReq::KeyInfoSectionNum))
2807 TkeyLength= keyInfoSec.sz;
2810 if (handle.getSection(attrInfoSec, TcKeyReq::AttrInfoSectionNum))
2811 TattrLen= attrInfoSec.sz;
2813 if (TcKeyReq::getDeferredConstraints(Treqinfo))
2815 regApiPtr->m_flags |= ApiConnectRecord::TF_DEFERRED_CONSTRAINTS;
2820 TkeyLength = TcKeyReq::getKeyLength(Treqinfo);
2821 TattrLen= TcKeyReq::getAttrinfoLen(tcKeyReq->attrLen);
2822 titcLenAiInTckeyreq = TcKeyReq::getAIInTcKeyReq(Treqinfo);
2825 regCachePtr->keylen = TkeyLength;
2826 regCachePtr->lenAiInTckeyreq = titcLenAiInTckeyreq;
2827 regCachePtr->currReclenAi = titcLenAiInTckeyreq;
2829 regTcPtr->apiConnect = TapiConnectptrIndex;
2830 regTcPtr->clientData = TsenderData;
2831 regTcPtr->commitAckMarker = RNIL;
2832 regTcPtr->m_special_op_flags = Tspecial_op_flags;
2833 regTcPtr->indexOp = regApiPtr->executingIndexOp;
2834 regTcPtr->savePointId = regApiPtr->currSavePointId;
2835 regApiPtr->executingIndexOp = RNIL;
2837 regApiPtr->singleUserMode |= 1 << localTabptr.p->singleUserMode;
2839 if (isExecutingTrigger)
2842 regTcPtr->triggeringOperation = TsenderData;
2844 ndbrequire(regApiPtr->immediateTriggerId != RNIL);
2845 regTcPtr->currentTriggerId= regApiPtr->immediateTriggerId;
2847 ndbassert(isExecutingTrigger ||
2848 (regApiPtr->immediateTriggerId == RNIL));
2851 Uint32 currSPId = regApiPtr->currSavePointId;
2852 regApiPtr->currSavePointId = ++currSPId;
2855 regCachePtr->attrlength = TattrLen;
2856 c_counters.cattrinfoCount += TattrLen;
2858 UintR TtabptrIndex = localTabptr.i;
2859 UintR TtableSchemaVersion = tcKeyReq->tableSchemaVersion;
2860 Uint8 TOperationType = TcKeyReq::getOperationType(Treqinfo);
2861 regCachePtr->tableref = TtabptrIndex;
2862 regCachePtr->schemaVersion = TtableSchemaVersion;
2863 regTcPtr->operation = TOperationType;
2865 Uint8 TSimpleFlag = TcKeyReq::getSimpleFlag(Treqinfo);
2866 Uint8 TDirtyFlag = TcKeyReq::getDirtyFlag(Treqinfo);
2867 Uint8 TInterpretedFlag = TcKeyReq::getInterpretedFlag(Treqinfo);
2868 Uint8 TDistrKeyFlag = TcKeyReq::getDistributionKeyFlag(Treqinfo);
2869 Uint8 TNoDiskFlag = TcKeyReq::getNoDiskFlag(Treqinfo);
2870 Uint8 TexecuteFlag = TexecFlag;
2871 Uint8 Treorg = TcKeyReq::getReorgFlag(Treqinfo);
2872 const Uint8 TViaSPJFlag = TcKeyReq::getViaSPJFlag(Treqinfo);
2873 const Uint8 Tqueue = TcKeyReq::getQueueOnRedoProblemFlag(Treqinfo);
2877 if (TOperationType == ZWRITE)
2878 regTcPtr->m_special_op_flags = TcConnectRecord::SOF_REORG_COPY;
2879 else if (TOperationType == ZDELETE)
2880 regTcPtr->m_special_op_flags = TcConnectRecord::SOF_REORG_DELETE;
2887 regTcPtr->dirtyOp = TDirtyFlag;
2888 regTcPtr->opSimple = TSimpleFlag;
2889 regCachePtr->opExec = TInterpretedFlag;
2890 regCachePtr->distributionKeyIndicator = TDistrKeyFlag;
2891 regCachePtr->m_no_disk_flag = TNoDiskFlag;
2892 regCachePtr->viaSPJFlag = TViaSPJFlag;
2893 regCachePtr->m_op_queue = Tqueue;
2899 Uint32* TOptionalDataPtr = (Uint32*)&tcKeyReq->scanInfo;
2901 Uint32 TDistrGHIndex = TcKeyReq::getScanIndFlag(Treqinfo);
2902 Uint32 TDistrKeyIndex = TDistrGHIndex;
2904 Uint32 TscanInfo = TcKeyReq::getTakeOverScanInfo(TOptionalDataPtr[0]);
2906 regCachePtr->scanTakeOverInd = TDistrGHIndex;
2907 regCachePtr->scanInfo = TscanInfo;
2909 regCachePtr->distributionKey = TOptionalDataPtr[TDistrKeyIndex];
2911 TkeyIndex = TDistrKeyIndex + TDistrKeyFlag;
2914 regCachePtr->m_no_hash =
false;
2916 if (TOperationType == ZUNLOCK)
2921 ndbassert( regCachePtr->distributionKeyIndicator );
2922 regCachePtr->m_no_hash = 1;
2923 regCachePtr->unlockNodeId = (regCachePtr->distributionKey >> 16);
2924 regCachePtr->distributionKey &= 0xffff;
2927 regCachePtr->m_special_hash =
2928 localTabptr.p->hasCharAttr |
2929 (localTabptr.p->noOfDistrKeys > 0) |
2930 regCachePtr->m_no_hash;
2932 if (TkeyLength == 0)
2934 releaseSections(handle);
2935 TCKEY_abort(signal, 4);
2944 if (regCachePtr->isLongTcKeyReq)
2946 ndbassert( titcLenAiInTckeyreq == 0);
2953 handle.getSection(keyInfoSection,
2954 TcKeyReq::KeyInfoSectionNum);
2956 regCachePtr->keyInfoSectionI= keyInfoSection.i;
2958 if (regCachePtr->attrlength != 0)
2960 ndbassert( handle.m_cnt == 2 );
2961 handle.getSection(attrInfoSection,
2962 TcKeyReq::AttrInfoSectionNum);
2963 regCachePtr->attrInfoSectionI= attrInfoSection.i;
2967 ndbassert( handle.m_cnt == 1 );
2984 ndbassert( handle.m_cnt == 0 );
2985 Uint32 keyInfoInTCKeyReq= MIN(TkeyLength, TcKeyReq::MaxKeyInfo);
2987 bool ok= appendToSection(regCachePtr->keyInfoSectionI,
2988 &TOptionalDataPtr[TkeyIndex],
2993 appendToSectionErrorLab(signal);
2997 if (titcLenAiInTckeyreq != 0)
2999 Uint32 TAIDataIndex= TkeyIndex + keyInfoInTCKeyReq;
3001 ok= appendToSection(regCachePtr->attrInfoSectionI,
3002 &TOptionalDataPtr[TAIDataIndex],
3003 titcLenAiInTckeyreq);
3007 appendToSectionErrorLab(signal);
3013 if (TOperationType == ZUNLOCK)
3018 else if (TOperationType == ZREAD || TOperationType == ZREAD_EX) {
3020 c_counters.creadCount++;
3025 if (!tc_testbit(regApiPtr->m_flags,
3026 ApiConnectRecord::TF_COMMIT_ACK_MARKER_RECEIVED))
3028 if(regApiPtr->commitAckMarker != RNIL)
3029 regTcPtr->commitAckMarker = regApiPtr->commitAckMarker;
3033 CommitAckMarkerPtr tmp;
3034 if (ERROR_INSERTED(8087))
3036 CLEAR_ERROR_INSERT_VALUE;
3037 TCKEY_abort(signal, 56);
3041 if (!m_commitAckMarkerHash.seize(tmp))
3043 TCKEY_abort(signal, 56);
3048 regTcPtr->commitAckMarker = tmp.i;
3049 regApiPtr->commitAckMarker = tmp.i;
3050 tmp.p->transid1 = tcKeyReq->transId1;
3051 tmp.p->transid2 = tcKeyReq->transId2;
3052 tmp.p->apiNodeId = refToNode(regApiPtr->ndbapiBlockref);
3053 tmp.p->apiConnectPtr = TapiIndex;
3054 tmp.p->m_commit_ack_marker_nodes.clear();
3055 #if defined VM_TRACE || defined ERROR_INSERT
3057 CommitAckMarkerPtr check;
3058 ndbrequire(!m_commitAckMarkerHash.find(check, *tmp.p));
3061 m_commitAckMarkerHash.add(tmp);
3064 regApiPtr->no_commit_ack_markers++;
3067 UintR Toperationsize = coperationsize;
3073 if (localTabptr.p->get_storedTable()) {
3074 coperationsize = ((Toperationsize + TattrLen) + TkeyLength) + 17;
3076 c_counters.cwriteCount++;
3077 switch (TOperationType) {
3084 if (unlikely((++ regApiPtr->m_write_count) > m_max_writes_per_trans))
3086 TCKEY_abort(signal, 65);
3091 TCKEY_abort(signal, 9);
3096 Uint32 TabortOption = TcKeyReq::getAbortOption(Treqinfo);
3097 regTcPtr->m_execAbortOption = TabortOption;
3103 if (TcKeyReq::getCommitFlag(Treqinfo) == 1) {
3104 ndbrequire(TexecuteFlag);
3105 regApiPtr->apiConnectstate = CS_REC_COMMITTING;
3115 if (regApiPtr->apiConnectstate == CS_START_COMMITTING) {
3118 regApiPtr->apiConnectstate = CS_REC_COMMITTING;
3119 }
else if (!regApiPtr->isExecutingDeferredTriggers()) {
3121 regApiPtr->apiConnectstate = CS_RECEIVING;
3125 if (regCachePtr->isLongTcKeyReq)
3129 tckeyreq050Lab(signal);
3131 else if (TkeyLength <= TcKeyReq::MaxKeyInfo)
3135 tckeyreq050Lab(signal);
3144 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
3145 regCachePtr->save1 = 8;
3146 regTcPtr->tcConnectstate = OS_WAIT_KEYINFO;
3157 if (conf->reqinfo & DiGetNodesConf::REORG_MOVING)
3159 conf->fragId = conf->nodes[MAX_REPLICAS];
3160 conf->reqinfo = conf->nodes[MAX_REPLICAS+1];
3161 memcpy(conf->nodes, conf->nodes+MAX_REPLICAS+2,
sizeof(conf->nodes));
3170 Dbtc::isRefreshSupported()
const
3173 const Uint32 minVer = nvi.m_type[
NodeInfo::DB].m_min_version;
3174 const Uint32 maxVer = nvi.m_type[
NodeInfo::DB].m_max_version;
3176 if (likely (minVer == maxVer))
3179 return ndb_refresh_tuple(minVer);
3186 for (Uint32
i=1;
i < MAX_NODES;
i++)
3189 if ((nodeInfo.
m_type == NODE_TYPE_DB) &&
3191 (! ndb_refresh_tuple(nodeInfo.
m_version)))
3202 void Dbtc::tckeyreq050Lab(
Signal* signal)
3212 CacheRecord *
const regCachePtr = cachePtr.p;
3213 TcConnectRecord *
const regTcPtr = tcConnectptr.p;
3214 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
3216 UintR TtcTimer = ctcTimer;
3217 UintR ThashValue = thashValue;
3218 UintR TdistrHashValue = tdistrHashValue;
3219 UintR Ttableref = regCachePtr->tableref;
3220 Uint8 Tspecial_op_flags = regTcPtr->m_special_op_flags;
3222 TableRecordPtr localTabptr;
3223 localTabptr.i = Ttableref;
3224 localTabptr.p = &tableRecord[localTabptr.i];
3225 Uint32 schemaVersion = regCachePtr->schemaVersion;
3226 if(localTabptr.p->checkTable(schemaVersion)){
3229 terrorCode = localTabptr.p->getErrorCode(schemaVersion);
3230 TCKEY_abort(signal, 58);
3234 setApiConTimer(apiConnectptr.i, TtcTimer, __LINE__);
3235 regCachePtr->hashValue = ThashValue;
3237 ndbassert( signal->getNoOfSections() == 0 );
3240 req->tableId = Ttableref;
3241 req->hashValue = TdistrHashValue;
3242 req->distr_key_indicator = regCachePtr->distributionKeyIndicator;
3254 DiGetNodesReq::SignalLength, 0);
3256 UintR Tdata2 = conf->reqinfo;
3257 UintR TerrorIndicator = signal->theData[0];
3259 if (TerrorIndicator != 0) {
3260 execDIGETNODESREF(signal);
3264 if((ERROR_INSERTED(8071) || ERROR_INSERTED(8072)) &&
3265 (regTcPtr->m_special_op_flags & TcConnectRecord::SOF_INDEX_TABLE_READ) &&
3266 signal->theData[3] != getOwnNodeId())
3269 signal->theData[1] = 626;
3270 execDIGETNODESREF(signal);
3274 if((ERROR_INSERTED(8050) || ERROR_INSERTED(8072)) &&
3275 refToBlock(regApiPtr->ndbapiBlockref) != DBUTIL &&
3276 regTcPtr->m_special_op_flags == 0 &&
3277 signal->theData[3] != getOwnNodeId())
3280 signal->theData[1] = 626;
3281 execDIGETNODESREF(signal);
3288 if (Tspecial_op_flags & TcConnectRecord::SOF_REORG_TRIGGER_BASE)
3291 handle_reorg_trigger(conf);
3292 Tdata2 = conf->reqinfo;
3294 else if (Tspecial_op_flags & TcConnectRecord::SOF_REORG_DELETE)
3297 handle_reorg_trigger(conf);
3298 Tdata2 = conf->reqinfo;
3300 else if (Tdata2 & DiGetNodesConf::REORG_MOVING)
3303 regTcPtr->m_special_op_flags |= TcConnectRecord::SOF_REORG_MOVING;
3305 else if (Tspecial_op_flags & TcConnectRecord::SOF_REORG_COPY)
3311 UintR Tdata1 = conf->fragId;
3312 UintR Tdata3 = conf->nodes[0];
3313 UintR Tdata4 = conf->nodes[1];
3314 UintR Tdata5 = conf->nodes[2];
3315 UintR Tdata6 = conf->nodes[3];
3317 regCachePtr->fragmentid = Tdata1;
3320 regTcPtr->tcNodedata[0] = Tdata3;
3321 regTcPtr->tcNodedata[1] = Tdata4;
3322 regTcPtr->tcNodedata[2] = Tdata5;
3323 regTcPtr->tcNodedata[3] = Tdata6;
3325 regTcPtr->lqhInstanceKey = (Tdata2 >> 24) & 127;
3327 Uint8 Toperation = regTcPtr->operation;
3328 Uint8 TopSimple = regTcPtr->opSimple;
3329 Uint8 TopDirty = regTcPtr->dirtyOp;
3330 tnoOfBackup = tnodeinfo & 3;
3331 tnoOfStandby = (tnodeinfo >> 8) & 3;
3333 regCachePtr->fragmentDistributionKey = (tnodeinfo >> 16) & 255;
3334 if (Toperation == ZREAD || Toperation == ZREAD_EX)
3336 regTcPtr->m_special_op_flags &= ~TcConnectRecord::SOF_REORG_MOVING;
3337 if (TopSimple == 1 && TopDirty == 0){
3345 arrGuard(tnoOfBackup, MAX_REPLICAS);
3347 UintR TownNode = cownNodeid;
3348 for (Tindex = 1; Tindex <= tnoOfBackup; Tindex++) {
3349 UintR Tnode = regTcPtr->tcNodedata[Tindex];
3351 if (Tnode == TownNode) {
3353 regTcPtr->tcNodedata[0] = Tnode;
3356 if(ERROR_INSERTED(8048) || ERROR_INSERTED(8049))
3358 for (Tindex = 0; Tindex <= tnoOfBackup; Tindex++)
3360 UintR Tnode = regTcPtr->tcNodedata[Tindex];
3362 if (Tnode != TownNode) {
3364 regTcPtr->tcNodedata[0] = Tnode;
3365 ndbout_c(
"Choosing %d", Tnode);
3371 regTcPtr->lastReplicaNo = 0;
3372 regTcPtr->noOfNodes = 1;
3374 else if (Toperation == ZUNLOCK)
3376 regTcPtr->m_special_op_flags &= ~TcConnectRecord::SOF_REORG_MOVING;
3378 const Uint32 numNodes = tnoOfBackup + 1;
3381 for (Uint32 idx = 0; idx < numNodes; idx ++)
3383 Uint32 nodeId = regTcPtr->tcNodedata[ idx ];
3385 if (nodeId == regCachePtr->unlockNodeId)
3393 if (unlikely(!found))
3399 TCKEY_abort(signal, 64);
3406 if (unlikely( lqhVersion < NDBD_UNLOCK_OP_SUPPORTED ))
3408 TCKEY_abort(signal, 63);
3413 regTcPtr->tcNodedata[0] = regCachePtr->unlockNodeId;
3414 regTcPtr->lastReplicaNo = 0;
3415 regTcPtr->noOfNodes = 1;
3418 UintR TlastReplicaNo;
3420 TlastReplicaNo = tnoOfBackup + tnoOfStandby;
3421 regTcPtr->lastReplicaNo = (Uint8)TlastReplicaNo;
3422 regTcPtr->noOfNodes = (Uint8)(TlastReplicaNo + 1);
3424 if (unlikely((Toperation == ZREFRESH) &&
3425 (! isRefreshSupported())))
3428 TCKEY_abort(signal,63);
3433 if (regCachePtr->isLongTcKeyReq ||
3434 (regCachePtr->lenAiInTckeyreq == regCachePtr->attrlength)) {
3443 switch (regApiPtr->apiConnectstate) {
3446 regApiPtr->apiConnectstate = CS_STARTED;
3448 case CS_REC_COMMITTING:
3450 regApiPtr->apiConnectstate = CS_START_COMMITTING;
3458 systemErrorLab(signal, __LINE__);
3461 attrinfoDihReceivedLab(signal);
3464 if (regCachePtr->lenAiInTckeyreq < regCachePtr->attrlength) {
3465 TtcTimer = ctcTimer;
3467 setApiConTimer(apiConnectptr.i, TtcTimer, __LINE__);
3468 regTcPtr->tcConnectstate = OS_WAIT_ATTR;
3471 TCKEY_abort(signal, 11);
3478 void Dbtc::attrinfoDihReceivedLab(
Signal* signal)
3480 CacheRecord *
const regCachePtr = cachePtr.p;
3481 TcConnectRecord *
const regTcPtr = tcConnectptr.p;
3482 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
3483 Uint16 Tnode = regTcPtr->tcNodedata[0];
3485 TableRecordPtr localTabptr;
3486 localTabptr.i = regCachePtr->tableref;
3487 localTabptr.p = &tableRecord[localTabptr.i];
3489 if(localTabptr.p->checkTable(regCachePtr->schemaVersion)){
3492 terrorCode = localTabptr.p->getErrorCode(regCachePtr->schemaVersion);
3493 TCKEY_abort(signal, 58);
3499 arrGuard(Tnode, MAX_NDB_NODES);
3500 Uint32 instanceKey = regTcPtr->lqhInstanceKey;
3501 BlockReference lqhRef;
3502 if(regCachePtr->viaSPJFlag){
3504 lqhRef = numberToRef(DBSPJ, Tnode);
3507 lqhRef = numberToRef(DBLQH, instanceKey, Tnode);
3509 packLqhkeyreq(signal, lqhRef);
3521 Uint32 trigOp = regTcPtr->triggeringOperation;
3522 Uint32 TclientData = regTcPtr->clientData;
3525 regApiPtr->lqhkeyreqrec--;
3526 unlinkReadyTcCon(signal);
3527 clearCommitAckMarker(regApiPtr, regTcPtr);
3534 TcConnectRecordPtr opPtr;
3536 ptrCheckGuard(opPtr, ctcConnectFilesize, tcConnectRecord);
3537 trigger_op_finished(signal, apiConnectptr, opPtr.p);
3543 Uint32 Ttckeyrec = regApiPtr->tckeyrec;
3544 regApiPtr->tcSendArray[Ttckeyrec] = TclientData;
3545 regApiPtr->tcSendArray[Ttckeyrec + 1] = 0;
3546 regApiPtr->tckeyrec = Ttckeyrec + 2;
3547 lqhKeyConf_checkTransactionState(signal, apiConnectptr);
3552 void Dbtc::packLqhkeyreq(
Signal* signal,
3553 BlockReference TBRef)
3555 CacheRecord *
const regCachePtr = cachePtr.p;
3556 UintR Tkeylen = regCachePtr->keylen;
3558 ndbassert( signal->getNoOfSections() == 0 );
3560 sendlqhkeyreq(signal, TBRef);
3563 if ((! regCachePtr->useLongLqhKeyReq) &&
3564 (Tkeylen > LqhKeyReq::MaxKeyInfo))
3567 sendKeyInfoTrain(signal,
3570 LqhKeyReq::MaxKeyInfo,
3571 regCachePtr->keyInfoSectionI);
3576 packLqhkeyreq040Lab(signal,
3581 void Dbtc::sendlqhkeyreq(
Signal* signal,
3582 BlockReference TBRef)
3586 TcConnectRecord *
const regTcPtr = tcConnectptr.p;
3587 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
3588 CacheRecord *
const regCachePtr = cachePtr.p;
3590 UintR sig0, sig1, sig2, sig3, sig4, sig5, sig6;
3592 if (ERROR_INSERTED(8002)) {
3593 systemErrorLab(signal, __LINE__);
3595 if (ERROR_INSERTED(8007)) {
3596 if (apiConnectptr.p->apiConnectstate == CS_STARTED) {
3597 CLEAR_ERROR_INSERT_VALUE;
3601 if (ERROR_INSERTED(8008)) {
3602 if (apiConnectptr.p->apiConnectstate == CS_START_COMMITTING) {
3603 CLEAR_ERROR_INSERT_VALUE;
3607 if (ERROR_INSERTED(8009)) {
3608 if (apiConnectptr.p->apiConnectstate == CS_STARTED) {
3612 if (ERROR_INSERTED(8010)) {
3613 if (apiConnectptr.p->apiConnectstate == CS_START_COMMITTING) {
3618 Uint32 Tdeferred = tc_testbit(regApiPtr->m_flags,
3619 ApiConnectRecord::TF_DEFERRED_CONSTRAINTS);
3621 Uint32 Tspecial_op = regTcPtr->m_special_op_flags;
3622 if (Tspecial_op == 0)
3625 else if (Tspecial_op & (TcConnectRecord::SOF_REORG_TRIGGER_BASE |
3626 TcConnectRecord::SOF_REORG_DELETE))
3630 else if (Tspecial_op & TcConnectRecord::SOF_REORG_MOVING)
3635 Uint32 inlineKeyLen= 0;
3636 Uint32 inlineAttrLen= 0;
3642 if (unlikely((version < NDBD_LONG_LQHKEYREQ) ||
3643 ERROR_INSERTED(8069)))
3646 regCachePtr->useLongLqhKeyReq= 0;
3647 inlineKeyLen= regCachePtr->keylen;
3648 inlineAttrLen= regCachePtr->attrlength;
3652 regCachePtr->useLongLqhKeyReq= 1;
3655 LqhKeyReq::setAttrLen(tslrAttrLen, inlineAttrLen);
3659 LqhKeyReq::setDistributionKey(tslrAttrLen, regCachePtr->fragmentDistributionKey);
3660 LqhKeyReq::setScanTakeOverFlag(tslrAttrLen, regCachePtr->scanTakeOverInd);
3661 LqhKeyReq::setReorgFlag(tslrAttrLen, reorg);
3664 sig0 = regTcPtr->opSimple;
3665 sig1 = regTcPtr->operation;
3666 sig2 = regTcPtr->dirtyOp;
3667 bool dirtyRead = (sig1 == ZREAD && sig2 == ZTRUE);
3668 LqhKeyReq::setKeyLen(Tdata10, inlineKeyLen);
3669 LqhKeyReq::setLastReplicaNo(Tdata10, regTcPtr->lastReplicaNo);
3670 if (unlikely(version < NDBD_ROWID_VERSION))
3672 Uint32 op = regTcPtr->operation;
3673 Uint32 lock = (Operation_t) op == ZREAD_EX ? ZUPDATE : (Operation_t) op == ZWRITE ? ZINSERT : (Operation_t) op;
3674 LqhKeyReq::setLockType(Tdata10, lock);
3679 LqhKeyReq::setApplicationAddressFlag(Tdata10, 1);
3680 LqhKeyReq::setDirtyFlag(Tdata10, sig2);
3681 LqhKeyReq::setInterpretedFlag(Tdata10, regCachePtr->opExec);
3682 LqhKeyReq::setSimpleFlag(Tdata10, sig0);
3683 LqhKeyReq::setOperation(Tdata10, sig1);
3684 LqhKeyReq::setNoDiskFlag(Tdata10, regCachePtr->m_no_disk_flag);
3685 LqhKeyReq::setQueueOnRedoProblemFlag(Tdata10, regCachePtr->m_op_queue);
3686 LqhKeyReq::setDeferredConstraints(Tdata10, (Tdeferred & m_deferred_enabled));
3693 UintR aiInLqhKeyReq= 0;
3695 if (! regCachePtr->useLongLqhKeyReq)
3700 aiInLqhKeyReq= MIN(LqhKeyReq::MaxAttrInfo, regCachePtr->attrlength);
3703 LqhKeyReq::setAIInLqhKeyReq(Tdata10, aiInLqhKeyReq);
3709 LqhKeyReq::setMarkerFlag(Tdata10, regTcPtr->commitAckMarker != RNIL ? 1 : 0);
3718 sig0 = tcConnectptr.i;
3719 sig2 = regCachePtr->hashValue;
3721 sig5 = regTcPtr->savePointId;
3723 lqhKeyReq->clientConnectPtr = sig0;
3724 lqhKeyReq->attrLen = tslrAttrLen;
3725 lqhKeyReq->hashValue = sig2;
3726 lqhKeyReq->requestInfo = Tdata10;
3727 lqhKeyReq->tcBlockref = sig4;
3728 lqhKeyReq->savePointId = sig5;
3730 sig0 = regCachePtr->tableref + ((regCachePtr->schemaVersion << 16) & 0xFFFF0000);
3731 sig1 = regCachePtr->fragmentid + (regTcPtr->tcNodedata[1] << 16);
3732 sig2 = regApiPtr->transid[0];
3733 sig3 = regApiPtr->transid[1];
3735 (regTcPtr->m_special_op_flags & TcConnectRecord::SOF_INDEX_TABLE_READ) ?
3736 reference() : regApiPtr->ndbapiBlockref;
3737 sig5 = regTcPtr->clientData;
3738 sig6 = regCachePtr->scanInfo;
3742 regApiPtr->m_transaction_nodes.set(regTcPtr->tcNodedata[0]);
3743 regApiPtr->m_transaction_nodes.set(regTcPtr->tcNodedata[1]);
3744 regApiPtr->m_transaction_nodes.set(regTcPtr->tcNodedata[2]);
3745 regApiPtr->m_transaction_nodes.set(regTcPtr->tcNodedata[3]);
3748 lqhKeyReq->tableSchemaVersion = sig0;
3749 lqhKeyReq->fragmentData = sig1;
3750 lqhKeyReq->transId1 = sig2;
3751 lqhKeyReq->transId2 = sig3;
3752 lqhKeyReq->scanInfo = sig6;
3754 lqhKeyReq->variableData[0] = sig4;
3755 lqhKeyReq->variableData[1] = sig5;
3759 if (regTcPtr->lastReplicaNo > 1) {
3760 sig0 = (UintR)regTcPtr->tcNodedata[2] +
3761 (UintR)(regTcPtr->tcNodedata[3] << 16);
3762 lqhKeyReq->variableData[nextPos] = sig0;
3767 regTcPtr->noFiredTriggers = 0;
3768 regTcPtr->triggerExecutionCount = 0;
3770 if (regCachePtr->useLongLqhKeyReq)
3776 getSection(keyInfoSection, regCachePtr->keyInfoSectionI);
3778 handle.m_ptr[ LqhKeyReq::KeyInfoSectionNum ]= keyInfoSection;
3781 if (regCachePtr->attrlength != 0)
3785 ndbassert(regCachePtr->attrInfoSectionI != RNIL);
3786 getSection(attrInfoSection, regCachePtr->attrInfoSectionI);
3788 handle.m_ptr[ LqhKeyReq::AttrInfoSectionNum ]= attrInfoSection;
3792 sendSignal(TBRef, GSN_LQHKEYREQ, signal,
3793 nextPos + LqhKeyReq::FixedSignalLength, JBB,
3797 ndbassert( handle.m_cnt == 0 );
3798 regCachePtr->keyInfoSectionI= RNIL;
3799 regCachePtr->attrInfoSectionI= RNIL;
3810 getSection(keyInfoSection, regCachePtr->keyInfoSectionI);
3811 SectionReader keyInfoReader(keyInfoSection, getSectionSegmentPool());
3813 UintR keyLenInLqhKeyReq= MIN(LqhKeyReq::MaxKeyInfo, regCachePtr->keylen);
3815 keyInfoReader.getWords(&lqhKeyReq->variableData[nextPos], keyLenInLqhKeyReq);
3817 nextPos+= keyLenInLqhKeyReq;
3819 if (aiInLqhKeyReq != 0)
3826 ndbassert(regCachePtr->attrInfoSectionI != RNIL);
3828 getSection(attrInfoSection, regCachePtr->attrInfoSectionI);
3829 SectionReader attrInfoReader(attrInfoSection, getSectionSegmentPool());
3831 attrInfoReader.getWords(&lqhKeyReq->variableData[nextPos], aiInLqhKeyReq);
3833 nextPos+= aiInLqhKeyReq;
3836 sendSignal(TBRef, GSN_LQHKEYREQ, signal,
3837 nextPos + LqhKeyReq::FixedSignalLength, JBB);
3841 void Dbtc::packLqhkeyreq040Lab(
Signal* signal,
3842 BlockReference TBRef)
3844 TcConnectRecord *
const regTcPtr = tcConnectptr.p;
3845 CacheRecord *
const regCachePtr = cachePtr.p;
3847 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
3849 if (ERROR_INSERTED(8009)) {
3850 if (regApiPtr->apiConnectstate == CS_STARTED) {
3851 CLEAR_ERROR_INSERT_VALUE;
3855 if (ERROR_INSERTED(8010)) {
3856 if (regApiPtr->apiConnectstate == CS_START_COMMITTING) {
3857 CLEAR_ERROR_INSERT_VALUE;
3864 if (!regCachePtr->useLongLqhKeyReq)
3867 if (regCachePtr->attrlength > LqhKeyReq::MaxAttrInfo)
3869 if (unlikely( !sendAttrInfoTrain(signal,
3872 LqhKeyReq::MaxAttrInfo,
3873 regCachePtr->attrInfoSectionI)))
3876 TCKEY_abort(signal, 17);
3885 UintR TtcTimer = ctcTimer;
3886 UintR Tread = (regTcPtr->operation == ZREAD);
3887 UintR Tdirty = (regTcPtr->dirtyOp == ZTRUE);
3888 UintR Tboth = Tread & Tdirty;
3889 setApiConTimer(apiConnectptr.i, TtcTimer, __LINE__);
3896 releaseDirtyRead(signal, apiConnectptr, tcConnectptr.p);
3899 regTcPtr->tcConnectstate = OS_OPERATING;
3906 void Dbtc::releaseAttrinfo()
3908 CacheRecord *
const regCachePtr = cachePtr.p;
3909 Uint32 attrInfoSectionI= cachePtr.p->attrInfoSectionI;
3912 releaseSection( attrInfoSectionI );
3913 cachePtr.p->attrInfoSectionI= RNIL;
3919 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
3920 UintR TfirstfreeCacheRec = cfirstfreeCacheRec;
3921 UintR TCacheIndex = cachePtr.i;
3922 regCachePtr->nextCacheRec = TfirstfreeCacheRec;
3923 cfirstfreeCacheRec = TCacheIndex;
3924 regApiPtr->cachePtr = RNIL;
3931 void Dbtc::releaseDirtyRead(
Signal* signal,
3932 ApiConnectRecordPtr regApiPtr,
3933 TcConnectRecord* regTcPtr)
3935 Uint32 Ttckeyrec = regApiPtr.p->tckeyrec;
3936 Uint32 TclientData = regTcPtr->clientData;
3937 Uint32 Tnode = regTcPtr->tcNodedata[0];
3938 Uint32 Tlqhkeyreqrec = regApiPtr.p->lqhkeyreqrec;
3941 regApiPtr.p->tcSendArray[Ttckeyrec] = TclientData;
3942 regApiPtr.p->tcSendArray[Ttckeyrec + 1] = TcKeyConf::DirtyReadBit | Tnode;
3943 regApiPtr.p->tckeyrec = Ttckeyrec + 2;
3945 unlinkReadyTcCon(signal);
3952 c_counters.csimpleReadCount++;
3953 regApiPtr.p->lqhkeyreqrec = --Tlqhkeyreqrec;
3955 if(Tlqhkeyreqrec == 0)
3961 sendtckeyconf(signal, state == CS_START_COMMITTING);
3962 regApiPtr.p->apiConnectstate =
3963 (state == CS_START_COMMITTING ? CS_CONNECTED : state);
3964 setApiConTimer(regApiPtr.i, 0, __LINE__);
3972 lqhKeyConf_checkTransactionState(signal, regApiPtr);
3978 void Dbtc::unlinkReadyTcCon(
Signal* signal)
3980 TcConnectRecordPtr urtTcConnectptr;
3982 TcConnectRecord *
const regTcPtr = tcConnectptr.p;
3983 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
3984 UintR TtcConnectFilesize = ctcConnectFilesize;
3985 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
3986 if (regTcPtr->prevTcConnect != RNIL) {
3988 urtTcConnectptr.i = regTcPtr->prevTcConnect;
3989 ptrCheckGuard(urtTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
3990 urtTcConnectptr.p->nextTcConnect = regTcPtr->nextTcConnect;
3993 regApiPtr->firstTcConnect = regTcPtr->nextTcConnect;
3995 if (regTcPtr->nextTcConnect != RNIL) {
3997 urtTcConnectptr.i = regTcPtr->nextTcConnect;
3998 ptrCheckGuard(urtTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
3999 urtTcConnectptr.p->prevTcConnect = regTcPtr->prevTcConnect;
4002 regApiPtr->lastTcConnect = tcConnectptr.p->prevTcConnect;
4006 void Dbtc::releaseTcCon()
4008 TcConnectRecord *
const regTcPtr = tcConnectptr.p;
4009 UintR TfirstfreeTcConnect = cfirstfreeTcConnect;
4010 UintR TtcConnectptrIndex = tcConnectptr.i;
4012 ndbrequire(regTcPtr->commitAckMarker == RNIL);
4013 regTcPtr->tcConnectstate = OS_CONNECTED;
4014 regTcPtr->nextTcConnect = TfirstfreeTcConnect;
4015 regTcPtr->apiConnect = RNIL;
4016 regTcPtr->m_special_op_flags = 0;
4017 regTcPtr->indexOp = RNIL;
4018 cfirstfreeTcConnect = TtcConnectptrIndex;
4019 c_counters.cconcurrentOp--;
4022 void Dbtc::execPACKED_SIGNAL(
Signal* signal)
4029 UintR TpackedData[28];
4030 UintR Tdata1, Tdata2, Tdata3, Tdata4;
4033 Tlength = signal->
length();
4036 systemErrorLab(signal, __LINE__);
4039 Uint32* TpackDataPtr;
4040 for (Ti = 0; Ti < Tlength; Ti += 4) {
4041 Uint32* TsigDataPtr = &signal->theData[Ti];
4042 Tdata1 = TsigDataPtr[0];
4043 Tdata2 = TsigDataPtr[1];
4044 Tdata3 = TsigDataPtr[2];
4045 Tdata4 = TsigDataPtr[3];
4047 TpackDataPtr = &TpackedData[Ti];
4048 TpackDataPtr[0] = Tdata1;
4049 TpackDataPtr[1] = Tdata2;
4050 TpackDataPtr[2] = Tdata3;
4051 TpackDataPtr[3] = Tdata4;
4053 while (Tlength > Tstep) {
4055 TpackDataPtr = &TpackedData[Tstep];
4056 Tdata1 = TpackDataPtr[0];
4057 Tdata2 = TpackDataPtr[1];
4058 Tdata3 = TpackDataPtr[2];
4060 lqhKeyConf->connectPtr = Tdata1 & 0x0FFFFFFF;
4061 lqhKeyConf->opPtr = Tdata2;
4062 lqhKeyConf->userRef = Tdata3;
4064 switch (Tdata1 >> 28) {
4066 signal->header.theLength = 3;
4067 execCOMMITTED(signal);
4071 signal->header.theLength = 3;
4072 execCOMPLETED(signal);
4077 Tdata1 = TpackDataPtr[3];
4078 Tdata2 = TpackDataPtr[4];
4079 Tdata3 = TpackDataPtr[5];
4080 Tdata4 = TpackDataPtr[6];
4083 lqhKeyConf->transId1 = Tdata2;
4084 lqhKeyConf->transId2 = Tdata3;
4085 lqhKeyConf->noFiredTriggers = Tdata4;
4086 signal->header.theLength = LqhKeyConf::SignalLength;
4087 execLQHKEYCONF(signal);
4088 Tstep += LqhKeyConf::SignalLength;
4090 case ZFIRE_TRIG_CONF:
4092 signal->header.theLength = 4;
4093 signal->theData[3] = TpackDataPtr[3];
4094 execFIRE_TRIG_CONF(signal);
4098 systemErrorLab(signal, __LINE__);
4106 void Dbtc::execSIGNAL_DROPPED_REP(
Signal* signal)
4121 Uint32 originalGSN= rep->originalGsn;
4123 DEBUG(
"SignalDroppedRep received for GSN " << originalGSN);
4125 switch(originalGSN) {
4140 const TcKeyReq *
const truncatedTcKeyReq =
4141 (
TcKeyReq *) &rep->originalData[0];
4143 const UintR apiIndex = truncatedTcKeyReq->apiConnectPtr;
4145 if (apiIndex >= capiConnectFilesize)
4148 warningHandlerLab(signal, __LINE__);
4156 apiConnectptr.i = apiIndex;
4157 ApiConnectRecord *
const regApiPtr = &apiConnectRecord[apiIndex];
4158 apiConnectptr.p = regApiPtr;
4159 UintR transId1= truncatedTcKeyReq->transId1;
4160 UintR transId2= truncatedTcKeyReq->transId2;
4166 apiConnectptr.p->transid[0] = transId1;
4167 apiConnectptr.p->transid[1] = transId2;
4168 apiConnectptr.p->returncode = ZGET_DATAREC_ERROR;
4171 apiConnectptr.p->m_flags |=
4172 TcKeyReq::getExecuteFlag(truncatedTcKeyReq->requestInfo) ?
4173 ApiConnectRecord::TF_EXEC_FLAG : 0;
4175 DEBUG(
" Execute flag set to " << tc_testbit(apiConnectptr.p->m_flags,
4176 ApiConnectRecord::TF_EXEC_FLAG)
4179 abortErrorLab(signal);
4183 case GSN_SCAN_TABREQ:
4188 const ScanTabReq *
const truncatedScanTabReq =
4191 Uint32 apiConnectPtr= truncatedScanTabReq->apiConnectPtr;
4192 Uint32 transId1= truncatedScanTabReq->transId1;
4193 Uint32 transId2= truncatedScanTabReq->transId2;
4195 if (apiConnectPtr >= capiConnectFilesize)
4198 warningHandlerLab(signal, __LINE__);
4202 apiConnectptr.i = apiConnectPtr;
4203 ptrAss(apiConnectptr, apiConnectRecord);
4204 ApiConnectRecord * transP = apiConnectptr.p;
4208 ref->apiConnectPtr = transP->ndbapiConnect;
4209 ref->transId1= transId1;
4210 ref->transId2= transId2;
4211 ref->errorCode= ZGET_ATTRBUF_ERROR;
4212 ref->closeNeeded= 0;
4214 sendSignal(transP->ndbapiBlockref, GSN_SCAN_TABREF,
4215 signal, ScanTabRef::SignalLength, JBB);
4225 SimulatedBlock::execSIGNAL_DROPPED_REP(signal);
4232 void Dbtc::execLQHKEYCONF(
Signal* signal)
4235 signal->getDataPtr());
4237 ndbout <<
"TC: Received LQHKEYCONF"
4238 <<
" transId1=" << lqhKeyConf-> transId1
4239 <<
" transId2=" << lqhKeyConf-> transId2
4242 UintR compare_transid1, compare_transid2;
4243 BlockReference tlastLqhBlockref;
4244 UintR tlastLqhConnect;
4246 UintR TtcConnectptrIndex;
4247 UintR TtcConnectFilesize = ctcConnectFilesize;
4249 tlastLqhConnect = lqhKeyConf->connectPtr;
4250 TtcConnectptrIndex = lqhKeyConf->opPtr;
4251 tlastLqhBlockref = lqhKeyConf->userRef;
4252 treadlenAi = lqhKeyConf->
readLen;
4253 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
4273 if (TtcConnectptrIndex >= TtcConnectFilesize) {
4274 TCKEY_abort(signal, 25);
4277 TcConnectRecord*
const regTcPtr = &localTcConnectRecord[TtcConnectptrIndex];
4278 OperationState TtcConnectstate = regTcPtr->tcConnectstate;
4279 tcConnectptr.i = TtcConnectptrIndex;
4280 tcConnectptr.p = regTcPtr;
4281 if (TtcConnectstate != OS_OPERATING) {
4282 warningReport(signal, 23);
4285 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
4286 UintR TapiConnectptrIndex = regTcPtr->apiConnect;
4287 UintR TapiConnectFilesize = capiConnectFilesize;
4288 UintR Ttrans1 = lqhKeyConf->transId1;
4289 UintR Ttrans2 = lqhKeyConf->transId2;
4290 Uint32 noFired = LqhKeyConf::getFiredCount(lqhKeyConf->noFiredTriggers);
4291 Uint32 deferred = LqhKeyConf::getDeferredBit(lqhKeyConf->noFiredTriggers);
4293 if (TapiConnectptrIndex >= TapiConnectFilesize) {
4294 TCKEY_abort(signal, 29);
4298 regApiPtr.i = TapiConnectptrIndex;
4299 regApiPtr.p = &localApiConnectRecord[TapiConnectptrIndex];
4300 apiConnectptr.i = TapiConnectptrIndex;
4301 apiConnectptr.p = regApiPtr.p;
4302 compare_transid1 = regApiPtr.p->transid[0] ^ Ttrans1;
4303 compare_transid2 = regApiPtr.p->transid[1] ^ Ttrans2;
4304 compare_transid1 = compare_transid1 | compare_transid2;
4305 if (compare_transid1 != 0) {
4306 warningReport(signal, 24);
4311 if (ERROR_INSERTED(8029)) {
4312 systemErrorLab(signal, __LINE__);
4314 if (ERROR_INSERTED(8003)) {
4315 if (regApiPtr.p->apiConnectstate == CS_STARTED) {
4316 CLEAR_ERROR_INSERT_VALUE;
4320 if (ERROR_INSERTED(8004)) {
4321 if (regApiPtr.p->apiConnectstate == CS_RECEIVING) {
4322 CLEAR_ERROR_INSERT_VALUE;
4326 if (ERROR_INSERTED(8005)) {
4327 if (regApiPtr.p->apiConnectstate == CS_REC_COMMITTING) {
4328 CLEAR_ERROR_INSERT_VALUE;
4332 if (ERROR_INSERTED(8006)) {
4333 if (regApiPtr.p->apiConnectstate == CS_START_COMMITTING) {
4334 CLEAR_ERROR_INSERT_VALUE;
4338 if (ERROR_INSERTED(8023)) {
4339 SET_ERROR_INSERT_VALUE(8024);
4343 UintR TtcTimer = ctcTimer;
4344 regTcPtr->lastLqhCon = tlastLqhConnect;
4345 regTcPtr->lastLqhNodeId = refToNode(tlastLqhBlockref);
4346 regTcPtr->noFiredTriggers = noFired;
4347 regTcPtr->m_special_op_flags |= (deferred) ?
4348 TcConnectRecord::SOF_DEFERRED_TRIGGER : 0;
4349 regApiPtr.p->m_flags |= (deferred) ?
4350 ApiConnectRecord::TF_DEFERRED_TRIGGERS : 0;
4352 UintR Ttckeyrec = (UintR)regApiPtr.p->tckeyrec;
4353 UintR TclientData = regTcPtr->clientData;
4354 UintR TdirtyOp = regTcPtr->dirtyOp;
4355 Uint32 TopSimple = regTcPtr->opSimple;
4356 Uint32 Toperation = regTcPtr->operation;
4359 if (TapiConnectstate == CS_ABORTING) {
4360 warningReport(signal, 27);
4364 Uint32 lockingOpI = RNIL;
4365 if (Toperation == ZUNLOCK)
4370 lockingOpI = treadlenAi;
4374 Uint32 commitAckMarker = regTcPtr->commitAckMarker;
4375 regTcPtr->commitAckMarker = RNIL;
4376 setApiConTimer(apiConnectptr.i, TtcTimer, __LINE__);
4378 if (commitAckMarker != RNIL)
4380 const Uint32 noOfLqhs = regTcPtr->noOfNodes;
4381 CommitAckMarker * tmp = m_commitAckMarkerHash.
getPtr(commitAckMarker);
4383 regApiPtr.p->m_flags |= ApiConnectRecord::TF_COMMIT_ACK_MARKER_RECEIVED;
4387 for(Uint32
i = 0;
i < noOfLqhs;
i++)
4388 tmp->m_commit_ack_marker_nodes.set(regTcPtr->tcNodedata[
i]);
4390 if (regTcPtr->isIndexOp(regTcPtr->m_special_op_flags)) {
4394 regTcPtr->attrInfoLen = treadlenAi;
4396 if (noFired == 0 && regTcPtr->triggeringOperation == RNIL) {
4399 if (Ttckeyrec > (ZTCOPCONF_SIZE - 2)) {
4400 TCKEY_abort(signal, 30);
4409 regApiPtr.p->tcSendArray[Ttckeyrec] = TclientData;
4410 regApiPtr.p->tcSendArray[Ttckeyrec + 1] = treadlenAi;
4411 regApiPtr.p->tckeyrec = Ttckeyrec + 2;
4414 if (TdirtyOp == ZTRUE)
4416 UintR Tlqhkeyreqrec = regApiPtr.p->lqhkeyreqrec;
4418 releaseDirtyWrite(signal);
4419 regApiPtr.p->lqhkeyreqrec = Tlqhkeyreqrec - 1;
4421 else if (Toperation == ZREAD && TopSimple)
4423 UintR Tlqhkeyreqrec = regApiPtr.p->lqhkeyreqrec;
4425 unlinkReadyTcCon(signal);
4427 regApiPtr.p->lqhkeyreqrec = Tlqhkeyreqrec - 1;
4429 else if (Toperation == ZUNLOCK)
4441 Uint32 unlockOpI = tcConnectptr.i;
4443 ndbrequire( noFired == 0 );
4444 ndbrequire( regTcPtr->triggeringOperation == RNIL );
4447 if (unlikely( lockingOpI >= ctcConnectFilesize ))
4450 TCKEY_abort(signal, 61);
4453 tcConnectptr.i = lockingOpI;
4454 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
4456 const TcConnectRecord * regLockTcPtr = tcConnectptr.p;
4459 bool locking_op_ok =
4460 ( ( regLockTcPtr->apiConnect == regTcPtr->apiConnect ) &&
4461 ( ( regLockTcPtr->operation == ZREAD ) ||
4462 ( regLockTcPtr->operation == ZREAD_EX ) ) &&
4463 ( regLockTcPtr->tcConnectstate == OS_PREPARED ) &&
4464 ( ! regLockTcPtr->dirtyOp ) &&
4465 ( ! regLockTcPtr->opSimple ) &&
4466 ( ! TcConnectRecord::isIndexOp(regLockTcPtr->m_special_op_flags) ) &&
4467 ( regLockTcPtr->commitAckMarker == RNIL ) );
4469 if (unlikely (! locking_op_ok ))
4472 TCKEY_abort(signal, 63);
4477 unlinkReadyTcCon(signal);
4483 ndbrequire( regApiPtr.p->lqhkeyreqrec );
4484 ndbrequire( regApiPtr.p->lqhkeyconfrec );
4485 regApiPtr.p->lqhkeyreqrec -= 1;
4486 regApiPtr.p->lqhkeyconfrec -= 1;
4489 tcConnectptr.i = unlockOpI;
4490 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
4493 unlinkReadyTcCon(signal);
4497 ndbrequire( regApiPtr.p->lqhkeyreqrec );
4498 regApiPtr.p->lqhkeyreqrec -= 1;
4508 UintR Tlqhkeyconfrec = regApiPtr.p->lqhkeyconfrec;
4509 regApiPtr.p->lqhkeyconfrec = Tlqhkeyconfrec + 1;
4510 regTcPtr->tcConnectstate = OS_PREPARED;
4517 if (regTcPtr->triggeringOperation != RNIL &&
4518 !regApiPtr.p->isExecutingDeferredTriggers()) {
4522 TcConnectRecordPtr opPtr;
4524 opPtr.i = regTcPtr->triggeringOperation;
4525 ptrCheckGuard(opPtr, ctcConnectFilesize, localTcConnectRecord);
4526 trigger_op_finished(signal, regApiPtr, opPtr.p);
4527 }
else if (noFired == 0) {
4530 if (regTcPtr->isIndexOp(regTcPtr->m_special_op_flags)) {
4532 setupIndexOpReturn(regApiPtr.p, regTcPtr);
4534 lqhKeyConf_checkTransactionState(signal, regApiPtr);
4538 saveTriggeringOpState(signal, regTcPtr);
4539 if (regTcPtr->noReceivedTriggers == noFired)
4543 executeTriggers(signal, ®ApiPtr);
4549 void Dbtc::setupIndexOpReturn(ApiConnectRecord* regApiPtr,
4550 TcConnectRecord* regTcPtr)
4552 regApiPtr->m_flags |= ApiConnectRecord::TF_INDEX_OP_RETURN;
4553 regApiPtr->indexOp = regTcPtr->indexOp;
4554 regApiPtr->clientData = regTcPtr->clientData;
4555 regApiPtr->attrInfoLen = regTcPtr->attrInfoLen;
4566 Dbtc::lqhKeyConf_checkTransactionState(
Signal * signal,
4579 UintR Tlqhkeyconfrec = regApiPtr.p->lqhkeyconfrec;
4580 UintR Tlqhkeyreqrec = regApiPtr.p->lqhkeyreqrec;
4581 int TnoOfOutStanding = Tlqhkeyreqrec - Tlqhkeyconfrec;
4583 apiConnectptr = regApiPtr;
4584 switch (TapiConnectstate) {
4585 case CS_START_COMMITTING:
4586 if (TnoOfOutStanding == 0) {
4588 diverify010Lab(signal);
4590 }
else if (TnoOfOutStanding > 0) {
4591 if (regApiPtr.p->tckeyrec == ZTCOPCONF_SIZE) {
4593 sendtckeyconf(signal, 0);
4596 else if (tc_testbit(regApiPtr.p->m_flags,
4597 ApiConnectRecord::TF_INDEX_OP_RETURN))
4600 sendtckeyconf(signal, 0);
4606 TCKEY_abort(signal, 44);
4612 if (TnoOfOutStanding == 0) {
4614 sendtckeyconf(signal, 2);
4617 if (regApiPtr.p->tckeyrec == ZTCOPCONF_SIZE) {
4619 sendtckeyconf(signal, 0);
4622 else if (tc_testbit(regApiPtr.p->m_flags,
4623 ApiConnectRecord::TF_INDEX_OP_RETURN))
4626 sendtckeyconf(signal, 0);
4632 case CS_REC_COMMITTING:
4633 if (TnoOfOutStanding > 0) {
4634 if (regApiPtr.p->tckeyrec == ZTCOPCONF_SIZE) {
4636 sendtckeyconf(signal, 0);
4639 else if (tc_testbit(regApiPtr.p->m_flags,
4640 ApiConnectRecord::TF_INDEX_OP_RETURN))
4643 sendtckeyconf(signal, 0);
4649 TCKEY_abort(signal, 45);
4658 regApiPtr.p->tckeyrec = 0;
4663 if (TnoOfOutStanding == 0 && regApiPtr.p->pendingTriggers == 0)
4666 regApiPtr.p->apiConnectstate = CS_START_COMMITTING;
4667 diverify010Lab(signal);
4672 TCKEY_abort(signal, 46);
4677 void Dbtc::sendtckeyconf(
Signal* signal, UintR TcommitFlag)
4679 if(ERROR_INSERTED(8049)){
4680 CLEAR_ERROR_INSERT_VALUE;
4681 signal->theData[0] = TcContinueB::DelayTCKEYCONF;
4682 signal->theData[1] = apiConnectptr.i;
4683 signal->theData[2] = TcommitFlag;
4684 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 3000, 3);
4688 HostRecordPtr localHostptr;
4689 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
4690 const UintR TopWords = (UintR)regApiPtr->tckeyrec;
4691 localHostptr.i = refToNode(regApiPtr->ndbapiBlockref);
4694 const BlockNumber TblockNum = refToBlock(regApiPtr->ndbapiBlockref);
4695 const Uint32 Tmarker = (regApiPtr->commitAckMarker == RNIL) ? 0 : 1;
4696 ptrAss(localHostptr, hostRecord);
4697 UintR TcurrLen = localHostptr.p->noOfWordsTCKEYCONF;
4699 TcKeyConf::setCommitFlag(confInfo, TcommitFlag == 1);
4700 TcKeyConf::setMarkerFlag(confInfo, Tmarker);
4701 const UintR TpacketLen = 6 + TopWords;
4702 regApiPtr->tckeyrec = 0;
4704 if (tc_testbit(regApiPtr->m_flags, ApiConnectRecord::TF_INDEX_OP_RETURN))
4709 TcKeyConf::setNoOfOperations(confInfo, 1);
4710 tcKeyConf->apiConnectPtr = regApiPtr->indexOp;
4711 tcKeyConf->gci_hi = Uint32(regApiPtr->globalcheckpointid >> 32);
4712 Uint32* gci_lo = (Uint32*)&tcKeyConf->operations[1];
4713 * gci_lo = Uint32(regApiPtr->globalcheckpointid);
4714 tcKeyConf->confInfo = confInfo;
4715 tcKeyConf->transId1 = regApiPtr->transid[0];
4716 tcKeyConf->transId2 = regApiPtr->transid[1];
4717 tcKeyConf->operations[0].apiOperationPtr = regApiPtr->clientData;
4718 tcKeyConf->operations[0].attrInfoLen = regApiPtr->attrInfoLen;
4720 TcKeyConf::StaticLength + TcKeyConf::OperationLength;
4722 tc_clearbit(regApiPtr->m_flags, ApiConnectRecord::TF_INDEX_OP_RETURN);
4723 if (TopWords == 0) {
4730 tc_clearbit(regApiPtr->m_flags, ApiConnectRecord::TF_EXEC_FLAG);
4732 TcKeyConf::setNoOfOperations(confInfo, (TopWords >> 1));
4733 if ((TpacketLen + 1 > 25) || !is_api){
4737 tcKeyConf->apiConnectPtr = regApiPtr->ndbapiConnect;
4738 tcKeyConf->gci_hi = Uint32(regApiPtr->globalcheckpointid >> 32);
4739 Uint32* gci_lo = (Uint32*)&tcKeyConf->operations[TopWords >> 1];
4740 tcKeyConf->confInfo = confInfo;
4741 tcKeyConf->transId1 = regApiPtr->transid[0];
4742 tcKeyConf->transId2 = regApiPtr->transid[1];
4743 copyFromToLen(®ApiPtr->tcSendArray[0],
4744 (UintR*)&tcKeyConf->operations,
4745 (UintR)ZTCOPCONF_SIZE);
4746 * gci_lo = Uint32(regApiPtr->globalcheckpointid);
4747 sendSignal(regApiPtr->ndbapiBlockref,
4748 GSN_TCKEYCONF, signal, (TpacketLen - 1) + 1 , JBB);
4750 }
else if (((TcurrLen + TpacketLen + 1 ) > 25) &&
4753 sendPackedTCKEYCONF(signal, localHostptr.p, localHostptr.i);
4757 updatePackedList(signal, localHostptr.p, localHostptr.i);
4764 UintR Tpack0 = (TblockNum << 16) + (TpacketLen - 4 + 1 );
4765 UintR Tpack1 = regApiPtr->ndbapiConnect;
4766 UintR Tpack2 = Uint32(regApiPtr->globalcheckpointid >> 32);
4767 UintR Tpack3 = confInfo;
4768 UintR Tpack4 = regApiPtr->transid[0];
4769 UintR Tpack5 = regApiPtr->transid[1];
4770 UintR Tpack6 = Uint32(regApiPtr->globalcheckpointid);
4772 localHostptr.p->noOfWordsTCKEYCONF = TcurrLen + TpacketLen + 1 ;
4774 localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 0] = Tpack0;
4775 localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 1] = Tpack1;
4776 localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 2] = Tpack2;
4777 localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 3] = Tpack3;
4778 localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 4] = Tpack4;
4779 localHostptr.p->packedWordsTCKEYCONF[TcurrLen + 5] = Tpack5;
4782 for (Ti = 6; Ti < TpacketLen; Ti++) {
4783 localHostptr.p->packedWordsTCKEYCONF[TcurrLen + Ti] =
4784 regApiPtr->tcSendArray[Ti - 6];
4786 localHostptr.p->packedWordsTCKEYCONF[TcurrLen + TpacketLen] = Tpack6;
4791 ndbassert(Tpack6 == 0 ||
4796 void Dbtc::copyFromToLen(UintR* sourceBuffer, UintR* destBuffer, UintR Tlen)
4801 UintR Tdata0 = sourceBuffer[Tindex + 0];
4802 UintR Tdata1 = sourceBuffer[Tindex + 1];
4803 UintR Tdata2 = sourceBuffer[Tindex + 2];
4804 UintR Tdata3 = sourceBuffer[Tindex + 3];
4806 destBuffer[Tindex + 0] = Tdata0;
4807 destBuffer[Tindex + 1] = Tdata1;
4808 destBuffer[Tindex + 2] = Tdata2;
4809 destBuffer[Tindex + 3] = Tdata3;
4812 for (Ti = 0; Ti < Tlen; Ti++, Tindex++) {
4813 destBuffer[Tindex] = sourceBuffer[Tindex];
4817 void Dbtc::execSEND_PACKED(
Signal* signal)
4819 HostRecordPtr Thostptr;
4820 HostRecord *localHostRecord = hostRecord;
4822 UintR TpackedListIndex = cpackedListIndex;
4824 for (i = 0; i < TpackedListIndex; i++) {
4825 Thostptr.i = cpackedList[
i];
4826 ptrAss(Thostptr, localHostRecord);
4827 arrGuard(Thostptr.i - 1, MAX_NODES - 1);
4828 UintR TnoOfPackedWordsLqh = Thostptr.p->noOfPackedWordsLqh;
4829 UintR TnoOfWordsTCKEYCONF = Thostptr.p->noOfWordsTCKEYCONF;
4831 if (TnoOfPackedWordsLqh > 0) {
4833 sendPackedSignalLqh(signal, Thostptr.p);
4835 if (TnoOfWordsTCKEYCONF > 0) {
4837 sendPackedTCKEYCONF(signal, Thostptr.p, (Uint32)Thostptr.i);
4839 Thostptr.p->inPackedList =
false;
4841 cpackedListIndex = 0;
4846 Dbtc::updatePackedList(
Signal* signal, HostRecord* ahostptr, Uint16 ahostIndex)
4848 if (ahostptr->inPackedList ==
false) {
4849 UintR TpackedListIndex = cpackedListIndex;
4851 ahostptr->inPackedList =
true;
4852 cpackedList[TpackedListIndex] = ahostIndex;
4853 cpackedListIndex = TpackedListIndex + 1;
4857 void Dbtc::sendPackedSignalLqh(
Signal* signal, HostRecord * ahostptr)
4860 UintR TnoOfWords = ahostptr->noOfPackedWordsLqh;
4861 for (Tj = 0; Tj < TnoOfWords; Tj += 4) {
4862 UintR sig0 = ahostptr->packedWordsLqh[Tj + 0];
4863 UintR sig1 = ahostptr->packedWordsLqh[Tj + 1];
4864 UintR sig2 = ahostptr->packedWordsLqh[Tj + 2];
4865 UintR sig3 = ahostptr->packedWordsLqh[Tj + 3];
4866 signal->theData[Tj + 0] = sig0;
4867 signal->theData[Tj + 1] = sig1;
4868 signal->theData[Tj + 2] = sig2;
4869 signal->theData[Tj + 3] = sig3;
4871 ahostptr->noOfPackedWordsLqh = 0;
4872 sendSignal(ahostptr->hostLqhBlockRef,
4879 void Dbtc::sendPackedTCKEYCONF(
Signal* signal,
4880 HostRecord * ahostptr,
4884 UintR TnoOfWords = ahostptr->noOfWordsTCKEYCONF;
4885 BlockReference TBref = numberToRef(API_PACKED, hostId);
4886 for (Tj = 0; Tj < ahostptr->noOfWordsTCKEYCONF; Tj += 4) {
4887 UintR sig0 = ahostptr->packedWordsTCKEYCONF[Tj + 0];
4888 UintR sig1 = ahostptr->packedWordsTCKEYCONF[Tj + 1];
4889 UintR sig2 = ahostptr->packedWordsTCKEYCONF[Tj + 2];
4890 UintR sig3 = ahostptr->packedWordsTCKEYCONF[Tj + 3];
4891 signal->theData[Tj + 0] = sig0;
4892 signal->theData[Tj + 1] = sig1;
4893 signal->theData[Tj + 2] = sig2;
4894 signal->theData[Tj + 3] = sig3;
4896 ahostptr->noOfWordsTCKEYCONF = 0;
4897 sendSignal(TBref, GSN_TCKEYCONF, signal, TnoOfWords, JBB);
4908 void Dbtc::diverify010Lab(
Signal* signal)
4910 UintR TfirstfreeApiConnectCopy = cfirstfreeApiConnectCopy;
4911 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
4912 signal->theData[0] = apiConnectptr.i;
4913 signal->theData[1] = instance() ? instance() - 1 : 0;
4914 if (ERROR_INSERTED(8022)) {
4916 systemErrorLab(signal, __LINE__);
4919 if (tc_testbit(regApiPtr->m_flags, ApiConnectRecord::TF_DEFERRED_TRIGGERS))
4926 regApiPtr->pendingTriggers = 0;
4927 tc_clearbit(regApiPtr->m_flags, ApiConnectRecord::TF_DEFERRED_TRIGGERS);
4928 sendFireTrigReq(signal, apiConnectptr, regApiPtr->firstTcConnect);
4932 if (regApiPtr->lqhkeyreqrec)
4934 if (TfirstfreeApiConnectCopy != RNIL) {
4935 seizeApiConnectCopy(signal);
4936 regApiPtr->apiConnectstate = CS_PREPARE_TO_COMMIT;
4945 2 +
sizeof(
void*)/
sizeof(Uint32), 0);
4946 if (signal->theData[3] == 0) {
4947 execDIVERIFYCONF(signal);
4960 terrorCode = ZSEIZE_API_COPY_ERROR;
4961 abortErrorLab(signal);
4968 sendtckeyconf(signal, 1);
4969 regApiPtr->apiConnectstate = CS_CONNECTED;
4970 regApiPtr->m_transaction_nodes.clear();
4971 setApiConTimer(apiConnectptr.i, 0,__LINE__);
4979 void Dbtc::seizeApiConnectCopy(
Signal* signal)
4981 ApiConnectRecordPtr locApiConnectptr;
4983 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
4984 UintR TapiConnectFilesize = capiConnectFilesize;
4985 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
4987 locApiConnectptr.i = cfirstfreeApiConnectCopy;
4988 ptrCheckGuard(locApiConnectptr, TapiConnectFilesize, localApiConnectRecord);
4989 cfirstfreeApiConnectCopy = locApiConnectptr.p->nextApiConnect;
4990 locApiConnectptr.p->nextApiConnect = RNIL;
4991 regApiPtr->apiCopyRecord = locApiConnectptr.i;
4992 tc_clearbit(regApiPtr->m_flags,
4993 ApiConnectRecord::TF_TRIGGER_PENDING);
4994 regApiPtr->m_special_op_flags = 0;
4997 void Dbtc::execDIVERIFYCONF(
Signal* signal)
4999 UintR TapiConnectptrIndex = signal->theData[0];
5000 UintR TapiConnectFilesize = capiConnectFilesize;
5001 UintR Tgci_hi = signal->theData[1];
5002 UintR Tgci_lo = signal->theData[2];
5003 Uint64 Tgci = Tgci_lo | (Uint64(Tgci_hi) << 32);
5004 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
5007 if (ERROR_INSERTED(8017)) {
5008 CLEAR_ERROR_INSERT_VALUE;
5011 if (TapiConnectptrIndex >= TapiConnectFilesize) {
5012 TCKEY_abort(signal, 31);
5015 ApiConnectRecord *
const regApiPtr =
5016 &localApiConnectRecord[TapiConnectptrIndex];
5018 UintR TApifailureNr = regApiPtr->failureNr;
5019 UintR Tfailure_nr = cfailure_nr;
5020 apiConnectptr.i = TapiConnectptrIndex;
5021 apiConnectptr.p = regApiPtr;
5022 if (TapiConnectstate != CS_PREPARE_TO_COMMIT) {
5023 TCKEY_abort(signal, 32);
5033 if (TApifailureNr != Tfailure_nr) {
5034 DIVER_node_fail_handling(signal, Tgci);
5037 commitGciHandling(signal, Tgci);
5044 UintR TtcConnectptrIndex = regApiPtr->firstTcConnect;
5045 UintR TtcConnectFilesize = ctcConnectFilesize;
5046 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
5048 regApiPtr->counter = regApiPtr->lqhkeyconfrec;
5049 regApiPtr->apiConnectstate = CS_COMMITTING;
5050 if (TtcConnectptrIndex >= TtcConnectFilesize) {
5051 TCKEY_abort(signal, 33);
5054 TcConnectRecord*
const regTcPtr = &localTcConnectRecord[TtcConnectptrIndex];
5055 tcConnectptr.i = TtcConnectptrIndex;
5056 tcConnectptr.p = regTcPtr;
5057 commit020Lab(signal);
5064 void Dbtc::commitGciHandling(
Signal* signal, Uint64 Tgci)
5066 GcpRecordPtr localGcpPointer;
5068 UintR TgcpFilesize = cgcpFilesize;
5069 UintR Tfirstgcp = cfirstgcp;
5071 GcpRecord *localGcpRecord = gcpRecord;
5073 regApiPtr.p->globalcheckpointid = Tgci;
5074 if (Tfirstgcp != RNIL) {
5076 localGcpPointer.i = Tfirstgcp;
5077 ptrCheckGuard(localGcpPointer, TgcpFilesize, localGcpRecord);
5079 if (regApiPtr.p->globalcheckpointid == localGcpPointer.p->gcpId) {
5081 linkApiToGcp(localGcpPointer, regApiPtr);
5084 if (unlikely(! (regApiPtr.p->globalcheckpointid > localGcpPointer.p->gcpId)))
5086 ndbout_c(
"%u/%u %u/%u",
5087 Uint32(regApiPtr.p->globalcheckpointid >> 32),
5088 Uint32(regApiPtr.p->globalcheckpointid),
5089 Uint32(localGcpPointer.p->gcpId >> 32),
5090 Uint32(localGcpPointer.p->gcpId));
5091 crash_gcp(__LINE__);
5093 localGcpPointer.i = localGcpPointer.p->nextGcp;
5095 if (localGcpPointer.i != RNIL) {
5097 ptrCheckGuard(localGcpPointer, TgcpFilesize, localGcpRecord);
5101 seizeGcp(localGcpPointer, Tgci);
5102 linkApiToGcp(localGcpPointer, regApiPtr);
5107 seizeGcp(localGcpPointer, Tgci);
5108 linkApiToGcp(localGcpPointer, regApiPtr);
5120 ApiConnectRecordPtr localApiConnectptr;
5121 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
5123 regApiPtr.p->nextGcpConnect = RNIL;
5124 if (regGcpPtr.p->firstApiConnect == RNIL) {
5125 regGcpPtr.p->firstApiConnect = regApiPtr.i;
5128 UintR TapiConnectFilesize = capiConnectFilesize;
5129 localApiConnectptr.i = regGcpPtr.p->lastApiConnect;
5131 ptrCheckGuard(localApiConnectptr,
5132 TapiConnectFilesize, localApiConnectRecord);
5133 localApiConnectptr.p->nextGcpConnect = regApiPtr.i;
5135 UintR TlastApiConnect = regGcpPtr.p->lastApiConnect;
5136 regApiPtr.p->gcpPointer = regGcpPtr.i;
5137 regApiPtr.p->prevGcpConnect = TlastApiConnect;
5138 regGcpPtr.p->lastApiConnect = regApiPtr.i;
5142 Dbtc::crash_gcp(Uint32 line)
5144 GcpRecordPtr localGcpPointer;
5146 localGcpPointer.i = cfirstgcp;
5148 while (localGcpPointer.i != RNIL)
5150 ptrCheckGuard(localGcpPointer, cgcpFilesize, gcpRecord);
5151 ndbout_c(
"%u : %u/%u nomoretrans: %u api %u %u next: %u",
5153 Uint32(localGcpPointer.p->gcpId >> 32),
5154 Uint32(localGcpPointer.p->gcpId),
5155 localGcpPointer.p->gcpNomoretransRec,
5156 localGcpPointer.p->firstApiConnect,
5157 localGcpPointer.p->lastApiConnect,
5158 localGcpPointer.p->nextGcp);
5159 localGcpPointer.i = localGcpPointer.p->nextGcp;
5167 GcpRecordPtr tmpGcpPointer;
5168 GcpRecordPtr localGcpPointer;
5170 UintR Tfirstgcp = cfirstgcp;
5171 UintR TgcpFilesize = cgcpFilesize;
5172 GcpRecord *localGcpRecord = gcpRecord;
5174 localGcpPointer.i = cfirstfreeGcp;
5175 if (unlikely(localGcpPointer.i > TgcpFilesize))
5177 ndbout_c(
"%u/%u", Uint32(Tgci >> 32), Uint32(Tgci));
5178 crash_gcp(__LINE__);
5180 ptrCheckGuard(localGcpPointer, TgcpFilesize, localGcpRecord);
5181 UintR TfirstfreeGcp = localGcpPointer.p->nextGcp;
5182 localGcpPointer.p->gcpId = Tgci;
5183 localGcpPointer.p->nextGcp = RNIL;
5184 localGcpPointer.p->firstApiConnect = RNIL;
5185 localGcpPointer.p->lastApiConnect = RNIL;
5186 localGcpPointer.p->gcpNomoretransRec = ZFALSE;
5187 cfirstfreeGcp = TfirstfreeGcp;
5189 if (Tfirstgcp == RNIL) {
5191 cfirstgcp = localGcpPointer.i;
5193 tmpGcpPointer.i = clastgcp;
5195 ptrCheckGuard(tmpGcpPointer, TgcpFilesize, localGcpRecord);
5196 tmpGcpPointer.p->nextGcp = localGcpPointer.i;
5198 clastgcp = localGcpPointer.i;
5199 dst = localGcpPointer;
5205 void Dbtc::commit020Lab(
Signal* signal)
5207 TcConnectRecordPtr localTcConnectptr;
5208 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
5209 UintR TtcConnectFilesize = ctcConnectFilesize;
5210 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
5212 localTcConnectptr.p = tcConnectptr.p;
5213 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
5222 localTcConnectptr.i = localTcConnectptr.p->nextTcConnect;
5223 localTcConnectptr.p->tcConnectstate = OS_COMMITTING;
5224 Tcount += sendCommitLqh(signal, localTcConnectptr.p);
5226 if (localTcConnectptr.i != RNIL) {
5228 ! (ERROR_INSERTED(8057) ||
5229 ERROR_INSERTED(8073) ||
5230 ERROR_INSERTED(8089)))
5232 ptrCheckGuard(localTcConnectptr,
5233 TtcConnectFilesize, localTcConnectRecord);
5238 if (ERROR_INSERTED(8014)) {
5239 CLEAR_ERROR_INSERT_VALUE;
5243 if (ERROR_INSERTED(8073))
5245 execSEND_PACKED(signal);
5246 signal->theData[0] = 9999;
5247 sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, 100, 1);
5250 signal->theData[0] = TcContinueB::ZSEND_COMMIT_LOOP;
5251 signal->theData[1] = apiConnectptr.i;
5252 signal->theData[2] = localTcConnectptr.i;
5253 if (ERROR_INSERTED(8089))
5255 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 100, 3);
5258 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
5263 if (ERROR_INSERTED(8057))
5264 CLEAR_ERROR_INSERT_VALUE;
5266 if (ERROR_INSERTED(8089))
5267 CLEAR_ERROR_INSERT_VALUE;
5269 regApiPtr->apiConnectstate = CS_COMMIT_SENT;
5276 Dbtc::sendCommitLqh(
Signal* signal,
5277 TcConnectRecord *
const regTcPtr)
5279 HostRecordPtr Thostptr;
5280 UintR ThostFilesize = chostFilesize;
5281 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
5282 Thostptr.i = regTcPtr->lastLqhNodeId;
5283 ptrCheckGuard(Thostptr, ThostFilesize, hostRecord);
5285 Uint32 Tnode = Thostptr.i;
5286 Uint32
self = getOwnNodeId();
5287 Uint32
ret = (Tnode ==
self) ? 4 : 1;
5290 Tdata[0] = regTcPtr->lastLqhCon;
5291 Tdata[1] = Uint32(regApiPtr->globalcheckpointid >> 32);
5292 Tdata[2] = regApiPtr->transid[0];
5293 Tdata[3] = regApiPtr->transid[1];
5294 Tdata[4] = Uint32(regApiPtr->globalcheckpointid);
5306 if (send_unpacked) {
5307 memcpy(&signal->theData[0], &Tdata[0], len << 2);
5308 Uint32 instanceKey = regTcPtr->lqhInstanceKey;
5309 BlockReference lqhRef = numberToRef(DBLQH, instanceKey, Tnode);
5310 sendSignal(lqhRef, GSN_COMMIT, signal, len, JBB);
5314 if (Thostptr.p->noOfPackedWordsLqh > 25 - 5) {
5316 sendPackedSignalLqh(signal, Thostptr.p);
5320 updatePackedList(signal, Thostptr.p, Thostptr.i);
5323 Tdata[0] |= (ZCOMMIT << 28);
5324 UintR Tindex = Thostptr.p->noOfPackedWordsLqh;
5325 UintR* TDataPtr = &Thostptr.p->packedWordsLqh[Tindex];
5326 memcpy(TDataPtr, &Tdata[0], len << 2);
5327 Thostptr.p->noOfPackedWordsLqh = Tindex + len;
5332 Dbtc::DIVER_node_fail_handling(
Signal* signal, Uint64 Tgci)
5341 setupFailData(signal);
5342 if (
false && tabortInd == ZFALSE) {
5344 commitGciHandling(signal, Tgci);
5345 toCommitHandlingLab(signal);
5348 apiConnectptr.p->returnsignal = RS_TCROLLBACKREP;
5349 apiConnectptr.p->returncode = ZNODEFAIL_BEFORE_COMMIT;
5350 toAbortHandlingLab(signal);
5360 void Dbtc::execCOMMITTED(
Signal* signal)
5362 TcConnectRecordPtr localTcConnectptr;
5363 ApiConnectRecordPtr localApiConnectptr;
5364 ApiConnectRecordPtr localCopyPtr;
5366 UintR TtcConnectFilesize = ctcConnectFilesize;
5367 UintR TapiConnectFilesize = capiConnectFilesize;
5368 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
5369 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
5372 if (ERROR_INSERTED(8018)) {
5373 CLEAR_ERROR_INSERT_VALUE;
5376 CRASH_INSERTION(8030);
5377 if (ERROR_INSERTED(8025)) {
5378 SET_ERROR_INSERT_VALUE(8026);
5381 if (ERROR_INSERTED(8041)) {
5382 CLEAR_ERROR_INSERT_VALUE;
5383 sendSignalWithDelay(cownref, GSN_COMMITTED, signal, 2000, 3);
5386 if (ERROR_INSERTED(8042)) {
5387 SET_ERROR_INSERT_VALUE(8046);
5388 sendSignalWithDelay(cownref, GSN_COMMITTED, signal, 2000, 4);
5392 localTcConnectptr.i = signal->theData[0];
5394 ptrCheckGuard(localTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
5395 localApiConnectptr.i = localTcConnectptr.p->apiConnect;
5396 if (localTcConnectptr.p->tcConnectstate != OS_COMMITTING) {
5397 warningReport(signal, 4);
5400 ptrCheckGuard(localApiConnectptr, TapiConnectFilesize,
5401 localApiConnectRecord);
5402 UintR Tcounter = localApiConnectptr.p->counter - 1;
5403 ConnectionState TapiConnectstate = localApiConnectptr.p->apiConnectstate;
5404 UintR Tdata1 = localApiConnectptr.p->transid[0] - signal->theData[1];
5405 UintR Tdata2 = localApiConnectptr.p->transid[1] - signal->theData[2];
5406 Tdata1 = Tdata1 | Tdata2;
5407 bool TcheckCondition =
5408 (TapiConnectstate != CS_COMMIT_SENT) || (Tcounter != 0);
5410 setApiConTimer(localApiConnectptr.i, ctcTimer, __LINE__);
5411 localApiConnectptr.p->counter = Tcounter;
5412 localTcConnectptr.p->tcConnectstate = OS_COMMITTED;
5414 warningReport(signal, 5);
5417 if (TcheckCondition) {
5427 if (ERROR_INSERTED(8020)) {
5429 systemErrorLab(signal, __LINE__);
5439 apiConnectptr = localApiConnectptr;
5440 localCopyPtr = sendApiCommit(signal);
5442 localTcConnectptr.i = localCopyPtr.p->firstTcConnect;
5443 UintR Tlqhkeyconfrec = localCopyPtr.p->lqhkeyconfrec;
5444 ptrCheckGuard(localTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
5445 localCopyPtr.p->counter = Tlqhkeyconfrec;
5447 apiConnectptr = localCopyPtr;
5448 tcConnectptr = localTcConnectptr;
5449 complete010Lab(signal);
5459 Dbtc::sendApiCommit(
Signal* signal)
5461 ApiConnectRecordPtr regApiPtr = apiConnectptr;
5463 if (ERROR_INSERTED(8055))
5470 signal->theData[0] = 9999;
5471 sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, 1000, 1);
5472 Uint32 node = refToNode(regApiPtr.p->ndbapiBlockref);
5473 signal->theData[0] = node;
5474 sendSignal(QMGR_REF, GSN_API_FAILREQ, signal, 1, JBB);
5476 SET_ERROR_INSERT_VALUE(8056);
5481 if (regApiPtr.p->returnsignal == RS_TCKEYCONF)
5483 if (ERROR_INSERTED(8054))
5485 CLEAR_ERROR_INSERT_VALUE;
5486 signal->theData[0] = 9999;
5487 sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, 5000, 1);
5491 sendtckeyconf(signal, 1);
5494 else if (regApiPtr.p->returnsignal == RS_TC_COMMITCONF)
5498 if(regApiPtr.p->commitAckMarker == RNIL)
5501 commitConf->apiConnectPtr = regApiPtr.p->ndbapiConnect;
5506 commitConf->apiConnectPtr = regApiPtr.p->ndbapiConnect | 1;
5508 commitConf->transId1 = regApiPtr.p->transid[0];
5509 commitConf->transId2 = regApiPtr.p->transid[1];
5510 commitConf->gci_hi = Uint32(regApiPtr.p->globalcheckpointid >> 32);
5511 commitConf->gci_lo = Uint32(regApiPtr.p->globalcheckpointid);
5513 sendSignal(regApiPtr.p->ndbapiBlockref, GSN_TC_COMMITCONF, signal,
5514 TcCommitConf::SignalLength, JBB);
5516 else if (regApiPtr.p->returnsignal == RS_NO_RETURN)
5522 TCKEY_abort(signal, 37);
5528 UintR TapiConnectFilesize = capiConnectFilesize;
5529 copyPtr.i = regApiPtr.p->apiCopyRecord;
5530 UintR TapiFailState = regApiPtr.p->apiFailState;
5531 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
5533 c_counters.ccommitCount++;
5534 ptrCheckGuard(copyPtr, TapiConnectFilesize, localApiConnectRecord);
5535 copyApi(copyPtr, regApiPtr);
5536 if (TapiFailState != ZTRUE) {
5540 handleApiFailState(signal, regApiPtr.i);
5550 void Dbtc::copyApi(ApiConnectRecordPtr copyPtr, ApiConnectRecordPtr regApiPtr)
5552 UintR TndbapiConnect = regApiPtr.p->ndbapiConnect;
5553 UintR TfirstTcConnect = regApiPtr.p->firstTcConnect;
5554 UintR Ttransid1 = regApiPtr.p->transid[0];
5555 UintR Ttransid2 = regApiPtr.p->transid[1];
5556 UintR Tlqhkeyconfrec = regApiPtr.p->lqhkeyconfrec;
5557 UintR TgcpPointer = regApiPtr.p->gcpPointer;
5558 UintR TgcpFilesize = cgcpFilesize;
5560 GcpRecord *localGcpRecord = gcpRecord;
5562 copyPtr.p->ndbapiBlockref = regApiPtr.p->ndbapiBlockref;
5563 copyPtr.p->ndbapiConnect = TndbapiConnect;
5564 copyPtr.p->firstTcConnect = TfirstTcConnect;
5565 copyPtr.p->apiConnectstate = CS_COMPLETING;
5566 copyPtr.p->transid[0] = Ttransid1;
5567 copyPtr.p->transid[1] = Ttransid2;
5568 copyPtr.p->lqhkeyconfrec = Tlqhkeyconfrec;
5569 copyPtr.p->commitAckMarker = RNIL;
5570 copyPtr.p->m_transaction_nodes = Tnodes;
5571 copyPtr.p->singleUserMode = 0;
5574 gcpPtr.i = TgcpPointer;
5575 ptrCheckGuard(gcpPtr, TgcpFilesize, localGcpRecord);
5576 unlinkApiConnect(gcpPtr, regApiPtr);
5577 linkApiToGcp(gcpPtr, copyPtr);
5578 setApiConTimer(regApiPtr.i, 0, __LINE__);
5579 regApiPtr.p->apiConnectstate = CS_CONNECTED;
5580 regApiPtr.p->commitAckMarker = RNIL;
5581 regApiPtr.p->firstTcConnect = RNIL;
5582 regApiPtr.p->lastTcConnect = RNIL;
5583 regApiPtr.p->m_transaction_nodes.clear();
5584 regApiPtr.p->singleUserMode = 0;
5585 releaseAllSeizedIndexOperations(regApiPtr.p);
5591 ApiConnectRecordPtr localApiConnectptr;
5592 UintR TapiConnectFilesize = capiConnectFilesize;
5593 UintR TprevGcpConnect = regApiPtr.p->prevGcpConnect;
5594 UintR TnextGcpConnect = regApiPtr.p->nextGcpConnect;
5595 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
5597 if (TprevGcpConnect == RNIL) {
5598 gcpPtr.p->firstApiConnect = TnextGcpConnect;
5601 localApiConnectptr.i = TprevGcpConnect;
5603 ptrCheckGuard(localApiConnectptr,
5604 TapiConnectFilesize, localApiConnectRecord);
5605 localApiConnectptr.p->nextGcpConnect = TnextGcpConnect;
5607 if (TnextGcpConnect == RNIL) {
5608 gcpPtr.p->lastApiConnect = TprevGcpConnect;
5611 localApiConnectptr.i = TnextGcpConnect;
5613 ptrCheckGuard(localApiConnectptr,
5614 TapiConnectFilesize, localApiConnectRecord);
5615 localApiConnectptr.p->prevGcpConnect = TprevGcpConnect;
5619 void Dbtc::complete010Lab(
Signal* signal)
5621 TcConnectRecordPtr localTcConnectptr;
5622 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
5623 UintR TtcConnectFilesize = ctcConnectFilesize;
5624 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
5626 localTcConnectptr.p = tcConnectptr.p;
5627 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
5628 UintR TapiConnectptrIndex = apiConnectptr.i;
5631 localTcConnectptr.p->apiConnect = TapiConnectptrIndex;
5632 localTcConnectptr.p->tcConnectstate = OS_COMPLETING;
5637 const Uint32 nextTcConnect = localTcConnectptr.p->nextTcConnect;
5638 Tcount += sendCompleteLqh(signal, localTcConnectptr.p);
5639 localTcConnectptr.i = nextTcConnect;
5640 if (localTcConnectptr.i != RNIL) {
5642 ptrCheckGuard(localTcConnectptr,
5643 TtcConnectFilesize, localTcConnectRecord);
5648 if (ERROR_INSERTED(8013)) {
5649 CLEAR_ERROR_INSERT_VALUE;
5652 signal->theData[0] = TcContinueB::ZSEND_COMPLETE_LOOP;
5653 signal->theData[1] = apiConnectptr.i;
5654 signal->theData[2] = localTcConnectptr.i;
5655 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
5660 regApiPtr->apiConnectstate = CS_COMPLETE_SENT;
5667 Dbtc::sendCompleteLqh(
Signal* signal,
5668 TcConnectRecord *
const regTcPtr)
5670 HostRecordPtr Thostptr;
5671 UintR ThostFilesize = chostFilesize;
5672 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
5673 Thostptr.i = regTcPtr->lastLqhNodeId;
5674 ptrCheckGuard(Thostptr, ThostFilesize, hostRecord);
5676 Uint32 Tnode = Thostptr.i;
5677 Uint32
self = getOwnNodeId();
5678 Uint32 ret = (Tnode ==
self) ? 4 : 1;
5681 Tdata[0] = regTcPtr->lastLqhCon;
5682 Tdata[1] = regApiPtr->transid[0];
5683 Tdata[2] = regApiPtr->transid[1];
5688 if (send_unpacked) {
5689 memcpy(&signal->theData[0], &Tdata[0], len << 2);
5690 Uint32 instanceKey = regTcPtr->lqhInstanceKey;
5691 BlockReference lqhRef = numberToRef(DBLQH, instanceKey, Tnode);
5692 sendSignal(lqhRef, GSN_COMPLETE, signal, 3, JBB);
5696 if (Thostptr.p->noOfPackedWordsLqh > 22) {
5698 sendPackedSignalLqh(signal, Thostptr.p);
5702 updatePackedList(signal, Thostptr.p, Thostptr.i);
5705 Tdata[0] |= (ZCOMPLETE << 28);
5706 UintR Tindex = Thostptr.p->noOfPackedWordsLqh;
5707 UintR* TDataPtr = &Thostptr.p->packedWordsLqh[Tindex];
5708 memcpy(TDataPtr, &Tdata[0], len << 2);
5709 Thostptr.p->noOfPackedWordsLqh = Tindex + len;
5715 Dbtc::sendFireTrigReq(
Signal* signal,
5719 UintR TtcConnectFilesize = ctcConnectFilesize;
5720 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
5721 TcConnectRecordPtr localTcConnectptr;
5723 setApiConTimer(regApiPtr.i, ctcTimer, __LINE__);
5726 localTcConnectptr.i = TopPtrI;
5727 ndbassert(TopPtrI != RNIL);
5728 Uint32 Tlqhkeyreqrec = regApiPtr.p->lqhkeyreqrec;
5729 Uint32 pass = regApiPtr.p->m_pre_commit_pass;
5730 for (Uint32 i = 0; localTcConnectptr.i != RNIL && i < 16; i++)
5732 ptrCheckGuard(localTcConnectptr,
5733 TtcConnectFilesize, localTcConnectRecord);
5735 const Uint32 nextTcConnect = localTcConnectptr.p->nextTcConnect;
5736 Uint32 flags = localTcConnectptr.p->m_special_op_flags;
5737 if (flags & TcConnectRecord::SOF_DEFERRED_TRIGGER)
5740 tc_clearbit(flags, TcConnectRecord::SOF_DEFERRED_TRIGGER);
5741 ndbrequire(localTcConnectptr.p->tcConnectstate == OS_PREPARED);
5742 localTcConnectptr.p->tcConnectstate = OS_FIRE_TRIG_REQ;
5743 localTcConnectptr.p->m_special_op_flags =
flags;
5744 i += sendFireTrigReqLqh(signal, localTcConnectptr, pass);
5747 localTcConnectptr.i = nextTcConnect;
5750 regApiPtr.p->lqhkeyreqrec = Tlqhkeyreqrec;
5751 if (localTcConnectptr.i == RNIL)
5758 ndbrequire(pass < 255);
5759 regApiPtr.p->m_pre_commit_pass = (Uint8)(pass + 1);
5765 signal->theData[0] = TcContinueB::ZSEND_FIRE_TRIG_REQ;
5766 signal->theData[1] = regApiPtr.i;
5767 signal->theData[2] = regApiPtr.p->transid[0];
5768 signal->theData[3] = regApiPtr.p->transid[1];
5769 signal->theData[4] = localTcConnectptr.i;
5770 if (ERROR_INSERTED_CLEAR(8090))
5772 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 5000, 5);
5776 sendSignal(cownref, GSN_CONTINUEB, signal, 5, JBB);
5782 Dbtc::sendFireTrigReqLqh(
Signal* signal,
5786 HostRecordPtr Thostptr;
5787 UintR ThostFilesize = chostFilesize;
5788 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
5789 Thostptr.i = regTcPtr.p->tcNodedata[0];
5790 ptrCheckGuard(Thostptr, ThostFilesize, hostRecord);
5792 Uint32 Tnode = Thostptr.i;
5793 Uint32
self = getOwnNodeId();
5794 Uint32 ret = (Tnode ==
self) ? 4 : 1;
5796 Uint32 Tdata[FireTrigReq::SignalLength];
5798 req->tcOpRec = regTcPtr.i;
5799 req->transId[0] = regApiPtr->transid[0];
5800 req->transId[1] = regApiPtr->transid[1];
5802 Uint32 len = FireTrigReq::SignalLength;
5806 if (send_unpacked) {
5807 memcpy(signal->theData, Tdata, len << 2);
5808 Uint32 instanceKey = regTcPtr.p->lqhInstanceKey;
5809 BlockReference lqhRef = numberToRef(DBLQH, instanceKey, Tnode);
5810 sendSignal(lqhRef, GSN_FIRE_TRIG_REQ, signal, len, JBB);
5814 if (Thostptr.p->noOfPackedWordsLqh > 25 - len) {
5816 sendPackedSignalLqh(signal, Thostptr.p);
5820 updatePackedList(signal, Thostptr.p, Thostptr.i);
5823 Tdata[0] |= (ZFIRE_TRIG_REQ << 28);
5824 UintR Tindex = Thostptr.p->noOfPackedWordsLqh;
5825 UintR* TDataPtr = &Thostptr.p->packedWordsLqh[Tindex];
5826 memcpy(TDataPtr, Tdata, len << 2);
5827 Thostptr.p->noOfPackedWordsLqh = Tindex + len;
5832 Dbtc::execFIRE_TRIG_CONF(
Signal* signal)
5834 TcConnectRecordPtr localTcConnectptr;
5835 ApiConnectRecordPtr regApiPtr;
5837 UintR TtcConnectFilesize = ctcConnectFilesize;
5838 UintR TapiConnectFilesize = capiConnectFilesize;
5839 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
5840 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
5843 localTcConnectptr.i = conf->tcOpRec;
5845 ptrCheckGuard(localTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
5846 regApiPtr.i = localTcConnectptr.p->apiConnect;
5847 if (localTcConnectptr.p->tcConnectstate != OS_FIRE_TRIG_REQ)
5849 warningReport(signal, 28);
5852 ptrCheckGuard(regApiPtr, TapiConnectFilesize,
5853 localApiConnectRecord);
5855 Uint32 Tlqhkeyreqrec = regApiPtr.p->lqhkeyreqrec;
5856 Uint32 TapiConnectstate = regApiPtr.p->apiConnectstate;
5857 UintR Tdata1 = regApiPtr.p->transid[0] - conf->transId[0];
5858 UintR Tdata2 = regApiPtr.p->transid[1] - conf->transId[1];
5859 Uint32 TcheckCondition =
5863 Tdata1 = Tdata1 | Tdata2 | TcheckCondition;
5866 warningReport(signal, 28);
5870 if (ERROR_INSERTED_CLEAR(8091))
5876 CRASH_INSERTION(8092);
5878 setApiConTimer(regApiPtr.i, ctcTimer, __LINE__);
5879 ndbassert(Tlqhkeyreqrec > 0);
5880 regApiPtr.p->lqhkeyreqrec = Tlqhkeyreqrec - 1;
5881 localTcConnectptr.p->tcConnectstate = OS_PREPARED;
5883 Uint32 noFired = FireTrigConf::getFiredCount(conf->noFiredTriggers);
5884 Uint32 deferred = FireTrigConf::getDeferredBit(conf->noFiredTriggers);
5886 regApiPtr.p->pendingTriggers += noFired;
5887 regApiPtr.p->m_flags |= (deferred) ?
5888 ApiConnectRecord::TF_DEFERRED_TRIGGERS : 0;
5889 localTcConnectptr.p->m_special_op_flags |= (deferred) ?
5890 TcConnectRecord::SOF_DEFERRED_TRIGGER : 0;
5892 if (regApiPtr.p->pendingTriggers == 0)
5895 lqhKeyConf_checkTransactionState(signal, regApiPtr);
5900 Dbtc::execFIRE_TRIG_REF(
Signal* signal)
5902 TcConnectRecordPtr localTcConnectptr;
5903 ApiConnectRecordPtr regApiPtr;
5905 UintR TtcConnectFilesize = ctcConnectFilesize;
5906 UintR TapiConnectFilesize = capiConnectFilesize;
5907 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
5908 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
5911 localTcConnectptr.i = ref->tcOpRec;
5913 ptrCheckGuard(localTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
5914 regApiPtr.i = localTcConnectptr.p->apiConnect;
5915 if (localTcConnectptr.p->tcConnectstate != OS_FIRE_TRIG_REQ)
5917 warningReport(signal, 28);
5920 ptrCheckGuard(regApiPtr, TapiConnectFilesize,
5921 localApiConnectRecord);
5923 apiConnectptr = regApiPtr;
5925 UintR Tdata1 = regApiPtr.p->transid[0] - ref->transId[0];
5926 UintR Tdata2 = regApiPtr.p->transid[1] - ref->transId[1];
5927 Tdata1 = Tdata1 | Tdata2;
5929 warningReport(signal, 28);
5937 warningReport(signal, 28);
5941 terrorCode = ref->errCode;
5942 abortErrorLab(signal);
5946 Dbtc::execTC_COMMIT_ACK(
Signal* signal){
5949 CommitAckMarker key;
5950 key.transid1 = signal->theData[0];
5951 key.transid2 = signal->theData[1];
5953 CommitAckMarkerPtr removedMarker;
5954 m_commitAckMarkerHash.
remove(removedMarker, key);
5955 if (removedMarker.i == RNIL) {
5957 warningHandlerLab(signal, __LINE__);
5960 sendRemoveMarkers(signal, removedMarker.p);
5961 m_commitAckMarkerPool.
release(removedMarker);
5965 Dbtc::sendRemoveMarkers(
Signal* signal,
const CommitAckMarker * marker)
5968 const Uint32 transId1 = marker->transid1;
5969 const Uint32 transId2 = marker->transid2;
5971 for(Uint32 node_id = 1; node_id < MAX_NDB_NODES; node_id++)
5974 if (marker->m_commit_ack_marker_nodes.get(node_id))
5975 sendRemoveMarker(signal, node_id, transId1, transId2);
5980 Dbtc::sendRemoveMarker(
Signal* signal,
5987 HostRecordPtr hostPtr;
5988 const UintR ThostFilesize = chostFilesize;
5990 ptrCheckGuard(hostPtr, ThostFilesize, hostRecord);
5994 Tdata[1] = transid1;
5995 Tdata[2] = transid2;
6000 if (send_unpacked) {
6003 memcpy(&signal->theData[0], &Tdata[1], (len - 1) << 2);
6004 Uint32 Tnode = hostPtr.i;
6006 for (i = 0; i < MAX_NDBMT_LQH_WORKERS; i++) {
6008 Uint32 instanceKey = 1 +
i;
6009 BlockReference ref = numberToRef(DBLQH, instanceKey, Tnode);
6010 sendSignal(ref, GSN_REMOVE_MARKER_ORD, signal, len - 1, JBB);
6015 if (hostPtr.p->noOfPackedWordsLqh > (25 - 3)){
6017 sendPackedSignalLqh(signal, hostPtr.p);
6020 updatePackedList(signal, hostPtr.p, hostPtr.i);
6023 UintR numWord = hostPtr.p->noOfPackedWordsLqh;
6024 UintR* dataPtr = &hostPtr.p->packedWordsLqh[numWord];
6026 Tdata[0] |= (ZREMOVE_MARKER << 28);
6027 memcpy(dataPtr, &Tdata[0], len << 2);
6028 hostPtr.p->noOfPackedWordsLqh = numWord + 3;
6031 void Dbtc::execCOMPLETED(
Signal* signal)
6033 TcConnectRecordPtr localTcConnectptr;
6034 ApiConnectRecordPtr localApiConnectptr;
6036 UintR TtcConnectFilesize = ctcConnectFilesize;
6037 UintR TapiConnectFilesize = capiConnectFilesize;
6038 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
6039 ApiConnectRecord *localApiConnectRecord = apiConnectRecord;
6042 if (ERROR_INSERTED(8031)) {
6043 systemErrorLab(signal, __LINE__);
6045 if (ERROR_INSERTED(8019)) {
6046 CLEAR_ERROR_INSERT_VALUE;
6049 if (ERROR_INSERTED(8027)) {
6050 SET_ERROR_INSERT_VALUE(8028);
6053 if (ERROR_INSERTED(8043)) {
6054 CLEAR_ERROR_INSERT_VALUE;
6055 sendSignalWithDelay(cownref, GSN_COMPLETED, signal, 2000, 3);
6058 if (ERROR_INSERTED(8044)) {
6059 SET_ERROR_INSERT_VALUE(8047);
6060 sendSignalWithDelay(cownref, GSN_COMPLETED, signal, 2000, 3);
6064 localTcConnectptr.i = signal->theData[0];
6066 ptrCheckGuard(localTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
6067 bool Tcond1 = (localTcConnectptr.p->tcConnectstate != OS_COMPLETING);
6068 localApiConnectptr.i = localTcConnectptr.p->apiConnect;
6070 warningReport(signal, 6);
6073 ptrCheckGuard(localApiConnectptr, TapiConnectFilesize,
6074 localApiConnectRecord);
6075 UintR Tdata1 = localApiConnectptr.p->transid[0] - signal->theData[1];
6076 UintR Tdata2 = localApiConnectptr.p->transid[1] - signal->theData[2];
6077 UintR Tcounter = localApiConnectptr.p->counter - 1;
6078 ConnectionState TapiConnectstate = localApiConnectptr.p->apiConnectstate;
6079 Tdata1 = Tdata1 | Tdata2;
6080 bool TcheckCondition =
6081 (TapiConnectstate != CS_COMPLETE_SENT) || (Tcounter != 0);
6083 warningReport(signal, 7);
6086 setApiConTimer(localApiConnectptr.i, ctcTimer, __LINE__);
6087 localApiConnectptr.p->counter = Tcounter;
6088 localTcConnectptr.p->tcConnectstate = OS_COMPLETED;
6089 localTcConnectptr.p->noOfNodes = 0;
6090 if (TcheckCondition) {
6100 if (ERROR_INSERTED(8021)) {
6102 systemErrorLab(signal, __LINE__);
6104 apiConnectptr = localApiConnectptr;
6105 releaseTransResources(signal);
6112 void Dbtc::releaseTransResources(
Signal* signal)
6114 TcConnectRecordPtr localTcConnectptr;
6115 UintR TtcConnectFilesize = ctcConnectFilesize;
6116 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
6117 apiConnectptr.p->m_transaction_nodes.
clear();
6118 localTcConnectptr.i = apiConnectptr.p->firstTcConnect;
6121 ptrCheckGuard(localTcConnectptr, TtcConnectFilesize, localTcConnectRecord);
6122 UintR rtrTcConnectptrIndex = localTcConnectptr.p->nextTcConnect;
6123 tcConnectptr.i = localTcConnectptr.i;
6124 tcConnectptr.p = localTcConnectptr.p;
6125 localTcConnectptr.i = rtrTcConnectptrIndex;
6127 }
while (localTcConnectptr.i != RNIL);
6128 handleGcp(signal, apiConnectptr);
6130 releaseAllSeizedIndexOperations(apiConnectptr.p);
6131 releaseApiConCopy(signal);
6143 GcpRecord *localGcpRecord = gcpRecord;
6144 GcpRecordPtr localGcpPtr;
6145 UintR TgcpFilesize = cgcpFilesize;
6146 localGcpPtr.i = apiConnectptr.p->gcpPointer;
6147 ptrCheckGuard(localGcpPtr, TgcpFilesize, localGcpRecord);
6148 unlinkApiConnect(localGcpPtr, regApiPtr);
6149 if (localGcpPtr.p->firstApiConnect == RNIL) {
6150 if (localGcpPtr.p->gcpNomoretransRec == ZTRUE) {
6151 if (c_ongoing_take_over_cnt == 0)
6154 gcpTcfinished(signal, localGcpPtr.p->gcpId);
6155 unlinkGcp(localGcpPtr);
6161 void Dbtc::releaseApiConCopy(
Signal* signal)
6163 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
6164 UintR TfirstfreeApiConnectCopyOld = cfirstfreeApiConnectCopy;
6165 cfirstfreeApiConnectCopy = apiConnectptr.i;
6166 regApiPtr->nextApiConnect = TfirstfreeApiConnectCopyOld;
6167 setApiConTimer(apiConnectptr.i, 0, __LINE__);
6168 regApiPtr->apiConnectstate = CS_RESTART;
6169 ndbrequire(regApiPtr->commitAckMarker == RNIL);
6175 void Dbtc::releaseDirtyWrite(
Signal* signal)
6177 unlinkReadyTcCon(signal);
6179 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
6180 if (regApiPtr->apiConnectstate == CS_START_COMMITTING) {
6181 if (regApiPtr->firstTcConnect == RNIL) {
6183 regApiPtr->apiConnectstate = CS_CONNECTED;
6184 setApiConTimer(apiConnectptr.i, 0, __LINE__);
6185 sendtckeyconf(signal, 1);
6206 void Dbtc::execLQHKEYREF(
Signal* signal)
6212 UintR compare_transid1, compare_transid2;
6213 UintR TtcConnectFilesize = ctcConnectFilesize;
6220 if (lqhKeyRef->connectPtr < TtcConnectFilesize) {
6230 tcConnectptr.i = lqhKeyRef->connectPtr;
6231 Uint32 errCode = terrorCode = lqhKeyRef->errorCode;
6232 ptrAss(tcConnectptr, tcConnectRecord);
6233 TcConnectRecord *
const regTcPtr = tcConnectptr.p;
6234 if (regTcPtr->tcConnectstate == OS_OPERATING) {
6235 Uint32 save = apiConnectptr.i = regTcPtr->apiConnect;
6236 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
6237 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
6238 compare_transid1 = regApiPtr->transid[0] ^ lqhKeyRef->transId1;
6239 compare_transid2 = regApiPtr->transid[1] ^ lqhKeyRef->transId2;
6240 compare_transid1 = compare_transid1 | compare_transid2;
6241 if (compare_transid1 != 0) {
6242 warningReport(signal, 25);
6246 const Uint32 triggeringOp = regTcPtr->triggeringOperation;
6247 if (triggeringOp != RNIL) {
6250 TcConnectRecordPtr opPtr;
6251 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
6253 opPtr.i = triggeringOp;
6254 ptrCheckGuard(opPtr, ctcConnectFilesize, localTcConnectRecord);
6256 const Uint32 opType = regTcPtr->operation;
6260 case TriggerType::SECONDARY_INDEX:{
6265 indexId = indexData->indexId;
6266 regApiPtr->errorData = indexId;
6267 if (errCode == ZALREADYEXIST)
6270 errCode = terrorCode = ZNOTUNIQUE;
6273 else if (!(opType == ZDELETE && errCode == ZNOT_FOUND)) {
6284 if (indexData->indexState != IS_BUILDING)
6292 case TriggerType::REORG_TRIGGER:
6294 if (opType == ZINSERT && errCode == ZALREADYEXIST)
6297 ndbout_c(
"reorg, ignore ZALREADYEXIST");
6300 else if (errCode == ZNOT_FOUND)
6303 ndbout_c(
"reorg, ignore ZNOT_FOUND");
6306 else if (errCode == 839)
6309 ndbout_c(
"reorg, ignore 839");
6314 ndbout_c(
"reorg: opType: %u errCode: %u", opType, errCode);
6327 regApiPtr->lqhkeyreqrec--;
6333 clearCommitAckMarker(regApiPtr, regTcPtr);
6335 unlinkReadyTcCon(signal);
6338 trigger_op_finished(signal, apiConnectptr, opPtr.p);
6343 markOperationAborted(regApiPtr, regTcPtr);
6345 if(regApiPtr->apiConnectstate == CS_ABORTING){
6353 const Uint32 abort = regTcPtr->m_execAbortOption;
6354 if (abort == TcKeyReq::AbortOnError || triggeringOp != RNIL) {
6358 TCKEY_abort(signal, 49);
6366 tcKeyRef->transId[0] = regApiPtr->transid[0];
6367 tcKeyRef->transId[1] = regApiPtr->transid[1];
6368 tcKeyRef->errorCode = terrorCode;
6369 bool isIndexOp = regTcPtr->isIndexOp(regTcPtr->m_special_op_flags);
6370 Uint32 indexOp = tcConnectptr.p->indexOp;
6371 Uint32 clientData = regTcPtr->clientData;
6372 unlinkReadyTcCon(signal);
6374 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
6377 regApiPtr->lqhkeyreqrec--;
6378 tcKeyRef->connectPtr = indexOp;
6379 tcKeyRef->errorData = indexId;
6380 EXECUTE_DIRECT(DBTC, GSN_TCKEYREF, signal, TcKeyRef::SignalLength);
6381 apiConnectptr.i = save;
6382 apiConnectptr.p = regApiPtr;
6385 tcKeyRef->connectPtr = clientData;
6386 tcKeyRef->errorData = indexId;
6387 sendSignal(regApiPtr->ndbapiBlockref,
6388 GSN_TCKEYREF, signal, TcKeyRef::SignalLength, JBB);
6397 regApiPtr->lqhkeyreqrec--;
6398 if (regApiPtr->lqhkeyconfrec == regApiPtr->lqhkeyreqrec) {
6399 if (regApiPtr->apiConnectstate == CS_START_COMMITTING) {
6401 diverify010Lab(signal);
6404 else if (regApiPtr->tckeyrec > 0 ||
6405 tc_testbit(regApiPtr->m_flags, ApiConnectRecord::TF_EXEC_FLAG))
6408 sendtckeyconf(signal, 2);
6415 warningReport(signal, 26);
6418 errorReport(signal, 6);
6423 void Dbtc::clearCommitAckMarker(ApiConnectRecord *
const regApiPtr,
6424 TcConnectRecord *
const regTcPtr)
6426 const Uint32 commitAckMarker = regTcPtr->commitAckMarker;
6427 if (regApiPtr->commitAckMarker == RNIL)
6429 ndbassert(commitAckMarker == RNIL);
6432 if(commitAckMarker != RNIL)
6435 ndbassert(regApiPtr->commitAckMarker == commitAckMarker);
6436 ndbrequire(regApiPtr->no_commit_ack_markers > 0);
6437 regApiPtr->no_commit_ack_markers--;
6438 regTcPtr->commitAckMarker = RNIL;
6439 if (regApiPtr->no_commit_ack_markers == 0)
6441 regApiPtr->commitAckMarker = RNIL;
6442 tc_clearbit(regApiPtr->m_flags,
6443 ApiConnectRecord::TF_COMMIT_ACK_MARKER_RECEIVED);
6444 m_commitAckMarkerHash.
release(commitAckMarker);
6449 void Dbtc::markOperationAborted(ApiConnectRecord *
const regApiPtr,
6450 TcConnectRecord *
const regTcPtr)
6457 regTcPtr->noOfNodes = 0;
6458 regTcPtr->tcConnectstate = OS_ABORTING;
6459 clearCommitAckMarker(regApiPtr, regTcPtr);
6467 void Dbtc::execTC_COMMITREQ(
Signal* signal)
6469 UintR compare_transid1, compare_transid2;
6472 apiConnectptr.i = signal->theData[0];
6473 if (apiConnectptr.i < capiConnectFilesize) {
6474 ptrAss(apiConnectptr, apiConnectRecord);
6475 compare_transid1 = apiConnectptr.p->transid[0] ^ signal->theData[1];
6476 compare_transid2 = apiConnectptr.p->transid[1] ^ signal->theData[2];
6477 compare_transid1 = compare_transid1 | compare_transid2;
6478 if (compare_transid1 != 0) {
6483 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
6485 const Uint32 apiConnectPtr = regApiPtr->ndbapiConnect;
6486 const Uint32 apiBlockRef = regApiPtr->ndbapiBlockref;
6487 const Uint32 transId1 = regApiPtr->transid[0];
6488 const Uint32 transId2 = regApiPtr->transid[1];
6489 Uint32 errorCode = 0;
6491 regApiPtr->m_flags |= ApiConnectRecord::TF_EXEC_FLAG;
6492 switch (regApiPtr->apiConnectstate) {
6494 tcConnectptr.i = regApiPtr->firstTcConnect;
6495 if (tcConnectptr.i != RNIL) {
6496 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
6497 if (regApiPtr->lqhkeyconfrec == regApiPtr->lqhkeyreqrec) {
6504 regApiPtr->returnsignal = RS_TC_COMMITCONF;
6505 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
6506 diverify010Lab(signal);
6515 regApiPtr->returnsignal = RS_NO_RETURN;
6516 errorCode = ZTRANS_STATUS_ERROR;
6517 abort010Lab(signal);
6525 commitConf->apiConnectPtr = apiConnectPtr;
6526 commitConf->transId1 = transId1;
6527 commitConf->transId2 = transId2;
6528 commitConf->gci_hi = 0;
6529 commitConf->gci_lo = 0;
6530 sendSignal(apiBlockRef, GSN_TC_COMMITCONF, signal,
6531 TcCommitConf::SignalLength, JBB);
6533 regApiPtr->returnsignal = RS_NO_RETURN;
6534 releaseAbortResources(signal);
6544 regApiPtr->returnsignal = RS_NO_RETURN;
6545 errorCode = ZPREPAREINPROGRESS;
6546 abort010Lab(signal);
6549 case CS_START_COMMITTING:
6551 case CS_COMMIT_SENT:
6553 case CS_COMPLETE_SENT:
6554 case CS_REC_COMMITTING:
6555 case CS_PREPARE_TO_COMMIT:
6561 errorCode = ZCOMMITINPROGRESS;
6565 errorCode = regApiPtr->returncode ?
6566 regApiPtr->returncode : ZABORTINPROGRESS;
6573 errorCode = ZSCANINPROGRESS;
6578 case CS_START_PREPARING:
6581 case CS_REC_PREPARING:
6586 warningHandlerLab(signal, __LINE__);
6590 commitRef->apiConnectPtr = apiConnectPtr;
6591 commitRef->transId1 = transId1;
6592 commitRef->transId2 = transId2;
6593 commitRef->errorCode = errorCode;
6594 sendSignal(apiBlockRef, GSN_TC_COMMITREF, signal,
6595 TcCommitRef::SignalLength, JBB);
6599 warningHandlerLab(signal, __LINE__);
6617 void Dbtc::execTCROLLBACKREQ(
Signal* signal)
6619 bool potentiallyBad=
false;
6620 UintR compare_transid1, compare_transid2;
6624 if(unlikely((signal->getLength() >= 4) && (signal->theData[3] & 0x1)))
6626 ndbout_c(
"Trying to roll back potentially bad txn\n");
6627 potentiallyBad=
true;
6630 apiConnectptr.i = signal->theData[0];
6631 if (apiConnectptr.i >= capiConnectFilesize) {
6632 goto TC_ROLL_warning;
6634 ptrAss(apiConnectptr, apiConnectRecord);
6635 compare_transid1 = apiConnectptr.p->transid[0] ^ signal->theData[1];
6636 compare_transid2 = apiConnectptr.p->transid[1] ^ signal->theData[2];
6637 compare_transid1 = compare_transid1 | compare_transid2;
6638 if (compare_transid1 != 0) {
6643 apiConnectptr.p->m_flags |= ApiConnectRecord::TF_EXEC_FLAG;
6644 switch (apiConnectptr.p->apiConnectstate) {
6648 apiConnectptr.p->returnsignal = RS_TCROLLBACKCONF;
6649 abort010Lab(signal);
6653 signal->theData[0] = apiConnectptr.p->ndbapiConnect;
6654 signal->theData[1] = apiConnectptr.p->transid[0];
6655 signal->theData[2] = apiConnectptr.p->transid[1];
6656 sendSignal(apiConnectptr.p->ndbapiBlockref, GSN_TCROLLBACKCONF,
6660 case CS_PREPARE_TO_COMMIT:
6662 case CS_COMMIT_SENT:
6664 case CS_COMPLETE_SENT:
6665 case CS_WAIT_COMMIT_CONF:
6666 case CS_WAIT_COMPLETE_CONF:
6668 case CS_DISCONNECTED:
6669 case CS_START_COMMITTING:
6670 case CS_REC_COMMITTING:
6675 signal->theData[0] = apiConnectptr.p->ndbapiConnect;
6676 signal->theData[1] = apiConnectptr.p->transid[0];
6677 signal->theData[2] = apiConnectptr.p->transid[1];
6678 signal->theData[3] = ZROLLBACKNOTALLOWED;
6679 signal->theData[4] = apiConnectptr.p->apiConnectstate;
6680 sendSignal(apiConnectptr.p->ndbapiBlockref, GSN_TCROLLBACKREF,
6686 if (apiConnectptr.p->abortState == AS_IDLE) {
6688 signal->theData[0] = apiConnectptr.p->ndbapiConnect;
6689 signal->theData[1] = apiConnectptr.p->transid[0];
6690 signal->theData[2] = apiConnectptr.p->transid[1];
6691 sendSignal(apiConnectptr.p->ndbapiBlockref, GSN_TCROLLBACKCONF,
6695 apiConnectptr.p->returnsignal = RS_TCROLLBACKCONF;
6698 case CS_WAIT_ABORT_CONF:
6700 apiConnectptr.p->returnsignal = RS_TCROLLBACKCONF;
6702 case CS_START_PREPARING:
6706 case CS_REC_PREPARING:
6709 goto TC_ROLL_system_error;
6716 if(likely(potentiallyBad==
false))
6717 warningHandlerLab(signal, __LINE__);
6720 TC_ROLL_system_error:
6722 if(likely(potentiallyBad==
false))
6723 systemErrorLab(signal, __LINE__);
6727 void Dbtc::execTC_HBREP(
Signal* signal)
6729 const TcHbRep *
const tcHbRep =
6730 (
TcHbRep *)signal->getDataPtr();
6733 apiConnectptr.i = tcHbRep->apiConnectPtr;
6734 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
6736 if (apiConnectptr.p->transid[0] == tcHbRep->transId1 &&
6737 apiConnectptr.p->transid[1] == tcHbRep->transId2){
6739 if (getApiConTimer(apiConnectptr.i) != 0){
6740 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
6742 DEBUG(
"TCHBREP received when timer was off apiConnectptr.i="
6743 << apiConnectptr.i);
6756 void Dbtc::warningReport(
Signal* signal,
int place)
6762 ndbout <<
"ABORTED to not active TC record" << endl;
6768 ndbout <<
"ABORTED to TC record active with new transaction" << endl;
6774 ndbout <<
"ABORTED to active TC record not expecting ABORTED" << endl;
6780 ndbout <<
"ABORTED to TC rec active with trans but wrong node" << endl;
6781 ndbout <<
"This is ok when aborting in node failure situations" << endl;
6787 ndbout <<
"Received COMMITTED in wrong state in Dbtc" << endl;
6793 ndbout <<
"Received COMMITTED with wrong transid in Dbtc" << endl;
6799 ndbout <<
"Received COMPLETED in wrong state in Dbtc" << endl;
6805 ndbout <<
"Received COMPLETED with wrong transid in Dbtc" << endl;
6811 ndbout <<
"Received COMMITCONF with tc-rec in wrong state in Dbtc" << endl;
6817 ndbout <<
"Received COMMITCONF with api-rec in wrong state in Dbtc" <<endl;
6823 ndbout <<
"Received COMMITCONF with wrong transid in Dbtc" << endl;
6829 ndbout <<
"Received COMMITCONF from wrong nodeid in Dbtc" << endl;
6835 ndbout <<
"Received COMPLETECONF, tc-rec in wrong state in Dbtc" << endl;
6841 ndbout <<
"Received COMPLETECONF, api-rec in wrong state in Dbtc" << endl;
6847 ndbout <<
"Received COMPLETECONF with wrong transid in Dbtc" << endl;
6853 ndbout <<
"Received COMPLETECONF from wrong nodeid in Dbtc" << endl;
6859 ndbout <<
"Received ABORTCONF, tc-rec in wrong state in Dbtc" << endl;
6865 ndbout <<
"Received ABORTCONF, api-rec in wrong state in Dbtc" << endl;
6871 ndbout <<
"Received ABORTCONF with wrong transid in Dbtc" << endl;
6877 ndbout <<
"Received ABORTCONF from wrong nodeid in Dbtc" << endl;
6883 ndbout <<
"Time-out waiting for ABORTCONF in Dbtc" << endl;
6889 ndbout <<
"Time-out waiting for COMMITCONF in Dbtc" << endl;
6895 ndbout <<
"Time-out waiting for COMPLETECONF in Dbtc" << endl;
6901 ndbout <<
"Received LQHKEYCONF in wrong tc-state in Dbtc" << endl;
6907 ndbout <<
"Received LQHKEYREF to wrong transid in Dbtc" << endl;
6913 ndbout <<
"Received LQHKEYREF in wrong state in Dbtc" << endl;
6919 ndbout <<
"Received LQHKEYCONF to wrong transid in Dbtc" << endl;
6926 ndbout <<
"Received LQHKEYCONF in wrong api-state in Dbtc" << endl;
6932 ndbout <<
"Discarding FIRE_TRIG_REF/CONF in Dbtc" << endl;
6938 ndbout <<
"Discarding TcContinueB::ZSEND_FIRE_TRIG_REQ in Dbtc" << endl;
6948 void Dbtc::errorReport(
Signal* signal,
int place)
6976 systemErrorLab(signal, __LINE__);
6984 void Dbtc::execABORTED(
Signal* signal)
6986 UintR compare_transid1, compare_transid2;
6989 tcConnectptr.i = signal->theData[0];
6990 UintR Tnodeid = signal->theData[3];
6991 UintR TlastLqhInd = signal->theData[4];
6993 if (ERROR_INSERTED(8040)) {
6994 CLEAR_ERROR_INSERT_VALUE;
6995 sendSignalWithDelay(cownref, GSN_ABORTED, signal, 2000, 5);
7001 if (tcConnectptr.i >= ctcConnectFilesize) {
7002 errorReport(signal, 0);
7010 ptrAss(tcConnectptr, tcConnectRecord);
7011 if (tcConnectptr.p->tcConnectstate != OS_ABORT_SENT) {
7012 warningReport(signal, 2);
7018 apiConnectptr.i = tcConnectptr.p->apiConnect;
7019 if (apiConnectptr.i >= capiConnectFilesize) {
7020 warningReport(signal, 0);
7023 ptrAss(apiConnectptr, apiConnectRecord);
7024 compare_transid1 = apiConnectptr.p->transid[0] ^ signal->theData[1];
7025 compare_transid2 = apiConnectptr.p->transid[1] ^ signal->theData[2];
7026 compare_transid1 = compare_transid1 | compare_transid2;
7027 if (compare_transid1 != 0) {
7028 warningReport(signal, 1);
7031 if (ERROR_INSERTED(8024)) {
7033 systemErrorLab(signal, __LINE__);
7039 clearCommitAckMarker(apiConnectptr.p, tcConnectptr.p);
7043 for (i = 0; i < tcConnectptr.p->noOfNodes; i++) {
7045 if (tcConnectptr.p->tcNodedata[i] == Tnodeid) {
7055 clearTcNodeData(signal, TlastLqhInd, i);
7059 warningReport(signal, 3);
7062 for (i = 0; i < tcConnectptr.p->noOfNodes; i++) {
7063 if (tcConnectptr.p->tcNodedata[i] != 0) {
7071 tcConnectptr.p->noOfNodes = 0;
7072 tcConnectptr.p->tcConnectstate = OS_ABORTING;
7073 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
7074 apiConnectptr.p->counter--;
7075 if (apiConnectptr.p->counter > 0) {
7088 releaseAbortResources(signal);
7091 void Dbtc::clearTcNodeData(
Signal* signal,
7092 UintR TLastLqhIndicator,
7096 if (TLastLqhIndicator == ZTRUE) {
7097 for (Ti = Tstart ; Ti < tcConnectptr.p->noOfNodes; Ti++) {
7099 tcConnectptr.p->tcNodedata[Ti] = 0;
7103 tcConnectptr.p->tcNodedata[Tstart] = 0;
7107 void Dbtc::abortErrorLab(
Signal* signal)
7109 ptrGuard(apiConnectptr);
7110 ApiConnectRecord * transP = apiConnectptr.p;
7111 if (transP->apiConnectstate == CS_ABORTING && transP->abortState != AS_IDLE){
7115 transP->returnsignal = RS_TCROLLBACKREP;
7116 if(transP->returncode == 0){
7118 transP->returncode = terrorCode;
7120 abort010Lab(signal);
7123 void Dbtc::abort010Lab(
Signal* signal)
7125 ApiConnectRecord * transP = apiConnectptr.p;
7126 if (transP->apiConnectstate == CS_ABORTING && transP->abortState != AS_IDLE){
7130 transP->apiConnectstate = CS_ABORTING;
7135 transP->abortState = AS_ACTIVE;
7136 transP->counter = 0;
7138 if (transP->firstTcConnect == RNIL) {
7143 releaseAbortResources(signal);
7146 tcConnectptr.i = transP->firstTcConnect;
7147 abort015Lab(signal);
7159 void Dbtc::abort015Lab(
Signal* signal)
7161 Uint32 TloopCount = 0;
7165 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
7166 switch (tcConnectptr.p->tcConnectstate) {
7168 case OS_WAIT_KEYINFO:
7175 tcConnectptr.p->noOfNodes = 0;
7176 tcConnectptr.p->tcConnectstate = OS_ABORTING;
7184 tcConnectptr.p->noOfNodes = 0;
7185 tcConnectptr.p->tcConnectstate = OS_ABORTING;
7191 case OS_FIRE_TRIG_REQ:
7198 releaseAndAbort(signal);
7199 tcConnectptr.p->tcConnectstate = OS_ABORT_SENT;
7207 DEBUG(
"ABORT_SENT state in abort015Lab(), not expected");
7208 systemErrorLab(signal, __LINE__);
7212 DEBUG(
"tcConnectstate = " << tcConnectptr.p->tcConnectstate);
7213 systemErrorLab(signal, __LINE__);
7217 if (tcConnectptr.p->nextTcConnect != RNIL) {
7219 tcConnectptr.i = tcConnectptr.p->nextTcConnect;
7220 if (TloopCount < 1024 && !
7221 (ERROR_INSERTED(8089)))
7233 apiConnectptr.p->counter++;
7234 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
7235 signal->theData[0] = TcContinueB::ZABORT_BREAK;
7236 signal->theData[1] = tcConnectptr.i;
7237 signal->theData[2] = apiConnectptr.i;
7238 if (ERROR_INSERTED(8089))
7240 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 100, 3);
7243 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
7248 if (ERROR_INSERTED(8089))
7250 CLEAR_ERROR_INSERT_VALUE;
7253 if (apiConnectptr.p->counter > 0) {
7255 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
7263 releaseAbortResources(signal);
7269 int Dbtc::releaseAndAbort(
Signal* signal)
7271 HostRecordPtr localHostptr;
7272 UintR TnoLoops = tcConnectptr.p->noOfNodes;
7274 apiConnectptr.p->counter++;
7275 bool prevAlive =
false;
7276 for (Uint32 Ti = 0; Ti < TnoLoops ; Ti++) {
7277 localHostptr.i = tcConnectptr.p->tcNodedata[Ti];
7278 ptrCheckGuard(localHostptr, chostFilesize, hostRecord);
7279 if (localHostptr.p->hostStatus == HS_ALIVE) {
7289 Uint32 instanceKey = tcConnectptr.p->lqhInstanceKey;
7290 tblockref = numberToRef(DBLQH, instanceKey, localHostptr.i);
7291 signal->theData[0] = tcConnectptr.i;
7292 signal->theData[1] = cownref;
7293 signal->theData[2] = apiConnectptr.p->transid[0];
7294 signal->theData[3] = apiConnectptr.p->transid[1];
7295 sendSignal(tblockref, GSN_ABORT, signal, 4, JBB);
7299 signal->theData[0] = tcConnectptr.i;
7300 signal->theData[1] = apiConnectptr.p->transid[0];
7301 signal->theData[2] = apiConnectptr.p->transid[1];
7302 signal->theData[3] = localHostptr.i;
7303 signal->theData[4] = ZFALSE;
7304 sendSignal(cownref, GSN_ABORTED, signal, 5, JBB);
7315 void Dbtc::execTIME_SIGNAL(
Signal* signal)
7320 if (csystemStart != SSS_TRUE) {
7324 checkStartTimeout(signal);
7325 checkStartFragTimeout(signal);
7331 void Dbtc::checkStartTimeout(
Signal* signal)
7333 ctimeOutCheckCounter++;
7334 if (ctimeOutCheckActive == TOCS_TRUE) {
7337 if(ctimeOutCheckHeartbeat > ctimeOutCheckLastHeartbeat){
7339 ctimeOutMissedHeartbeats = 0;
7342 ctimeOutMissedHeartbeats++;
7343 if (ctimeOutMissedHeartbeats > 100){
7345 systemErrorLab(signal, __LINE__);
7348 ctimeOutCheckLastHeartbeat = ctimeOutCheckHeartbeat;
7351 if (ctimeOutCheckCounter < ctimeOutCheckDelay) {
7359 ctimeOutCheckActive = TOCS_TRUE;
7360 ctimeOutCheckCounter = 0;
7361 timeOutLoopStartLab(signal, 0);
7368 void Dbtc::checkStartFragTimeout(
Signal* signal)
7370 ctimeOutCheckFragCounter++;
7371 if (ctimeOutCheckFragActive == TOCS_TRUE) {
7375 if (ctimeOutCheckFragCounter < ctimeOutCheckDelay) {
7384 ctimeOutCheckFragActive = TOCS_TRUE;
7385 ctimeOutCheckFragCounter = 0;
7386 timeOutLoopStartFragLab(signal, 0);
7405 void Dbtc::timeOutLoopStartLab(
Signal* signal, Uint32 api_con_ptr)
7407 Uint32 end_ptr, time_passed, time_out_value, mask_value;
7408 Uint32 old_mask_value= 0;
7409 const Uint32 api_con_sz= capiConnectFilesize;
7410 const Uint32 tc_timer= ctcTimer;
7411 const Uint32 time_out_param= ctimeOutValue;
7412 const Uint32 old_time_out_param= c_abortRec.oldTimeOutValue;
7414 ctimeOutCheckHeartbeat = tc_timer;
7416 if (api_con_ptr + 1024 < api_con_sz) {
7418 end_ptr= api_con_ptr + 1024;
7421 end_ptr= api_con_sz;
7423 if (time_out_param > 300) {
7426 }
else if (time_out_param < 30) {
7433 if (time_out_param != old_time_out_param &&
7438 if (old_time_out_param > 300) {
7441 }
else if (old_time_out_param < 30) {
7449 for ( ; api_con_ptr < end_ptr; api_con_ptr++) {
7450 Uint32 api_timer= getApiConTimer(api_con_ptr);
7452 if (api_timer != 0) {
7453 Uint32 error= ZTIME_OUT_ERROR;
7454 time_out_value= time_out_param + (ndb_rand() & mask_value);
7455 if (unlikely(old_mask_value))
7457 apiConnectptr.i = api_con_ptr;
7458 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
7460 refToNode(apiConnectptr.p->ndbapiBlockref)) ||
7461 !(apiConnectptr.p->singleUserMode & (1 << NDB_SUM_LOCKED)))
7465 old_time_out_param + (api_con_ptr & old_mask_value);
7469 error= ZCLUSTER_IN_SINGLEUSER_MODE;
7472 time_passed= tc_timer - api_timer;
7473 if (time_passed > time_out_value)
7476 timeOutFoundLab(signal, api_con_ptr, error);
7482 if (api_con_ptr == api_con_sz) {
7490 ctimeOutCheckActive = TOCS_FALSE;
7493 sendContinueTimeOutControl(signal, api_con_ptr);
7498 void Dbtc::timeOutFoundLab(
Signal* signal, Uint32 TapiConPtr, Uint32 errCode)
7500 apiConnectptr.i = TapiConPtr;
7501 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
7507 DEBUG(
"[ H'" << hex << apiConnectptr.p->transid[0]
7508 <<
" H'" << apiConnectptr.p->transid[1] <<
"] " << dec
7509 <<
"Time-out in state = " << apiConnectptr.p->apiConnectstate
7510 <<
" apiConnectptr.i = " << apiConnectptr.i
7512 << tc_testbit(apiConnectptr.p->m_flags, ApiConnectRecord::TF_EXEC_FLAG)
7513 <<
" - place: " << c_apiConTimer_line[apiConnectptr.i]
7514 <<
" code: " << errCode);
7515 switch (apiConnectptr.p->apiConnectstate) {
7517 if(apiConnectptr.p->lqhkeyreqrec == apiConnectptr.p->lqhkeyconfrec &&
7518 errCode != ZCLUSTER_IN_SINGLEUSER_MODE){
7525 if (c_appl_timeout_value == 0 ||
7526 (ctcTimer - getApiConTimer(apiConnectptr.i)) <= c_appl_timeout_value) {
7531 apiConnectptr.p->returnsignal = RS_TCROLLBACKREP;
7532 apiConnectptr.p->returncode = errCode;
7533 abort010Lab(signal);
7536 case CS_REC_COMMITTING:
7537 case CS_START_COMMITTING:
7547 terrorCode = errCode;
7548 abortErrorLab(signal);
7562 case CS_PREPARE_TO_COMMIT:
7572 Uint32 time_passed = ctcTimer - getApiConTimer(apiConnectptr.i);
7573 if (time_passed > 500 &&
7574 time_passed > (5 * cDbHbInterval) &&
7575 time_passed > (10 * ctimeOutValue))
7578 ndbout_c(
"timeOutFoundLab trans: 0x%x 0x%x state: %u",
7579 apiConnectptr.p->transid[0],
7580 apiConnectptr.p->transid[1],
7581 (Uint32)apiConnectptr.p->apiConnectstate);
7584 setApiConTimer(apiConnectptr.i, 0, __LINE__);
7588 case CS_COMMIT_SENT:
7597 tabortInd = ZCOMMIT_SETUP;
7598 setupFailData(signal);
7599 toCommitHandlingLab(signal);
7601 case CS_COMPLETE_SENT:
7610 tabortInd = ZCOMMIT_SETUP;
7611 setupFailData(signal);
7612 toCompleteHandlingLab(signal);
7620 tcConnectptr.i = apiConnectptr.p->firstTcConnect;
7621 sendAbortedAfterTimeout(signal, 0);
7623 case CS_START_SCAN:{
7631 if (c_appl_timeout_value == 0 ||
7632 (ctcTimer - getApiConTimer(apiConnectptr.i)) <= c_appl_timeout_value) {
7637 ScanRecordPtr scanPtr;
7638 scanPtr.i = apiConnectptr.p->apiScanRec;
7639 ptrCheckGuard(scanPtr, cscanrecFileSize, scanRecord);
7640 scanError(signal, scanPtr, ZSCANTIME_OUT_ERROR);
7643 case CS_WAIT_ABORT_CONF:
7645 tcConnectptr.i = apiConnectptr.p->currentTcConnect;
7646 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
7647 arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS);
7648 hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo];
7649 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
7650 if (hostptr.p->hostStatus == HS_ALIVE) {
7655 warningReport(signal, 20);
7656 apiConnectptr.p->timeOutCounter++;
7657 if (apiConnectptr.p->timeOutCounter > 3) {
7662 reportNodeFailed(signal, hostptr.i);
7664 apiConnectptr.p->currentReplicaNo++;
7666 tcurrentReplicaNo = (Uint8)Z8NIL;
7667 toAbortHandlingLab(signal);
7669 case CS_WAIT_COMMIT_CONF:
7671 CRASH_INSERTION(8053);
7672 tcConnectptr.i = apiConnectptr.p->currentTcConnect;
7673 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
7674 arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS);
7675 hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo];
7676 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
7677 if (hostptr.p->hostStatus == HS_ALIVE) {
7682 warningReport(signal, 21);
7683 apiConnectptr.p->timeOutCounter++;
7684 if (apiConnectptr.p->timeOutCounter > 3) {
7689 reportNodeFailed(signal, hostptr.i);
7691 apiConnectptr.p->currentReplicaNo++;
7693 tcurrentReplicaNo = (Uint8)Z8NIL;
7694 toCommitHandlingLab(signal);
7696 case CS_WAIT_COMPLETE_CONF:
7698 tcConnectptr.i = apiConnectptr.p->currentTcConnect;
7699 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
7700 arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS);
7701 hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo];
7702 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
7703 if (hostptr.p->hostStatus == HS_ALIVE) {
7708 warningReport(signal, 22);
7709 apiConnectptr.p->timeOutCounter++;
7710 if (apiConnectptr.p->timeOutCounter > 100) {
7715 reportNodeFailed(signal, hostptr.i);
7717 apiConnectptr.p->currentReplicaNo++;
7719 tcurrentReplicaNo = (Uint8)Z8NIL;
7720 toCompleteHandlingLab(signal);
7722 case CS_FAIL_PREPARED:
7724 case CS_FAIL_COMMITTING:
7726 case CS_FAIL_COMMITTED:
7728 case CS_REC_PREPARING:
7730 case CS_START_PREPARING:
7736 case CS_FAIL_ABORTED:
7738 case CS_DISCONNECTED:
7745 DEBUG(
"State = " << apiConnectptr.p->apiConnectstate);
7746 systemErrorLab(signal, __LINE__);
7752 void Dbtc::sendAbortedAfterTimeout(
Signal* signal,
int Tcheck)
7754 ApiConnectRecord * transP = apiConnectptr.p;
7755 if(transP->abortState == AS_IDLE){
7757 warningEvent(
"TC: %d: %d state=%d abort==IDLE place: %d fop=%d t: %d",
7760 transP->apiConnectstate,
7761 c_apiConTimer_line[apiConnectptr.i],
7762 transP->firstTcConnect,
7763 c_apiConTimer[apiConnectptr.i]
7765 ndbout_c(
"TC: %d: %d state=%d abort==IDLE place: %d fop=%d t: %d",
7768 transP->apiConnectstate,
7769 c_apiConTimer_line[apiConnectptr.i],
7770 transP->firstTcConnect,
7771 c_apiConTimer[apiConnectptr.i]
7774 setApiConTimer(apiConnectptr.i, 0, __LINE__);
7779 OperationState tmp[16];
7781 Uint32 TloopCount = 0;
7784 if (tcConnectptr.i == RNIL) {
7788 ndbout_c(
"found: %d Tcheck: %d apiConnectptr.p->counter: %d",
7789 found, Tcheck, apiConnectptr.p->counter);
7791 if (found || apiConnectptr.p->counter)
7805 releaseAbortResources(signal);
7817 char buf[96]; buf[0] = 0;
7820 __LINE__, apiConnectptr.i,
7821 apiConnectptr.p->counter);
7822 for(Uint32 i = 0; i<TloopCount; i++)
7828 ndbout_c(
"%s", buf);
7830 releaseAbortResources(signal);
7837 if (TloopCount >= 1024) {
7843 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
7844 apiConnectptr.p->counter++;
7845 signal->theData[0] = TcContinueB::ZABORT_TIMEOUT_BREAK;
7846 signal->theData[1] = tcConnectptr.i;
7847 signal->theData[2] = apiConnectptr.i;
7848 if (ERROR_INSERTED(8080))
7850 ndbout_c(
"sending ZABORT_TIMEOUT_BREAK delayed (%d %d)",
7851 Tcheck, apiConnectptr.p->counter);
7852 sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 2000, 3);
7856 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
7860 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
7861 if(TloopCount < 16){
7863 tmp[TloopCount-1] = tcConnectptr.p->tcConnectstate;
7866 if (tcConnectptr.p->tcConnectstate == OS_ABORT_SENT) {
7875 arrGuard(tcConnectptr.p->noOfNodes, MAX_REPLICAS+1);
7876 for (Ti = 0; Ti < tcConnectptr.p->noOfNodes; Ti++) {
7878 if (tcConnectptr.p->tcNodedata[Ti] != 0) {
7881 hostptr.i = tcConnectptr.p->tcNodedata[Ti];
7882 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
7883 if (hostptr.p->hostStatus == HS_ALIVE) {
7900 Uint32 instanceKey = tcConnectptr.p->lqhInstanceKey;
7901 BlockReference TBRef = numberToRef(DBLQH, instanceKey, hostptr.i);
7902 signal->theData[0] = tcConnectptr.i;
7903 signal->theData[1] = cownref;
7904 signal->theData[2] = apiConnectptr.p->transid[0];
7905 signal->theData[3] = apiConnectptr.p->transid[1];
7906 sendSignal(TBRef, GSN_ABORT, signal, 4, JBB);
7907 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
7915 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
7916 signal->theData[0] = tcConnectptr.i;
7917 signal->theData[1] = apiConnectptr.p->transid[0];
7918 signal->theData[2] = apiConnectptr.p->transid[1];
7919 signal->theData[3] = hostptr.i;
7920 signal->theData[4] = ZFALSE;
7921 sendSignal(cownref, GSN_ABORTED, signal, 5, JBB);
7926 tcConnectptr.i = tcConnectptr.p->nextTcConnect;
7930 void Dbtc::reportNodeFailed(
Signal* signal, Uint32 nodeId)
7933 rep->nodeId = nodeId;
7934 rep->err = DisconnectRep::TcReportNodeFailed;
7935 sendSignal(QMGR_REF, GSN_DISCONNECT_REP, signal,
7936 DisconnectRep::SignalLength, JBB);
7942 void Dbtc::timeOutLoopStartFragLab(
Signal* signal, Uint32 TscanConPtr)
7944 ScanFragRecPtr timeOutPtr[8];
7945 UintR tfragTimer[8];
7946 UintR texpiredTime[8];
7947 UintR TloopCount = 0;
7948 Uint32 TtcTimer = ctcTimer;
7950 while ((TscanConPtr + 8) < cscanFragrecFileSize) {
7952 timeOutPtr[0].i = TscanConPtr + 0;
7953 timeOutPtr[1].i = TscanConPtr + 1;
7954 timeOutPtr[2].i = TscanConPtr + 2;
7955 timeOutPtr[3].i = TscanConPtr + 3;
7956 timeOutPtr[4].i = TscanConPtr + 4;
7957 timeOutPtr[5].i = TscanConPtr + 5;
7958 timeOutPtr[6].i = TscanConPtr + 6;
7959 timeOutPtr[7].i = TscanConPtr + 7;
7970 tfragTimer[0] = timeOutPtr[0].p->scanFragTimer;
7971 tfragTimer[1] = timeOutPtr[1].p->scanFragTimer;
7972 tfragTimer[2] = timeOutPtr[2].p->scanFragTimer;
7973 tfragTimer[3] = timeOutPtr[3].p->scanFragTimer;
7974 tfragTimer[4] = timeOutPtr[4].p->scanFragTimer;
7975 tfragTimer[5] = timeOutPtr[5].p->scanFragTimer;
7976 tfragTimer[6] = timeOutPtr[6].p->scanFragTimer;
7977 tfragTimer[7] = timeOutPtr[7].p->scanFragTimer;
7979 texpiredTime[0] = TtcTimer - tfragTimer[0];
7980 texpiredTime[1] = TtcTimer - tfragTimer[1];
7981 texpiredTime[2] = TtcTimer - tfragTimer[2];
7982 texpiredTime[3] = TtcTimer - tfragTimer[3];
7983 texpiredTime[4] = TtcTimer - tfragTimer[4];
7984 texpiredTime[5] = TtcTimer - tfragTimer[5];
7985 texpiredTime[6] = TtcTimer - tfragTimer[6];
7986 texpiredTime[7] = TtcTimer - tfragTimer[7];
7988 for (Uint32 Ti = 0; Ti < 8; Ti++) {
7990 if (tfragTimer[Ti] != 0) {
7992 if (texpiredTime[Ti] > ctimeOutValue) {
7994 DEBUG(
"Fragment timeout found:"<<
7995 " ctimeOutValue=" <<ctimeOutValue
7996 <<
", texpiredTime="<<texpiredTime[Ti]<<endl
7997 <<
" tfragTimer="<<tfragTimer[Ti]
7998 <<
", ctcTimer="<<ctcTimer);
7999 timeOutFoundFragLab(signal, TscanConPtr + Ti);
8009 if (TloopCount++ > 128 ) {
8011 signal->theData[0] = TcContinueB::ZCONTINUE_TIME_OUT_FRAG_CONTROL;
8012 signal->theData[1] = TscanConPtr;
8013 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
8017 for ( ; TscanConPtr < cscanFragrecFileSize; TscanConPtr++){
8019 timeOutPtr[0].i = TscanConPtr;
8021 if (timeOutPtr[0].p->scanFragTimer != 0) {
8022 texpiredTime[0] = ctcTimer - timeOutPtr[0].p->scanFragTimer;
8023 if (texpiredTime[0] > ctimeOutValue) {
8025 DEBUG(
"Fragment timeout found:"<<
8026 " ctimeOutValue=" <<ctimeOutValue
8027 <<
", texpiredTime="<<texpiredTime[0]<<endl
8028 <<
" tfragTimer="<<tfragTimer[0]
8029 <<
", ctcTimer="<<ctcTimer);
8030 timeOutFoundFragLab(signal, TscanConPtr);
8035 ctimeOutCheckFragActive = TOCS_FALSE;
8044 void Dbtc::execSCAN_HBREP(
Signal* signal)
8048 scanFragptr.i = signal->theData[0];
8049 c_scan_frag_pool.
getPtr(scanFragptr);
8050 switch (scanFragptr.p->scanFragState){
8051 case ScanFragRec::LQH_ACTIVE:
8054 DEBUG(
"execSCAN_HBREP: scanFragState="<<scanFragptr.p->scanFragState);
8055 systemErrorLab(signal, __LINE__);
8059 ScanRecordPtr scanptr;
8060 scanptr.i = scanFragptr.p->scanRec;
8061 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
8063 apiConnectptr.i = scanptr.p->scanApiRec;
8064 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
8066 if (!(apiConnectptr.p->transid[0] == signal->theData[1] &&
8067 apiConnectptr.p->transid[1] == signal->theData[2])){
8073 signal->theData[3] = signal->theData[0];
8074 signal->theData[4] = signal->theData[1];
8076 signal->theData[1] = RNIL;
8077 signal->theData[2] = RNIL;
8079 sendSignal(signal->senderBlockRef(), GSN_SCAN_HBREP, signal, 5, JBA);
8080 DEBUG(
"SCAN_HBREP with wrong transid("
8081 <<signal->theData[3]<<
", "<<signal->theData[4]<<
")");
8086 if (scanFragptr.p->scanFragTimer != 0){
8087 updateBuddyTimer(apiConnectptr);
8088 scanFragptr.p->startFragTimer(ctcTimer);
8091 DEBUG(
"SCAN_HBREP when scanFragTimer was turned off");
8099 void Dbtc::timeOutFoundFragLab(
Signal* signal, UintR TscanConPtr)
8102 c_scan_frag_pool.
getPtr(ptr, TscanConPtr);
8105 ScanRecordPtr scanptr;
8106 scanptr.i = ptr.p->scanRec;
8107 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
8108 ApiConnectRecordPtr TlocalApiConnectptr;
8109 TlocalApiConnectptr.i = scanptr.p->scanApiRec;
8110 ptrCheckGuard(TlocalApiConnectptr, capiConnectFilesize, apiConnectRecord);
8112 DEBUG(
"[ H'" << hex << TlocalApiConnectptr.p->transid[0]
8113 <<
" H'" << TlocalApiConnectptr.p->transid[1] <<
"] "
8114 << TscanConPtr <<
" timeOutFoundFragLab: scanFragState = "
8115 << ptr.p->scanFragState);
8119 const Uint32 time_out_param= ctimeOutValue;
8120 const Uint32 old_time_out_param= c_abortRec.oldTimeOutValue;
8122 if (unlikely(time_out_param != old_time_out_param &&
8126 ScanRecordPtr scanptr;
8127 scanptr.i = ptr.p->scanRec;
8128 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
8129 ApiConnectRecordPtr TlocalApiConnectptr;
8130 TlocalApiConnectptr.i = scanptr.p->scanApiRec;
8131 ptrCheckGuard(TlocalApiConnectptr, capiConnectFilesize, apiConnectRecord);
8133 if (refToNode(TlocalApiConnectptr.p->ndbapiBlockref) ==
8137 Uint32 val = ctcTimer - ptr.p->scanFragTimer;
8138 if (val <= old_time_out_param)
8150 switch (ptr.p->scanFragState) {
8151 case ScanFragRec::WAIT_GET_PRIMCONF:
8155 case ScanFragRec::LQH_ACTIVE:{
8161 Uint32 nodeId = refToNode(ptr.p->lqhBlockref);
8163 ScanRecordPtr scanptr;
8164 scanptr.i = ptr.p->scanRec;
8165 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
8167 if(connectCount != ptr.p->m_connectCount){
8172 ptr.p->scanFragState = ScanFragRec::COMPLETED;
8173 ptr.p->stopFragTimer();
8175 ScanFragList
run(c_scan_frag_pool, scanptr.p->m_running_scan_frags);
8180 scanError(signal, scanptr, ZSCAN_FRAG_LQH_ERROR);
8183 case ScanFragRec::DELIVERED:
8185 case ScanFragRec::IDLE:
8187 case ScanFragRec::QUEUED_FOR_DELIVERY:
8195 systemErrorLab(signal, __LINE__);
8197 scanFragptr.p->stopFragTimer();
8204 systemErrorLab(signal, __LINE__);
8209 signal->theData[0] = TcContinueB::ZCONTINUE_TIME_OUT_FRAG_CONTROL;
8210 signal->theData[1] = TscanConPtr + 1;
8211 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
8233 void Dbtc::execGCP_NOMORETRANS(
Signal* signal)
8237 c_gcp_ref = req->senderRef;
8238 c_gcp_data = req->senderData;
8239 Uint32 gci_lo = req->gci_lo;
8240 Uint32 gci_hi = req->gci_hi;
8241 tcheckGcpId = gci_lo | (Uint64(gci_hi) << 32);
8244 if (cfirstgcp != RNIL) {
8247 gcpPtr.i = cfirstgcp;
8248 ptrCheckGuard(gcpPtr, cgcpFilesize, gcpRecord);
8249 if (gcpPtr.p->gcpId == tcheckGcpId)
8252 bool empty = gcpPtr.p->firstApiConnect == RNIL;
8253 bool nfhandling = c_ongoing_take_over_cnt;
8255 if (empty && nfhandling)
8258 ndbout_c(
"NOT returning gcpTcfinished due to nfhandling %u/%u",
8262 if (!empty || c_ongoing_take_over_cnt)
8265 gcpPtr.p->gcpNomoretransRec = ZTRUE;
8268 gcpTcfinished(signal, tcheckGcpId);
8272 else if (c_ongoing_take_over_cnt == 0)
8280 gcpTcfinished(signal, tcheckGcpId);
8288 else if (c_ongoing_take_over_cnt == 0)
8291 gcpTcfinished(signal, tcheckGcpId);
8297 ndbout_c(
"execGCP_NOMORETRANS(%u/%u) c_ongoing_take_over_cnt -> seize",
8299 seizeGcp(gcpPtr, tcheckGcpId);
8300 gcpPtr.p->gcpNomoretransRec = ZTRUE;
8305 printf(
"ooo: execGCP_NOMORETRANS tcheckGcpId: %u/%u cfirstgcp: %u/%u",
8307 Uint32(gcpPtr.p->gcpId >> 32), Uint32(gcpPtr.p->gcpId));
8309 if (tcheckGcpId < gcpPtr.p->gcpId)
8314 tmp.i = cfirstfreeGcp;
8315 ptrCheckGuard(tmp, cgcpFilesize, gcpRecord);
8316 cfirstfreeGcp = tmp.p->nextGcp;
8318 tmp.p->gcpId = tcheckGcpId;
8319 tmp.p->nextGcp = cfirstgcp;
8320 tmp.p->firstApiConnect = RNIL;
8321 tmp.p->lastApiConnect = RNIL;
8322 tmp.p->gcpNomoretransRec = ZTRUE;
8324 ndbout_c(
"LINK FIRST");
8330 while (tcheckGcpId > gcpPtr.p->gcpId)
8333 if (gcpPtr.p->nextGcp == RNIL)
8335 printf(
"nextGcp == RNIL -> ");
8340 gcpPtr.i = gcpPtr.p->nextGcp;
8341 ptrCheckGuard(gcpPtr, cgcpFilesize, gcpRecord);
8344 if (tcheckGcpId == gcpPtr.p->gcpId)
8347 gcpPtr.p->gcpNomoretransRec = ZTRUE;
8351 ndbrequire(prev.i != gcpPtr.i);
8352 ndbrequire(prev.p->gcpId < tcheckGcpId);
8353 ndbrequire(gcpPtr.p->gcpId > tcheckGcpId);
8356 tmp.i = cfirstfreeGcp;
8357 ptrCheckGuard(tmp, cgcpFilesize, gcpRecord);
8358 cfirstfreeGcp = tmp.p->nextGcp;
8360 tmp.p->gcpId = tcheckGcpId;
8361 tmp.p->nextGcp = gcpPtr.i;
8362 tmp.p->firstApiConnect = RNIL;
8363 tmp.p->lastApiConnect = RNIL;
8364 tmp.p->gcpNomoretransRec = ZTRUE;
8365 prev.p->nextGcp = tmp.i;
8366 ndbout_c(
"link middle %u/%u < %u/%u < %u/%u",
8367 Uint32(prev.p->gcpId >> 32), Uint32(prev.p->gcpId),
8369 Uint32(gcpPtr.p->gcpId >> 32), Uint32(gcpPtr.p->gcpId));
8391 void Dbtc::execNODE_FAILREP(
Signal* signal)
8397 cfailure_nr = nodeFail->failNo;
8398 const Uint32 tnoOfNodes = nodeFail->noOfNodes;
8401 arrGuard(tnoOfNodes, MAX_NDB_NODES);
8404 for (i = 1; i< MAX_NDB_NODES; i++)
8413 cmasterNodeId = tnewMasterId;
8415 HostRecordPtr myHostPtr;
8417 tcNodeFailptr.i = 0;
8418 ptrAss(tcNodeFailptr, tcFailRecord);
8419 for (i = 0; i < tnoOfNodes; i++)
8422 myHostPtr.i = cdata[
i];
8423 ptrCheckGuard(myHostPtr, chostFilesize, hostRecord);
8429 myHostPtr.p->hostStatus = HS_DEAD;
8430 myHostPtr.p->m_nf_bits = HostRecord::NF_NODE_FAIL_BITS;
8431 c_ongoing_take_over_cnt++;
8432 c_alive_nodes.
clear(myHostPtr.i);
8434 if (tcNodeFailptr.p->failStatus == FS_LISTENING)
8441 if (myHostPtr.p->lqhTransStatus == LTS_ACTIVE)
8448 signal->theData[0] = TcContinueB::ZNODE_TAKE_OVER_COMPLETED;
8449 signal->theData[1] = myHostPtr.i;
8450 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
8455 signal->theData[0] = myHostPtr.i;
8456 sendSignal(cownref, GSN_TAKE_OVERTCREQ, signal, 1, JBB);
8458 checkScanActiveInFailedLqh(signal, 0, myHostPtr.i);
8459 nodeFailCheckTransactions(signal, 0, myHostPtr.i);
8460 Callback cb = {safe_cast(&Dbtc::ndbdFailBlockCleanupCallback),
8465 if (m_deferred_enabled == 0)
8470 n != c_alive_nodes.NotFound;
8473 if (!ndbd_deferred_unique_constraints(
getNodeInfo(
n).m_version))
8483 m_deferred_enabled = ~Uint32(0);
8489 Dbtc::checkNodeFailComplete(
Signal* signal,
8490 Uint32 failedNodeId,
8493 hostptr.i = failedNodeId;
8494 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
8495 hostptr.p->m_nf_bits &= ~bit;
8496 if (hostptr.p->m_nf_bits == 0)
8500 nfRep->
nodeId = cownNodeid;
8503 if (instance() == 0)
8506 sendSignal(cdihblockref, GSN_NF_COMPLETEREP, signal,
8507 NFCompleteRep::SignalLength, JBB);
8508 sendSignal(QMGR_REF, GSN_NF_COMPLETEREP, signal,
8509 NFCompleteRep::SignalLength, JBB);
8516 sendSignal(DBTC_REF, GSN_NF_COMPLETEREP, signal,
8517 NFCompleteRep::SignalLength, JBB);
8521 CRASH_INSERTION(8058);
8522 if (ERROR_INSERTED(8059))
8524 signal->theData[0] = 9999;
8525 sendSignalWithDelay(numberToRef(CMVMI, hostptr.i),
8526 GSN_NDB_TAMPER, signal, 100, 1);
8530 void Dbtc::checkScanActiveInFailedLqh(
Signal* signal,
8532 Uint32 failedNodeId){
8534 ScanRecordPtr scanptr;
8535 for (scanptr.i = scanPtrI; scanptr.i < cscanrecFileSize; scanptr.i++) {
8537 ptrAss(scanptr, scanRecord);
8539 if (scanptr.p->scanState != ScanRecord::IDLE){
8542 ScanFragList
run(c_scan_frag_pool, scanptr.p->m_running_scan_frags);
8544 for(
run.first(ptr); !ptr.isNull(); ){
8546 ScanFragRecPtr curr = ptr;
8548 if (curr.p->scanFragState == ScanFragRec::LQH_ACTIVE &&
8549 refToNode(curr.p->lqhBlockref) == failedNodeId){
8553 curr.p->scanFragState = ScanFragRec::COMPLETED;
8554 curr.p->stopFragTimer();
8559 ScanFragList deliv(c_scan_frag_pool, scanptr.p->m_delivered_scan_frags);
8560 for(deliv.first(ptr); !ptr.isNull(); deliv.next(ptr))
8563 if (refToNode(ptr.p->lqhBlockref) == failedNodeId)
8573 scanError(signal, scanptr, ZSCAN_LQH_ERROR);
8577 signal->theData[0] = TcContinueB::ZCHECK_SCAN_ACTIVE_FAILED_LQH;
8578 signal->theData[1] = scanptr.i + 1;
8579 signal->theData[2] = failedNodeId;
8580 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
8584 checkNodeFailComplete(signal, failedNodeId, HostRecord::NF_CHECK_SCAN);
8588 Dbtc::nodeFailCheckTransactions(
Signal* signal,
8590 Uint32 failedNodeId)
8594 Uint32 TtcTimer = ctcTimer;
8595 Uint32 TapplTimeout = c_appl_timeout_value;
8596 Uint32 RT_BREAK = 64;
8597 Uint32 endPtrI = transPtrI + RT_BREAK;
8598 if (endPtrI > capiConnectFilesize)
8600 endPtrI = capiConnectFilesize;
8603 for (transPtr.i = transPtrI; transPtr.i < endPtrI; transPtr.i++)
8605 ptrCheckGuard(transPtr, capiConnectFilesize, apiConnectRecord);
8606 if (transPtr.p->m_transaction_nodes.
get(failedNodeId))
8611 c_appl_timeout_value = 1;
8612 setApiConTimer(transPtr.i, TtcTimer - 2, __LINE__);
8613 timeOutFoundLab(signal, transPtr.i, ZNODEFAIL_BEFORE_COMMIT);
8614 c_appl_timeout_value = TapplTimeout;
8621 if (transPtr.i == capiConnectFilesize)
8624 checkNodeFailComplete(signal, failedNodeId,
8625 HostRecord::NF_CHECK_TRANSACTION);
8629 signal->theData[0] = TcContinueB::ZNF_CHECK_TRANSACTIONS;
8630 signal->theData[1] = transPtr.i;
8631 signal->theData[2] = failedNodeId;
8632 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
8637 Dbtc::ndbdFailBlockCleanupCallback(
Signal* signal,
8638 Uint32 failedNodeId,
8643 checkNodeFailComplete(signal, failedNodeId,
8644 HostRecord::NF_BLOCK_HANDLE);
8648 Dbtc::apiFailBlockCleanupCallback(
Signal* signal,
8649 Uint32 failedNodeId,
8654 signal->theData[0] = failedNodeId;
8655 signal->theData[1] = reference();
8656 sendSignal(capiFailRef, GSN_API_FAILCONF, signal, 2, JBB);
8660 Dbtc::checkScanFragList(
Signal* signal,
8661 Uint32 failedNodeId,
8663 ScanFragList::Head & head){
8665 DEBUG(
"checkScanActiveInFailedLqh: scanFragError");
8668 void Dbtc::execTAKE_OVERTCCONF(
Signal* signal)
8678 tfailedNodeId = signal->theData[0];
8679 hostptr.i = tfailedNodeId;
8680 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
8682 Uint32 senderRef = signal->theData[1];
8683 if (signal->getLength() < 2)
8689 if (senderRef != reference())
8693 tcNodeFailptr.i = 0;
8694 ptrAss(tcNodeFailptr, tcFailRecord);
8700 Uint32 end = tcNodeFailptr.p->queueIndex;
8704 if (tcNodeFailptr.p->queueList[i] == hostptr.i)
8710 ndbrequire(i != end);
8711 tcNodeFailptr.p->queueList[
i] = tcNodeFailptr.p->queueList[end-1];
8712 tcNodeFailptr.p->queueIndex = end - 1;
8715 Uint32 cnt = c_ongoing_take_over_cnt;
8717 c_ongoing_take_over_cnt = cnt - 1;
8718 checkNodeFailComplete(signal, hostptr.i, HostRecord::NF_TAKEOVER);
8720 if (cnt == 1 && cfirstgcp != RNIL)
8725 GcpRecordPtr tmpGcpPointer;
8726 tmpGcpPointer.i = cfirstgcp;
8727 ptrCheckGuard(tmpGcpPointer, cgcpFilesize, gcpRecord);
8728 if (tmpGcpPointer.p->gcpNomoretransRec &&
8729 tmpGcpPointer.p->firstApiConnect == RNIL)
8732 ndbout_c(
"completing gcp %u/%u in execTAKE_OVERTCCONF",
8733 Uint32(tmpGcpPointer.p->gcpId >> 32),
8734 Uint32(tmpGcpPointer.p->gcpId));
8735 gcpTcfinished(signal, tmpGcpPointer.p->gcpId);
8736 unlinkGcp(tmpGcpPointer);
8741 void Dbtc::execTAKE_OVERTCREQ(
Signal* signal)
8744 tfailedNodeId = signal->theData[0];
8745 tcNodeFailptr.i = 0;
8746 ptrAss(tcNodeFailptr, tcFailRecord);
8747 if (tcNodeFailptr.p->failStatus != FS_IDLE ||
8748 cmasterNodeId != getOwnNodeId() ||
8749 (! (instance() == 0 ||
8750 instance() == TAKE_OVER_INSTANCE)))
8761 arrGuard(tcNodeFailptr.p->queueIndex, MAX_NDB_NODES);
8762 tcNodeFailptr.p->queueList[tcNodeFailptr.p->queueIndex] = tfailedNodeId;
8763 tcNodeFailptr.p->queueIndex = tcNodeFailptr.p->queueIndex + 1;
8766 ndbrequire(instance() == 0 || instance() == TAKE_OVER_INSTANCE);
8767 startTakeOverLab(signal);
8774 void Dbtc::startTakeOverLab(
Signal* signal)
8776 for (tindex = 0; tindex <= 511; tindex++) {
8777 ctransidFailHash[tindex] = RNIL;
8779 for (tindex = 0; tindex <= 1023; tindex++) {
8780 ctcConnectFailHash[tindex] = RNIL;
8782 tcNodeFailptr.p->failStatus = FS_LISTENING;
8783 tcNodeFailptr.p->takeOverNode = tfailedNodeId;
8784 for (hostptr.i = 1; hostptr.i < MAX_NDB_NODES; hostptr.i++) {
8786 ptrAss(hostptr, hostRecord);
8787 if (hostptr.p->hostStatus == HS_ALIVE) {
8789 tblockref = calcLqhBlockRef(hostptr.i);
8790 hostptr.p->lqhTransStatus = LTS_ACTIVE;
8791 signal->theData[0] = tcNodeFailptr.i;
8792 signal->theData[1] = cownref;
8793 signal->theData[2] = tfailedNodeId;
8794 if (ERROR_INSERTED(8064) && hostptr.i == getOwnNodeId())
8796 ndbout_c(
"sending delayed GSN_LQH_TRANSREQ to self");
8797 sendSignalWithDelay(tblockref, GSN_LQH_TRANSREQ, signal, 100, 3);
8798 CLEAR_ERROR_INSERT_VALUE;
8802 sendSignal(tblockref, GSN_LQH_TRANSREQ, signal, 3, JBB);
8811 void Dbtc::execLQH_TRANSCONF(
Signal* signal)
8816 CRASH_INSERTION(8060);
8818 tcNodeFailptr.i = lqhTransConf->tcRef;
8819 ptrCheckGuard(tcNodeFailptr, 1, tcFailRecord);
8820 tnodeid = lqhTransConf->lqhNodeId;
8821 ttransStatus = (LqhTransConf::OperationStatus)lqhTransConf->operationStatus;
8822 ttransid1 = lqhTransConf->transId1;
8823 ttransid2 = lqhTransConf->transId2;
8824 ttcOprec = lqhTransConf->oldTcOpRec;
8825 treqinfo = lqhTransConf->requestInfo;
8826 tgci = Uint64(lqhTransConf->gci_hi) << 32;
8827 cnodes[0] = lqhTransConf->nextNodeId1;
8828 cnodes[1] = lqhTransConf->nextNodeId2;
8829 cnodes[2] = lqhTransConf->nextNodeId3;
8830 const Uint32 ref = tapplRef = lqhTransConf->apiRef;
8831 tapplOprec = lqhTransConf->apiOpRec;
8832 const Uint32 tableId = lqhTransConf->tableId;
8833 Uint32 gci_lo = lqhTransConf->gci_lo;
8834 Uint32 fragId = lqhTransConf->fragId;
8835 if (ttransStatus == LqhTransConf::Committed &&
8836 unlikely(signal->getLength() < LqhTransConf::SignalLength_GCI_LO))
8840 ndbassert(!ndb_check_micro_gcp(
getNodeInfo(tnodeid).m_version));
8844 if (ttransStatus == LqhTransConf::LastTransConf){
8849 nodeTakeOverCompletedLab(signal);
8852 if (ttransStatus == LqhTransConf::Marker){
8855 LqhTransConf::setMarkerFlag(treqinfo, 1);
8857 TableRecordPtr tabPtr;
8859 ptrCheckGuard(tabPtr, ctabrecFilesize, tableRecord);
8861 case DictTabInfo::SystemTable:
8862 case DictTabInfo::UserTable:
8870 findApiConnectFail(signal);
8872 if(apiConnectptr.p->ndbapiBlockref == 0 && tapplRef != 0){
8873 apiConnectptr.p->ndbapiBlockref = ref;
8874 apiConnectptr.p->ndbapiConnect = tapplOprec;
8877 if (ttransStatus != LqhTransConf::Marker)
8883 if (unlikely(signal->getLength() < LqhTransConf::SignalLength_FRAG_ID))
8891 instanceKey = getInstanceKey(tableId, fragId);
8893 findTcConnectFail(signal, instanceKey);
8900 void Dbtc::nodeTakeOverCompletedLab(
Signal* signal)
8904 CRASH_INSERTION(8061);
8906 hostptr.i = tnodeid;
8907 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
8908 hostptr.p->lqhTransStatus = LTS_IDLE;
8909 for (hostptr.i = 1; hostptr.i < MAX_NDB_NODES; hostptr.i++) {
8911 ptrAss(hostptr, hostRecord);
8912 if (hostptr.p->hostStatus == HS_ALIVE) {
8913 if (hostptr.p->lqhTransStatus == LTS_ACTIVE) {
8931 tcNodeFailptr.p->currentHashIndexTakeOver = 0;
8932 tcNodeFailptr.p->completedTakeOver = 0;
8933 tcNodeFailptr.p->failStatus = FS_COMPLETING;
8934 guard0 = cnoParallelTakeOver - 1;
8943 arrGuard(guard0, MAX_NDB_NODES);
8944 for (tindex = 0; tindex <= guard0; tindex++) {
8946 tcNodeFailptr.p->takeOverProcState[tindex] = ZTAKE_OVER_ACTIVE;
8947 signal->theData[0] = TcContinueB::ZCOMPLETE_TRANS_AT_TAKE_OVER;
8948 signal->theData[1] = tcNodeFailptr.i;
8949 signal->theData[2] = tindex;
8950 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
8958 void Dbtc::completeTransAtTakeOverLab(
Signal* signal, UintR TtakeOverInd)
8961 while (tcNodeFailptr.p->currentHashIndexTakeOver < 512){
8964 ctransidFailHash[tcNodeFailptr.p->currentHashIndexTakeOver];
8965 if (apiConnectptr.i != RNIL) {
8973 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
8974 ctransidFailHash[tcNodeFailptr.p->currentHashIndexTakeOver] =
8975 apiConnectptr.p->nextApiConnect;
8977 completeTransAtTakeOverDoOne(signal, TtakeOverInd);
8983 if (tcNodeFailptr.p->currentHashIndexTakeOver < 511){
8985 tcNodeFailptr.p->currentHashIndexTakeOver++;
8988 completeTransAtTakeOverDoLast(signal, TtakeOverInd);
8989 tcNodeFailptr.p->currentHashIndexTakeOver++;
8998 void Dbtc::completeTransAtTakeOverDoLast(
Signal* signal, UintR TtakeOverInd)
9005 arrGuard(TtakeOverInd, MAX_NDB_NODES);
9006 if (tcNodeFailptr.p->takeOverProcState[TtakeOverInd] != ZTAKE_OVER_ACTIVE) {
9008 systemErrorLab(signal, __LINE__);
9011 tcNodeFailptr.p->takeOverProcState[TtakeOverInd] = ZTAKE_OVER_IDLE;
9012 tcNodeFailptr.p->completedTakeOver++;
9014 CRASH_INSERTION(8062);
9016 if (tcNodeFailptr.p->completedTakeOver == cnoParallelTakeOver) {
9024 signal->theData[0] = tcNodeFailptr.p->takeOverNode;
9025 signal->theData[1] = reference();
9026 sendSignal(rg, GSN_TAKE_OVERTCCONF, signal, 2, JBB);
9028 if (tcNodeFailptr.p->queueIndex > 0) {
9034 tfailedNodeId = tcNodeFailptr.p->queueList[0];
9035 guard0 = tcNodeFailptr.p->queueIndex - 1;
9036 arrGuard(guard0 + 1, MAX_NDB_NODES);
9037 for (tindex = 0; tindex <= guard0; tindex++) {
9039 tcNodeFailptr.p->queueList[tindex] =
9040 tcNodeFailptr.p->queueList[tindex + 1];
9042 tcNodeFailptr.p->queueIndex--;
9043 startTakeOverLab(signal);
9047 tcNodeFailptr.p->failStatus = FS_IDLE;
9053 void Dbtc::completeTransAtTakeOverDoOne(
Signal* signal, UintR TtakeOverInd)
9055 apiConnectptr.p->takeOverRec = (Uint8)tcNodeFailptr.i;
9056 apiConnectptr.p->takeOverInd = TtakeOverInd;
9058 switch (apiConnectptr.p->apiConnectstate) {
9059 case CS_FAIL_COMMITTED:
9067 sendTCKEY_FAILCONF(signal, apiConnectptr.p);
9068 tcConnectptr.i = apiConnectptr.p->firstTcConnect;
9069 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
9070 apiConnectptr.p->currentTcConnect = tcConnectptr.i;
9071 apiConnectptr.p->currentReplicaNo = tcConnectptr.p->lastReplicaNo;
9072 tcurrentReplicaNo = tcConnectptr.p->lastReplicaNo;
9073 commitGciHandling(signal, apiConnectptr.p->globalcheckpointid);
9074 toCompleteHandlingLab(signal);
9076 case CS_FAIL_COMMITTING:
9083 tcConnectptr.i = apiConnectptr.p->firstTcConnect;
9084 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
9085 apiConnectptr.p->currentTcConnect = tcConnectptr.i;
9086 apiConnectptr.p->currentReplicaNo = tcConnectptr.p->lastReplicaNo;
9087 tcurrentReplicaNo = tcConnectptr.p->lastReplicaNo;
9088 commitGciHandling(signal, apiConnectptr.p->globalcheckpointid);
9089 toCommitHandlingLab(signal);
9091 case CS_FAIL_ABORTING:
9092 case CS_FAIL_PREPARED:
9105 tcConnectptr.i = apiConnectptr.p->firstTcConnect;
9106 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
9107 apiConnectptr.p->currentTcConnect = tcConnectptr.i;
9108 apiConnectptr.p->currentReplicaNo = tcConnectptr.p->lastReplicaNo;
9109 tcurrentReplicaNo = tcConnectptr.p->lastReplicaNo;
9110 toAbortHandlingLab(signal);
9112 case CS_FAIL_ABORTED:
9114 sendTCKEY_FAILREF(signal, apiConnectptr.p);
9116 signal->theData[0] = TcContinueB::ZCOMPLETE_TRANS_AT_TAKE_OVER;
9117 signal->theData[1] = (UintR)apiConnectptr.p->takeOverRec;
9118 signal->theData[2] = apiConnectptr.p->takeOverInd;
9119 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
9120 releaseTakeOver(signal);
9122 case CS_FAIL_COMPLETED:
9124 sendTCKEY_FAILCONF(signal, apiConnectptr.p);
9126 signal->theData[0] = TcContinueB::ZCOMPLETE_TRANS_AT_TAKE_OVER;
9127 signal->theData[1] = (UintR)apiConnectptr.p->takeOverRec;
9128 signal->theData[2] = apiConnectptr.p->takeOverInd;
9129 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
9130 releaseApiConnectFail(signal);
9134 systemErrorLab(signal, __LINE__);
9140 Dbtc::sendTCKEY_FAILREF(
Signal* signal, ApiConnectRecord * regApiPtr){
9143 const Uint32 ref = regApiPtr->ndbapiBlockref;
9144 const Uint32 nodeId = refToNode(ref);
9149 signal->theData[0] = regApiPtr->ndbapiConnect;
9150 signal->theData[1] = regApiPtr->transid[0];
9151 signal->theData[2] = regApiPtr->transid[1];
9153 if (likely(connectedToNode))
9156 sendSignal(ref, GSN_TCKEY_FAILREF, signal, 3, JBB);
9160 routeTCKEY_FAILREFCONF(signal, regApiPtr, GSN_TCKEY_FAILREF, 3);
9164 const Uint32 marker = regApiPtr->commitAckMarker;
9168 m_commitAckMarkerHash.
release(marker);
9169 regApiPtr->commitAckMarker = RNIL;
9174 Dbtc::sendTCKEY_FAILCONF(
Signal* signal, ApiConnectRecord * regApiPtr){
9178 const Uint32 ref = regApiPtr->ndbapiBlockref;
9179 const Uint32 marker = regApiPtr->commitAckMarker;
9180 const Uint32 nodeId = refToNode(ref);
9184 failConf->apiConnectPtr = regApiPtr->ndbapiConnect | (marker != RNIL);
9185 failConf->transId1 = regApiPtr->transid[0];
9186 failConf->transId2 = regApiPtr->transid[1];
9189 if (likely(connectedToNode))
9192 sendSignal(ref, GSN_TCKEY_FAILCONF, signal,
9193 TcKeyFailConf::SignalLength, JBB);
9197 routeTCKEY_FAILREFCONF(signal, regApiPtr,
9198 GSN_TCKEY_FAILCONF, TcKeyFailConf::SignalLength);
9201 regApiPtr->commitAckMarker = RNIL;
9205 Dbtc::routeTCKEY_FAILREFCONF(
Signal* signal,
const ApiConnectRecord* regApiPtr,
9206 Uint32 gsn, Uint32 len)
9210 Uint32 ref = regApiPtr->ndbapiBlockref;
9217 tcNodeFailptr.i = regApiPtr->takeOverRec;
9218 ptrCheckGuard(tcNodeFailptr, 1, tcFailRecord);
9224 ndbrequire(len <= 25);
9225 memcpy(save, signal->theData, 4*len);
9227 Uint32 node = tcNodeFailptr.p->takeOverNode;
9230 sd->blockRef = reference();
9232 CheckNodeGroups::Direct |
9233 CheckNodeGroups::GetNodeGroupMembers;
9236 CheckNodeGroups::SignalLength);
9241 mask.
clear(getOwnNodeId());
9242 memcpy(signal->theData, save, 4*len);
9245 while((i = mask.
find(i + 1)) != NdbNodeBitmask::NotFound)
9248 HostRecordPtr localHostptr;
9250 ptrCheckGuard(localHostptr, chostFilesize, hostRecord);
9251 if (localHostptr.p->hostStatus == HS_ALIVE)
9254 signal->theData[len] = gsn;
9255 signal->theData[len+1] = ref;
9256 sendSignal(calcTcBlockRef(i), GSN_TCKEY_FAILREFCONF_R,
9257 signal, len+2, JBB);
9274 Dbtc::execTCKEY_FAILREFCONF_R(
Signal* signal)
9277 Uint32 len = signal->getLength();
9278 Uint32 gsn = signal->theData[len-2];
9279 Uint32 ref = signal->theData[len-1];
9280 sendSignal(ref, gsn, signal, len-2, JBB);
9289 void Dbtc::execABORTCONF(
Signal* signal)
9291 UintR compare_transid1, compare_transid2;
9294 tcConnectptr.i = signal->theData[0];
9295 tnodeid = signal->theData[2];
9296 if (ERROR_INSERTED(8045)) {
9297 CLEAR_ERROR_INSERT_VALUE;
9298 sendSignalWithDelay(cownref, GSN_ABORTCONF, signal, 2000, 5);
9301 if (tcConnectptr.i >= ctcConnectFilesize) {
9302 errorReport(signal, 5);
9305 ptrAss(tcConnectptr, tcConnectRecord);
9306 if (tcConnectptr.p->tcConnectstate != OS_WAIT_ABORT_CONF) {
9307 warningReport(signal, 16);
9310 apiConnectptr.i = tcConnectptr.p->apiConnect;
9311 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
9312 if (apiConnectptr.p->apiConnectstate != CS_WAIT_ABORT_CONF) {
9313 warningReport(signal, 17);
9316 compare_transid1 = apiConnectptr.p->transid[0] ^ signal->theData[3];
9317 compare_transid2 = apiConnectptr.p->transid[1] ^ signal->theData[4];
9318 compare_transid1 = compare_transid1 | compare_transid2;
9319 if (compare_transid1 != 0) {
9320 warningReport(signal, 18);
9323 arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS);
9324 if (tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo] !=
9326 warningReport(signal, 19);
9329 tcurrentReplicaNo = (Uint8)Z8NIL;
9330 tcConnectptr.p->tcConnectstate = OS_ABORTING;
9331 toAbortHandlingLab(signal);
9334 void Dbtc::toAbortHandlingLab(
Signal* signal)
9337 if (tcurrentReplicaNo != (Uint8)Z8NIL) {
9339 arrGuard(tcurrentReplicaNo, MAX_REPLICAS);
9340 const LqhTransConf::OperationStatus stat =
9341 (LqhTransConf::OperationStatus)
9342 tcConnectptr.p->failData[tcurrentReplicaNo];
9344 case LqhTransConf::InvalidStatus:
9345 case LqhTransConf::Aborted:
9349 case LqhTransConf::Prepared:
9351 hostptr.i = tcConnectptr.p->tcNodedata[tcurrentReplicaNo];
9352 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
9353 if (hostptr.p->hostStatus == HS_ALIVE) {
9355 Uint32 instanceKey = tcConnectptr.p->lqhInstanceKey;
9356 tblockref = numberToRef(DBLQH, instanceKey, hostptr.i);
9357 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
9358 tcConnectptr.p->tcConnectstate = OS_WAIT_ABORT_CONF;
9359 apiConnectptr.p->apiConnectstate = CS_WAIT_ABORT_CONF;
9360 apiConnectptr.p->timeOutCounter = 0;
9361 signal->theData[0] = tcConnectptr.i;
9362 signal->theData[1] = cownref;
9363 signal->theData[2] = apiConnectptr.p->transid[0];
9364 signal->theData[3] = apiConnectptr.p->transid[1];
9365 signal->theData[4] = apiConnectptr.p->tcBlockref;
9366 signal->theData[5] = tcConnectptr.p->tcOprec;
9367 sendSignal(tblockref, GSN_ABORTREQ, signal, 6, JBB);
9373 systemErrorLab(signal, __LINE__);
9377 if (apiConnectptr.p->currentReplicaNo > 0) {
9383 apiConnectptr.p->currentReplicaNo--;
9384 tcurrentReplicaNo = apiConnectptr.p->currentReplicaNo;
9389 tcConnectptr.i = tcConnectptr.p->nextTcConnect;
9390 if (tcConnectptr.i == RNIL) {
9396 if (apiConnectptr.p->takeOverRec != (Uint8)Z8NIL) {
9398 sendTCKEY_FAILREF(signal, apiConnectptr.p);
9404 signal->theData[0] = TcContinueB::ZCOMPLETE_TRANS_AT_TAKE_OVER;
9405 signal->theData[1] = (UintR)apiConnectptr.p->takeOverRec;
9406 signal->theData[2] = apiConnectptr.p->takeOverInd;
9407 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
9408 releaseTakeOver(signal);
9411 releaseAbortResources(signal);
9415 apiConnectptr.p->currentTcConnect = tcConnectptr.i;
9416 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
9417 apiConnectptr.p->currentReplicaNo = tcConnectptr.p->lastReplicaNo;
9418 tcurrentReplicaNo = tcConnectptr.p->lastReplicaNo;
9429 void Dbtc::execCOMMITCONF(
Signal* signal)
9431 UintR compare_transid1, compare_transid2;
9434 tcConnectptr.i = signal->theData[0];
9435 tnodeid = signal->theData[1];
9436 if (ERROR_INSERTED(8046)) {
9437 CLEAR_ERROR_INSERT_VALUE;
9438 sendSignalWithDelay(cownref, GSN_COMMITCONF, signal, 2000, 4);
9441 if (tcConnectptr.i >= ctcConnectFilesize) {
9442 errorReport(signal, 4);
9445 ptrAss(tcConnectptr, tcConnectRecord);
9446 if (tcConnectptr.p->tcConnectstate != OS_WAIT_COMMIT_CONF) {
9447 warningReport(signal, 8);
9450 apiConnectptr.i = tcConnectptr.p->apiConnect;
9451 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
9452 if (apiConnectptr.p->apiConnectstate != CS_WAIT_COMMIT_CONF) {
9453 warningReport(signal, 9);
9456 compare_transid1 = apiConnectptr.p->transid[0] ^ signal->theData[2];
9457 compare_transid2 = apiConnectptr.p->transid[1] ^ signal->theData[3];
9458 compare_transid1 = compare_transid1 | compare_transid2;
9459 if (compare_transid1 != 0) {
9460 warningReport(signal, 10);
9463 arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS);
9464 if (tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo] !=
9466 warningReport(signal, 11);
9469 if (ERROR_INSERTED(8026)) {
9471 systemErrorLab(signal, __LINE__);
9473 tcurrentReplicaNo = (Uint8)Z8NIL;
9474 tcConnectptr.p->tcConnectstate = OS_COMMITTED;
9475 toCommitHandlingLab(signal);
9478 void Dbtc::toCommitHandlingLab(
Signal* signal)
9481 if (tcurrentReplicaNo != (Uint8)Z8NIL) {
9483 arrGuard(tcurrentReplicaNo, MAX_REPLICAS);
9484 switch (tcConnectptr.p->failData[tcurrentReplicaNo]) {
9485 case LqhTransConf::InvalidStatus:
9489 case LqhTransConf::Committed:
9493 case LqhTransConf::Prepared:
9499 hostptr.i = tcConnectptr.p->tcNodedata[tcurrentReplicaNo];
9500 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
9501 if (hostptr.p->hostStatus == HS_ALIVE) {
9503 Uint32 instanceKey = tcConnectptr.p->lqhInstanceKey;
9504 tblockref = numberToRef(DBLQH, instanceKey, hostptr.i);
9505 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
9506 apiConnectptr.p->apiConnectstate = CS_WAIT_COMMIT_CONF;
9507 apiConnectptr.p->timeOutCounter = 0;
9508 tcConnectptr.p->tcConnectstate = OS_WAIT_COMMIT_CONF;
9509 Uint64 gci = apiConnectptr.p->globalcheckpointid;
9510 signal->theData[0] = tcConnectptr.i;
9511 signal->theData[1] = cownref;
9512 signal->theData[2] = Uint32(gci >> 32);
9513 signal->theData[3] = apiConnectptr.p->transid[0];
9514 signal->theData[4] = apiConnectptr.p->transid[1];
9515 signal->theData[5] = apiConnectptr.p->tcBlockref;
9516 signal->theData[6] = tcConnectptr.p->tcOprec;
9517 signal->theData[7] = Uint32(gci);
9518 sendSignal(tblockref, GSN_COMMITREQ, signal, 8, JBB);
9524 systemErrorLab(signal, __LINE__);
9529 if (apiConnectptr.p->currentReplicaNo > 0) {
9535 apiConnectptr.p->currentReplicaNo--;
9536 tcurrentReplicaNo = apiConnectptr.p->currentReplicaNo;
9541 tcConnectptr.i = tcConnectptr.p->nextTcConnect;
9542 if (tcConnectptr.i == RNIL) {
9548 if (apiConnectptr.p->takeOverRec != (Uint8)Z8NIL) {
9550 sendTCKEY_FAILCONF(signal, apiConnectptr.p);
9553 apiConnectptr = sendApiCommit(signal);
9555 apiConnectptr.p->currentTcConnect = apiConnectptr.p->firstTcConnect;
9556 tcConnectptr.i = apiConnectptr.p->firstTcConnect;
9557 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
9558 tcurrentReplicaNo = tcConnectptr.p->lastReplicaNo;
9559 apiConnectptr.p->currentReplicaNo = tcurrentReplicaNo;
9560 toCompleteHandlingLab(signal);
9563 apiConnectptr.p->currentTcConnect = tcConnectptr.i;
9564 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
9565 apiConnectptr.p->currentReplicaNo = tcConnectptr.p->lastReplicaNo;
9566 tcurrentReplicaNo = tcConnectptr.p->lastReplicaNo;
9577 void Dbtc::execCOMPLETECONF(
Signal* signal)
9579 UintR compare_transid1, compare_transid2;
9582 tcConnectptr.i = signal->theData[0];
9583 tnodeid = signal->theData[1];
9584 if (ERROR_INSERTED(8047)) {
9585 CLEAR_ERROR_INSERT_VALUE;
9586 sendSignalWithDelay(cownref, GSN_COMPLETECONF, signal, 2000, 4);
9589 if (tcConnectptr.i >= ctcConnectFilesize) {
9590 errorReport(signal, 3);
9593 ptrAss(tcConnectptr, tcConnectRecord);
9594 if (tcConnectptr.p->tcConnectstate != OS_WAIT_COMPLETE_CONF) {
9595 warningReport(signal, 12);
9598 apiConnectptr.i = tcConnectptr.p->apiConnect;
9599 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
9600 if (apiConnectptr.p->apiConnectstate != CS_WAIT_COMPLETE_CONF) {
9601 warningReport(signal, 13);
9604 compare_transid1 = apiConnectptr.p->transid[0] ^ signal->theData[2];
9605 compare_transid2 = apiConnectptr.p->transid[1] ^ signal->theData[3];
9606 compare_transid1 = compare_transid1 | compare_transid2;
9607 if (compare_transid1 != 0) {
9608 warningReport(signal, 14);
9611 arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS);
9612 if (tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo] !=
9614 warningReport(signal, 15);
9617 if (ERROR_INSERTED(8028)) {
9619 systemErrorLab(signal, __LINE__);
9621 tcConnectptr.p->tcConnectstate = OS_COMPLETED;
9622 tcurrentReplicaNo = (Uint8)Z8NIL;
9623 toCompleteHandlingLab(signal);
9626 void Dbtc::toCompleteHandlingLab(
Signal* signal)
9629 if (tcurrentReplicaNo != (Uint8)Z8NIL) {
9631 arrGuard(tcurrentReplicaNo, MAX_REPLICAS);
9632 switch (tcConnectptr.p->failData[tcurrentReplicaNo]) {
9633 case LqhTransConf::InvalidStatus:
9646 hostptr.i = tcConnectptr.p->tcNodedata[tcurrentReplicaNo];
9647 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
9648 if (hostptr.p->hostStatus == HS_ALIVE) {
9650 Uint32 instanceKey = tcConnectptr.p->lqhInstanceKey;
9651 tblockref = numberToRef(DBLQH, instanceKey, hostptr.i);
9652 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
9653 tcConnectptr.p->tcConnectstate = OS_WAIT_COMPLETE_CONF;
9654 apiConnectptr.p->apiConnectstate = CS_WAIT_COMPLETE_CONF;
9655 apiConnectptr.p->timeOutCounter = 0;
9656 tcConnectptr.p->apiConnect = apiConnectptr.i;
9657 signal->theData[0] = tcConnectptr.i;
9658 signal->theData[1] = cownref;
9659 signal->theData[2] = apiConnectptr.p->transid[0];
9660 signal->theData[3] = apiConnectptr.p->transid[1];
9661 signal->theData[4] = apiConnectptr.p->tcBlockref;
9662 signal->theData[5] = tcConnectptr.p->tcOprec;
9663 sendSignal(tblockref, GSN_COMPLETEREQ, signal, 6, JBB);
9669 if (apiConnectptr.p->currentReplicaNo != 0) {
9675 apiConnectptr.p->currentReplicaNo--;
9676 tcurrentReplicaNo = apiConnectptr.p->currentReplicaNo;
9678 tcConnectptr.i = tcConnectptr.p->nextTcConnect;
9679 if (tcConnectptr.i == RNIL) {
9684 if (apiConnectptr.p->takeOverRec != (Uint8)Z8NIL) {
9686 signal->theData[0] = TcContinueB::ZCOMPLETE_TRANS_AT_TAKE_OVER;
9687 signal->theData[1] = (UintR)apiConnectptr.p->takeOverRec;
9688 signal->theData[2] = apiConnectptr.p->takeOverInd;
9689 sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
9690 handleGcp(signal, apiConnectptr);
9691 releaseTakeOver(signal);
9694 releaseTransResources(signal);
9703 apiConnectptr.p->currentTcConnect = tcConnectptr.i;
9704 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
9705 tcurrentReplicaNo = tcConnectptr.p->lastReplicaNo;
9706 apiConnectptr.p->currentReplicaNo = tcurrentReplicaNo;
9718 void Dbtc::findApiConnectFail(
Signal* signal)
9720 ApiConnectRecordPtr fafPrevApiConnectptr;
9721 ApiConnectRecordPtr fafNextApiConnectptr;
9722 UintR tfafHashNumber;
9724 tfafHashNumber = ttransid1 & 511;
9725 fafPrevApiConnectptr.i = RNIL;
9726 ptrNull(fafPrevApiConnectptr);
9727 arrGuard(tfafHashNumber, 512);
9728 fafNextApiConnectptr.i = ctransidFailHash[tfafHashNumber];
9729 ptrCheck(fafNextApiConnectptr, capiConnectFilesize, apiConnectRecord);
9732 if (fafNextApiConnectptr.i == RNIL) {
9734 if (cfirstfreeApiConnectFail == RNIL) {
9736 systemErrorLab(signal, __LINE__);
9739 seizeApiConnectFail(signal);
9740 if (fafPrevApiConnectptr.i == RNIL) {
9742 ctransidFailHash[tfafHashNumber] = apiConnectptr.i;
9745 ptrGuard(fafPrevApiConnectptr);
9746 fafPrevApiConnectptr.p->nextApiConnect = apiConnectptr.i;
9748 apiConnectptr.p->nextApiConnect = RNIL;
9749 initApiConnectFail(signal);
9752 fafPrevApiConnectptr.i = fafNextApiConnectptr.i;
9753 fafPrevApiConnectptr.p = fafNextApiConnectptr.p;
9754 apiConnectptr.i = fafNextApiConnectptr.i;
9755 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
9756 fafNextApiConnectptr.i = apiConnectptr.p->nextApiConnect;
9757 ptrCheck(fafNextApiConnectptr, capiConnectFilesize, apiConnectRecord);
9758 if ((apiConnectptr.p->transid[1] != ttransid2) ||
9759 (apiConnectptr.p->transid[0] != ttransid1)) {
9762 updateApiStateFail(signal);
9769 void Dbtc::findTcConnectFail(
Signal* signal, Uint32 instanceKey)
9771 UintR tftfHashNumber;
9773 tftfHashNumber = (ttransid1 ^ ttcOprec) & 1023;
9774 tcConnectptr.i = ctcConnectFailHash[tftfHashNumber];
9776 if (tcConnectptr.i == RNIL) {
9778 if (cfirstfreeTcConnectFail == RNIL) {
9780 systemErrorLab(signal, __LINE__);
9783 seizeTcConnectFail(signal);
9784 linkTcInConnectionlist(signal);
9785 tcConnectptr.p->nextTcFailHash = ctcConnectFailHash[tftfHashNumber];
9786 ctcConnectFailHash[tftfHashNumber] = tcConnectptr.i;
9787 initTcConnectFail(signal, instanceKey);
9790 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
9791 if (tcConnectptr.p->tcOprec != ttcOprec) {
9793 tcConnectptr.i = tcConnectptr.p->nextTcFailHash;
9795 updateTcStateFail(signal, instanceKey);
9805 void Dbtc::initApiConnectFail(
Signal* signal)
9807 apiConnectptr.p->transid[0] = ttransid1;
9808 apiConnectptr.p->transid[1] = ttransid2;
9809 apiConnectptr.p->firstTcConnect = RNIL;
9810 apiConnectptr.p->currSavePointId = 0;
9811 apiConnectptr.p->lastTcConnect = RNIL;
9812 tblockref = calcTcBlockRef(tcNodeFailptr.p->takeOverNode);
9814 apiConnectptr.p->tcBlockref = tblockref;
9815 apiConnectptr.p->ndbapiBlockref = 0;
9816 apiConnectptr.p->ndbapiConnect = 0;
9817 apiConnectptr.p->buddyPtr = RNIL;
9818 apiConnectptr.p->m_transaction_nodes.
clear();
9819 apiConnectptr.p->singleUserMode = 0;
9820 setApiConTimer(apiConnectptr.i, 0, __LINE__);
9821 switch(ttransStatus){
9822 case LqhTransConf::Committed:
9824 apiConnectptr.p->globalcheckpointid = tgci;
9825 apiConnectptr.p->apiConnectstate = CS_FAIL_COMMITTED;
9827 case LqhTransConf::Prepared:
9829 apiConnectptr.p->apiConnectstate = CS_FAIL_PREPARED;
9831 case LqhTransConf::Aborted:
9833 apiConnectptr.p->apiConnectstate = CS_FAIL_ABORTED;
9835 case LqhTransConf::Marker:
9837 apiConnectptr.p->apiConnectstate = CS_FAIL_COMPLETED;
9841 systemErrorLab(signal, __LINE__);
9843 apiConnectptr.p->commitAckMarker = RNIL;
9844 if(LqhTransConf::getMarkerFlag(treqinfo)){
9846 CommitAckMarkerPtr tmp;
9847 m_commitAckMarkerHash.
seize(tmp);
9849 ndbrequire(tmp.i != RNIL);
9851 apiConnectptr.p->commitAckMarker = tmp.i;
9852 tmp.p->transid1 = ttransid1;
9853 tmp.p->transid2 = ttransid2;
9854 tmp.p->apiNodeId = refToNode(tapplRef);
9855 tmp.p->m_commit_ack_marker_nodes.clear();
9856 tmp.p->m_commit_ack_marker_nodes.set(tnodeid);
9857 tmp.p->apiConnectPtr = apiConnectptr.i;
9859 #if defined VM_TRACE || defined ERROR_INSERT
9861 CommitAckMarkerPtr check;
9862 ndbrequire(!m_commitAckMarkerHash.
find(check, *tmp.p));
9865 m_commitAckMarkerHash.
add(tmp);
9873 void Dbtc::initTcConnectFail(
Signal* signal, Uint32 instanceKey)
9875 tcConnectptr.p->apiConnect = apiConnectptr.i;
9876 tcConnectptr.p->tcOprec = ttcOprec;
9877 Uint32 treplicaNo = LqhTransConf::getReplicaNo(treqinfo);
9878 for (Uint32 i = 0; i < MAX_REPLICAS; i++) {
9879 tcConnectptr.p->failData[
i] = LqhTransConf::InvalidStatus;
9881 tcConnectptr.p->tcNodedata[treplicaNo] = tnodeid;
9882 tcConnectptr.p->failData[treplicaNo] = ttransStatus;
9883 tcConnectptr.p->lastReplicaNo = LqhTransConf::getLastReplicaNo(treqinfo);
9884 tcConnectptr.p->dirtyOp = LqhTransConf::getDirtyFlag(treqinfo);
9885 tcConnectptr.p->lqhInstanceKey = instanceKey;
9892 void Dbtc::initTcFail(
Signal* signal)
9894 tcNodeFailptr.i = 0;
9895 ptrAss(tcNodeFailptr, tcFailRecord);
9896 tcNodeFailptr.p->queueIndex = 0;
9897 tcNodeFailptr.p->failStatus = FS_IDLE;
9903 void Dbtc::releaseTakeOver(
Signal* signal)
9905 TcConnectRecordPtr rtoNextTcConnectptr;
9907 rtoNextTcConnectptr.i = apiConnectptr.p->firstTcConnect;
9910 tcConnectptr.i = rtoNextTcConnectptr.i;
9911 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
9912 rtoNextTcConnectptr.i = tcConnectptr.p->nextTcConnect;
9913 releaseTcConnectFail(signal);
9914 }
while (rtoNextTcConnectptr.i != RNIL);
9915 releaseApiConnectFail(signal);
9923 void Dbtc::setupFailData(
Signal* signal)
9925 tcConnectptr.i = apiConnectptr.p->firstTcConnect;
9927 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
9928 switch (tcConnectptr.p->tcConnectstate) {
9932 arrGuard(tcConnectptr.p->lastReplicaNo, MAX_REPLICAS);
9933 for (tindex = 0; tindex <= tcConnectptr.p->lastReplicaNo; tindex++) {
9940 tcConnectptr.p->failData[tindex] = LqhTransConf::Prepared;
9946 arrGuard(tcConnectptr.p->lastReplicaNo, MAX_REPLICAS);
9947 for (tindex = 0; tindex <= tcConnectptr.p->lastReplicaNo; tindex++) {
9954 tcConnectptr.p->failData[tindex] = LqhTransConf::Committed;
9959 arrGuard(tcConnectptr.p->lastReplicaNo, MAX_REPLICAS);
9960 for (tindex = 0; tindex <= tcConnectptr.p->lastReplicaNo; tindex++) {
9966 tcConnectptr.p->failData[tindex] = LqhTransConf::InvalidStatus;
9971 sendSystemError(signal, __LINE__);
9974 if (tabortInd != ZCOMMIT_SETUP) {
9976 for (UintR Ti = 0; Ti <= tcConnectptr.p->lastReplicaNo; Ti++) {
9977 hostptr.i = tcConnectptr.p->tcNodedata[Ti];
9978 ptrCheckGuard(hostptr, chostFilesize, hostRecord);
9979 if (hostptr.p->hostStatus != HS_ALIVE) {
9988 tcConnectptr.p->tcConnectstate = OS_TAKE_OVER;
9989 tcConnectptr.p->tcOprec = tcConnectptr.i;
9990 tcConnectptr.i = tcConnectptr.p->nextTcConnect;
9991 }
while (tcConnectptr.i != RNIL);
9992 apiConnectptr.p->tcBlockref = cownref;
9993 apiConnectptr.p->currentTcConnect = apiConnectptr.p->firstTcConnect;
9994 tcConnectptr.i = apiConnectptr.p->firstTcConnect;
9995 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
9996 apiConnectptr.p->currentReplicaNo = tcConnectptr.p->lastReplicaNo;
9997 tcurrentReplicaNo = tcConnectptr.p->lastReplicaNo;
10003 void Dbtc::updateApiStateFail(
Signal* signal)
10005 if(LqhTransConf::getMarkerFlag(treqinfo))
10007 CommitAckMarkerPtr tmp;
10008 const Uint32 marker = apiConnectptr.p->commitAckMarker;
10009 if (marker == RNIL)
10013 m_commitAckMarkerHash.
seize(tmp);
10014 ndbrequire(tmp.i != RNIL);
10016 apiConnectptr.p->commitAckMarker = tmp.i;
10017 tmp.p->transid1 = ttransid1;
10018 tmp.p->transid2 = ttransid2;
10019 tmp.p->apiNodeId = refToNode(tapplRef);
10020 tmp.p->apiConnectPtr = apiConnectptr.i;
10021 tmp.p->m_commit_ack_marker_nodes.clear();
10022 #if defined VM_TRACE || defined ERROR_INSERT
10024 CommitAckMarkerPtr check;
10025 ndbrequire(!m_commitAckMarkerHash.
find(check, *tmp.p));
10028 m_commitAckMarkerHash.
add(tmp);
10032 tmp.p = m_commitAckMarkerHash.
getPtr(marker);
10034 ndbassert(tmp.p->transid1 == ttransid1);
10035 ndbassert(tmp.p->transid2 == ttransid2);
10037 tmp.p->m_commit_ack_marker_nodes.set(tnodeid);
10040 switch (ttransStatus) {
10041 case LqhTransConf::Committed:
10043 switch (apiConnectptr.p->apiConnectstate) {
10044 case CS_FAIL_COMMITTING:
10045 case CS_FAIL_COMMITTED:
10047 ndbrequire(tgci == apiConnectptr.p->globalcheckpointid);
10049 case CS_FAIL_PREPARED:
10051 apiConnectptr.p->apiConnectstate = CS_FAIL_COMMITTING;
10052 apiConnectptr.p->globalcheckpointid = tgci;
10054 case CS_FAIL_COMPLETED:
10056 apiConnectptr.p->globalcheckpointid = tgci;
10057 apiConnectptr.p->apiConnectstate = CS_FAIL_COMMITTED;
10061 systemErrorLab(signal, __LINE__);
10065 case LqhTransConf::Prepared:
10067 switch (apiConnectptr.p->apiConnectstate) {
10068 case CS_FAIL_COMMITTED:
10070 apiConnectptr.p->apiConnectstate = CS_FAIL_COMMITTING;
10072 case CS_FAIL_ABORTED:
10074 apiConnectptr.p->apiConnectstate = CS_FAIL_ABORTING;
10076 case CS_FAIL_COMMITTING:
10077 case CS_FAIL_PREPARED:
10078 case CS_FAIL_ABORTING:
10084 systemErrorLab(signal, __LINE__);
10088 case LqhTransConf::Aborted:
10090 switch (apiConnectptr.p->apiConnectstate) {
10091 case CS_FAIL_COMMITTING:
10092 case CS_FAIL_COMMITTED:
10094 systemErrorLab(signal, __LINE__);
10096 case CS_FAIL_PREPARED:
10098 apiConnectptr.p->apiConnectstate = CS_FAIL_ABORTING;
10100 case CS_FAIL_ABORTING:
10101 case CS_FAIL_ABORTED:
10107 systemErrorLab(signal, __LINE__);
10111 case LqhTransConf::Marker:
10116 systemErrorLab(signal, __LINE__);
10128 void Dbtc::updateTcStateFail(
Signal* signal, Uint32 instanceKey)
10130 const Uint8 treplicaNo = LqhTransConf::getReplicaNo(treqinfo);
10131 const Uint8 tlastReplicaNo = LqhTransConf::getLastReplicaNo(treqinfo);
10132 const Uint8 tdirtyOp = LqhTransConf::getDirtyFlag(treqinfo);
10134 TcConnectRecord * regTcPtr = tcConnectptr.p;
10136 ndbrequire(regTcPtr->apiConnect == apiConnectptr.i);
10137 ndbrequire(regTcPtr->failData[treplicaNo] == LqhTransConf::InvalidStatus);
10138 ndbrequire(regTcPtr->lastReplicaNo == tlastReplicaNo);
10139 ndbrequire(regTcPtr->dirtyOp == tdirtyOp);
10141 regTcPtr->tcNodedata[treplicaNo] = tnodeid;
10142 regTcPtr->failData[treplicaNo] = ttransStatus;
10143 ndbrequire(regTcPtr->lqhInstanceKey == instanceKey)
10146 void Dbtc::execTCGETOPSIZEREQ(
Signal* signal)
10149 CRASH_INSERTION(8000);
10151 UintR Tuserpointer = signal->theData[0];
10152 BlockReference Tusersblkref = signal->theData[1];
10153 signal->theData[0] = Tuserpointer;
10154 signal->theData[1] = coperationsize;
10155 sendSignal(Tusersblkref, GSN_TCGETOPSIZECONF, signal, 2, JBB);
10158 void Dbtc::execTC_CLOPSIZEREQ(
Signal* signal)
10161 CRASH_INSERTION(8001);
10163 tuserpointer = signal->theData[0];
10164 tusersblkref = signal->theData[1];
10166 coperationsize = 0;
10167 signal->theData[0] = tuserpointer;
10168 sendSignal(tusersblkref, GSN_TC_CLOPSIZECONF, signal, 1, JBB);
10174 void Dbtc::tabStateErrorLab(
Signal* signal)
10176 terrorCode = ZSTATE_ERROR;
10177 releaseAtErrorLab(signal);
10180 void Dbtc::wrongSchemaVersionErrorLab(
Signal* signal)
10184 TableRecordPtr tabPtr;
10185 tabPtr.i = tcKeyReq->tableId;
10186 const Uint32 schemVer = tcKeyReq->tableSchemaVersion;
10187 ptrCheckGuard(tabPtr, ctabrecFilesize, tableRecord);
10189 terrorCode = tabPtr.p->getErrorCode(schemVer);
10191 abortErrorLab(signal);
10194 void Dbtc::noFreeConnectionErrorLab(
Signal* signal)
10196 terrorCode = ZNO_FREE_TC_CONNECTION;
10197 abortErrorLab(signal);
10200 void Dbtc::aiErrorLab(
Signal* signal)
10202 terrorCode = ZLENGTH_ERROR;
10203 abortErrorLab(signal);
10206 void Dbtc::seizeDatabuferrorLab(
Signal* signal)
10208 terrorCode = ZGET_DATAREC_ERROR;
10209 releaseAtErrorLab(signal);
10212 void Dbtc::appendToSectionErrorLab(
Signal* signal)
10214 terrorCode = ZGET_DATAREC_ERROR;
10215 releaseAtErrorLab(signal);
10218 void Dbtc::releaseAtErrorLab(
Signal* signal)
10220 ptrGuard(tcConnectptr);
10221 tcConnectptr.p->tcConnectstate = OS_ABORTING;
10231 tcConnectptr.p->noOfNodes = 0;
10232 abortErrorLab(signal);
10235 void Dbtc::warningHandlerLab(
Signal* signal,
int line)
10240 void Dbtc::systemErrorLab(
Signal* signal,
int line)
10246 #ifdef ERROR_INSERT
10247 bool Dbtc::testFragmentDrop(
Signal* signal)
10249 Uint32 fragIdToDrop= ~0;
10251 if (ERROR_INSERTED(8074))
10253 else if (ERROR_INSERTED(8075))
10255 else if (ERROR_INSERTED(8076))
10258 if ((signal->header.m_fragmentInfo == fragIdToDrop) ||
10259 ERROR_INSERTED(8077))
10268 Uint32 secCount= handle.m_cnt;
10269 releaseSections(handle);
10271 Uint32 gsn = signal->header.theVerId_signalNumber;
10272 Uint32 len = signal->header.theLength;
10273 Uint32 newLen= (len > 22 ? 22 : len);
10274 memmove(rep->originalData, signal->theData, (4 * newLen));
10275 rep->originalGsn = gsn;
10276 rep->originalLength = len;
10277 rep->originalSectionCount = secCount;
10278 signal->header.theVerId_signalNumber = GSN_SIGNAL_DROPPED_REP;
10279 signal->header.theLength = newLen + 3;
10280 signal->header.m_noOfSections = 0;
10381 void Dbtc::execSCAN_TABREQ(
Signal* signal)
10385 #ifdef ERROR_INSERT
10387 if (ERROR_INSERTED(8074) ||
10388 ERROR_INSERTED(8075) ||
10389 ERROR_INSERTED(8076) ||
10390 ERROR_INSERTED(8077))
10393 if (testFragmentDrop(signal)) {
10407 const Uint32 ri = scanTabReq->requestInfo;
10408 const Uint32 schemaVersion = scanTabReq->tableSchemaVersion;
10409 const Uint32 transid1 = scanTabReq->transId1;
10410 const Uint32 transid2 = scanTabReq->transId2;
10411 const Uint32 tmpXX = scanTabReq->buddyConPtr;
10412 const Uint32 buddyPtr = (tmpXX == 0xFFFFFFFF ? RNIL : tmpXX);
10413 Uint32 currSavePointId = 0;
10415 Uint32 scanConcurrency = scanTabReq->getParallelism(ri);
10416 Uint32 noOprecPerFrag = ScanTabReq::getScanBatch(ri);
10417 Uint32 scanParallel = scanConcurrency;
10419 ScanRecordPtr scanptr;
10426 Uint32 numSections= signal->getNoOfSections();
10427 ndbassert( numSections >= 1 );
10428 bool isLongReq= numSections >= 2;
10432 handle.getSection(api_op_ptr, 0);
10433 copy(&cdata[0], api_op_ptr);
10435 Uint32 aiLength= 0;
10438 if (likely(isLongReq))
10442 handle.getSection(attrInfoPtr, ScanTabReq::AttrInfoSectionNum);
10443 aiLength= attrInfoPtr.sz;
10444 if (numSections == 3)
10446 handle.getSection(keyInfoPtr, ScanTabReq::KeyInfoSectionNum);
10447 keyLen= keyInfoPtr.sz;
10453 aiLength = (scanTabReq->attrLenKeyLen & 0xFFFF);
10454 keyLen = scanTabReq->attrLenKeyLen >> 16;
10458 apiConnectptr.i = scanTabReq->apiConnectPtr;
10459 tabptr.i = scanTabReq->tableId;
10461 if (apiConnectptr.i >= capiConnectFilesize)
10464 releaseSections(handle);
10465 warningHandlerLab(signal, __LINE__);
10469 ptrAss(apiConnectptr, apiConnectRecord);
10470 ApiConnectRecord * transP = apiConnectptr.p;
10472 if (transP->apiConnectstate != CS_CONNECTED) {
10475 if (transP->apiConnectstate == CS_ABORTING &&
10476 transP->abortState == AS_IDLE) {
10478 }
else if(transP->apiConnectstate == CS_STARTED &&
10479 transP->firstTcConnect == RNIL){
10484 jamLine(transP->apiConnectstate);
10485 errCode = ZSTATE_ERROR;
10486 goto SCAN_TAB_error_no_state_change;
10490 if(tabptr.i >= ctabrecFilesize)
10492 errCode = ZUNKNOWN_TABLE_ERROR;
10493 goto SCAN_TAB_error;
10496 ptrAss(tabptr, tableRecord);
10497 if ((aiLength == 0) ||
10499 (scanConcurrency == 0) ||
10500 (cfirstfreeTcConnect == RNIL) ||
10501 (cfirstfreeScanrec == RNIL)) {
10502 goto SCAN_error_check;
10504 if (buddyPtr != RNIL) {
10506 ApiConnectRecordPtr buddyApiPtr;
10507 buddyApiPtr.i = buddyPtr;
10508 ptrCheckGuard(buddyApiPtr, capiConnectFilesize, apiConnectRecord);
10509 if ((transid1 == buddyApiPtr.p->transid[0]) &&
10510 (transid2 == buddyApiPtr.p->transid[1])) {
10513 if (buddyApiPtr.p->apiConnectstate == CS_ABORTING) {
10516 errCode = buddyApiPtr.p->returncode;
10517 goto SCAN_TAB_error;
10519 currSavePointId = buddyApiPtr.p->currSavePointId;
10520 buddyApiPtr.p->currSavePointId++;
10524 if (
getNodeState().startLevel == NodeState::SL_SINGLEUSER &&
10526 refToNode(apiConnectptr.p->ndbapiBlockref))
10528 errCode = ZCLUSTER_IN_SINGLEUSER_MODE;
10529 goto SCAN_TAB_error;
10532 seizeTcConnect(signal);
10533 tcConnectptr.p->apiConnect = apiConnectptr.i;
10534 tcConnectptr.p->tcConnectstate = OS_WAIT_SCAN;
10535 apiConnectptr.p->lastTcConnect = tcConnectptr.i;
10537 seizeCacheRecord(signal);
10539 if (likely(isLongReq))
10542 cachePtr.p->attrInfoSectionI= handle.m_ptr[ScanTabReq::AttrInfoSectionNum].i;
10544 cachePtr.p->keyInfoSectionI= handle.m_ptr[ScanTabReq::KeyInfoSectionNum].i;
10547 releaseSection(handle.m_ptr[ScanTabReq::ReceiverIdSectionNum].i);
10550 cachePtr.p->keylen = keyLen;
10551 cachePtr.p->save1 = 0;
10552 cachePtr.p->distributionKey = scanTabReq->distributionKey;
10553 cachePtr.p->distributionKeyIndicator= ScanTabReq::getDistributionKeyFlag(ri);
10554 scanptr = seizeScanrec(signal);
10556 ndbrequire(transP->apiScanRec == RNIL);
10557 ndbrequire(scanptr.p->scanApiRec == RNIL);
10559 errCode = initScanrec(scanptr, scanTabReq, scanParallel, noOprecPerFrag, aiLength, keyLen);
10560 if (unlikely(errCode))
10563 goto SCAN_TAB_error;
10566 transP->apiScanRec = scanptr.i;
10567 transP->returncode = 0;
10568 transP->transid[0] = transid1;
10569 transP->transid[1] = transid2;
10570 transP->buddyPtr = buddyPtr;
10573 transP->apiConnectstate = CS_START_SCAN;
10574 transP->currSavePointId = currSavePointId;
10580 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
10581 updateBuddyTimer(apiConnectptr);
10588 scanptr.p->scanState = ScanRecord::WAIT_AI;
10590 if (ERROR_INSERTED(8038))
10596 rep->nodeId = refToNode(apiConnectptr.p->ndbapiBlockref);
10599 sendSignal(CMVMI_REF, GSN_DISCONNECT_REP, signal, 2, JBA);
10600 CLEAR_ERROR_INSERT_VALUE;
10608 diFcountReqLab(signal, scanptr);
10614 if (aiLength == 0) {
10616 errCode = ZSCAN_AI_LEN_ERROR;
10617 goto SCAN_TAB_error;
10621 errCode = tabptr.p->getErrorCode(schemaVersion);
10622 goto SCAN_TAB_error;
10624 if (scanConcurrency == 0) {
10626 errCode = ZNO_CONCURRENCY_ERROR;
10627 goto SCAN_TAB_error;
10629 if (cfirstfreeTcConnect == RNIL) {
10631 errCode = ZNO_FREE_TC_CONNECTION;
10632 goto SCAN_TAB_error;
10634 ndbrequire(cfirstfreeScanrec == RNIL);
10636 errCode = ZNO_SCANREC_ERROR;
10637 goto SCAN_TAB_error;
10644 transP->apiConnectstate = CS_ABORTING;
10645 transP->abortState = AS_IDLE;
10646 transP->transid[0] = transid1;
10647 transP->transid[1] = transid2;
10649 SCAN_TAB_error_no_state_change:
10651 releaseSections(handle);
10654 ref->apiConnectPtr = transP->ndbapiConnect;
10655 ref->transId1 = transid1;
10656 ref->transId2 = transid2;
10657 ref->errorCode = errCode;
10658 ref->closeNeeded = 0;
10659 sendSignal(transP->ndbapiBlockref, GSN_SCAN_TABREF,
10660 signal, ScanTabRef::SignalLength, JBB);
10665 Dbtc::initScanrec(ScanRecordPtr scanptr,
10667 UintR scanParallel,
10668 UintR noOprecPerFrag,
10672 const UintR ri = scanTabReq->requestInfo;
10673 scanptr.p->scanTcrec = tcConnectptr.i;
10674 scanptr.p->scanApiRec = apiConnectptr.i;
10675 scanptr.p->scanAiLength = aiLength;
10676 scanptr.p->scanKeyLen = keyLength;
10677 scanptr.p->scanTableref = tabptr.i;
10678 scanptr.p->scanSchemaVersion = scanTabReq->tableSchemaVersion;
10679 scanptr.p->scanParallel = scanParallel;
10680 scanptr.p->first_batch_size_rows = scanTabReq->first_batch_size;
10681 scanptr.p->batch_byte_size = scanTabReq->batch_byte_size;
10682 scanptr.p->batch_size_rows = noOprecPerFrag;
10683 scanptr.p->m_scan_block_no = DBLQH;
10686 ScanFragReq::setLockMode(tmp, ScanTabReq::getLockMode(ri));
10687 ScanFragReq::setHoldLockFlag(tmp, ScanTabReq::getHoldLockFlag(ri));
10688 ScanFragReq::setKeyinfoFlag(tmp, ScanTabReq::getKeyinfoFlag(ri));
10689 ScanFragReq::setReadCommittedFlag(tmp,ScanTabReq::getReadCommittedFlag(ri));
10690 ScanFragReq::setRangeScanFlag(tmp, ScanTabReq::getRangeScanFlag(ri));
10691 ScanFragReq::setDescendingFlag(tmp, ScanTabReq::getDescendingFlag(ri));
10692 ScanFragReq::setTupScanFlag(tmp, ScanTabReq::getTupScanFlag(ri));
10693 ScanFragReq::setNoDiskFlag(tmp, ScanTabReq::getNoDiskFlag(ri));
10694 if (ScanTabReq::getViaSPJFlag(ri))
10697 scanptr.p->m_scan_block_no = DBSPJ;
10700 scanptr.p->scanRequestInfo = tmp;
10701 scanptr.p->scanStoredProcId = scanTabReq->storedProcId;
10702 scanptr.p->scanState = ScanRecord::RUNNING;
10703 scanptr.p->m_queued_count = 0;
10704 scanptr.p->m_scan_cookie = RNIL;
10705 scanptr.p->m_close_scan_req =
false;
10706 scanptr.p->m_pass_all_confs = ScanTabReq::getPassAllConfsFlag(ri);
10707 scanptr.p->m_4word_conf = ScanTabReq::get4WordConf(ri);
10709 ScanFragList list(c_scan_frag_pool,
10710 scanptr.p->m_running_scan_frags);
10711 for (Uint32 i = 0; i < scanParallel; i++) {
10713 ScanFragRecPtr ptr;
10714 if (unlikely(list.seize(ptr) ==
false))
10719 ptr.p->scanFragState = ScanFragRec::IDLE;
10720 ptr.p->scanRec = scanptr.i;
10721 ptr.p->scanFragId = 0;
10722 ptr.p->m_apiPtr = cdata[
i];
10725 (* (ScanTabReq::getRangeScanFlag(ri) ?
10726 &c_counters.c_range_scan_count :
10727 &c_counters.c_scan_count))++;
10731 return ZSCAN_FRAGREC_ERROR;
10734 void Dbtc::scanTabRefLab(
Signal* signal, Uint32 errCode)
10737 ref->apiConnectPtr = apiConnectptr.p->ndbapiConnect;
10738 ref->transId1 = apiConnectptr.p->transid[0];
10739 ref->transId2 = apiConnectptr.p->transid[1];
10740 ref->errorCode = errCode;
10741 ref->closeNeeded = 0;
10742 sendSignal(apiConnectptr.p->ndbapiBlockref, GSN_SCAN_TABREF,
10743 signal, ScanTabRef::SignalLength, JBB);
10750 void Dbtc::scanKeyinfoLab(
Signal* signal)
10755 CacheRecord *
const regCachePtr = cachePtr.p;
10756 UintR TkeyLen = regCachePtr->keylen;
10757 UintR Tlen = regCachePtr->save1;
10759 Uint32 wordsInSignal= MIN(KeyInfo::DataLength,
10762 ndbassert( signal->getLength() ==
10763 (KeyInfo::HeaderLength + wordsInSignal) );
10765 if (unlikely (! appendToSection(regCachePtr->keyInfoSectionI,
10766 &signal->theData[KeyInfo::HeaderLength],
10770 seizeDatabuferrorLab(signal);
10774 Tlen+= wordsInSignal;
10775 regCachePtr->save1 = Tlen;
10777 if (Tlen < TkeyLen)
10781 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
10789 ndbassert(Tlen == TkeyLen);
10797 void Dbtc::scanAttrinfoLab(
Signal* signal, UintR Tlen)
10799 ScanRecordPtr scanptr;
10800 scanptr.i = apiConnectptr.p->apiScanRec;
10801 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
10802 tcConnectptr.i = scanptr.p->scanTcrec;
10803 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
10804 cachePtr.i = apiConnectptr.p->cachePtr;
10805 ptrCheckGuard(cachePtr, ccacheFilesize, cacheRecord);
10806 CacheRecord *
const regCachePtr = cachePtr.p;
10807 ndbrequire(scanptr.p->scanState == ScanRecord::WAIT_AI);
10809 regCachePtr->currReclenAi = regCachePtr->currReclenAi + Tlen;
10811 if (unlikely(! appendToSection(regCachePtr->attrInfoSectionI,
10812 &signal->theData[AttrInfo::HeaderLength],
10816 abortScanLab(signal, scanptr, ZGET_ATTRBUF_ERROR,
true);
10820 if (regCachePtr->currReclenAi == scanptr.p->scanAiLength)
10825 diFcountReqLab(signal, scanptr);
10828 else if (unlikely (regCachePtr->currReclenAi > scanptr.p->scanAiLength))
10831 abortScanLab(signal, scanptr, ZLENGTH_ERROR,
true);
10839 void Dbtc::diFcountReqLab(
Signal* signal, ScanRecordPtr scanptr)
10844 TableRecordPtr tabPtr;
10845 tabPtr.i = scanptr.p->scanTableref;
10846 tabPtr.p = &tableRecord[tabPtr.i];
10847 if (tabPtr.p->checkTable(scanptr.p->scanSchemaVersion)){
10850 abortScanLab(signal, scanptr,
10851 tabPtr.p->getErrorCode(scanptr.p->scanSchemaVersion),
10856 scanptr.p->scanNextFragId = 0;
10857 scanptr.p->m_booked_fragments_count= 0;
10858 scanptr.p->scanState = ScanRecord::WAIT_FRAGMENT_COUNT;
10864 req->senderRef = reference();
10865 req->senderData = tcConnectptr.i;
10866 req->tableId = scanptr.p->scanTableref;
10867 req->schemaTransId = 0;
10868 sendSignal(cdihblockref, GSN_DIH_SCAN_TAB_REQ, signal,
10869 DihScanTabReq::SignalLength, JBB);
10882 void Dbtc::execDIH_SCAN_TAB_CONF(
Signal* signal)
10886 tcConnectptr.i = conf->senderData;
10887 Uint32 tfragCount = conf->fragmentCount;
10888 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
10889 apiConnectptr.i = tcConnectptr.p->apiConnect;
10890 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
10891 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
10892 ScanRecordPtr scanptr;
10893 scanptr.i = regApiPtr->apiScanRec;
10894 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
10895 ndbrequire(scanptr.p->scanState == ScanRecord::WAIT_FRAGMENT_COUNT);
10896 scanptr.p->m_scan_cookie = conf->scanCookie;
10898 if (conf->reorgFlag)
10901 ScanFragReq::setReorgFlag(scanptr.p->scanRequestInfo, 1);
10903 if (regApiPtr->apiFailState == ZTRUE) {
10905 releaseScanResources(signal, scanptr,
true);
10906 handleApiFailState(signal, apiConnectptr.i);
10909 if (tfragCount == 0) {
10911 abortScanLab(signal, scanptr, ZNO_FRAGMENT_ERROR,
true);
10918 TableRecordPtr tabPtr;
10919 tabPtr.i = scanptr.p->scanTableref;
10920 tabPtr.p = &tableRecord[tabPtr.i];
10921 if (tabPtr.p->checkTable(scanptr.p->scanSchemaVersion)){
10924 abortScanLab(signal, scanptr,
10925 tabPtr.p->getErrorCode(scanptr.p->scanSchemaVersion),
10930 cachePtr.i = regApiPtr->cachePtr;
10931 ptrCheckGuard(cachePtr, ccacheFilesize, cacheRecord);
10932 CacheRecord * regCachePtrP = cachePtr.p;
10935 if (unlikely(!ndb_scan_distributionkey(version)))
10938 regCachePtrP->distributionKeyIndicator = 0;
10940 if (regCachePtrP->distributionKeyIndicator)
10943 ndbrequire(DictTabInfo::isOrderedIndex(tabPtr.p->tableType) ||
10944 tabPtr.p->get_user_defined_partitioning());
10948 req->tableId = tabPtr.i;
10949 req->hashValue = cachePtr.p->distributionKey;
10950 req->distr_key_indicator = tabPtr.p->get_user_defined_partitioning();
10953 DiGetNodesReq::SignalLength, 0);
10954 UintR TerrorIndicator = signal->theData[0];
10956 if (TerrorIndicator != 0)
10959 abortScanLab(signal, scanptr,
10960 signal->theData[1],
10965 scanptr.p->scanNextFragId = get_conf->fragId;
10969 scanptr.p->scanParallel = tfragCount;
10970 scanptr.p->scanNoFrag = tfragCount;
10971 scanptr.p->scanState = ScanRecord::RUNNING;
10973 setApiConTimer(apiConnectptr.i, 0, __LINE__);
10974 updateBuddyTimer(apiConnectptr);
10976 ScanFragRecPtr ptr;
10977 ScanFragList list(c_scan_frag_pool, scanptr.p->m_running_scan_frags);
10978 for (list.first(ptr); !ptr.isNull() && tfragCount;
10979 list.next(ptr), tfragCount--){
10982 ptr.p->lqhBlockref = 0;
10983 ptr.p->startFragTimer(ctcTimer);
10984 ptr.p->scanFragId = scanptr.p->scanNextFragId++;
10985 ptr.p->scanFragState = ScanFragRec::WAIT_GET_PRIMCONF;
10986 ptr.p->startFragTimer(ctcTimer);
10990 req->senderRef = reference();
10991 req->senderData = ptr.i;
10992 req->tableId = scanptr.p->scanTableref;
10993 req->fragId = ptr.p->scanFragId;
10994 req->scanCookie = scanptr.p->m_scan_cookie;
10995 sendSignal(cdihblockref, GSN_DIH_SCAN_GET_NODES_REQ, signal,
10996 DihScanGetNodesReq::SignalLength, JBB);
10999 ScanFragList queued(c_scan_frag_pool, scanptr.p->m_queued_scan_frags);
11000 for (; !ptr.isNull();)
11003 ptr.p->m_totalLen = 0;
11004 ptr.p->m_scan_frag_conf_status = 1;
11005 ptr.p->scanFragState = ScanFragRec::QUEUED_FOR_DELIVERY;
11006 ptr.p->stopFragTimer();
11008 ScanFragRecPtr tmp;
11014 scanptr.p->m_queued_count++;
11021 void Dbtc::execDIH_SCAN_TAB_REF(
Signal* signal)
11025 tcConnectptr.i = ref->senderData;
11026 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
11027 const Uint32 errCode = ref->error;
11028 apiConnectptr.i = tcConnectptr.p->apiConnect;
11029 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
11030 ScanRecordPtr scanptr;
11031 scanptr.i = apiConnectptr.p->apiScanRec;
11032 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
11033 ndbrequire(scanptr.p->scanState == ScanRecord::WAIT_FRAGMENT_COUNT);
11034 if (apiConnectptr.p->apiFailState == ZTRUE) {
11036 releaseScanResources(signal, scanptr,
true);
11037 handleApiFailState(signal, apiConnectptr.i);
11040 abortScanLab(signal, scanptr, errCode,
true);
11043 void Dbtc::abortScanLab(
Signal* signal, ScanRecordPtr scanptr, Uint32 errCode,
11046 scanTabRefLab(signal, errCode);
11047 releaseScanResources(signal, scanptr, not_started);
11050 void Dbtc::releaseScanResources(
Signal* signal,
11051 ScanRecordPtr scanPtr,
11054 if (apiConnectptr.p->cachePtr != RNIL) {
11055 cachePtr.i = apiConnectptr.p->cachePtr;
11056 ptrCheckGuard(cachePtr, ccacheFilesize, cacheRecord);
11060 tcConnectptr.i = scanPtr.p->scanTcrec;
11061 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
11067 ScanFragList
run(c_scan_frag_pool, scanPtr.p->m_running_scan_frags);
11068 ScanFragList queue(c_scan_frag_pool, scanPtr.p->m_queued_scan_frags);
11073 ndbrequire(scanPtr.p->m_running_scan_frags.isEmpty());
11074 ndbrequire(scanPtr.p->m_queued_scan_frags.isEmpty());
11075 ndbrequire(scanPtr.p->m_delivered_scan_frags.isEmpty());
11077 ndbassert(scanPtr.p->scanApiRec == apiConnectptr.i);
11078 ndbassert(apiConnectptr.p->apiScanRec == scanPtr.i);
11081 rep->tableId = scanPtr.p->scanTableref;
11082 rep->scanCookie = scanPtr.p->m_scan_cookie;
11083 sendSignal(cdihblockref, GSN_DIH_SCAN_TAB_COMPLETE_REP,
11084 signal, DihScanTabCompleteRep::SignalLength, JBB);
11087 scanPtr.p->nextScan = cfirstfreeScanrec;
11088 scanPtr.p->scanState = ScanRecord::IDLE;
11089 scanPtr.p->scanTcrec = RNIL;
11090 scanPtr.p->scanApiRec = RNIL;
11091 cfirstfreeScanrec = scanPtr.i;
11093 apiConnectptr.p->apiScanRec = RNIL;
11094 apiConnectptr.p->apiConnectstate = CS_CONNECTED;
11095 setApiConTimer(apiConnectptr.i, 0, __LINE__);
11106 void Dbtc::execDIH_SCAN_GET_NODES_CONF(
Signal* signal)
11110 scanFragptr.i = conf->senderData;
11111 c_scan_frag_pool.
getPtr(scanFragptr);
11113 tnodeid = conf->nodes[0];
11114 arrGuard(tnodeid, MAX_NDB_NODES);
11116 if(ERROR_INSERTED(8050) && tnodeid != getOwnNodeId())
11122 CRASH_INSERTION(8050);
11125 ndbrequire(scanFragptr.p->scanFragState == ScanFragRec::WAIT_GET_PRIMCONF);
11126 scanFragptr.p->stopFragTimer();
11128 ScanRecordPtr scanptr;
11129 scanptr.i = scanFragptr.p->scanRec;
11130 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
11137 if(
false && ScanFragReq::getReadCommittedFlag(scanptr.p->scanRequestInfo))
11140 Uint32 nodeid = getOwnNodeId();
11141 for(Uint32 i = 1; i<conf->count; i++)
11143 if(conf->nodes[i] == nodeid)
11156 TableRecordPtr tabPtr;
11157 tabPtr.i = scanptr.p->scanTableref;
11158 ptrAss(tabPtr, tableRecord);
11159 Uint32 schemaVersion = scanptr.p->scanSchemaVersion;
11160 if (ERROR_INSERTED(8081) || tabPtr.p->checkTable(schemaVersion) ==
false)
11164 if (ERROR_INSERTED(8081))
11166 err = ZTIME_OUT_ERROR;
11167 CLEAR_ERROR_INSERT_VALUE;
11171 err = tabPtr.p->getErrorCode(schemaVersion);
11174 ScanFragList
run(c_scan_frag_pool, scanptr.p->m_running_scan_frags);
11175 run.release(scanFragptr);
11177 scanError(signal, scanptr, err);
11182 tcConnectptr.i = scanptr.p->scanTcrec;
11183 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
11184 apiConnectptr.i = scanptr.p->scanApiRec;
11185 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
11186 cachePtr.i = apiConnectptr.p->cachePtr;
11187 ptrCheckGuard(cachePtr, ccacheFilesize, cacheRecord);
11188 switch (scanptr.p->scanState) {
11189 case ScanRecord::CLOSING_SCAN:
11191 updateBuddyTimer(apiConnectptr);
11193 ScanFragList
run(c_scan_frag_pool, scanptr.p->m_running_scan_frags);
11194 run.release(scanFragptr);
11196 close_scan_req_send_conf(signal, scanptr);
11211 Uint32 instanceKey = conf->instanceKey;
11212 scanFragptr.p->lqhBlockref = numberToRef(scanptr.p->m_scan_block_no,
11213 instanceKey, tnodeid);
11214 if (scanptr.p->m_scan_block_no == DBSPJ)
11217 scanFragptr.p->lqhBlockref = numberToRef(scanptr.p->m_scan_block_no,
11230 bool isLastScanFragReq= ((scanptr.p->scanNextFragId >=
11231 scanptr.p->scanNoFrag) &&
11232 (scanFragptr.p->scanFragId ==
11233 (scanptr.p->scanNextFragId - 1)));
11235 sendScanFragReq(signal, scanptr.p, scanFragptr.p, isLastScanFragReq);
11237 scanFragptr.p->scanFragState = ScanFragRec::LQH_ACTIVE;
11238 scanFragptr.p->startFragTimer(ctcTimer);
11239 updateBuddyTimer(apiConnectptr);
11253 void Dbtc::execDIH_SCAN_GET_NODES_REF(
Signal* signal)
11257 scanFragptr.i = signal->theData[1];
11258 const Uint32 errCode = signal->theData[2];
11259 c_scan_frag_pool.
getPtr(scanFragptr);
11260 ndbrequire(scanFragptr.p->scanFragState == ScanFragRec::WAIT_GET_PRIMCONF);
11262 ScanRecordPtr scanptr;
11263 scanptr.i = scanFragptr.p->scanRec;
11264 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
11267 ScanFragList
run(c_scan_frag_pool, scanptr.p->m_running_scan_frags);
11268 run.release(scanFragptr);
11271 scanError(signal, scanptr, errCode);
11280 void Dbtc::execSCAN_FRAGREF(
Signal* signal)
11285 const Uint32 errCode = ref->errorCode;
11287 scanFragptr.i = ref->senderData;
11288 c_scan_frag_pool.
getPtr(scanFragptr);
11290 ScanRecordPtr scanptr;
11291 scanptr.i = scanFragptr.p->scanRec;
11292 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
11294 apiConnectptr.i = scanptr.p->scanApiRec;
11295 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
11297 Uint32 transid1 = apiConnectptr.p->transid[0] ^ ref->transId1;
11298 Uint32 transid2 = apiConnectptr.p->transid[1] ^ ref->transId2;
11299 transid1 = transid1 | transid2;
11300 if (transid1 != 0) {
11302 systemErrorLab(signal, __LINE__);
11310 ndbrequire(scanFragptr.p->scanFragState == ScanFragRec::LQH_ACTIVE);
11311 scanFragptr.p->scanFragState = ScanFragRec::COMPLETED;
11312 scanFragptr.p->stopFragTimer();
11314 ScanFragList
run(c_scan_frag_pool, scanptr.p->m_running_scan_frags);
11315 run.release(scanFragptr);
11317 scanError(signal, scanptr, errCode);
11325 void Dbtc::scanError(
Signal* signal, ScanRecordPtr scanptr, Uint32 errorCode)
11328 ScanRecord* scanP = scanptr.p;
11330 DEBUG(
"scanError, errorCode = "<< errorCode <<
11331 ", scanState = " << scanptr.p->scanState);
11333 apiConnectptr.i = scanP->scanApiRec;
11334 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
11335 ndbrequire(apiConnectptr.p->apiScanRec == scanptr.i);
11337 if(scanP->scanState == ScanRecord::CLOSING_SCAN){
11339 close_scan_req_send_conf(signal, scanptr);
11343 ndbrequire(scanP->scanState == ScanRecord::RUNNING);
11348 close_scan_req(signal, scanptr,
false);
11350 const bool apiFail = (apiConnectptr.p->apiFailState == ZTRUE);
11357 ref->apiConnectPtr = apiConnectptr.p->ndbapiConnect;
11358 ref->transId1 = apiConnectptr.p->transid[0];
11359 ref->transId2 = apiConnectptr.p->transid[1];
11360 ref->errorCode = errorCode;
11361 ref->closeNeeded = 1;
11362 sendSignal(apiConnectptr.p->ndbapiBlockref, GSN_SCAN_TABREF,
11363 signal, ScanTabRef::SignalLength, JBB);
11372 void Dbtc::execSCAN_FRAGCONF(
Signal* signal)
11374 Uint32 transid1, transid2, total_len;
11378 const Uint32 noCompletedOps = conf->completedOps;
11379 const Uint32 status = conf->fragmentCompleted;
11381 scanFragptr.i = conf->senderData;
11382 c_scan_frag_pool.
getPtr(scanFragptr);
11384 ScanRecordPtr scanptr;
11385 scanptr.i = scanFragptr.p->scanRec;
11386 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
11388 apiConnectptr.i = scanptr.p->scanApiRec;
11389 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
11391 transid1 = apiConnectptr.p->transid[0] ^ conf->transId1;
11392 transid2 = apiConnectptr.p->transid[1] ^ conf->transId2;
11393 total_len= conf->total_len;
11394 transid1 = transid1 | transid2;
11395 if (transid1 != 0) {
11397 systemErrorLab(signal, __LINE__);
11400 ndbrequire(scanFragptr.p->scanFragState == ScanFragRec::LQH_ACTIVE);
11402 if(scanptr.p->scanState == ScanRecord::CLOSING_SCAN){
11411 scanFragptr.p->stopFragTimer();
11412 scanFragptr.p->scanFragState = ScanFragRec::COMPLETED;
11414 ScanFragList
run(c_scan_frag_pool, scanptr.p->m_running_scan_frags);
11415 run.release(scanFragptr);
11418 close_scan_req_send_conf(signal, scanptr);
11422 if(noCompletedOps == 0 && status != 0 &&
11423 !scanptr.p->m_pass_all_confs &&
11424 scanptr.p->scanNextFragId+scanptr.p->m_booked_fragments_count < scanptr.p->scanNoFrag){
11433 scanFragptr.p->scanFragState = ScanFragRec::WAIT_GET_PRIMCONF;
11434 scanFragptr.p->startFragTimer(ctcTimer);
11436 tcConnectptr.i = scanptr.p->scanTcrec;
11437 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
11438 scanFragptr.p->scanFragId = scanptr.p->scanNextFragId++;
11440 req->senderRef = reference();
11441 req->senderData = scanFragptr.i;
11442 req->tableId = scanptr.p->scanTableref;
11443 req->fragId = scanFragptr.p->scanFragId;
11444 req->scanCookie = scanptr.p->m_scan_cookie;
11445 sendSignal(cdihblockref, GSN_DIH_SCAN_GET_NODES_REQ, signal,
11446 DihScanGetNodesReq::SignalLength, JBB);
11457 ScanFragList
run(c_scan_frag_pool, scanptr.p->m_running_scan_frags);
11458 ScanFragList queued(c_scan_frag_pool, scanptr.p->m_queued_scan_frags);
11460 run.remove(scanFragptr);
11461 queued.add(scanFragptr);
11462 scanptr.p->m_queued_count++;
11466 scanptr.p->m_pass_all_confs &&
11467 scanptr.p->scanNextFragId+scanptr.p->m_booked_fragments_count
11468 < scanptr.p->scanNoFrag){
11473 ndbrequire(total_len==0);
11481 scanFragptr.p->m_scan_frag_conf_status = status;
11482 scanFragptr.p->m_ops = noCompletedOps;
11483 scanFragptr.p->m_totalLen = total_len;
11484 scanFragptr.p->scanFragState = ScanFragRec::QUEUED_FOR_DELIVERY;
11485 scanFragptr.p->stopFragTimer();
11487 if(scanptr.p->m_queued_count > 0){
11489 sendScanTabConf(signal, scanptr);
11499 void Dbtc::execSCAN_NEXTREQ(
Signal* signal)
11502 const UintR transid1 = req->transId1;
11503 const UintR transid2 = req->transId2;
11504 const UintR stopScan = req->stopScan;
11509 apiConnectptr.i = req->apiConnectPtr;
11510 if (apiConnectptr.i >= capiConnectFilesize) {
11512 releaseSections(handle);
11513 warningHandlerLab(signal, __LINE__);
11516 ptrAss(apiConnectptr, apiConnectRecord);
11521 const UintR ctransid1 = apiConnectptr.p->transid[0] ^ transid1;
11522 const UintR ctransid2 = apiConnectptr.p->transid[1] ^ transid2;
11523 if ((ctransid1 | ctransid2) != 0){
11524 releaseSections(handle);
11526 ref->apiConnectPtr = apiConnectptr.p->ndbapiConnect;
11527 ref->transId1 = transid1;
11528 ref->transId2 = transid2;
11529 ref->errorCode = ZSTATE_ERROR;
11530 ref->closeNeeded = 0;
11531 sendSignal(signal->senderBlockRef(), GSN_SCAN_TABREF,
11532 signal, ScanTabRef::SignalLength, JBB);
11533 DEBUG(
"Wrong transid");
11540 if (apiConnectptr.p->apiConnectstate != CS_START_SCAN) {
11542 releaseSections(handle);
11543 if (apiConnectptr.p->apiConnectstate == CS_CONNECTED) {
11549 DEBUG(
"scanTabRefLab: ZSCANTIME_OUT_ERROR2");
11550 ndbout_c(
"apiConnectptr(%d) -> abort", apiConnectptr.i);
11552 scanTabRefLab(signal, ZSCANTIME_OUT_ERROR2);
11555 DEBUG(
"scanTabRefLab: ZSTATE_ERROR");
11556 DEBUG(
" apiConnectstate="<<apiConnectptr.p->apiConnectstate);
11558 scanTabRefLab(signal, ZSTATE_ERROR);
11566 setApiConTimer(apiConnectptr.i, 0, __LINE__);
11567 ScanRecordPtr scanptr;
11568 scanptr.i = apiConnectptr.p->apiScanRec;
11569 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
11570 ScanRecord* scanP = scanptr.p;
11576 if (handle.m_cnt > 0)
11581 ndbrequire(signal->getLength() == ScanNextReq::SignalLength);
11582 ndbrequire(handle.m_cnt == 1);
11584 ndbrequire(handle.getSection(receiverIdsSection,
11585 ScanNextReq::ReceiverIdsSectionNum));
11586 len= receiverIdsSection.p->m_sz;
11587 ndbassert(len < (8192 - 25));
11589 copy(signal->getDataPtrSend()+25, receiverIdsSection);
11590 releaseSections(handle);
11595 len= signal->getLength() - ScanNextReq::SignalLength;
11596 memcpy(signal->getDataPtrSend()+25,
11597 signal->getDataPtr()+ ScanNextReq::SignalLength,
11601 if (stopScan == ZTRUE) {
11606 close_scan_req(signal, scanptr,
true);
11610 if (scanptr.p->scanState == ScanRecord::CLOSING_SCAN){
11622 tmp.requestInfo = 0;
11623 tmp.transId1 = apiConnectptr.p->transid[0];
11624 tmp.transId2 = apiConnectptr.p->transid[1];
11625 tmp.batch_size_rows = scanP->batch_size_rows;
11626 tmp.batch_size_bytes = scanP->batch_byte_size;
11628 ScanFragList running(c_scan_frag_pool, scanP->m_running_scan_frags);
11629 ScanFragList delivered(c_scan_frag_pool, scanP->m_delivered_scan_frags);
11630 for(Uint32 i = 0 ; i<len; i++){
11632 scanFragptr.i = signal->theData[i+25];
11633 c_scan_frag_pool.
getPtr(scanFragptr);
11634 ndbrequire(scanFragptr.p->scanFragState == ScanFragRec::DELIVERED);
11636 scanFragptr.p->startFragTimer(ctcTimer);
11637 scanFragptr.p->m_ops = 0;
11639 if(scanFragptr.p->m_scan_frag_conf_status)
11645 ndbrequire(scanptr.p->scanNextFragId < scanptr.p->scanNoFrag);
11647 ndbassert(scanptr.p->m_booked_fragments_count);
11648 scanptr.p->m_booked_fragments_count--;
11649 scanFragptr.p->scanFragState = ScanFragRec::WAIT_GET_PRIMCONF;
11651 tcConnectptr.i = scanptr.p->scanTcrec;
11652 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
11653 scanFragptr.p->scanFragId = scanptr.p->scanNextFragId++;
11656 req->senderRef = reference();
11657 req->senderData = scanFragptr.i;
11658 req->tableId = scanptr.p->scanTableref;
11659 req->fragId = scanFragptr.p->scanFragId;
11660 req->scanCookie = scanptr.p->m_scan_cookie;
11661 sendSignal(cdihblockref, GSN_DIH_SCAN_GET_NODES_REQ, signal,
11662 DihScanGetNodesReq::SignalLength, JBB);
11667 scanFragptr.p->scanFragState = ScanFragRec::LQH_ACTIVE;
11670 req->senderData = scanFragptr.i;
11671 sendSignal(scanFragptr.p->lqhBlockref, GSN_SCAN_NEXTREQ, signal,
11672 ScanFragNextReq::SignalLength, JBB);
11674 delivered.remove(scanFragptr);
11675 running.add(scanFragptr);
11681 Dbtc::close_scan_req(
Signal* signal, ScanRecordPtr scanPtr,
bool req_received){
11683 ScanRecord* scanP = scanPtr.p;
11684 ndbrequire(scanPtr.p->scanState != ScanRecord::IDLE);
11686 scanPtr.p->scanState = ScanRecord::CLOSING_SCAN;
11687 scanPtr.p->m_close_scan_req = req_received;
11689 if (old == ScanRecord::WAIT_FRAGMENT_COUNT)
11692 scanPtr.p->scanState = old;
11708 nextReq->requestInfo = ScanFragNextReq::ZCLOSE;
11709 nextReq->transId1 = apiConnectptr.p->transid[0];
11710 nextReq->transId2 = apiConnectptr.p->transid[1];
11713 ScanFragRecPtr ptr;
11714 ScanFragList running(c_scan_frag_pool, scanP->m_running_scan_frags);
11715 ScanFragList delivered(c_scan_frag_pool, scanP->m_delivered_scan_frags);
11716 ScanFragList queued(c_scan_frag_pool, scanP->m_queued_scan_frags);
11719 for(running.first(ptr); !ptr.isNull(); ){
11720 ScanFragRecPtr curr = ptr;
11723 switch(curr.p->scanFragState){
11724 case ScanFragRec::IDLE:
11726 ndbrequire(old == ScanRecord::WAIT_AI);
11727 running.release(curr);
11729 case ScanFragRec::WAIT_GET_PRIMCONF:
11732 case ScanFragRec::LQH_ACTIVE:
11736 jamLine(curr.p->scanFragState);
11740 curr.p->startFragTimer(ctcTimer);
11741 curr.p->scanFragState = ScanFragRec::LQH_ACTIVE;
11742 nextReq->senderData = curr.i;
11743 sendSignal(curr.p->lqhBlockref, GSN_SCAN_NEXTREQ, signal,
11744 ScanFragNextReq::SignalLength, JBB);
11748 for(delivered.first(ptr); !ptr.isNull(); ){
11750 ScanFragRecPtr curr = ptr;
11751 delivered.next(ptr);
11753 ndbrequire(curr.p->scanFragState == ScanFragRec::DELIVERED);
11754 delivered.remove(curr);
11756 if (curr.p->m_scan_frag_conf_status == 0)
11760 curr.p->scanFragState = ScanFragRec::LQH_ACTIVE;
11761 curr.p->startFragTimer(ctcTimer);
11762 nextReq->senderData = curr.i;
11763 sendSignal(curr.p->lqhBlockref, GSN_SCAN_NEXTREQ, signal,
11764 ScanFragNextReq::SignalLength, JBB);
11770 c_scan_frag_pool.
release(curr);
11771 curr.p->scanFragState = ScanFragRec::COMPLETED;
11772 curr.p->stopFragTimer();
11779 for(queued.first(ptr); !ptr.isNull(); ){
11781 ndbrequire(ptr.p->scanFragState == ScanFragRec::QUEUED_FOR_DELIVERY);
11782 ScanFragRecPtr curr = ptr;
11785 queued.remove(curr);
11786 scanP->m_queued_count--;
11788 if (curr.p->m_scan_frag_conf_status == 0)
11792 curr.p->scanFragState = ScanFragRec::LQH_ACTIVE;
11793 curr.p->startFragTimer(ctcTimer);
11794 nextReq->senderData = curr.i;
11795 sendSignal(curr.p->lqhBlockref, GSN_SCAN_NEXTREQ, signal,
11796 ScanFragNextReq::SignalLength, JBB);
11801 c_scan_frag_pool.
release(curr);
11802 curr.p->scanFragState = ScanFragRec::COMPLETED;
11803 curr.p->stopFragTimer();
11807 close_scan_req_send_conf(signal, scanPtr);
11811 Dbtc::close_scan_req_send_conf(
Signal* signal, ScanRecordPtr scanPtr){
11815 ndbrequire(scanPtr.p->m_queued_scan_frags.isEmpty());
11816 ndbrequire(scanPtr.p->m_delivered_scan_frags.isEmpty());
11821 ScanFragList comp(c_scan_frag_pool, scanPtr.p->m_completed_scan_frags);
11822 ScanFragRecPtr ptr;
11823 for(comp.first(ptr); !ptr.isNull(); comp.next(ptr)){
11824 ndbrequire(ptr.p->scanFragTimer == 0);
11825 ndbrequire(ptr.p->scanFragState == ScanFragRec::COMPLETED);
11830 if(!scanPtr.p->m_running_scan_frags.isEmpty()){
11835 const bool apiFail = (apiConnectptr.p->apiFailState == ZTRUE);
11837 if(!scanPtr.p->m_close_scan_req){
11845 Uint32 ref = apiConnectptr.p->ndbapiBlockref;
11846 if(!apiFail && ref){
11849 conf->apiConnectPtr = apiConnectptr.p->ndbapiConnect;
11850 conf->requestInfo = ScanTabConf::EndOfData;
11851 conf->transId1 = apiConnectptr.p->transid[0];
11852 conf->transId2 = apiConnectptr.p->transid[1];
11853 sendSignal(ref, GSN_SCAN_TABCONF, signal, ScanTabConf::SignalLength, JBB);
11856 releaseScanResources(signal, scanPtr);
11863 handleApiFailState(signal, apiConnectptr.i);
11868 Dbtc::seizeScanrec(
Signal* signal) {
11869 ScanRecordPtr scanptr;
11870 scanptr.i = cfirstfreeScanrec;
11871 ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord);
11872 cfirstfreeScanrec = scanptr.p->nextScan;
11873 scanptr.p->nextScan = RNIL;
11874 ndbrequire(scanptr.p->scanState == ScanRecord::IDLE);
11878 void Dbtc::sendScanFragReq(
Signal* signal,
11880 ScanFragRec* scanFragP,
11884 bool longFragReq= ((version >= NDBD_LONG_SCANFRAGREQ) &&
11885 (! ERROR_INSERTED(8070) &&
11886 ! ERROR_INSERTED(8088)));
11887 cachePtr.i = apiConnectptr.p->cachePtr;
11888 ptrCheckGuard(cachePtr, ccacheFilesize, cacheRecord);
11890 Uint32 reqKeyLen = scanP->scanKeyLen;
11893 sections.m_ptr[0].i = cachePtr.p->attrInfoSectionI;
11894 sections.m_cnt = 1;
11899 ndbassert(cachePtr.p->keyInfoSectionI != RNIL);
11900 sections.m_ptr[1].i = cachePtr.p->keyInfoSectionI;
11901 sections.m_cnt = 2;
11909 cachePtr.p->attrInfoSectionI = RNIL;
11910 cachePtr.p->keyInfoSectionI = RNIL;
11913 getSections(sections.m_cnt, sections.m_ptr);
11916 Uint32 requestInfo = scanP->scanRequestInfo;
11917 ScanFragReq::setScanPrio(requestInfo, 1);
11918 apiConnectptr.i = scanP->scanApiRec;
11919 req->tableId = scanP->scanTableref;
11920 req->schemaVersion = scanP->scanSchemaVersion;
11921 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
11922 req->senderData = scanFragptr.i;
11923 req->requestInfo = requestInfo;
11924 req->fragmentNoKeyLen = scanFragP->scanFragId;
11925 req->resultRef = apiConnectptr.p->ndbapiBlockref;
11926 req->savePointId = apiConnectptr.p->currSavePointId;
11927 req->transId1 = apiConnectptr.p->transid[0];
11928 req->transId2 = apiConnectptr.p->transid[1];
11929 req->clientOpPtr = scanFragP->m_apiPtr;
11930 req->batch_size_rows= scanP->batch_size_rows;
11931 req->batch_size_bytes= scanP->batch_byte_size;
11933 if (likely(longFragReq))
11956 FragmentSendInfo fragSendInfo;
11962 ScanFragReq::SignalLength,
11968 while (fragSendInfo.m_status != FragmentSendInfo::SendComplete)
11984 Uint32 reqAttrLen = sections.m_ptr[0].sz;
11985 ScanFragReq::setAttrLen(req->requestInfo, reqAttrLen);
11986 req->fragmentNoKeyLen |= reqKeyLen;
11987 sendSignal(scanFragP->lqhBlockref, GSN_SCAN_FRAGREQ, signal,
11988 ScanFragReq::SignalLength, JBB);
11992 tcConnectptr.i = scanFragptr.i;
11994 sendKeyInfoTrain(signal,
11995 scanFragP->lqhBlockref,
11998 sections.m_ptr[1].i);
12001 if(ERROR_INSERTED(8035))
12004 if (!ERROR_INSERTED(8088))
12006 ndbrequire(sendAttrInfoTrain(signal,
12007 scanFragP->lqhBlockref,
12010 sections.m_ptr[0].i));
12013 if(ERROR_INSERTED(8035))
12019 releaseSections(sections);
12027 if (ERROR_INSERTED(8088))
12029 signal->theData[0] = 9999;
12030 sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, 100, 1);
12035 void Dbtc::sendScanTabConf(
Signal* signal, ScanRecordPtr scanPtr) {
12037 Uint32* ops = signal->getDataPtrSend()+4;
12038 Uint32 op_count = scanPtr.p->m_queued_count;
12040 Uint32 words_per_op = 4;
12041 const Uint32 ref = apiConnectptr.p->ndbapiBlockref;
12042 if (!scanPtr.p->m_4word_conf)
12048 if (4 + words_per_op * op_count > 25)
12054 int left = scanPtr.p->scanNoFrag - scanPtr.p->scanNextFragId;
12055 Uint32 booked = scanPtr.p->m_booked_fragments_count;
12058 conf->apiConnectPtr = apiConnectptr.p->ndbapiConnect;
12059 conf->requestInfo = op_count;
12060 conf->transId1 = apiConnectptr.p->transid[0];
12061 conf->transId2 = apiConnectptr.p->transid[1];
12062 ScanFragRecPtr ptr;
12064 ScanFragList queued(c_scan_frag_pool, scanPtr.p->m_queued_scan_frags);
12065 ScanFragList delivered(c_scan_frag_pool,scanPtr.p->m_delivered_scan_frags);
12066 for(queued.first(ptr); !ptr.isNull(); ){
12067 ndbrequire(ptr.p->scanFragState == ScanFragRec::QUEUED_FOR_DELIVERY);
12068 ScanFragRecPtr curr = ptr;
12071 bool done = curr.p->m_scan_frag_conf_status && (left <= (int)booked);
12072 if(curr.p->m_scan_frag_conf_status)
12075 * ops++ = curr.p->m_apiPtr;
12076 * ops++ = done ? RNIL : curr.i;
12077 if (words_per_op == 4)
12079 * ops++ = curr.p->m_ops;
12080 * ops++ = curr.p->m_totalLen;
12084 * ops++ = (curr.p->m_totalLen << 10) + curr.p->m_ops;
12087 queued.remove(curr);
12089 delivered.add(curr);
12090 curr.p->scanFragState = ScanFragRec::DELIVERED;
12091 curr.p->stopFragTimer();
12093 c_scan_frag_pool.
release(curr);
12094 curr.p->scanFragState = ScanFragRec::COMPLETED;
12095 curr.p->stopFragTimer();
12100 bool release =
false;
12101 scanPtr.p->m_booked_fragments_count = booked;
12102 if(scanPtr.p->m_delivered_scan_frags.isEmpty() &&
12103 scanPtr.p->m_running_scan_frags.isEmpty())
12107 conf->requestInfo = op_count | ScanTabConf::EndOfData;
12111 if (scanPtr.p->m_running_scan_frags.isEmpty())
12117 setApiConTimer(apiConnectptr.i, ctcTimer, __LINE__);
12121 if (4 + words_per_op * op_count > 25)
12125 ptr[0].p = signal->getDataPtrSend()+25;
12126 ptr[0].sz = words_per_op * op_count;
12127 sendSignal(ref, GSN_SCAN_TABCONF, signal,
12128 ScanTabConf::SignalLength, JBB, ptr, 1);
12133 sendSignal(ref, GSN_SCAN_TABCONF, signal,
12134 ScanTabConf::SignalLength + words_per_op * op_count, JBB);
12136 scanPtr.p->m_queued_count = 0;
12141 releaseScanResources(signal, scanPtr);
12147 void Dbtc::gcpTcfinished(
Signal* signal, Uint64 gci)
12150 conf->senderData = c_gcp_data;
12151 conf->gci_hi = Uint32(gci >> 32);
12152 conf->gci_lo = Uint32(gci);
12153 sendSignal(c_gcp_ref, GSN_GCP_TCFINISHED, signal,
12154 GCPTCFinished::SignalLength, JBB);
12157 void Dbtc::initApiConnect(
Signal* signal)
12162 tiacTmp = capiConnectFilesize / 3;
12163 ndbrequire(tiacTmp > 0);
12164 guard4 = tiacTmp + 1;
12165 for (cachePtr.i = 0; cachePtr.i < guard4; cachePtr.i++) {
12167 ptrAss(cachePtr, cacheRecord);
12168 cachePtr.p->nextCacheRec = cachePtr.i + 1;
12170 cachePtr.i = tiacTmp;
12171 ptrCheckGuard(cachePtr, ccacheFilesize, cacheRecord);
12172 cachePtr.p->nextCacheRec = RNIL;
12173 cfirstfreeCacheRec = 0;
12175 guard4 = tiacTmp - 1;
12176 for (apiConnectptr.i = 0; apiConnectptr.i <= guard4; apiConnectptr.i++) {
12179 ptrAss(apiConnectptr, apiConnectRecord);
12180 apiConnectptr.p->apiConnectstate = CS_DISCONNECTED;
12181 apiConnectptr.p->apiFailState = ZFALSE;
12182 setApiConTimer(apiConnectptr.i, 0, __LINE__);
12183 apiConnectptr.p->takeOverRec = (Uint8)Z8NIL;
12184 apiConnectptr.p->cachePtr = RNIL;
12185 apiConnectptr.p->nextApiConnect = apiConnectptr.i + 1;
12186 apiConnectptr.p->ndbapiBlockref = 0xFFFFFFFF;
12187 apiConnectptr.p->commitAckMarker = RNIL;
12188 apiConnectptr.p->firstTcConnect = RNIL;
12189 apiConnectptr.p->lastTcConnect = RNIL;
12190 apiConnectptr.p->m_flags = 0;
12191 apiConnectptr.p->m_special_op_flags = 0;
12192 apiConnectptr.p->accumulatingIndexOp = RNIL;
12193 apiConnectptr.p->executingIndexOp = RNIL;
12194 apiConnectptr.p->buddyPtr = RNIL;
12195 apiConnectptr.p->currSavePointId = 0;
12196 apiConnectptr.p->m_transaction_nodes.
clear();
12197 apiConnectptr.p->singleUserMode = 0;
12199 apiConnectptr.i = tiacTmp - 1;
12200 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
12201 apiConnectptr.p->nextApiConnect = RNIL;
12202 cfirstfreeApiConnect = 0;
12203 guard4 = (2 * tiacTmp) - 1;
12204 for (apiConnectptr.i = tiacTmp; apiConnectptr.i <= guard4; apiConnectptr.i++)
12208 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
12209 apiConnectptr.p->apiConnectstate = CS_RESTART;
12210 apiConnectptr.p->apiFailState = ZFALSE;
12211 setApiConTimer(apiConnectptr.i, 0, __LINE__);
12212 apiConnectptr.p->takeOverRec = (Uint8)Z8NIL;
12213 apiConnectptr.p->cachePtr = RNIL;
12214 apiConnectptr.p->nextApiConnect = apiConnectptr.i + 1;
12215 apiConnectptr.p->ndbapiBlockref = 0xFFFFFFFF;
12216 apiConnectptr.p->commitAckMarker = RNIL;
12217 apiConnectptr.p->firstTcConnect = RNIL;
12218 apiConnectptr.p->lastTcConnect = RNIL;
12219 apiConnectptr.p->m_flags = 0;
12220 apiConnectptr.p->m_special_op_flags = 0;
12221 apiConnectptr.p->accumulatingIndexOp = RNIL;
12222 apiConnectptr.p->executingIndexOp = RNIL;
12223 apiConnectptr.p->buddyPtr = RNIL;
12224 apiConnectptr.p->currSavePointId = 0;
12225 apiConnectptr.p->m_transaction_nodes.
clear();
12226 apiConnectptr.p->singleUserMode = 0;
12228 apiConnectptr.i = (2 * tiacTmp) - 1;
12229 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
12230 apiConnectptr.p->nextApiConnect = RNIL;
12231 cfirstfreeApiConnectCopy = tiacTmp;
12232 guard4 = (3 * tiacTmp) - 1;
12233 for (apiConnectptr.i = 2 * tiacTmp; apiConnectptr.i <= guard4;
12234 apiConnectptr.i++) {
12237 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
12238 setApiConTimer(apiConnectptr.i, 0, __LINE__);
12239 apiConnectptr.p->apiFailState = ZFALSE;
12240 apiConnectptr.p->apiConnectstate = CS_RESTART;
12241 apiConnectptr.p->takeOverRec = (Uint8)Z8NIL;
12242 apiConnectptr.p->cachePtr = RNIL;
12243 apiConnectptr.p->nextApiConnect = apiConnectptr.i + 1;
12244 apiConnectptr.p->ndbapiBlockref = 0xFFFFFFFF;
12245 apiConnectptr.p->commitAckMarker = RNIL;
12246 apiConnectptr.p->firstTcConnect = RNIL;
12247 apiConnectptr.p->lastTcConnect = RNIL;
12248 apiConnectptr.p->m_flags = 0;
12249 apiConnectptr.p->m_special_op_flags = 0;
12250 apiConnectptr.p->accumulatingIndexOp = RNIL;
12251 apiConnectptr.p->executingIndexOp = RNIL;
12252 apiConnectptr.p->buddyPtr = RNIL;
12253 apiConnectptr.p->currSavePointId = 0;
12254 apiConnectptr.p->m_transaction_nodes.
clear();
12255 apiConnectptr.p->singleUserMode = 0;
12257 apiConnectptr.i = (3 * tiacTmp) - 1;
12258 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
12259 apiConnectptr.p->nextApiConnect = RNIL;
12260 cfirstfreeApiConnectFail = 2 * tiacTmp;
12263 void Dbtc::initgcp(
Signal* signal)
12266 ndbrequire(cgcpFilesize > 0);
12267 for (gcpPtr.i = 0; gcpPtr.i < cgcpFilesize; gcpPtr.i++) {
12268 ptrAss(gcpPtr, gcpRecord);
12269 gcpPtr.p->nextGcp = gcpPtr.i + 1;
12271 gcpPtr.i = cgcpFilesize - 1;
12272 ptrCheckGuard(gcpPtr, cgcpFilesize, gcpRecord);
12273 gcpPtr.p->nextGcp = RNIL;
12279 void Dbtc::inithost(
Signal* signal)
12281 cpackedListIndex = 0;
12282 ndbrequire(chostFilesize > 0);
12283 for (hostptr.i = 0; hostptr.i < chostFilesize; hostptr.i++) {
12285 ptrAss(hostptr, hostRecord);
12286 hostptr.p->hostStatus = HS_DEAD;
12287 hostptr.p->inPackedList =
false;
12288 hostptr.p->lqhTransStatus = LTS_IDLE;
12289 hostptr.p->noOfWordsTCKEYCONF = 0;
12290 hostptr.p->noOfPackedWordsLqh = 0;
12291 hostptr.p->hostLqhBlockRef = calcLqhBlockRef(hostptr.i);
12292 hostptr.p->m_nf_bits = 0;
12294 c_alive_nodes.
clear();
12297 void Dbtc::initialiseRecordsLab(
Signal* signal, UintR Tdata0,
12298 Uint32 retRef, Uint32 retData)
12303 initApiConnect(signal);
12331 initialiseScanrec(signal);
12335 initialiseScanOprec(signal);
12339 initialiseScanFragrec(signal);
12343 initialiseTcConnect(signal);
12347 initTcFail(signal);
12351 conf->senderRef = reference();
12352 conf->senderData = retData;
12353 sendSignal(retRef, GSN_READ_CONFIG_CONF, signal,
12354 ReadConfigConf::SignalLength, JBB);
12360 systemErrorLab(signal, __LINE__);
12365 signal->theData[0] = TcContinueB::ZINITIALISE_RECORDS;
12366 signal->theData[1] = Tdata0 + 1;
12367 signal->theData[2] = 0;
12368 signal->theData[3] = retRef;
12369 signal->theData[4] = retData;
12370 sendSignal(reference(), GSN_CONTINUEB, signal, 5, JBB);
12377 void Dbtc::initialiseScanrec(
Signal* signal)
12379 ScanRecordPtr scanptr;
12380 ndbrequire(cscanrecFileSize > 0);
12381 for (scanptr.i = 0; scanptr.i < cscanrecFileSize; scanptr.i++) {
12384 ptrAss(scanptr, scanRecord);
12385 new (scanptr.p) ScanRecord();
12386 scanptr.p->scanState = ScanRecord::IDLE;
12387 scanptr.p->scanApiRec = RNIL;
12388 scanptr.p->nextScan = scanptr.i + 1;
12390 scanptr.i = cscanrecFileSize - 1;
12391 ptrAss(scanptr, scanRecord);
12392 scanptr.p->nextScan = RNIL;
12393 cfirstfreeScanrec = 0;
12396 void Dbtc::initialiseScanFragrec(
Signal* signal)
12400 void Dbtc::initialiseScanOprec(
Signal* signal)
12404 void Dbtc::initTable(
Signal* signal)
12407 ndbrequire(ctabrecFilesize > 0);
12408 for (tabptr.i = 0; tabptr.i < ctabrecFilesize; tabptr.i++) {
12410 ptrAss(tabptr, tableRecord);
12411 tabptr.p->currentSchemaVersion = 0;
12412 tabptr.p->m_flags = 0;
12413 tabptr.p->set_storedTable(
true);
12414 tabptr.p->tableType = 0;
12415 tabptr.p->set_enabled(
false);
12416 tabptr.p->set_dropping(
false);
12417 tabptr.p->noOfKeyAttr = 0;
12418 tabptr.p->hasCharAttr = 0;
12419 tabptr.p->noOfDistrKeys = 0;
12420 tabptr.p->hasVarKeys = 0;
12424 void Dbtc::initialiseTcConnect(
Signal* signal)
12426 ndbrequire(ctcConnectFilesize >= 2);
12429 Uint32 titcTmp = ctcConnectFilesize / 2;
12430 for (tcConnectptr.i = 0; tcConnectptr.i < titcTmp; tcConnectptr.i++) {
12433 ptrAss(tcConnectptr, tcConnectRecord);
12434 tcConnectptr.p->tcConnectstate = OS_RESTART;
12435 tcConnectptr.p->apiConnect = RNIL;
12436 tcConnectptr.p->noOfNodes = 0;
12437 tcConnectptr.p->nextTcConnect = tcConnectptr.i + 1;
12438 tcConnectptr.p->commitAckMarker = RNIL;
12440 tcConnectptr.i = titcTmp - 1;
12441 ptrAss(tcConnectptr, tcConnectRecord);
12442 tcConnectptr.p->nextTcConnect = RNIL;
12443 cfirstfreeTcConnectFail = 0;
12446 for (tcConnectptr.i = titcTmp; tcConnectptr.i < ctcConnectFilesize;
12447 tcConnectptr.i++) {
12450 ptrAss(tcConnectptr, tcConnectRecord);
12451 tcConnectptr.p->tcConnectstate = OS_RESTART;
12452 tcConnectptr.p->apiConnect = RNIL;
12453 tcConnectptr.p->noOfNodes = 0;
12454 tcConnectptr.p->nextTcConnect = tcConnectptr.i + 1;
12455 tcConnectptr.p->commitAckMarker = RNIL;
12457 tcConnectptr.i = ctcConnectFilesize - 1;
12458 ptrAss(tcConnectptr, tcConnectRecord);
12459 tcConnectptr.p->nextTcConnect = RNIL;
12460 cfirstfreeTcConnect = titcTmp;
12461 c_counters.cconcurrentOp = 0;
12470 GcpRecordPtr tmpGcpPointer;
12471 if (cfirstgcp == RNIL) {
12473 cfirstgcp = gcpPtr.i;
12476 tmpGcpPointer.i = clastgcp;
12477 ptrCheckGuard(tmpGcpPointer, cgcpFilesize, gcpRecord);
12478 tmpGcpPointer.p->nextGcp = gcpPtr.i;
12480 clastgcp = gcpPtr.i;
12486 void Dbtc::linkTcInConnectionlist(
Signal* signal)
12489 TcConnectRecordPtr ltcTcConnectptr;
12491 tcConnectptr.p->nextTcConnect = RNIL;
12492 ltcTcConnectptr.i = apiConnectptr.p->lastTcConnect;
12493 ptrCheck(ltcTcConnectptr, ctcConnectFilesize, tcConnectRecord);
12494 apiConnectptr.p->lastTcConnect = tcConnectptr.i;
12495 if (ltcTcConnectptr.i == RNIL) {
12497 apiConnectptr.p->firstTcConnect = tcConnectptr.i;
12500 ptrGuard(ltcTcConnectptr);
12501 ltcTcConnectptr.p->nextTcConnect = tcConnectptr.i;
12510 void Dbtc::releaseAbortResources(
Signal* signal)
12512 TcConnectRecordPtr rarTcConnectptr;
12514 c_counters.cabortCount++;
12515 if (apiConnectptr.p->cachePtr != RNIL) {
12516 cachePtr.i = apiConnectptr.p->cachePtr;
12517 ptrCheckGuard(cachePtr, ccacheFilesize, cacheRecord);
12521 tcConnectptr.i = apiConnectptr.p->firstTcConnect;
12522 while (tcConnectptr.i != RNIL) {
12524 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
12526 clearCommitAckMarker(apiConnectptr.p, tcConnectptr.p);
12527 rarTcConnectptr.i = tcConnectptr.p->nextTcConnect;
12529 tcConnectptr.i = rarTcConnectptr.i;
12532 Uint32 marker = apiConnectptr.p->commitAckMarker;
12533 if (marker != RNIL)
12536 m_commitAckMarkerHash.
release(marker);
12537 apiConnectptr.p->commitAckMarker = RNIL;
12540 apiConnectptr.p->firstTcConnect = RNIL;
12541 apiConnectptr.p->lastTcConnect = RNIL;
12542 apiConnectptr.p->m_transaction_nodes.
clear();
12543 apiConnectptr.p->singleUserMode = 0;
12550 apiConnectptr.p->apiConnectstate = CS_ABORTING;
12551 apiConnectptr.p->abortState = AS_IDLE;
12552 releaseAllSeizedIndexOperations(apiConnectptr.p);
12554 if (tc_testbit(apiConnectptr.p->m_flags, ApiConnectRecord::TF_EXEC_FLAG) ||
12555 apiConnectptr.p->apiFailState == ZTRUE)
12559 Uint32 blockRef = apiConnectptr.p->ndbapiBlockref;
12560 ReturnSignal ret = apiConnectptr.p->returnsignal;
12561 apiConnectptr.p->returnsignal = RS_NO_RETURN;
12562 tc_clearbit(apiConnectptr.p->m_flags, ApiConnectRecord::TF_EXEC_FLAG);
12564 case RS_TCROLLBACKCONF:
12567 signal->theData[0] = apiConnectptr.p->ndbapiConnect;
12568 signal->theData[1] = apiConnectptr.p->transid[0];
12569 signal->theData[2] = apiConnectptr.p->transid[1];
12570 sendSignal(blockRef, GSN_TCROLLBACKCONF, signal, 3, JBB);
12572 case RS_TCROLLBACKREP:{
12578 tcRollbackRep->connectPtr = apiConnectptr.p->ndbapiConnect;
12579 tcRollbackRep->transId[0] = apiConnectptr.p->transid[0];
12580 tcRollbackRep->transId[1] = apiConnectptr.p->transid[1];
12581 tcRollbackRep->returnCode = apiConnectptr.p->returncode;
12582 tcRollbackRep->errorData = apiConnectptr.p->errorData;
12583 sendSignal(blockRef, GSN_TCROLLBACKREP, signal,
12584 TcRollbackRep::SignalLength, JBB);
12592 case RS_TC_COMMITCONF:
12597 ndbout_c(
"returnsignal = %d", apiConnectptr.p->returnsignal);
12598 sendSystemError(signal, __LINE__);
12602 setApiConTimer(apiConnectptr.i, 0,
12603 100000+c_apiConTimer_line[apiConnectptr.i]);
12604 if (apiConnectptr.p->apiFailState == ZTRUE) {
12606 handleApiFailState(signal, apiConnectptr.i);
12611 void Dbtc::releaseApiCon(
Signal* signal, UintR TapiConnectPtr)
12613 ApiConnectRecordPtr TlocalApiConnectptr;
12615 TlocalApiConnectptr.i = TapiConnectPtr;
12616 ptrCheckGuard(TlocalApiConnectptr, capiConnectFilesize, apiConnectRecord);
12617 TlocalApiConnectptr.p->nextApiConnect = cfirstfreeApiConnect;
12618 cfirstfreeApiConnect = TlocalApiConnectptr.i;
12619 setApiConTimer(TlocalApiConnectptr.i, 0, __LINE__);
12620 TlocalApiConnectptr.p->apiConnectstate = CS_DISCONNECTED;
12621 ndbassert(TlocalApiConnectptr.p->m_transaction_nodes.isclear());
12622 ndbassert(TlocalApiConnectptr.p->apiScanRec == RNIL);
12623 TlocalApiConnectptr.p->ndbapiBlockref = 0;
12626 void Dbtc::releaseApiConnectFail(
Signal* signal)
12628 apiConnectptr.p->apiConnectstate = CS_RESTART;
12629 apiConnectptr.p->takeOverRec = (Uint8)Z8NIL;
12630 setApiConTimer(apiConnectptr.i, 0, __LINE__);
12631 apiConnectptr.p->nextApiConnect = cfirstfreeApiConnectFail;
12632 cfirstfreeApiConnectFail = apiConnectptr.i;
12633 ndbrequire(apiConnectptr.p->commitAckMarker == RNIL);
12636 void Dbtc::releaseKeys()
12638 Uint32 keyInfoSectionI= cachePtr.p->keyInfoSectionI;
12641 releaseSection(keyInfoSectionI);
12642 cachePtr.p->keyInfoSectionI= RNIL;
12646 void Dbtc::releaseTcConnectFail(
Signal* signal)
12648 ptrGuard(tcConnectptr);
12649 tcConnectptr.p->nextTcConnect = cfirstfreeTcConnectFail;
12650 cfirstfreeTcConnectFail = tcConnectptr.i;
12653 void Dbtc::seizeApiConnect(
Signal* signal)
12655 if (cfirstfreeApiConnect != RNIL) {
12658 apiConnectptr.i = cfirstfreeApiConnect;
12659 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
12660 cfirstfreeApiConnect = apiConnectptr.p->nextApiConnect;
12661 apiConnectptr.p->nextApiConnect = RNIL;
12662 setApiConTimer(apiConnectptr.i, 0, __LINE__);
12663 apiConnectptr.p->apiConnectstate = CS_CONNECTED;
12664 tc_clearbit(apiConnectptr.p->m_flags,
12665 ApiConnectRecord::TF_TRIGGER_PENDING);
12666 apiConnectptr.p->m_special_op_flags = 0;
12669 terrorCode = ZNO_FREE_API_CONNECTION;
12673 void Dbtc::seizeApiConnectFail(
Signal* signal)
12675 apiConnectptr.i = cfirstfreeApiConnectFail;
12676 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
12677 cfirstfreeApiConnectFail = apiConnectptr.p->nextApiConnect;
12680 void Dbtc::seizeTcConnect(
Signal* signal)
12682 tcConnectptr.i = cfirstfreeTcConnect;
12683 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
12684 cfirstfreeTcConnect = tcConnectptr.p->nextTcConnect;
12685 c_counters.cconcurrentOp++;
12686 tcConnectptr.p->m_special_op_flags = 0;
12687 tcConnectptr.p->tcConnectstate = OS_ABORTING;
12688 tcConnectptr.p->noOfNodes = 0;
12691 void Dbtc::seizeTcConnectFail(
Signal* signal)
12693 tcConnectptr.i = cfirstfreeTcConnectFail;
12694 ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord);
12695 cfirstfreeTcConnectFail = tcConnectptr.p->nextTcConnect;
12703 bool Dbtc::sendAttrInfoTrain(
Signal* signal,
12707 Uint32 attrInfoIVal)
12709 ApiConnectRecord *
const regApiPtr = apiConnectptr.p;
12711 ndbassert( attrInfoIVal != RNIL );
12712 SectionReader attrInfoReader(attrInfoIVal, getSectionSegmentPool());
12713 Uint32 attrInfoLength= attrInfoReader.getSize();
12715 ndbassert( offset < attrInfoLength );
12716 if (unlikely(! attrInfoReader.step( offset )))
12718 attrInfoLength-=
offset;
12720 signal->theData[0] = connectPtr;
12721 signal->theData[1] = regApiPtr->transid[0];
12722 signal->theData[2] = regApiPtr->transid[1];
12724 while (attrInfoLength != 0)
12726 Uint32 dataInSignal= MIN(AttrInfo::DataLength, attrInfoLength);
12728 if (unlikely(! attrInfoReader.getWords(&signal->theData[3],
12732 sendSignal(TBRef, GSN_ATTRINFO, signal,
12733 AttrInfo::HeaderLength + dataInSignal, JBB);
12735 attrInfoLength-= dataInSignal;
12740 void Dbtc::sendContinueTimeOutControl(
Signal* signal, Uint32 TapiConPtr)
12742 signal->theData[0] = TcContinueB::ZCONTINUE_TIME_OUT_CONTROL;
12743 signal->theData[1] = TapiConPtr;
12744 sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
12747 void Dbtc::sendSystemError(
Signal* signal,
int line)
12757 ndbrequire(cfirstgcp == tmpGcpPtr.i);
12759 cfirstgcp = tmpGcpPtr.p->nextGcp;
12760 if (tmpGcpPtr.i == clastgcp) {
12765 tmpGcpPtr.p->nextGcp = cfirstfreeGcp;
12766 cfirstfreeGcp = tmpGcpPtr.i;
12770 Dbtc::execDUMP_STATE_ORD(
Signal* signal)
12774 Uint32 arg = signal->theData[0];
12775 if (signal->theData[0] == DumpStateOrd::CommitAckMarkersSize)
12777 infoEvent(
"TC: m_commitAckMarkerPool: %d free size: %d",
12778 m_commitAckMarkerPool.getNoOfFree(),
12779 m_commitAckMarkerPool.getSize());
12782 if (signal->theData[0] == DumpStateOrd::CommitAckMarkersDump)
12784 infoEvent(
"TC: m_commitAckMarkerPool: %d free size: %d",
12785 m_commitAckMarkerPool.getNoOfFree(),
12786 m_commitAckMarkerPool.getSize());
12787 CommitAckMarkerIterator iter;
12788 for(m_commitAckMarkerHash.
first(iter); iter.curr.i != RNIL;
12789 m_commitAckMarkerHash.
next(iter)){
12790 infoEvent(
"CommitAckMarker: i = %d (0x%x, 0x%x)"
12791 " Api: %d %x %x %x %x bucket = %d",
12793 iter.curr.p->transid1,
12794 iter.curr.p->transid2,
12795 iter.curr.p->apiNodeId,
12796 iter.curr.p->m_commit_ack_marker_nodes.getWord(0),
12797 iter.curr.p->m_commit_ack_marker_nodes.getWord(1),
12798 iter.curr.p->m_commit_ack_marker_nodes.getWord(2),
12799 iter.curr.p->m_commit_ack_marker_nodes.getWord(3),
12805 if (dumpState->args[0] == DumpStateOrd::TcDumpAllScanFragRec){
12806 Uint32 recordNo = 0;
12807 if (signal->getLength() == 1)
12808 infoEvent(
"TC: Dump all ScanFragRec - size: %d",
12809 cscanFragrecFileSize);
12810 else if (signal->getLength() == 2)
12811 recordNo = dumpState->args[1];
12815 dumpState->args[0] = DumpStateOrd::TcDumpOneScanFragRec;
12816 dumpState->args[1] = recordNo;
12817 execDUMP_STATE_ORD(signal);
12819 if (recordNo < cscanFragrecFileSize-1){
12820 dumpState->args[0] = DumpStateOrd::TcDumpAllScanFragRec;
12821 dumpState->args[1] = recordNo+1;
12822 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 2, JBB);
12827 if (dumpState->args[0] == DumpStateOrd::TcDumpOneScanFragRec){
12828 Uint32 recordNo = RNIL;
12829 if (signal->getLength() == 2)
12830 recordNo = dumpState->args[1];
12834 if (recordNo >= cscanFragrecFileSize)
12837 ScanFragRecPtr sfp;
12839 c_scan_frag_pool.
getPtr(sfp);
12840 infoEvent(
"Dbtc::ScanFragRec[%d]: state=%d fragid=%d",
12842 sfp.p->scanFragState,
12843 sfp.p->scanFragId);
12845 refToNode(sfp.p->lqhBlockref),
12846 sfp.p->scanFragTimer);
12850 if (dumpState->args[0] == DumpStateOrd::TcDumpAllScanRec){
12851 Uint32 recordNo = 0;
12852 if (signal->getLength() == 1)
12853 infoEvent(
"TC: Dump all ScanRecord - size: %d",
12855 else if (signal->getLength() == 2)
12856 recordNo = dumpState->args[1];
12860 dumpState->args[0] = DumpStateOrd::TcDumpOneScanRec;
12861 dumpState->args[1] = recordNo;
12862 execDUMP_STATE_ORD(signal);
12864 if (recordNo < cscanrecFileSize-1){
12865 dumpState->args[0] = DumpStateOrd::TcDumpAllScanRec;
12866 dumpState->args[1] = recordNo+1;
12867 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 2, JBB);
12872 if (dumpState->args[0] == DumpStateOrd::TcDumpAllActiveScanRec){
12873 Uint32 recordNo = 0;
12874 if (signal->getLength() == 1)
12875 infoEvent(
"TC: Dump active ScanRecord - size: %d",
12877 else if (signal->getLength() == 2)
12878 recordNo = dumpState->args[1];
12884 ptrAss(sp, scanRecord);
12885 if (sp.p->scanState != ScanRecord::IDLE){
12886 dumpState->args[0] = DumpStateOrd::TcDumpOneScanRec;
12887 dumpState->args[1] = recordNo;
12888 execDUMP_STATE_ORD(signal);
12891 if (recordNo < cscanrecFileSize-1){
12892 dumpState->args[0] = DumpStateOrd::TcDumpAllActiveScanRec;
12893 dumpState->args[1] = recordNo+1;
12894 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 2, JBB);
12900 if (dumpState->args[0] == DumpStateOrd::TcDumpOneScanRec){
12901 Uint32 recordNo = RNIL;
12902 if (signal->getLength() == 2)
12903 recordNo = dumpState->args[1];
12907 if (recordNo >= cscanrecFileSize)
12912 ptrAss(sp, scanRecord);
12913 infoEvent(
"Dbtc::ScanRecord[%d]: state=%d"
12914 "nextfrag=%d, nofrag=%d",
12917 sp.p->scanNextFragId,
12919 infoEvent(
" ailen=%d, para=%d, receivedop=%d, noOprePperFrag=%d",
12920 sp.p->scanAiLength,
12921 sp.p->scanParallel,
12922 sp.p->scanReceivedOperations,
12923 sp.p->batch_size_rows);
12924 infoEvent(
" schv=%d, tab=%d, sproc=%d",
12925 sp.p->scanSchemaVersion,
12926 sp.p->scanTableref,
12927 sp.p->scanStoredProcId);
12929 sp.p->scanApiRec, sp.p->nextScan);
12931 if (sp.p->scanState != ScanRecord::IDLE){
12933 ScanFragRecPtr sfptr;
12934 #define DUMP_SFR(x){\
12935 ScanFragList list(c_scan_frag_pool, x);\
12936 for(list.first(sfptr); !sfptr.isNull(); list.next(sfptr)){\
12937 dumpState->args[0] = DumpStateOrd::TcDumpOneScanFragRec; \
12938 dumpState->args[1] = sfptr.i;\
12939 execDUMP_STATE_ORD(signal);\
12942 DUMP_SFR(sp.p->m_running_scan_frags);
12943 DUMP_SFR(sp.p->m_queued_scan_frags);
12944 DUMP_SFR(sp.p->m_delivered_scan_frags);
12947 dumpState->args[0] = DumpStateOrd::TcDumpOneApiConnectRec;
12948 dumpState->args[1] = sp.p->scanApiRec;
12949 execDUMP_STATE_ORD(signal);
12955 if (dumpState->args[0] == DumpStateOrd::TcDumpAllApiConnectRec){
12956 Uint32 recordNo = 0;
12957 if (signal->getLength() == 1)
12958 infoEvent(
"TC: Dump all ApiConnectRecord - size: %d",
12959 capiConnectFilesize);
12960 else if (signal->getLength() == 2)
12961 recordNo = dumpState->args[1];
12965 dumpState->args[0] = DumpStateOrd::TcDumpOneApiConnectRec;
12966 dumpState->args[1] = recordNo;
12967 execDUMP_STATE_ORD(signal);
12969 if (recordNo < capiConnectFilesize-1){
12970 dumpState->args[0] = DumpStateOrd::TcDumpAllApiConnectRec;
12971 dumpState->args[1] = recordNo+1;
12972 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 2, JBB);
12977 if (dumpState->args[0] == DumpStateOrd::TcDumpOneApiConnectRec){
12978 Uint32 recordNo = RNIL;
12979 if (signal->getLength() == 2)
12980 recordNo = dumpState->args[1];
12984 if (recordNo >= capiConnectFilesize)
12987 ApiConnectRecordPtr ap;
12989 ptrAss(ap, apiConnectRecord);
12990 infoEvent(
"Dbtc::ApiConnectRecord[%d]: state=%d, abortState=%d, "
12993 ap.p->apiConnectstate,
12995 ap.p->apiFailState);
12996 infoEvent(
" transid(0x%x, 0x%x), apiBref=0x%x, scanRec=%d",
12999 ap.p->ndbapiBlockref,
13001 infoEvent(
" ctcTimer=%d, apiTimer=%d, counter=%d, retcode=%d, "
13003 ctcTimer, getApiConTimer(ap.i),
13006 ap.p->returnsignal);
13007 infoEvent(
" lqhkeyconfrec=%d, lqhkeyreqrec=%d, "
13009 ap.p->lqhkeyconfrec,
13010 ap.p->lqhkeyreqrec,
13013 ap.p->nextApiConnect);
13016 if (dumpState->args[0] == DumpStateOrd::TcSetTransactionTimeout){
13018 if(signal->getLength() > 1){
13019 set_timeout_value(signal->theData[1]);
13023 if (dumpState->args[0] == DumpStateOrd::TcSetApplTransactionTimeout){
13025 if(signal->getLength() > 1){
13026 set_appl_timeout_value(signal->theData[1]);
13030 if (dumpState->args[0] == DumpStateOrd::TcStartDumpIndexOpCount)
13032 static int frequency = 1;
13033 if (signal->getLength() > 1)
13034 frequency = signal->theData[1];
13036 if (refToBlock(signal->getSendersBlockRef()) != DBTC)
13041 dumpState->args[0] = DumpStateOrd::TcDumpIndexOpCount;
13042 execDUMP_STATE_ORD(signal);
13043 dumpState->args[0] = DumpStateOrd::TcStartDumpIndexOpCount;
13045 Uint32 delay = 1000 * (frequency > 25 ? 25 : frequency);
13046 sendSignalWithDelay(cownref, GSN_DUMP_STATE_ORD, signal, delay, 1);
13050 if (dumpState->args[0] == DumpStateOrd::TcDumpIndexOpCount)
13052 infoEvent(
"IndexOpCount: pool: %d free: %d",
13057 if (dumpState->args[0] == 2514)
13059 if (signal->getLength() == 2)
13061 dumpState->args[0] = DumpStateOrd::TcDumpOneApiConnectRec;
13062 execDUMP_STATE_ORD(signal);
13066 dumpState->args[0] = 15;
13067 sendSignal(rg, GSN_DUMP_STATE_ORD, signal, 1, JBB);
13069 signal->theData[0] = 2515;
13070 sendSignalWithDelay(cownref, GSN_DUMP_STATE_ORD, signal, 1000, 1);
13074 if (dumpState->args[0] == 2515)
13077 mask.
clear(getOwnNodeId());
13080 sendSignal(rg, GSN_SYSTEM_ERROR, signal, 1, JBB);
13081 sendSignalWithDelay(cownref, GSN_SYSTEM_ERROR, signal, 300, 1);
13088 Uint32 len = signal->getLength() - 1;
13095 if (validate_filter(signal))
13098 memmove(signal->theData + 2, signal->theData + 1, 4 * len);
13099 signal->theData[0] = 2551;
13100 signal->theData[1] = 0;
13101 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, len + 2, JBB);
13103 infoEvent(
"Starting dump of transactions");
13111 Uint32
record = signal->theData[1];
13112 Uint32 len = signal->getLength();
13113 ndbassert(len > 1);
13115 ApiConnectRecordPtr ap;
13117 ptrAss(ap, apiConnectRecord);
13119 bool print =
false;
13120 for (Uint32 i = 0; i<32; i++)
13123 print = match_and_print(signal, ap);
13126 if (ap.i == capiConnectFilesize || print)
13132 ptrAss(ap, apiConnectRecord);
13135 if (ap.i == capiConnectFilesize)
13142 signal->theData[1] = ap.i;
13146 sendSignalWithDelay(reference(), GSN_DUMP_STATE_ORD, signal, 200, len);
13151 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, len, JBB);
13155 #ifdef ERROR_INSERT
13156 if (arg == 2552 || arg == 4002)
13158 ndbrequire(m_commitAckMarkerPool.getNoOfFree() == m_commitAckMarkerPool.getSize());
13163 if (arg == 7019 && signal->getLength() == 2)
13166 Uint32 nodeId = signal->theData[1];
13167 if (nodeId < MAX_NODES && nodeId < NDB_ARRAY_SIZE(capiConnectClosing))
13170 nodeId, capiConnectClosing[nodeId]);
13174 warningEvent(
" DBTC: dump-7019 to unknown node: %u", nodeId);
13179 void Dbtc::execDBINFO_SCANREQ(
Signal *signal)
13188 switch(req.tableId){
13189 case Ndbinfo::POOLS_TABLEID:
13193 {
"Defined Trigger",
13198 { CFG_DB_NO_TRIGGERS,0,0,0 }},
13204 { CFG_DB_NO_TRIGGER_OPS,0,0,0 }},
13210 { CFG_DB_NO_TABLES,
13211 CFG_DB_NO_ORDERED_INDEXES,
13212 CFG_DB_NO_UNIQUE_HASH_INDEXES,0 }},
13214 c_scan_frag_pool.getUsed(),
13215 c_scan_frag_pool.getSize(),
13216 c_scan_frag_pool.getEntrySize(),
13217 c_scan_frag_pool.getUsedHi(),
13218 { CFG_DB_NO_LOCAL_SCANS,0,0,0 }},
13219 {
"Commit ACK Marker",
13220 m_commitAckMarkerPool.getUsed(),
13221 m_commitAckMarkerPool.getSize(),
13222 m_commitAckMarkerPool.getEntrySize(),
13223 m_commitAckMarkerPool.getUsedHi(),
13224 { CFG_DB_NO_TRANSACTIONS,0,0,0 }},
13230 { CFG_DB_NO_INDEX_OPS,0,0,0 }},
13232 c_counters.cconcurrentOp,
13233 ctcConnectFilesize,
13234 sizeof(TcConnectRecord),
13236 { CFG_DB_NO_TRANSACTIONS,
13237 CFG_DB_NO_OPS,0,0 }},
13238 { NULL, 0,0,0,0,{0,0,0,0} }
13241 const size_t num_config_params =
13242 sizeof(pools[0].config_params) /
sizeof(pools[0].config_params[0]);
13243 Uint32 pool =
cursor->data[0];
13244 BlockNumber bn = blockToMain(number());
13245 while(pools[pool].poolname)
13249 row.write_uint32(getOwnNodeId());
13250 row.write_uint32(bn);
13251 row.write_uint32(instance());
13252 row.write_string(pools[pool].poolname);
13254 row.write_uint64(pools[pool].used);
13255 row.write_uint64(pools[pool].total);
13256 row.write_uint64(pools[pool].used_hi);
13257 row.write_uint64(pools[pool].entry_size);
13258 for (
size_t i = 0; i < num_config_params; i++)
13259 row.write_uint32(pools[pool].config_params[i]);
13260 ndbinfo_send_row(signal, req, row, rl);
13262 if (rl.need_break(req))
13265 ndbinfo_send_scan_break(signal, req, rl, pool);
13272 case Ndbinfo::COUNTERS_TABLEID:
13275 { Ndbinfo::ATTRINFO_COUNTER, c_counters.cattrinfoCount },
13276 { Ndbinfo::TRANSACTIONS_COUNTER, c_counters.ctransCount },
13277 { Ndbinfo::COMMITS_COUNTER, c_counters.ccommitCount },
13278 { Ndbinfo::READS_COUNTER, c_counters.creadCount },
13279 { Ndbinfo::SIMPLE_READS_COUNTER, c_counters.csimpleReadCount },
13280 { Ndbinfo::WRITES_COUNTER, c_counters.cwriteCount },
13281 { Ndbinfo::ABORTS_COUNTER, c_counters.cabortCount },
13282 { Ndbinfo::TABLE_SCANS_COUNTER, c_counters.c_scan_count },
13283 { Ndbinfo::RANGE_SCANS_COUNTER, c_counters.c_range_scan_count }
13285 const size_t num_counters =
sizeof(counters) /
sizeof(counters[0]);
13287 Uint32 i =
cursor->data[0];
13288 BlockNumber bn = blockToMain(number());
13289 while(i < num_counters)
13293 row.write_uint32(getOwnNodeId());
13294 row.write_uint32(bn);
13295 row.write_uint32(instance());
13296 row.write_uint32(counters[i].
id);
13298 row.write_uint64(counters[i].val);
13299 ndbinfo_send_row(signal, req, row, rl);
13301 if (rl.need_break(req))
13304 ndbinfo_send_scan_break(signal, req, rl, i);
13316 ndbinfo_send_scan_conf(signal, req, rl);
13320 Dbtc::validate_filter(
Signal* signal)
13322 Uint32 * start = signal->theData + 1;
13323 Uint32 * end = signal->theData + signal->getLength();
13326 infoEvent(
"No filter specified, not listing...");
13341 infoEvent(
"Invalid filter op: 0x%x pos: %ld",
13343 (
long int)(start - (signal->theData + 1)));
13350 infoEvent(
"Invalid filter, unexpected end");
13358 Dbtc::match_and_print(
Signal* signal, ApiConnectRecordPtr apiPtr)
13360 Uint32 conState = apiPtr.p->apiConnectstate;
13361 if (conState == CS_CONNECTED ||
13362 conState == CS_DISCONNECTED ||
13363 conState == CS_RESTART)
13366 Uint32 len = signal->getLength();
13367 Uint32* start = signal->theData + 2;
13368 Uint32* end = signal->theData + len;
13369 Uint32 apiTimer = getApiConTimer(apiPtr.i);
13370 while (start < end)
13376 if (refToNode(apiPtr.p->ndbapiBlockref) != * (start + 1))
13382 if (apiPtr.p->transid[0] != * (start + 1) ||
13383 apiPtr.p->transid[1] != * (start + 2))
13389 if (apiTimer == 0 || ((ctcTimer - apiTimer) / 100) < * (start + 1))
13409 Uint32 *
temp = signal->theData + 25;
13410 memcpy(temp, signal->theData, 4 * len);
13413 const char *stateptr =
"";
13415 switch(apiPtr.p->apiConnectstate){
13417 stateptr =
"Prepared";
13420 case CS_REC_COMMITTING:
13421 case CS_START_COMMITTING:
13422 stateptr =
"Running";
13424 case CS_COMMITTING:
13425 stateptr =
"Committing";
13427 case CS_COMPLETING:
13428 stateptr =
"Completing";
13430 case CS_PREPARE_TO_COMMIT:
13431 stateptr =
"Prepare to commit";
13433 case CS_COMMIT_SENT:
13434 stateptr =
"Commit sent";
13436 case CS_COMPLETE_SENT:
13437 stateptr =
"Complete sent";
13440 stateptr =
"Aborting";
13442 case CS_START_SCAN:
13443 stateptr =
"Scanning";
13445 case CS_WAIT_ABORT_CONF:
13446 case CS_WAIT_COMMIT_CONF:
13447 case CS_WAIT_COMPLETE_CONF:
13448 case CS_FAIL_PREPARED:
13449 case CS_FAIL_COMMITTING:
13450 case CS_FAIL_COMMITTED:
13451 case CS_REC_PREPARING:
13452 case CS_START_PREPARING:
13455 case CS_FAIL_ABORTED:
13456 case CS_DISCONNECTED:
13459 "%u", apiPtr.p->apiConnectstate);
13466 "TRX[%u]: API: %d(0x%x)"
13467 "transid: 0x%x 0x%x inactive: %u(%d) state: %s",
13469 refToNode(apiPtr.p->ndbapiBlockref),
13470 refToBlock(apiPtr.p->ndbapiBlockref),
13471 apiPtr.p->transid[0],
13472 apiPtr.p->transid[1],
13473 apiTimer ? (ctcTimer - apiTimer) / 100 : 0,
13474 c_apiConTimer_line[apiPtr.i],
13478 memcpy(signal->theData, temp, 4*len);
13482 void Dbtc::execABORT_ALL_REQ(
Signal* signal)
13488 const Uint32 senderData = req->senderData;
13489 const BlockReference senderRef = req->senderRef;
13494 ref->senderData = senderData;
13495 ref->errorCode = AbortAllRef::InvalidState;
13496 sendSignal(senderRef, GSN_ABORT_ALL_REF, signal,
13497 AbortAllRef::SignalLength, JBB);
13501 if(c_abortRec.clientRef != 0){
13504 ref->senderData = senderData;
13505 ref->errorCode = AbortAllRef::AbortAlreadyInProgress;
13506 sendSignal(senderRef, GSN_ABORT_ALL_REF, signal,
13507 AbortAllRef::SignalLength, JBB);
13511 if(refToNode(senderRef) != getOwnNodeId()){
13514 ref->senderData = senderData;
13515 ref->errorCode = AbortAllRef::FunctionNotImplemented;
13516 sendSignal(senderRef, GSN_ABORT_ALL_REF, signal,
13517 AbortAllRef::SignalLength, JBB);
13521 c_abortRec.clientRef = senderRef;
13522 c_abortRec.clientData = senderData;
13523 c_abortRec.oldTimeOutValue = ctimeOutValue;
13526 const Uint32 sleepTime = (2 * 10 * ctimeOutCheckDelay + 199) / 200;
13528 checkAbortAllTimeout(signal, (sleepTime == 0 ? 1 : sleepTime));
13531 void Dbtc::checkAbortAllTimeout(
Signal* signal, Uint32 sleepTime)
13534 ndbrequire(c_abortRec.clientRef != 0);
13540 signal->theData[0] = TcContinueB::ZWAIT_ABORT_ALL;
13541 signal->theData[1] = sleepTime;
13542 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 200, 2);
13547 conf->senderData = c_abortRec.clientData;
13548 sendSignal(c_abortRec.clientRef, GSN_ABORT_ALL_CONF, signal,
13549 AbortAllConf::SignalLength, JBB);
13551 ctimeOutValue = c_abortRec.oldTimeOutValue;
13552 c_abortRec.clientRef = 0;
13561 void Dbtc::execCREATE_TRIG_IMPL_REQ(
Signal* signal)
13571 const Uint32 senderRef = req->senderRef;
13572 const Uint32 senderData = req->senderData;
13575 releaseSections(handle);
13577 TcDefinedTriggerData* triggerData;
13578 DefinedTriggerPtr triggerPtr;
13580 triggerPtr.i = req->triggerId;
13581 if (ERROR_INSERTED(8033) ||
13584 CLEAR_ERROR_INSERT_VALUE;
13589 ref->senderRef = reference();
13590 ref->senderData = senderData;
13591 ref->errorCode = CreateTrigImplRef::InconsistentTC;
13592 ref->errorLine = __LINE__;
13593 sendSignal(senderRef, GSN_CREATE_TRIG_IMPL_REF,
13594 signal, CreateTrigImplRef::SignalLength, JBB);
13598 triggerData = triggerPtr.p;
13599 triggerData->triggerId = req->triggerId;
13600 triggerData->triggerType = TriggerInfo::getTriggerType(req->triggerInfo);
13601 triggerData->triggerEvent = TriggerInfo::getTriggerEvent(req->triggerInfo);
13602 triggerData->oldTriggerIds[0] = RNIL;
13603 triggerData->oldTriggerIds[1] = RNIL;
13605 switch(triggerData->triggerType){
13606 case TriggerType::SECONDARY_INDEX:
13608 triggerData->indexId = req->indexId;
13610 case TriggerType::REORG_TRIGGER:
13612 triggerData->tableId = req->tableId;
13619 if (unlikely(req->triggerId != req->upgradeExtra[1]))
13625 ndbrequire(req->triggerId == req->upgradeExtra[0]);
13626 ndbrequire(triggerData->triggerType == TriggerType::SECONDARY_INDEX);
13628 DefinedTriggerPtr insertPtr = triggerPtr;
13629 DefinedTriggerPtr updatePtr;
13630 DefinedTriggerPtr deletePtr;
13646 insertPtr.p->triggerEvent = TriggerEvent::TE_INSERT;
13648 updatePtr.p->triggerId = req->upgradeExtra[1];
13649 updatePtr.p->triggerType = TriggerType::SECONDARY_INDEX;
13650 updatePtr.p->triggerEvent = TriggerEvent::TE_UPDATE;
13651 updatePtr.p->oldTriggerIds[0] = RNIL;
13652 updatePtr.p->oldTriggerIds[1] = RNIL;
13653 updatePtr.p->indexId = req->indexId;
13655 deletePtr.p->triggerId = req->upgradeExtra[2];
13656 deletePtr.p->triggerType = TriggerType::SECONDARY_INDEX;
13657 deletePtr.p->triggerEvent = TriggerEvent::TE_DELETE;
13658 deletePtr.p->oldTriggerIds[0] = RNIL;
13659 deletePtr.p->oldTriggerIds[1] = RNIL;
13660 deletePtr.p->indexId = req->indexId;
13664 conf->senderRef = reference();
13665 conf->senderData = senderData;
13666 sendSignal(senderRef, GSN_CREATE_TRIG_IMPL_CONF,
13667 signal, CreateTrigImplConf::SignalLength, JBB);
13670 void Dbtc::execDROP_TRIG_IMPL_REQ(
Signal* signal)
13674 const Uint32 senderRef = req->senderRef;
13675 const Uint32 senderData = req->senderData;
13677 DefinedTriggerPtr triggerPtr;
13678 triggerPtr.i = req->triggerId;
13680 if (ERROR_INSERTED(8035) ||
13684 CLEAR_ERROR_INSERT_VALUE;
13688 ref->senderRef = reference();
13689 ref->senderData = senderData;
13690 ref->errorCode = DropTrigImplRef::InconsistentTC;
13691 ref->errorLine = __LINE__;
13692 sendSignal(senderRef, GSN_DROP_TRIG_IMPL_REF,
13693 signal, DropTrigImplRef::SignalLength, JBB);
13697 if (unlikely(triggerPtr.p->oldTriggerIds[0] != RNIL))
13709 conf->senderRef = reference();
13710 conf->senderData = senderData;
13712 sendSignal(senderRef, GSN_DROP_TRIG_IMPL_CONF,
13713 signal, DropTrigImplConf::SignalLength, JBB);
13716 void Dbtc::execCREATE_INDX_IMPL_REQ(
Signal* signal)
13721 const Uint32 senderRef = req->senderRef;
13722 const Uint32 senderData = req->senderData;
13723 TcIndexData* indexData;
13724 TcIndexDataPtr indexPtr;
13727 if (ERROR_INSERTED(8034) ||
13730 CLEAR_ERROR_INSERT_VALUE;
13735 ref->senderRef = reference();
13736 ref->senderData = senderData;
13737 ref->errorCode = CreateIndxImplRef::InconsistentTC;
13738 ref->errorLine = __LINE__;
13739 releaseSections(handle);
13740 sendSignal(senderRef, GSN_CREATE_INDX_IMPL_REF,
13741 signal, CreateIndxImplRef::SignalLength, JBB);
13744 indexData = indexPtr.p;
13747 indexData->indexState = IS_BUILDING;
13748 indexData->indexId = indexPtr.i;
13749 indexData->primaryTableId = req->tableId;
13753 handle.getSection(ssPtr, CreateIndxReq::ATTRIBUTE_LIST_SECTION);
13756 if (!r0.getWord(&indexData->attributeList.sz) ||
13757 !r0.getWords(indexData->attributeList.id, indexData->attributeList.sz)) {
13760 indexData->primaryKeyPos = indexData->attributeList.sz;
13762 releaseSections(handle);
13767 conf->senderRef = reference();
13768 conf->senderData = senderData;
13769 sendSignal(senderRef, GSN_CREATE_INDX_IMPL_CONF,
13770 signal, CreateIndxImplConf::SignalLength, JBB);
13773 void Dbtc::execALTER_INDX_IMPL_REQ(
Signal* signal)
13778 const Uint32 senderRef = req->senderRef;
13779 const Uint32 senderData = req->senderData;
13780 TcIndexData* indexData;
13781 const Uint32 requestType = req->requestType;
13782 const Uint32 indexId = req->indexId;
13790 ref->senderRef = reference();
13791 ref->senderData = senderData;
13792 ref->errorCode = AlterIndxImplRef::InconsistentTC;
13793 ref->errorLine = __LINE__;
13795 sendSignal(senderRef, GSN_ALTER_INDX_IMPL_REF,
13796 signal, AlterIndxImplRef::SignalLength, JBB);
13800 switch (requestType) {
13801 case AlterIndxImplReq::AlterIndexOnline:
13803 indexData->indexState = IS_ONLINE;
13805 case AlterIndxImplReq::AlterIndexOffline:
13807 indexData->indexState = IS_BUILDING;
13816 conf->senderRef = reference();
13817 conf->senderData = senderData;
13818 sendSignal(senderRef, GSN_ALTER_INDX_IMPL_CONF,
13819 signal, AlterIndxImplConf::SignalLength, JBB);
13822 void Dbtc::execFIRE_TRIG_ORD(
Signal* signal)
13826 ApiConnectRecordPtr transPtr;
13827 TcConnectRecordPtr opPtr;
13828 bool transIdOk =
true;
13832 const Uint32 sourceNode = refToNode(signal->getSendersBlockRef());
13834 bool sigContainsTransId = ndb_fire_trig_ord_transid(sourceNodeVersion);
13837 opPtr.i = fireOrd->getConnectionPtr();
13838 ptrCheckGuard(opPtr, ctcConnectFilesize, tcConnectRecord);
13841 transPtr.i = opPtr.p->apiConnect;
13842 if (unlikely(transPtr.i == RNIL))
13851 ptrCheckGuard(transPtr, capiConnectFilesize, apiConnectRecord);
13854 transIdOk = (! sigContainsTransId) |
13855 (! ((fireOrd->m_transId1 ^ transPtr.p->transid[0]) |
13856 (fireOrd->m_transId2 ^ transPtr.p->transid[1])));
13859 TcFiredTriggerData key;
13860 key.fireingOperation = opPtr.i;
13861 key.nodeId = refToNode(signal->getSendersBlockRef());
13862 FiredTriggerPtr trigPtr;
13863 if(likely(c_firedTriggerHash.
find(trigPtr, key)))
13866 c_firedTriggerHash.
remove(trigPtr);
13868 trigPtr.p->triggerType = (TriggerType::Value)fireOrd->m_triggerType;
13871 if (unlikely(signal->getLength() < FireTrigOrd::SignalLength))
13874 ndbrequire(! sigContainsTransId );
13880 trigPtr.p->fragId= fireOrd->fragId;
13881 bool ok = transIdOk;
13882 ok &= trigPtr.p->keyValues.getSize() == fireOrd->m_noPrimKeyWords;
13883 ok &= trigPtr.p->afterValues.getSize() == fireOrd->m_noAfterValueWords;
13884 ok &= trigPtr.p->beforeValues.getSize() == fireOrd->m_noBeforeValueWords;
13886 if (ERROR_INSERTED(8085))
13894 setApiConTimer(transPtr.i, ctcTimer, __LINE__);
13895 opPtr.p->noReceivedTriggers++;
13896 opPtr.p->triggerExecutionCount++;
13899 transPtr.p->theFiredTriggers.add(trigPtr);
13900 if (opPtr.p->noReceivedTriggers == opPtr.p->noFiredTriggers ||
13901 transPtr.p->isExecutingDeferredTriggers()) {
13902 executeTriggers(signal, &transPtr);
13915 AttributeBuffer::DataBufferPool & pool = c_theAttributeBufferPool;
13936 abortTransFromTrigger(signal, transPtr, ZGET_DATAREC_ERROR);
13942 void Dbtc::execTRIG_ATTRINFO(
Signal* signal)
13946 Uint32 attrInfoLength = signal->getLength() - TrigAttrInfo::StaticLength;
13947 const Uint32 *src = trigAttrInfo->getData();
13948 FiredTriggerPtr firedTrigPtr;
13950 TcFiredTriggerData key;
13951 key.fireingOperation = trigAttrInfo->getConnectionPtr();
13952 key.nodeId = refToNode(signal->getSendersBlockRef());
13953 if(!c_firedTriggerHash.
find(firedTrigPtr, key)){
13956 if(!c_firedTriggerHash.
seize(firedTrigPtr)){
13961 ndbout_c(
"op: %d node: %d failed to seize",
13962 key.fireingOperation, key.nodeId);
13965 ndbrequire(firedTrigPtr.p->keyValues.getSize() == 0 &&
13966 firedTrigPtr.p->beforeValues.getSize() == 0 &&
13967 firedTrigPtr.p->afterValues.getSize() == 0);
13969 firedTrigPtr.p->nodeId = refToNode(signal->getSendersBlockRef());
13970 firedTrigPtr.p->fireingOperation = key.fireingOperation;
13971 firedTrigPtr.p->triggerId = trigAttrInfo->getTriggerId();
13972 c_firedTriggerHash.
add(firedTrigPtr);
13975 AttributeBuffer::DataBufferPool & pool = c_theAttributeBufferPool;
13976 switch (trigAttrInfo->getAttrInfoType()) {
13977 case(TrigAttrInfo::PRIMARY_KEY):
13981 buf.append(src, attrInfoLength);
13984 case(TrigAttrInfo::BEFORE_VALUES):
13988 buf.append(src, attrInfoLength);
13991 case(TrigAttrInfo::AFTER_VALUES):
13995 buf.append(src, attrInfoLength);
14003 void Dbtc::execDROP_INDX_IMPL_REQ(
Signal* signal)
14008 const Uint32 senderRef = req->senderRef;
14009 const Uint32 senderData = req->senderData;
14010 TcIndexData* indexData;
14012 if (ERROR_INSERTED(8036) ||
14015 CLEAR_ERROR_INSERT_VALUE;
14020 ref->senderRef = reference();
14021 ref->senderData = senderData;
14022 ref->errorCode = DropIndxImplRef::InconsistentTC;
14023 ref->errorLine = __LINE__;
14024 sendSignal(senderRef, GSN_DROP_INDX_IMPL_REF,
14025 signal, DropIndxImplRef::SignalLength, JBB);
14034 conf->senderRef = reference();
14035 conf->senderData = senderData;
14036 sendSignal(senderRef, GSN_DROP_INDX_IMPL_CONF,
14037 signal, DropIndxImplConf::SignalLength, JBB);
14040 void Dbtc::execTCINDXREQ(
Signal* signal)
14045 const UintR TapiIndex = tcIndxReq->apiConnectPtr;
14046 Uint32 tcIndxRequestInfo = tcIndxReq->requestInfo;
14047 Uint32 startFlag = tcIndxReq->getStartFlag(tcIndxRequestInfo);
14048 ApiConnectRecordPtr transPtr;
14049 bool isLongTcIndxReq= (signal->getNoOfSections() != 0);
14052 transPtr.i = TapiIndex;
14053 if (transPtr.i >= capiConnectFilesize) {
14055 warningHandlerLab(signal, __LINE__);
14056 releaseSections(handle);
14059 ptrAss(transPtr, apiConnectRecord);
14060 ApiConnectRecord *
const regApiPtr = transPtr.p;
14062 TcIndexOperationPtr indexOpPtr;
14076 if (((startFlag == 1) &&
14077 (regApiPtr->apiConnectstate == CS_CONNECTED ||
14078 (regApiPtr->apiConnectstate == CS_STARTED &&
14079 regApiPtr->firstTcConnect == RNIL))) ||
14080 (regApiPtr->apiConnectstate == CS_ABORTING &&
14081 regApiPtr->abortState == AS_IDLE))
14086 releaseAllSeizedIndexOperations(regApiPtr);
14088 regApiPtr->apiConnectstate = CS_STARTED;
14089 regApiPtr->transid[0] = tcIndxReq->transId1;
14090 regApiPtr->transid[1] = tcIndxReq->transId2;
14093 if (
getNodeState().startLevel == NodeState::SL_SINGLEUSER &&
14095 refToNode(regApiPtr->ndbapiBlockref))
14098 releaseSections(handle);
14099 terrorCode = ZCLUSTER_IN_SINGLEUSER_MODE;
14100 regApiPtr->m_flags |=
14101 TcKeyReq::getExecuteFlag(tcIndxRequestInfo) ?
14102 ApiConnectRecord::TF_EXEC_FLAG : 0;
14103 apiConnectptr = transPtr;
14104 abortErrorLab(signal);
14108 if (ERROR_INSERTED(8036) || !seizeIndexOperation(regApiPtr, indexOpPtr)) {
14110 releaseSections(handle);
14113 regApiPtr->m_flags |=
14114 TcKeyReq::getExecuteFlag(tcIndxRequestInfo) ?
14115 ApiConnectRecord::TF_EXEC_FLAG : 0;
14116 apiConnectptr = transPtr;
14117 abortErrorLab(signal);
14120 TcIndexOperation* indexOp = indexOpPtr.p;
14121 indexOp->indexOpId = indexOpPtr.i;
14124 indexOp->tcIndxReq = *tcIndxReq;
14125 indexOp->connectionIndex = TapiIndex;
14126 regApiPtr->accumulatingIndexOp = indexOp->indexOpId;
14128 if (isLongTcIndxReq)
14137 handle.getSection(keyInfoSection,
14138 TcKeyReq::KeyInfoSectionNum);
14140 indexOp->keyInfoSectionIVal= keyInfoSection.i;
14142 if (handle.m_cnt == 2)
14144 handle.getSection(attrInfoSection,
14145 TcKeyReq::AttrInfoSectionNum);
14146 indexOp->attrInfoSectionIVal= attrInfoSection.i;
14156 readIndexTable(signal, regApiPtr, indexOp);
14165 Uint32 * dataPtr = &tcIndxReq->scanInfo;
14166 Uint32 indexLength = TcKeyReq::getKeyLength(tcIndxRequestInfo);
14167 Uint32 attrLength = TcKeyReq::getAttrinfoLen(tcIndxReq->attrLen);
14169 indexOp->pendingKeyInfo = indexLength;
14170 indexOp->pendingAttrInfo = attrLength;
14172 const Uint32 includedIndexLength = MIN(indexLength, TcKeyReq::MaxKeyInfo);
14173 const Uint32 includedAttrLength = MIN(attrLength, TcKeyReq::MaxAttrInfo);
14176 if ((ret = saveINDXKEYINFO(signal,
14179 includedIndexLength)) == 0)
14183 readIndexTable(signal, regApiPtr, indexOp);
14186 else if (ret == -1)
14192 dataPtr += includedIndexLength;
14194 if (saveINDXATTRINFO(signal,
14197 includedAttrLength) == 0) {
14200 readIndexTable(signal, regApiPtr, indexOp);
14206 void Dbtc::execINDXKEYINFO(
Signal* signal)
14209 Uint32 keyInfoLength = signal->getLength() - IndxKeyInfo::HeaderLength;
14211 const Uint32 *src = indxKeyInfo->getData();
14212 const UintR TconnectIndex = indxKeyInfo->connectPtr;
14213 ApiConnectRecordPtr transPtr;
14214 transPtr.i = TconnectIndex;
14215 if (transPtr.i >= capiConnectFilesize) {
14217 warningHandlerLab(signal, __LINE__);
14220 ptrAss(transPtr, apiConnectRecord);
14221 ApiConnectRecord *
const regApiPtr = transPtr.p;
14222 TcIndexOperationPtr indexOpPtr;
14223 TcIndexOperation* indexOp;
14225 if (compare_transid(regApiPtr->transid, indxKeyInfo->transId) ==
false)
14227 TCKEY_abort(signal, 19);
14231 if (regApiPtr->apiConnectstate == CS_ABORTING)
14237 if((indexOpPtr.i = regApiPtr->accumulatingIndexOp) != RNIL)
14241 ndbassert( indexOp->pendingKeyInfo > 0 );
14243 if (saveINDXKEYINFO(signal,
14246 keyInfoLength) == 0) {
14249 readIndexTable(signal, regApiPtr, indexOp);
14254 void Dbtc::execINDXATTRINFO(
Signal* signal)
14257 Uint32 attrInfoLength = signal->getLength() - IndxAttrInfo::HeaderLength;
14259 const Uint32 *src = indxAttrInfo->getData();
14260 const UintR TconnectIndex = indxAttrInfo->connectPtr;
14261 ApiConnectRecordPtr transPtr;
14262 transPtr.i = TconnectIndex;
14263 if (transPtr.i >= capiConnectFilesize) {
14265 warningHandlerLab(signal, __LINE__);
14268 ptrAss(transPtr, apiConnectRecord);
14269 ApiConnectRecord *
const regApiPtr = transPtr.p;
14270 TcIndexOperationPtr indexOpPtr;
14271 TcIndexOperation* indexOp;
14273 if (compare_transid(regApiPtr->transid, indxAttrInfo->transId) ==
false)
14275 TCKEY_abort(signal, 19);
14279 if (regApiPtr->apiConnectstate == CS_ABORTING)
14285 if((indexOpPtr.i = regApiPtr->accumulatingIndexOp) != RNIL)
14289 ndbassert( indexOp->pendingAttrInfo > 0 );
14291 if (saveINDXATTRINFO(signal,
14294 attrInfoLength) == 0) {
14297 readIndexTable(signal, regApiPtr, indexOp);
14309 Dbtc::saveINDXKEYINFO(
Signal* signal,
14310 TcIndexOperation* indexOp,
14314 if (ERROR_INSERTED(8052) ||
14315 ! appendToSection(indexOp->keyInfoSectionIVal,
14322 ndbout_c(
"Dbtc::saveINDXKEYINFO: Failed to seize buffer for KeyInfo\n");
14325 apiConnectptr.i = indexOp->connectionIndex;
14326 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
14327 releaseIndexOperation(apiConnectptr.p, indexOp);
14329 if(TcKeyReq::getExecuteFlag(indexOp->tcIndxReq.requestInfo))
14330 apiConnectptr.p->m_flags |= ApiConnectRecord::TF_EXEC_FLAG;
14331 abortErrorLab(signal);
14334 indexOp->pendingKeyInfo-= len;
14336 if (receivedAllINDXKEYINFO(indexOp) && receivedAllINDXATTRINFO(indexOp)) {
14343 bool Dbtc::receivedAllINDXKEYINFO(TcIndexOperation* indexOp)
14345 return (indexOp->pendingKeyInfo == 0);
14353 Dbtc::saveINDXATTRINFO(
Signal* signal,
14354 TcIndexOperation* indexOp,
14358 if (ERROR_INSERTED(8051) ||
14359 ! appendToSection(indexOp->attrInfoSectionIVal,
14365 ndbout_c(
"Dbtc::saveINDXATTRINFO: Failed to seize buffer for attrInfo\n");
14367 apiConnectptr.i = indexOp->connectionIndex;
14368 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
14369 releaseIndexOperation(apiConnectptr.p, indexOp);
14371 if(TcKeyReq::getExecuteFlag(indexOp->tcIndxReq.requestInfo))
14372 apiConnectptr.p->m_flags |= ApiConnectRecord::TF_EXEC_FLAG;
14373 abortErrorLab(signal);
14377 indexOp->pendingAttrInfo-= len;
14379 if (receivedAllINDXKEYINFO(indexOp) && receivedAllINDXATTRINFO(indexOp)) {
14386 bool Dbtc::receivedAllINDXATTRINFO(TcIndexOperation* indexOp)
14388 return (indexOp->pendingAttrInfo == 0);
14391 #ifdef ERROR_INSERT
14392 extern bool ErrorImportActive;
14395 bool Dbtc::saveTRANSID_AI(
Signal* signal,
14396 TcIndexOperation* indexOp,
14436 Uint32 remain= len;
14438 while (remain != 0)
14440 switch(indexOp->transIdAIState) {
14441 case ITAS_WAIT_HEADER:
14444 ndbassert(indexOp->transIdAISectionIVal == RNIL);
14450 indexOp->pendingTransIdAI = 1 + head->getDataSize();
14454 indexOp->transIdAIState = ITAS_WAIT_FRAGID;
14457 case ITAS_WAIT_FRAGID:
14460 ndbassert(indexOp->transIdAISectionIVal == RNIL);
14462 indexOp->fragmentId= *src;
14466 indexOp->transIdAIState = ITAS_WAIT_KEY;
14469 case ITAS_WAIT_KEY:
14473 #ifdef ERROR_INSERT
14474 if (ERROR_INSERTED(8066))
14476 ErrorImportActive =
true;
14480 bool res = appendToSection(indexOp->transIdAISectionIVal, src, remain);
14481 #ifdef ERROR_INSERT
14482 if (ERROR_INSERTED(8066))
14484 ErrorImportActive =
false;
14498 ndbout_c(
"Dbtc::saveTRANSID_AI: Failed to seize buffer for TRANSID_AI\n");
14500 indexOp->transIdAIState= ITAS_WAIT_KEY_FAIL;
14505 case ITAS_WAIT_KEY_FAIL:
14510 if (indexOp->pendingTransIdAI > len)
14520 apiConnectptr.i = indexOp->connectionIndex;
14521 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
14522 releaseIndexOperation(apiConnectptr.p, indexOp);
14523 terrorCode = ZGET_DATAREC_ERROR;
14524 abortErrorLab(signal);
14528 case ITAS_ALL_RECEIVED:
14536 ndbout_c(
"Dbtc::saveTRANSID_AI: Bad state when receiving\n");
14538 apiConnectptr.i = indexOp->connectionIndex;
14539 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
14540 releaseIndexOperation(apiConnectptr.p, indexOp);
14542 abortErrorLab(signal);
14547 if ((indexOp->pendingTransIdAI-= len) == 0)
14548 indexOp->transIdAIState = ITAS_ALL_RECEIVED;
14553 bool Dbtc::receivedAllTRANSID_AI(TcIndexOperation* indexOp)
14555 return (indexOp->transIdAIState == ITAS_ALL_RECEIVED);
14563 void Dbtc::execTCKEYCONF(
Signal* signal)
14566 TcIndexOperationPtr indexOpPtr;
14569 indexOpPtr.i = tcKeyConf->apiConnectPtr;
14571 Uint32 confInfo = tcKeyConf->confInfo;
14576 ndbassert(TcKeyConf::getCommitFlag(confInfo) ==
false);
14578 indexOpPtr.p = indexOp;
14584 const UintR TconnectIndex = indexOp->connectionIndex;
14585 ApiConnectRecord *
const regApiPtr = &apiConnectRecord[TconnectIndex];
14586 apiConnectptr.p = regApiPtr;
14587 apiConnectptr.i = TconnectIndex;
14588 switch(indexOp->indexOpState) {
14594 tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
14595 tcIndxRef->transId[0] = regApiPtr->transid[0];
14596 tcIndxRef->transId[1] = regApiPtr->transid[1];
14597 tcIndxRef->errorCode = 4349;
14598 tcIndxRef->errorData = 0;
14599 sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
14600 TcKeyRef::SignalLength, JBB);
14603 case(IOS_INDEX_ACCESS): {
14606 indexOp->indexOpState = IOS_INDEX_ACCESS_WAIT_FOR_TRANSID_AI;
14609 case(IOS_INDEX_ACCESS_WAIT_FOR_TRANSID_AI): {
14614 tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
14615 tcIndxRef->transId[0] = regApiPtr->transid[0];
14616 tcIndxRef->transId[1] = regApiPtr->transid[1];
14617 tcIndxRef->errorCode = 4349;
14618 tcIndxRef->errorData = 0;
14619 sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
14620 TcKeyRef::SignalLength, JBB);
14623 case(IOS_INDEX_ACCESS_WAIT_FOR_TCKEYCONF): {
14626 executeIndexOperation(signal, regApiPtr, indexOp);
14632 void Dbtc::execTCKEYREF(
Signal* signal)
14635 TcIndexOperationPtr indexOpPtr;
14638 indexOpPtr.i = tcKeyRef->connectPtr;
14640 indexOpPtr.p = indexOp;
14646 const UintR TconnectIndex = indexOp->connectionIndex;
14647 ApiConnectRecord *
const regApiPtr = &apiConnectRecord[TconnectIndex];
14649 switch(indexOp->indexOpState) {
14655 case(IOS_INDEX_ACCESS):
14656 case(IOS_INDEX_ACCESS_WAIT_FOR_TRANSID_AI):
14657 case(IOS_INDEX_ACCESS_WAIT_FOR_TCKEYCONF): {
14661 TcKeyReq *
const tcIndxReq = &indexOp->tcIndxReq;
14664 tcIndxRef->connectPtr = tcIndxReq->senderData;
14665 tcIndxRef->transId[0] = tcKeyRef->transId[0];
14666 tcIndxRef->transId[1] = tcKeyRef->transId[1];
14667 tcIndxRef->errorCode = tcKeyRef->errorCode;
14668 tcIndxRef->errorData = 0;
14670 releaseIndexOperation(regApiPtr, indexOp);
14672 sendSignal(regApiPtr->ndbapiBlockref,
14673 GSN_TCINDXREF, signal, TcKeyRef::SignalLength, JBB);
14679 void Dbtc::execTRANSID_AI_R(
Signal* signal){
14681 Uint32 sigLen = signal->
length();
14682 Uint32 dataLen = sigLen - TransIdAI::HeaderLength - 1;
14683 Uint32 recBlockref = transIdAI->attrData[dataLen];
14693 sendSignal(recBlockref, GSN_TRANSID_AI,
14694 signal, sigLen - 1, JBB,
14698 void Dbtc::execKEYINFO20_R(
Signal* signal){
14700 Uint32 sigLen = signal->
length();
14701 Uint32 dataLen = sigLen - KeyInfo20::HeaderLength - 1;
14702 Uint32 recBlockref = keyInfo->keyData[dataLen];
14712 sendSignal(recBlockref, GSN_KEYINFO20,
14713 signal, sigLen - 1, JBB,
14727 void Dbtc::execTRANSID_AI(
Signal* signal)
14732 TcIndexOperationPtr indexOpPtr;
14733 indexOpPtr.i = transIdAI->connectPtr;
14735 indexOpPtr.p = indexOp;
14740 const UintR TconnectIndex = indexOp->connectionIndex;
14741 ApiConnectRecordPtr transPtr;
14743 transPtr.i = TconnectIndex;
14744 ptrCheckGuard(transPtr, capiConnectFilesize, apiConnectRecord);
14745 ApiConnectRecord *
const regApiPtr = transPtr.p;
14749 bool longSignal = (handle.m_cnt == 1);
14754 ndbrequire(handle.getSection(dataPtr, 0));
14755 dataLen = dataPtr.sz;
14758 while (dataLen > NDB_SECTION_SEGMENT_SZ)
14760 if (!saveTRANSID_AI(signal, indexOp, &ptrP->theData[0],
14761 NDB_SECTION_SEGMENT_SZ))
14763 releaseSections(handle);
14766 dataLen -= NDB_SECTION_SEGMENT_SZ;
14767 ptrP = g_sectionSegmentPool.
getPtr(ptrP->m_nextSegment);
14769 if (!saveTRANSID_AI(signal, indexOp, &ptrP->theData[0], dataLen))
14771 releaseSections(handle);
14775 releaseSections(handle);
14780 if (!saveTRANSID_AI(signal,
14782 transIdAI->getData(),
14783 signal->getLength() - TransIdAI::HeaderLength)) {
14791 tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
14792 tcIndxRef->transId[0] = regApiPtr->transid[0];
14793 tcIndxRef->transId[1] = regApiPtr->transid[1];
14794 tcIndxRef->errorCode = ZGET_DATAREC_ERROR;
14795 tcIndxRef->errorData = 0;
14796 sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
14797 TcKeyRef::SignalLength, JBB);
14802 switch(indexOp->indexOpState) {
14808 tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
14809 tcIndxRef->transId[0] = regApiPtr->transid[0];
14810 tcIndxRef->transId[1] = regApiPtr->transid[1];
14811 tcIndxRef->errorCode = 4349;
14812 tcIndxRef->errorData = 0;
14813 sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
14814 TcKeyRef::SignalLength, JBB);
14818 case(IOS_INDEX_ACCESS): {
14821 if (receivedAllTRANSID_AI(indexOp)) {
14824 indexOp->indexOpState = IOS_INDEX_ACCESS_WAIT_FOR_TCKEYCONF;
14829 case(IOS_INDEX_ACCESS_WAIT_FOR_TCKEYCONF): {
14832 ndbout_c(
"Dbtc::execTRANSID_AI: Too many TRANSID_AI, ignore for now\n");
14848 case(IOS_INDEX_ACCESS_WAIT_FOR_TRANSID_AI): {
14851 if (receivedAllTRANSID_AI(indexOp)) {
14854 executeIndexOperation(signal, regApiPtr, indexOp);
14862 void Dbtc::execTCROLLBACKREP(
Signal* signal)
14866 TcIndexOperationPtr indexOpPtr;
14867 indexOpPtr.i = tcRollbackRep->connectPtr;
14869 indexOpPtr.p = indexOp;
14871 tcRollbackRep->connectPtr = indexOp->tcIndxReq.senderData;
14872 sendSignal(apiConnectptr.p->ndbapiBlockref,
14873 GSN_TCROLLBACKREP, signal, TcRollbackRep::SignalLength, JBB);
14879 void Dbtc::readIndexTable(
Signal* signal,
14880 ApiConnectRecord* regApiPtr,
14881 TcIndexOperation* indexOp)
14884 Uint32 tcKeyRequestInfo = indexOp->tcIndxReq.requestInfo;
14885 TcIndexData* indexData;
14886 Uint32 transId1 = indexOp->tcIndxReq.transId1;
14887 Uint32 transId2 = indexOp->tcIndxReq.transId2;
14889 const Operation_t opType =
14890 (Operation_t)TcKeyReq::getOperationType(tcKeyRequestInfo);
14900 tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
14901 tcIndxRef->transId[0] = regApiPtr->transid[0];
14902 tcIndxRef->transId[1] = regApiPtr->transid[1];
14903 tcIndxRef->errorCode = 4000;
14905 sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
14906 TcKeyRef::SignalLength, JBB);
14909 tcKeyReq->transId1 = transId1;
14910 tcKeyReq->transId2 = transId2;
14911 tcKeyReq->tableId = indexData->indexId;
14912 tcKeyReq->tableSchemaVersion = indexOp->tcIndxReq.tableSchemaVersion;
14913 TcKeyReq::setOperationType(tcKeyRequestInfo,
14914 opType == ZREAD ? ZREAD : ZREAD_EX);
14915 TcKeyReq::setAIInTcKeyReq(tcKeyRequestInfo, 0);
14916 TcKeyReq::setInterpretedFlag(tcKeyRequestInfo, 0);
14917 tcKeyReq->senderData = indexOp->indexOpId;
14918 indexOp->indexOpState = IOS_INDEX_ACCESS;
14919 regApiPtr->executingIndexOp = regApiPtr->accumulatingIndexOp;
14920 regApiPtr->accumulatingIndexOp = RNIL;
14921 regApiPtr->m_special_op_flags = TcConnectRecord::SOF_INDEX_TABLE_READ;
14923 if (ERROR_INSERTED(8037))
14925 ndbout_c(
"shifting index version");
14926 tcKeyReq->tableSchemaVersion = ~(Uint32)indexOp->tcIndxReq.tableSchemaVersion;
14928 tcKeyReq->attrLen = 1;
14929 tcKeyReq->requestInfo = tcKeyRequestInfo;
14931 ndbassert(TcKeyReq::getDirtyFlag(tcKeyRequestInfo) == 0);
14932 ndbassert(TcKeyReq::getSimpleFlag(tcKeyRequestInfo) == 0);
14940 Uint32 singleAIWord;
14943 if (!
import(indexLookupAttrInfoSection,
14953 ndbout_c(
"Dbtc::readIndexTable: Failed to create AttrInfo section");
14955 apiConnectptr.i = indexOp->connectionIndex;
14956 ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
14957 releaseIndexOperation(apiConnectptr.p, indexOp);
14959 abortErrorLab(signal);
14963 ndbassert(signal->header.m_noOfSections == 0);
14965 signal->m_sectionPtrI[ TcKeyReq::KeyInfoSectionNum ]
14966 = indexOp->keyInfoSectionIVal;
14969 indexOp->keyInfoSectionIVal= RNIL;
14971 signal->m_sectionPtrI[ TcKeyReq::AttrInfoSectionNum ]
14972 = indexLookupAttrInfoSection.i;
14973 signal->header.m_noOfSections= 2;
14979 EXECUTE_DIRECT(DBTC, GSN_TCKEYREQ, signal, TcKeyReq::StaticLength);
14982 if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
14994 regApiPtr->lqhkeyreqrec++;
15000 indexOp->indexReadTcConnect = regApiPtr->lastTcConnect;
15010 void Dbtc::executeIndexOperation(
Signal* signal,
15011 ApiConnectRecord* regApiPtr,
15012 TcIndexOperation* indexOp) {
15014 TcKeyReq *
const tcIndxReq = &indexOp->tcIndxReq;
15016 Uint32 tcKeyRequestInfo = tcIndxReq->requestInfo;
15017 TcIndexData* indexData;
15026 tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
15027 tcIndxRef->transId[0] = regApiPtr->transid[0];
15028 tcIndxRef->transId[1] = regApiPtr->transid[1];
15029 tcIndxRef->errorCode = 4349;
15030 tcIndxRef->errorData = 0;
15031 sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
15032 TcKeyRef::SignalLength, JBB);
15037 TableRecordPtr tabPtr;
15038 tabPtr.i = indexData->primaryTableId;
15039 ptrCheckGuard(tabPtr, ctabrecFilesize, tableRecord);
15041 tcKeyReq->apiConnectPtr = tcIndxReq->apiConnectPtr;
15042 tcKeyReq->attrLen = tcIndxReq->attrLen;
15043 tcKeyReq->tableId = indexData->primaryTableId;
15044 tcKeyReq->tableSchemaVersion = tabPtr.p->currentSchemaVersion;
15045 tcKeyReq->transId1 = regApiPtr->transid[0];
15046 tcKeyReq->transId2 = regApiPtr->transid[1];
15047 tcKeyReq->senderData = tcIndxReq->senderData;
15049 if (tabPtr.p->get_user_defined_partitioning())
15052 tcKeyReq->scanInfo = indexOp->fragmentId;
15053 TcKeyReq::setDistributionKeyFlag(tcKeyRequestInfo, 1
U);
15055 regApiPtr->m_special_op_flags = 0;
15056 regApiPtr->executingIndexOp = 0;
15063 ndbassert( indexOp->transIdAISectionIVal != RNIL );
15064 getSection(keyInfoFromTransIdAI, indexOp->transIdAISectionIVal);
15066 ndbassert( signal->header.m_noOfSections == 0 );
15067 signal->m_sectionPtrI[ TcKeyReq::KeyInfoSectionNum ]
15068 = indexOp->transIdAISectionIVal;
15069 signal->header.m_noOfSections = 1;
15071 indexOp->transIdAISectionIVal = RNIL;
15076 if ( indexOp->attrInfoSectionIVal != RNIL )
15081 getSection(attrInfoFromInitialReq, indexOp->attrInfoSectionIVal);
15082 signal->m_sectionPtrI[ TcKeyReq::AttrInfoSectionNum ]
15083 = indexOp->attrInfoSectionIVal;
15084 signal->header.m_noOfSections = 2;
15085 indexOp->attrInfoSectionIVal = RNIL;
15088 releaseIndexOperation(regApiPtr, indexOp);
15090 TcKeyReq::setKeyLength(tcKeyRequestInfo, keyInfoFromTransIdAI.sz);
15091 TcKeyReq::setAIInTcKeyReq(tcKeyRequestInfo, 0);
15092 TcKeyReq::setCommitFlag(tcKeyRequestInfo, 0);
15093 TcKeyReq::setExecuteFlag(tcKeyRequestInfo, 0);
15094 tcKeyReq->requestInfo = tcKeyRequestInfo;
15096 ndbassert(TcKeyReq::getDirtyFlag(tcKeyRequestInfo) == 0);
15097 ndbassert(TcKeyReq::getSimpleFlag(tcKeyRequestInfo) == 0);
15104 regApiPtr->lqhkeyreqrec--;
15111 TcConnectRecordPtr tmp;
15112 tmp.i = indexOp->indexReadTcConnect;
15113 ptrCheckGuard(tmp, ctcConnectFilesize, tcConnectRecord);
15114 const Uint32 currSavePointId = regApiPtr->currSavePointId;
15115 regApiPtr->currSavePointId = tmp.p->savePointId;
15117 #ifdef ERROR_INSERT
15118 bool err8072 = ERROR_INSERTED(8072);
15121 CLEAR_ERROR_INSERT_VALUE;
15128 EXECUTE_DIRECT(DBTC, GSN_TCKEYREQ, signal, TcKeyReq::StaticLength);
15131 #ifdef ERROR_INSERT
15134 SET_ERROR_INSERT_VALUE(8072);
15138 if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
15145 regApiPtr->currSavePointId = currSavePointId;
15149 bool Dbtc::seizeIndexOperation(ApiConnectRecord* regApiPtr,
15150 TcIndexOperationPtr& indexOpPtr)
15152 if (regApiPtr->theSeizedIndexOperations.seize(indexOpPtr))
15154 ndbassert(indexOpPtr.p->pendingKeyInfo == 0);
15155 ndbassert(indexOpPtr.p->keyInfoSectionIVal == RNIL);
15156 ndbassert(indexOpPtr.p->pendingAttrInfo == 0);
15157 ndbassert(indexOpPtr.p->attrInfoSectionIVal == RNIL);
15158 ndbassert(indexOpPtr.p->transIdAIState == ITAS_WAIT_HEADER);
15159 ndbassert(indexOpPtr.p->pendingTransIdAI == 0);
15160 ndbassert(indexOpPtr.p->transIdAISectionIVal == RNIL);
15167 void Dbtc::releaseIndexOperation(ApiConnectRecord* regApiPtr,
15168 TcIndexOperation* indexOp)
15170 indexOp->indexOpState = IOS_NOOP;
15171 indexOp->pendingKeyInfo = 0;
15172 releaseSection(indexOp->keyInfoSectionIVal);
15173 indexOp->keyInfoSectionIVal= RNIL;
15174 indexOp->pendingAttrInfo = 0;
15175 releaseSection(indexOp->attrInfoSectionIVal);
15176 indexOp->attrInfoSectionIVal= RNIL;
15177 indexOp->transIdAIState = ITAS_WAIT_HEADER;
15178 indexOp->pendingTransIdAI = 0;
15179 releaseSection(indexOp->transIdAISectionIVal);
15180 indexOp->transIdAISectionIVal= RNIL;
15181 regApiPtr->theSeizedIndexOperations.release(indexOp->indexOpId);
15184 void Dbtc::releaseAllSeizedIndexOperations(ApiConnectRecord* regApiPtr)
15186 TcIndexOperationPtr seizedIndexOpPtr;
15188 regApiPtr->theSeizedIndexOperations.first(seizedIndexOpPtr);
15189 while(seizedIndexOpPtr.i != RNIL) {
15191 TcIndexOperation* indexOp = seizedIndexOpPtr.p;
15193 indexOp->indexOpState = IOS_NOOP;
15194 indexOp->pendingKeyInfo = 0;
15195 releaseSection(indexOp->keyInfoSectionIVal);
15196 indexOp->keyInfoSectionIVal = RNIL;
15197 indexOp->pendingAttrInfo = 0;
15198 releaseSection(indexOp->attrInfoSectionIVal);
15199 indexOp->attrInfoSectionIVal = RNIL;
15200 indexOp->transIdAIState = ITAS_WAIT_HEADER;
15201 indexOp->pendingTransIdAI = 0;
15202 releaseSection(indexOp->transIdAISectionIVal);
15203 indexOp->transIdAISectionIVal = RNIL;
15204 regApiPtr->theSeizedIndexOperations.next(seizedIndexOpPtr);
15206 regApiPtr->theSeizedIndexOperations.release();
15209 void Dbtc::saveTriggeringOpState(
Signal* signal, TcConnectRecord* trigOp)
15212 copyFromToLen((UintR*)lqhKeyConf,
15213 &trigOp->savedState[0],
15214 LqhKeyConf::SignalLength);
15218 Dbtc::trigger_op_finished(
Signal* signal, ApiConnectRecordPtr regApiPtr,
15219 TcConnectRecord* triggeringOp)
15221 if (!regApiPtr.p->isExecutingDeferredTriggers())
15223 ndbassert(triggeringOp->triggerExecutionCount > 0);
15224 triggeringOp->triggerExecutionCount--;
15225 if (triggeringOp->triggerExecutionCount == 0)
15232 continueTriggeringOp(signal, triggeringOp);
15238 lqhKeyConf_checkTransactionState(signal, regApiPtr);
15242 void Dbtc::continueTriggeringOp(
Signal* signal, TcConnectRecord* trigOp)
15245 copyFromToLen(&trigOp->savedState[0],
15246 (UintR*)lqhKeyConf,
15247 LqhKeyConf::SignalLength);
15249 ndbassert(trigOp->savedState[LqhKeyConf::SignalLength-1] != ~Uint32(0));
15250 trigOp->savedState[LqhKeyConf::SignalLength-1] = ~Uint32(0);
15252 lqhKeyConf->noFiredTriggers = 0;
15253 trigOp->noReceivedTriggers = 0;
15256 execLQHKEYCONF(signal);
15259 void Dbtc::executeTriggers(
Signal* signal, ApiConnectRecordPtr* transPtr)
15261 ApiConnectRecord* regApiPtr = transPtr->p;
15262 TcConnectRecord *localTcConnectRecord = tcConnectRecord;
15263 TcConnectRecordPtr opPtr;
15264 FiredTriggerPtr trigPtr;
15266 if (!regApiPtr->theFiredTriggers.isEmpty()) {
15268 if ((regApiPtr->apiConnectstate == CS_STARTED) ||
15269 (regApiPtr->apiConnectstate == CS_START_COMMITTING) ||
15274 regApiPtr->theFiredTriggers.first(trigPtr);
15275 while (trigPtr.i != RNIL) {
15278 opPtr.i = trigPtr.p->fireingOperation;
15279 ptrCheckGuard(opPtr, ctcConnectFilesize, localTcConnectRecord);
15280 FiredTriggerPtr nextTrigPtr = trigPtr;
15281 regApiPtr->theFiredTriggers.next(nextTrigPtr);
15282 if (opPtr.p->noReceivedTriggers == opPtr.p->noFiredTriggers ||
15283 regApiPtr->isExecutingDeferredTriggers()) {
15286 executeTrigger(signal, trigPtr.p, transPtr, &opPtr);
15290 AttributeBuffer::DataBufferPool & pool = c_theAttributeBufferPool;
15297 regApiPtr->theFiredTriggers.release(trigPtr);
15299 trigPtr = nextTrigPtr;
15311 if ((regApiPtr->apiConnectstate == CS_RECEIVING) ||
15312 (regApiPtr->apiConnectstate == CS_REC_COMMITTING))
15316 if (!tc_testbit(regApiPtr->m_flags,
15317 ApiConnectRecord::TF_TRIGGER_PENDING))
15320 regApiPtr->m_flags |= ApiConnectRecord::TF_TRIGGER_PENDING;
15321 signal->theData[0] = TcContinueB::TRIGGER_PENDING;
15322 signal->theData[1] = transPtr->i;
15323 signal->theData[2] = regApiPtr->transid[0];
15324 signal->theData[3] = regApiPtr->transid[1];
15325 sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB);
15335 ndbrequire(regApiPtr->apiConnectstate == CS_ABORTING);
15341 void Dbtc::executeTrigger(
Signal* signal,
15342 TcFiredTriggerData* firedTriggerData,
15343 ApiConnectRecordPtr* transPtr,
15344 TcConnectRecordPtr* opPtr)
15346 TcDefinedTriggerData* definedTriggerData;
15348 if ((definedTriggerData =
15352 transPtr->p->pendingTriggers--;
15353 switch(firedTriggerData->triggerType) {
15354 case(TriggerType::SECONDARY_INDEX):
15356 executeIndexTrigger(signal, definedTriggerData, firedTriggerData,
15359 case TriggerType::REORG_TRIGGER:
15361 executeReorgTrigger(signal, definedTriggerData, firedTriggerData,
15370 void Dbtc::executeIndexTrigger(
Signal* signal,
15371 TcDefinedTriggerData* definedTriggerData,
15372 TcFiredTriggerData* firedTriggerData,
15373 ApiConnectRecordPtr* transPtr,
15374 TcConnectRecordPtr* opPtr)
15377 ndbassert(indexData != NULL);
15379 switch (firedTriggerData->triggerEvent) {
15380 case(TriggerEvent::TE_INSERT): {
15382 insertIntoIndexTable(signal, firedTriggerData, transPtr, opPtr, indexData);
15385 case(TriggerEvent::TE_DELETE): {
15387 deleteFromIndexTable(signal, firedTriggerData, transPtr, opPtr, indexData);
15390 case(TriggerEvent::TE_UPDATE): {
15392 opPtr->p->triggerExecutionCount++;
15393 deleteFromIndexTable(signal, firedTriggerData, transPtr, opPtr, indexData);
15394 insertIntoIndexTable(signal, firedTriggerData, transPtr, opPtr, indexData);
15404 FiredTriggerPtr trigPtr;
15406 triggers->
first(trigPtr);
15407 while (trigPtr.i != RNIL) {
15411 AttributeBuffer::DataBufferPool & pool = c_theAttributeBufferPool;
15419 triggers->
next(trigPtr);
15421 triggers->release();
15431 void Dbtc::abortTransFromTrigger(
Signal* signal,
15432 const ApiConnectRecordPtr& transPtr,
15436 terrorCode = error;
15438 apiConnectptr = transPtr;
15440 abortErrorLab(signal);
15454 bool Dbtc::appendAttrDataToSection(Uint32& sectionIVal,
15460 AttributeBuffer::DataBufferIterator iter;
15461 bool moreData= values.
first(iter);
15468 Uint32 dataSize= attrHeader->getDataSize();
15469 hasNull |= (dataSize == 0);
15474 ah.setAttributeId(attrId);
15475 if (unlikely(!appendToSection(sectionIVal,
15479 releaseSection(sectionIVal);
15485 moreData= values.next(iter, 1);
15489 ndbrequire(moreData);
15491 Uint32 contigLeft= segSize - iter.ind;
15492 ndbassert(contigLeft);
15493 Uint32 contigValid= MIN(dataSize, contigLeft);
15495 if (unlikely(!appendToSection(sectionIVal,
15499 releaseSection(sectionIVal);
15503 moreData= values.next(iter, contigValid);
15504 dataSize-= contigValid;
15512 void Dbtc::insertIntoIndexTable(
Signal* signal,
15513 TcFiredTriggerData* firedTriggerData,
15514 ApiConnectRecordPtr* transPtr,
15515 TcConnectRecordPtr* opPtr,
15516 TcIndexData* indexData)
15518 ApiConnectRecord* regApiPtr = transPtr->p;
15519 TcConnectRecord* opRecord = opPtr->p;
15521 Uint32 tcKeyRequestInfo = 0;
15522 TableRecordPtr indexTabPtr;
15526 indexTabPtr.i = indexData->indexId;
15527 ptrCheckGuard(indexTabPtr, ctabrecFilesize, tableRecord);
15528 tcKeyReq->apiConnectPtr = transPtr->i;
15529 tcKeyReq->senderData = opPtr->i;
15538 AttributeBuffer::DataBufferPool & pool = c_theAttributeBufferPool;
15542 if (afterValues.getSize() == 0)
15545 ndbrequire(tc_testbit(regApiPtr->m_flags,
15546 ApiConnectRecord::TF_DEFERRED_CONSTRAINTS));
15547 trigger_op_finished(signal, *transPtr, opRecord);
15551 Uint32 keyIVal= RNIL;
15552 Uint32 attrIVal= RNIL;
15553 bool appendOk=
false;
15557 bool hasNull=
false;
15560 if (unlikely(! appendAttrDataToSection(keyIVal,
15570 if(ERROR_INSERTED(8086))
15582 releaseSection(keyIVal);
15583 trigger_op_finished(signal, *transPtr, opRecord);
15592 if (unlikely((! appendAttrDataToSection(attrIVal,
15597 (! appendToSection(attrIVal,
15606 Uint32 startSz= getSectionSz(attrIVal);
15607 if (unlikely((! appendToSection(attrIVal,
15608 &firedTriggerData->fragId,
15610 (! appendAttrDataToSection(attrIVal,
15623 pkHeader->setDataSize(getSectionSz(attrIVal) - startSz);
15626 if (unlikely(!appendOk))
15629 releaseSection(keyIVal);
15630 releaseSection(attrIVal);
15631 abortTransFromTrigger(signal, *transPtr, ZGET_DATAREC_ERROR);
15636 TcKeyReq::setKeyLength(tcKeyRequestInfo, 0);
15637 tcKeyReq->attrLen = 0;
15638 TcKeyReq::setAIInTcKeyReq(tcKeyRequestInfo, 0);
15639 tcKeyReq->tableId = indexData->indexId;
15640 TcKeyReq::setOperationType(tcKeyRequestInfo, ZINSERT);
15641 tcKeyReq->tableSchemaVersion = indexTabPtr.p->currentSchemaVersion;
15642 tcKeyReq->transId1 = regApiPtr->transid[0];
15643 tcKeyReq->transId2 = regApiPtr->transid[1];
15644 tcKeyReq->requestInfo = tcKeyRequestInfo;
15647 ndbrequire(signal->header.m_noOfSections == 0);
15648 signal->m_sectionPtrI[ TcKeyReq::KeyInfoSectionNum ] = keyIVal;
15649 signal->m_sectionPtrI[ TcKeyReq::AttrInfoSectionNum ] = attrIVal;
15650 signal->header.m_noOfSections= 2;
15656 const Uint32 currSavePointId = regApiPtr->currSavePointId;
15657 regApiPtr->currSavePointId = opRecord->savePointId;
15658 regApiPtr->m_special_op_flags = TcConnectRecord::SOF_TRIGGER;
15660 ndbrequire(regApiPtr->immediateTriggerId == RNIL);
15661 regApiPtr->immediateTriggerId= firedTriggerData->triggerId;
15663 EXECUTE_DIRECT(DBTC, GSN_TCKEYREQ, signal, TcKeyReq::StaticLength);
15669 regApiPtr->currSavePointId = currSavePointId;
15670 regApiPtr->immediateTriggerId = RNIL;
15673 void Dbtc::deleteFromIndexTable(
Signal* signal,
15674 TcFiredTriggerData* firedTriggerData,
15675 ApiConnectRecordPtr* transPtr,
15676 TcConnectRecordPtr* opPtr,
15677 TcIndexData* indexData)
15679 ApiConnectRecord* regApiPtr = transPtr->p;
15680 TcConnectRecord* opRecord = opPtr->p;
15682 Uint32 tcKeyRequestInfo = 0;
15683 TableRecordPtr indexTabPtr;
15685 indexTabPtr.i = indexData->indexId;
15686 ptrCheckGuard(indexTabPtr, ctabrecFilesize, tableRecord);
15687 tcKeyReq->apiConnectPtr = transPtr->i;
15688 tcKeyReq->senderData = opPtr->i;
15691 AttributeBuffer::DataBufferPool & pool = c_theAttributeBufferPool;
15694 Uint32 keyIVal= RNIL;
15696 bool hasNull=
false;
15698 if (beforeValues.getSize() == 0)
15701 ndbrequire(tc_testbit(regApiPtr->m_flags,
15702 ApiConnectRecord::TF_DEFERRED_CONSTRAINTS));
15703 trigger_op_finished(signal, *transPtr, opRecord);
15708 if (unlikely((! appendAttrDataToSection(keyIVal,
15713 ERROR_INSERTED(8086)))
15716 releaseSection(keyIVal);
15717 abortTransFromTrigger(signal, *transPtr, ZGET_DATAREC_ERROR);
15727 releaseSection(keyIVal);
15728 trigger_op_finished(signal, *transPtr, opRecord);
15732 TcKeyReq::setKeyLength(tcKeyRequestInfo, 0);
15733 TcKeyReq::setAIInTcKeyReq(tcKeyRequestInfo, 0);
15734 tcKeyReq->attrLen = 0;
15735 tcKeyReq->tableId = indexData->indexId;
15736 TcKeyReq::setOperationType(tcKeyRequestInfo, ZDELETE);
15737 tcKeyReq->tableSchemaVersion = indexTabPtr.p->currentSchemaVersion;
15738 tcKeyReq->transId1 = regApiPtr->transid[0];
15739 tcKeyReq->transId2 = regApiPtr->transid[1];
15740 tcKeyReq->requestInfo = tcKeyRequestInfo;
15743 ndbrequire(signal->header.m_noOfSections == 0);
15744 signal->m_sectionPtrI[ TcKeyReq::KeyInfoSectionNum ] = keyIVal;
15745 signal->header.m_noOfSections= 1;
15751 const Uint32 currSavePointId = regApiPtr->currSavePointId;
15752 regApiPtr->currSavePointId = opRecord->savePointId;
15753 regApiPtr->m_special_op_flags = TcConnectRecord::SOF_TRIGGER;
15755 ndbrequire(regApiPtr->immediateTriggerId == RNIL);
15756 regApiPtr->immediateTriggerId= firedTriggerData->triggerId;
15757 EXECUTE_DIRECT(DBTC, GSN_TCKEYREQ, signal, TcKeyReq::StaticLength);
15763 regApiPtr->currSavePointId = currSavePointId;
15764 regApiPtr->immediateTriggerId = RNIL;
15768 Dbtc::TableRecord::getErrorCode(Uint32 schemaVersion)
const {
15770 return ZNO_SUCH_TABLE;
15772 return ZDROP_TABLE_IN_PROGRESS;
15773 if(table_version_major(schemaVersion) != table_version_major(currentSchemaVersion))
15774 return ZWRONG_SCHEMA_VERSION_ERROR;
15775 ErrorReporter::handleAssert(
"Dbtc::TableRecord::getErrorCode",
15776 __FILE__, __LINE__);
15780 void Dbtc::executeReorgTrigger(
Signal* signal,
15781 TcDefinedTriggerData* definedTriggerData,
15782 TcFiredTriggerData* firedTriggerData,
15783 ApiConnectRecordPtr* transPtr,
15784 TcConnectRecordPtr* opPtr)
15787 ApiConnectRecord* regApiPtr = transPtr->p;
15788 TcConnectRecord* opRecord = opPtr->p;
15791 tcKeyReq->apiConnectPtr = transPtr->i;
15792 tcKeyReq->senderData = opPtr->i;
15794 AttributeBuffer::DataBufferPool & pool = c_theAttributeBufferPool;
15799 bool sendAttrInfo=
true;
15801 switch (firedTriggerData->triggerEvent) {
15802 case TriggerEvent::TE_INSERT:
15805 case TriggerEvent::TE_UPDATE:
15813 case TriggerEvent::TE_DELETE:
15815 sendAttrInfo=
false;
15822 tablePtr.i = definedTriggerData->tableId;
15823 ptrCheckGuard(tablePtr, ctabrecFilesize, tableRecord);
15824 Uint32 tableVersion = tablePtr.p->currentSchemaVersion;
15826 Uint32 tcKeyRequestInfo = 0;
15827 TcKeyReq::setKeyLength(tcKeyRequestInfo, 0);
15828 TcKeyReq::setOperationType(tcKeyRequestInfo, optype);
15829 TcKeyReq::setAIInTcKeyReq(tcKeyRequestInfo, 0);
15830 tcKeyReq->attrLen = 0;
15831 tcKeyReq->tableId = tablePtr.i;
15832 tcKeyReq->requestInfo = tcKeyRequestInfo;
15833 tcKeyReq->tableSchemaVersion = tableVersion;
15834 tcKeyReq->transId1 = regApiPtr->transid[0];
15835 tcKeyReq->transId2 = regApiPtr->transid[1];
15837 Uint32 keyIVal= RNIL;
15838 Uint32 attrIVal= RNIL;
15840 bool hasNull=
false;
15843 if (unlikely(!appendAttrDataToSection(keyIVal,
15849 releaseSection(keyIVal);
15850 abortTransFromTrigger(signal, *transPtr, ZGET_DATAREC_ERROR);
15854 ndbrequire(!hasNull);
15863 buffers[0]= &keyValues;
15864 buffers[1]= &attrValues;
15866 for (
int buf=0; buf < 2; buf++)
15869 bool moreData= buffers[
buf]->
first(attrIter);
15873 ndbrequire(moreData);
15874 Uint32 contigLeft= segSize - attrIter.ind;
15875 Uint32 contigValid= MIN(dataSize, contigLeft);
15877 if (unlikely(!appendToSection(attrIVal,
15881 releaseSection(keyIVal);
15882 releaseSection(attrIVal);
15883 abortTransFromTrigger(signal, *transPtr, ZGET_DATAREC_ERROR);
15886 moreData= buffers[
buf]->next(attrIter, contigValid);
15887 dataSize-= contigValid;
15889 ndbassert(!moreData);
15894 ndbrequire(signal->header.m_noOfSections == 0);
15895 signal->m_sectionPtrI[ TcKeyReq::KeyInfoSectionNum ] = keyIVal;
15896 signal->m_sectionPtrI[ TcKeyReq::AttrInfoSectionNum ] = attrIVal;
15897 signal->header.m_noOfSections= sendAttrInfo? 2 : 1;
15903 const Uint32 currSavePointId = regApiPtr->currSavePointId;
15904 regApiPtr->currSavePointId = opRecord->savePointId;
15905 regApiPtr->m_special_op_flags = TcConnectRecord::SOF_REORG_TRIGGER;
15907 ndbrequire(regApiPtr->immediateTriggerId == RNIL);
15909 regApiPtr->immediateTriggerId= firedTriggerData->triggerId;
15910 EXECUTE_DIRECT(DBTC, GSN_TCKEYREQ, signal, TcKeyReq::StaticLength);
15916 regApiPtr->currSavePointId = currSavePointId;
15917 regApiPtr->immediateTriggerId = RNIL;
15921 Dbtc::execROUTE_ORD(
Signal* signal)
15932 Uint32 dstRef = ord->dstRef;
15933 Uint32 srcRef = ord->srcRef;
15934 Uint32 gsn = ord->gsn;
15936 if (likely(
getNodeInfo(refToNode(dstRef)).m_connected))
15939 Uint32 secCount = handle.m_cnt;
15940 ndbrequire(secCount >= 1 && secCount <= 3);
15947 Uint32 sigLen = handle.m_ptr[0].sz;
15948 ndbrequire(sigLen <= 25);
15949 copy(signal->theData, handle.m_ptr[0]);
15952 for (Uint32 i = 0; i < secCount - 1; i++)
15953 handle.m_ptr[i] = handle.m_ptr[i+1];
15956 sendSignal(dstRef, gsn, signal, sigLen, JBB, &handle);
15959 handle.m_ptr[0] = save;
15960 releaseSections(handle);
15964 releaseSections(handle);
15966 gsn, srcRef, dstRef);