19 #include <ndb_global.h>
23 #include <signaldata/TcCommit.hpp>
24 #include <signaldata/TcKeyFailConf.hpp>
25 #include <signaldata/TcKeyConf.hpp>
26 #include <signaldata/TestOrd.hpp>
27 #include <signaldata/CreateIndx.hpp>
28 #include <signaldata/DropIndx.hpp>
29 #include <signaldata/TcIndx.hpp>
30 #include <signaldata/TransIdAI.hpp>
31 #include <signaldata/ScanFrag.hpp>
32 #include <signaldata/ScanTab.hpp>
33 #include <signaldata/SumaImpl.hpp>
34 #include <signaldata/NodeFailRep.hpp>
35 #include <signaldata/NFCompleteRep.hpp>
36 #include <signaldata/AllocNodeId.hpp>
38 #include <ndb_limits.h>
42 #include <EventLogger.hpp>
56 DBUG_ENTER(
"Ndb::init");
61 int tMaxNoOfTransactions;
63 if (theInitState != NotInitialised) {
74 theInitState = StartingInit;
76 theEventBuffer->m_mutex = theFacade->theMutexPtr;
78 const Uint32 tRef = theImpl->open(theFacade);
86 Uint32 nodeId = refToNode(tRef);
87 theNdbBlockNumber = refToBlock(tRef);
91 connected(Uint32(tRef));
95 theFacade->lock_mutex();
96 theCachedMinDbNodeVersion = theFacade->getMinDbNodeVersion();
97 theFacade->unlock_mutex();
99 theDictionary->setTransporter(
this, theFacade);
101 aNrOfCon = theImpl->theNoOfDBnodes;
102 aNrOfOp = 2*theImpl->theNoOfDBnodes;
105 if((createConIdleList(aNrOfCon)) == -1){
106 theError.
code = 4000;
111 if((createOpIdleList(aNrOfOp)) == -1){
112 theError.
code = 4000;
117 tMaxNoOfTransactions = aMaxNoOfTransactions;
118 theMaxNoOfTransactions = tMaxNoOfTransactions;
119 theRemainingStartTransactions= tMaxNoOfTransactions;
120 thePreparedTransactionsArray =
new NdbTransaction* [tMaxNoOfTransactions];
121 theSentTransactionsArray =
new NdbTransaction* [tMaxNoOfTransactions];
122 theCompletedTransactionsArray =
new NdbTransaction* [tMaxNoOfTransactions];
124 if ((thePreparedTransactionsArray == NULL) ||
125 (theSentTransactionsArray == NULL) ||
126 (theCompletedTransactionsArray == NULL)) {
130 for (i = 0; i < tMaxNoOfTransactions; i++) {
131 thePreparedTransactionsArray[
i] = NULL;
132 theSentTransactionsArray[
i] = NULL;
133 theCompletedTransactionsArray[
i] = NULL;
135 for (i = 0; i < 16; i++){
136 tSignal[
i] = getSignal();
137 if(tSignal[i] == NULL) {
138 theError.
code = 4000;
142 for (i = 0; i < 16; i++)
143 releaseSignal(tSignal[i]);
144 theInitState = Initialised;
149 ndbout <<
"error_handler" << endl;
150 releaseTransactionArrays();
151 delete theDictionary;
157 Ndb::releaseTransactionArrays()
159 DBUG_ENTER(
"Ndb::releaseTransactionArrays");
160 if (thePreparedTransactionsArray != NULL) {
161 delete [] thePreparedTransactionsArray;
163 if (theSentTransactionsArray != NULL) {
164 delete [] theSentTransactionsArray;
166 if (theCompletedTransactionsArray != NULL) {
167 delete [] theCompletedTransactionsArray;
176 m_ndb.handleReceivedSignal(aSignal, ptr);
179 void Ndb::connected(Uint32 ref)
183 Uint32 tmpTheNode= refToNode(ref);
184 Uint64 tBlockNo= refToBlock(ref);
185 if (theNdbBlockNumber >= 0){
186 assert(theMyRef == numberToRef(theNdbBlockNumber, tmpTheNode));
190 theImpl->m_ndb_cluster_connection.get_db_nodes(theImpl->theDBnodes);
191 theImpl->theNoOfDBnodes = cnt;
193 theFirstTransId += ((Uint64)tBlockNo << 52)+
194 ((Uint64)tmpTheNode << 40);
196 DBUG_PRINT(
"info",(
"connected with ref=%x, id=%d, no_db_nodes=%d, first_trans_id: 0x%lx",
199 theImpl->theNoOfDBnodes,
200 (
long) theFirstTransId));
203 theDictionary->m_receiver.m_reference= theMyRef;
208 Ndb::report_node_failure(Uint32 node_id)
217 theImpl->the_release_ind[node_id] = 1;
219 theImpl->the_release_ind[0] = 1;
220 theImpl->theWaiter.nodeFail(node_id);
226 Ndb::report_node_failure_completed(Uint32 node_id)
235 abortTransactionsAfterNodeFailure(node_id);
246 Ndb::abortTransactionsAfterNodeFailure(Uint16 aNodeId)
248 Uint32 tNoSentTransactions = theNoOfSentTransactions;
249 for (
int i = tNoSentTransactions - 1;
i >= 0;
i--) {
252 const NdbTransaction::SendStatusType sendStatus = localCon->theSendStatus;
253 if (sendStatus == NdbTransaction::sendTC_OP ||
254 sendStatus == NdbTransaction::sendTC_COMMIT) {
261 localCon->setOperationErrorCodeAbort(4010);
262 localCon->theCompletionStatus = NdbTransaction::CompletedFailure;
263 }
else if (sendStatus == NdbTransaction::sendTC_ROLLBACK) {
268 localCon->theCompletionStatus = NdbTransaction::CompletedSuccess;
271 printState(
"abortTransactionsAfterNodeFailure %lx", (
long)
this);
280 localCon->theReturnStatus = NdbTransaction::ReturnFailure;
282 localCon->theReleaseOnClose =
true;
283 completedTransaction(localCon);
285 else if(localCon->report_node_failure(aNodeId))
287 completedTransaction(localCon);
306 int tReturnCode = -1;
307 const Uint32* tDataPtr = aSignal->
getDataPtr();
308 const Uint32 tWaitState = theImpl->theWaiter.get_state();
309 const Uint32 tSignalNumber = aSignal->readSignalNumber();
310 const Uint32 tFirstData = *tDataPtr;
311 const Uint32 tLen = aSignal->getLength();
312 Uint32 tNewState = tWaitState;
313 void * tFirstDataPtr;
314 NdbWaiter *t_waiter = &theImpl->theWaiter;
317 theCachedMinDbNodeVersion = theImpl->m_transporter_facade->getMinDbNodeVersion();
319 if (likely(NdbImpl::recordGSN(tSignalNumber)))
321 Uint32 secs = aSignal->m_noOfSections;
322 theImpl->incClientStat(BytesRecvdCount,
323 ((aSignal->getLength() << 2) +
324 ((secs > 2)? ptr[2].sz << 2: 0) +
325 ((secs > 1)? ptr[1].sz << 2: 0) +
326 ((secs > 0)? ptr[0].sz << 2: 0)));
339 switch (tSignalNumber){
344 if (tFirstData != RNIL)
346 tFirstDataPtr = int2void(tFirstData);
347 if (tFirstDataPtr == 0)
goto InvalidSignal;
348 tCon = void2con(tFirstDataPtr);
352 tCon = lookupTransactionFromOperation(keyConf);
354 const BlockReference aTCRef = aSignal->theSendersBlockRef;
356 if ((tCon->checkMagicNumber() == 0) &&
357 (tCon->theSendStatus == NdbTransaction::sendTC_OP)) {
358 tReturnCode = tCon->receiveTCKEYCONF(keyConf, tLen);
359 if (tReturnCode != -1) {
360 completedTransaction(tCon);
363 if(TcKeyConf::getMarkerFlag(keyConf->confInfo)){
364 NdbTransaction::sendTC_COMMIT_ACK(theImpl,
377 case GSN_TRANSID_AI:{
378 tFirstDataPtr = int2void(tFirstData);
381 if(!tRec->checkMagicNumber()){
384 tCon = tRec->getTransaction();
386 tCon->checkState_TransId(((
const TransIdAI*)tDataPtr)->transId)){
388 if(aSignal->m_noOfSections > 0){
389 if(tRec->getType()==NdbReceiver::NDB_QUERY_OPERATION){
391 ->execTRANSID_AI(ptr[0].p, ptr[0].sz);
393 com = tRec->execTRANSID_AI(ptr[0].p, ptr[0].sz);
396 assert(tRec->getType()!=NdbReceiver::NDB_QUERY_OPERATION);
397 com = tRec->execTRANSID_AI(tDataPtr + TransIdAI::HeaderLength,
398 tLen - TransIdAI::HeaderLength);
402 tCon->theNdb->theImpl->incClientStat(Ndb::ReadRowCount, 1);
403 if (refToNode(aSignal->theSendersBlockRef) == tCon->theDBnode)
404 tCon->theNdb->theImpl->incClientStat(Ndb::TransLocalReadRowCount,1);
410 switch(tRec->getType()){
411 case NdbReceiver::NDB_OPERATION:
412 case NdbReceiver::NDB_INDEX_OPERATION:
413 if(tCon->OpCompleteSuccess() != -1){
414 completedTransaction(tCon);
417 case NdbReceiver::NDB_SCANRECEIVER:
419 tNewState = (((WaitSignalType) tWaitState) == WAIT_SCAN ?
420 (Uint32) NO_WAIT : tWaitState);
422 case NdbReceiver::NDB_QUERY_OPERATION:
426 if (tmp->getQueryDef().isScanQuery()) {
427 tNewState = (((WaitSignalType) tWaitState) == WAIT_SCAN ?
428 (Uint32) NO_WAIT : tWaitState);
431 if (tCon->OpCompleteSuccess() != -1) {
432 completedTransaction(tCon);
452 case GSN_TCKEY_FAILCONF:
454 tFirstDataPtr = int2void(tFirstData);
456 const BlockReference aTCRef = aSignal->theSendersBlockRef;
457 if (tFirstDataPtr != 0){
458 tOp = void2rec_op(tFirstDataPtr);
460 if (tOp->checkMagicNumber(
false) == 0) {
461 tCon = tOp->theNdbCon;
463 if ((tCon->theSendStatus == NdbTransaction::sendTC_OP) ||
464 (tCon->theSendStatus == NdbTransaction::sendTC_COMMIT)) {
465 tReturnCode = tCon->receiveTCKEY_FAILCONF(failConf);
466 if (tReturnCode != -1) {
467 completedTransaction(tCon);
474 ndbout_c(
"Recevied TCKEY_FAILCONF wo/ operation");
478 NdbTransaction::sendTC_COMMIT_ACK(theImpl,
486 case GSN_TCKEY_FAILREF:
488 tFirstDataPtr = int2void(tFirstData);
489 if(tFirstDataPtr != 0){
490 tOp = void2rec_op(tFirstDataPtr);
491 if (tOp->checkMagicNumber(
false) == 0) {
492 tCon = tOp->theNdbCon;
494 if ((tCon->theSendStatus == NdbTransaction::sendTC_OP) ||
495 (tCon->theSendStatus == NdbTransaction::sendTC_ROLLBACK)) {
496 tReturnCode = tCon->receiveTCKEY_FAILREF(aSignal);
497 if (tReturnCode != -1) {
498 completedTransaction(tCon);
506 ndbout_c(
"Recevied TCKEY_FAILREF wo/ operation");
513 tFirstDataPtr = int2void(tFirstData);
514 if (tFirstDataPtr == 0)
goto InvalidSignal;
516 const NdbReceiver*
const receiver = void2rec(tFirstDataPtr);
517 if(!receiver->checkMagicNumber()){
520 tCon = receiver->getTransaction();
522 if (tCon->theSendStatus == NdbTransaction::sendTC_OP) {
523 if (receiver->getType()==NdbReceiver::NDB_QUERY_OPERATION) {
527 tCon->OpCompleteFailure() != -1) {
528 completedTransaction(tCon);
532 tOp = void2rec_op(tFirstDataPtr);
535 assert(tOp->checkMagicNumber()==0);
537 if (tReturnCode != -1) {
538 completedTransaction(tCon);
548 case GSN_TC_COMMITCONF:
550 tFirstDataPtr = int2void(tFirstData);
551 if (tFirstDataPtr == 0)
goto InvalidSignal;
554 const BlockReference aTCRef = aSignal->theSendersBlockRef;
556 tCon = void2con(tFirstDataPtr);
557 if ((tCon->checkMagicNumber() == 0) &&
558 (tCon->theSendStatus == NdbTransaction::sendTC_COMMIT)) {
559 tReturnCode = tCon->receiveTC_COMMITCONF(commitConf, tLen);
560 if (tReturnCode != -1) {
561 completedTransaction(tCon);
565 NdbTransaction::sendTC_COMMIT_ACK(theImpl,
567 commitConf->transId1,
568 commitConf->transId2,
577 case GSN_TC_COMMITREF:
579 tFirstDataPtr = int2void(tFirstData);
580 if (tFirstDataPtr == 0)
goto InvalidSignal;
582 tCon = void2con(tFirstDataPtr);
583 if ((tCon->checkMagicNumber() == 0) &&
584 (tCon->theSendStatus == NdbTransaction::sendTC_COMMIT)) {
585 tReturnCode = tCon->receiveTC_COMMITREF(aSignal);
586 if (tReturnCode != -1) {
587 completedTransaction(tCon);
592 case GSN_TCROLLBACKCONF:
594 tFirstDataPtr = int2void(tFirstData);
595 if (tFirstDataPtr == 0)
goto InvalidSignal;
597 tCon = void2con(tFirstDataPtr);
598 if ((tCon->checkMagicNumber() == 0) &&
599 (tCon->theSendStatus == NdbTransaction::sendTC_ROLLBACK)) {
600 tReturnCode = tCon->receiveTCROLLBACKCONF(aSignal);
601 if (tReturnCode != -1) {
602 completedTransaction(tCon);
607 case GSN_TCROLLBACKREF:
609 tFirstDataPtr = int2void(tFirstData);
610 if (tFirstDataPtr == 0)
goto InvalidSignal;
612 tCon = void2con(tFirstDataPtr);
613 if ((tCon->checkMagicNumber() == 0) &&
614 (tCon->theSendStatus == NdbTransaction::sendTC_ROLLBACK)) {
615 tReturnCode = tCon->receiveTCROLLBACKREF(aSignal);
616 if (tReturnCode != -1) {
617 completedTransaction(tCon);
622 case GSN_TCROLLBACKREP:
624 tFirstDataPtr = int2void(tFirstData);
625 if (tFirstDataPtr == 0)
goto InvalidSignal;
627 tCon = void2con(tFirstDataPtr);
628 if (tCon->checkMagicNumber() == 0) {
629 tReturnCode = tCon->receiveTCROLLBACKREP(aSignal);
630 if (tReturnCode != -1) {
631 completedTransaction(tCon);
636 case GSN_TCSEIZECONF:
638 tFirstDataPtr = int2void(tFirstData);
639 if (tFirstDataPtr == 0)
goto InvalidSignal;
641 if (tWaitState != WAIT_TC_SEIZE) {
644 tCon = void2con(tFirstDataPtr);
645 if (tCon->checkMagicNumber() != 0) {
648 tReturnCode = tCon->receiveTCSEIZECONF(aSignal);
649 if (tReturnCode != -1) {
658 tFirstDataPtr = int2void(tFirstData);
659 if (tFirstDataPtr == 0)
goto InvalidSignal;
661 if (tWaitState != WAIT_TC_SEIZE) {
664 tCon = void2con(tFirstDataPtr);
665 if (tCon->checkMagicNumber() != 0) {
668 tReturnCode = tCon->receiveTCSEIZEREF(aSignal);
669 if (tReturnCode != -1) {
676 case GSN_TCRELEASECONF:
678 tFirstDataPtr = int2void(tFirstData);
679 if (tFirstDataPtr == 0)
goto InvalidSignal;
681 if (tWaitState != WAIT_TC_RELEASE) {
684 tCon = void2con(tFirstDataPtr);
685 if (tCon->checkMagicNumber() != 0) {
688 tReturnCode = tCon->receiveTCRELEASECONF(aSignal);
689 if (tReturnCode != -1) {
694 case GSN_TCRELEASEREF:
696 tFirstDataPtr = int2void(tFirstData);
697 if (tFirstDataPtr == 0)
goto InvalidSignal;
699 if (tWaitState != WAIT_TC_RELEASE) {
702 tCon = void2con(tFirstDataPtr);
703 if (tCon->checkMagicNumber() != 0) {
706 tReturnCode = tCon->receiveTCRELEASEREF(aSignal);
707 if (tReturnCode != -1) {
713 case GSN_GET_TABINFOREF:
714 case GSN_GET_TABINFO_CONF:
715 case GSN_CREATE_TABLE_REF:
716 case GSN_CREATE_TABLE_CONF:
717 case GSN_DROP_TABLE_CONF:
718 case GSN_DROP_TABLE_REF:
719 case GSN_ALTER_TABLE_CONF:
720 case GSN_ALTER_TABLE_REF:
721 case GSN_CREATE_INDX_CONF:
722 case GSN_CREATE_INDX_REF:
723 case GSN_DROP_INDX_CONF:
724 case GSN_DROP_INDX_REF:
725 case GSN_INDEX_STAT_CONF:
726 case GSN_INDEX_STAT_REF:
727 case GSN_CREATE_EVNT_CONF:
728 case GSN_CREATE_EVNT_REF:
729 case GSN_DROP_EVNT_CONF:
730 case GSN_DROP_EVNT_REF:
731 case GSN_LIST_TABLES_CONF:
732 case GSN_CREATE_FILE_REF:
733 case GSN_CREATE_FILE_CONF:
734 case GSN_CREATE_FILEGROUP_REF:
735 case GSN_CREATE_FILEGROUP_CONF:
736 case GSN_DROP_FILE_REF:
737 case GSN_DROP_FILE_CONF:
738 case GSN_DROP_FILEGROUP_REF:
739 case GSN_DROP_FILEGROUP_CONF:
740 case GSN_SCHEMA_TRANS_BEGIN_CONF:
741 case GSN_SCHEMA_TRANS_BEGIN_REF:
742 case GSN_SCHEMA_TRANS_END_CONF:
743 case GSN_SCHEMA_TRANS_END_REF:
744 case GSN_SCHEMA_TRANS_END_REP:
745 case GSN_WAIT_GCP_CONF:
746 case GSN_WAIT_GCP_REF:
747 case GSN_CREATE_HASH_MAP_REF:
748 case GSN_CREATE_HASH_MAP_CONF:
749 NdbDictInterface::execSignal(&theDictionary->m_receiver,
753 case GSN_SUB_REMOVE_CONF:
754 case GSN_SUB_REMOVE_REF:
756 case GSN_SUB_START_CONF:
757 case GSN_SUB_START_REF:
758 case GSN_SUB_STOP_CONF:
759 case GSN_SUB_STOP_REF:
760 NdbDictInterface::execSignal(&theDictionary->m_receiver,
763 case GSN_SUB_GCP_COMPLETE_REP:
770 case GSN_SUB_TABLE_DATA:
774 const Uint32 oid = sdata->senderData;
777 if (unlikely(op == 0 || op->m_magic_number != NDB_EVENT_OP_MAGIC_NUMBER))
779 g_eventLogger->
error(
"dropped GSN_SUB_TABLE_DATA due to wrong magic "
785 if (SubTableData::getOperation(sdata->requestInfo) ==
786 NdbDictionary::Event::_TE_ALTER &&
787 !op->execSUB_TABLE_DATA(aSignal, ptr))
791 for (
int i = 0;
i<aSignal->m_noOfSections;
i++)
795 for (
int i = aSignal->m_noOfSections;
i < 3;
i++)
800 DBUG_PRINT(
"info",(
"oid=senderData: %d, gci{hi/lo}: %d/%d, operation: %d, "
802 sdata->senderData, sdata->gci_hi, sdata->gci_lo,
803 SubTableData::getOperation(sdata->requestInfo),
806 theEventBuffer->
insertDataL(op, sdata, tLen, copy);
809 case GSN_SCAN_TABCONF:
811 tFirstDataPtr = int2void(tFirstData);
812 assert(tFirstDataPtr);
813 assert(void2con(tFirstDataPtr));
814 assert(void2con(tFirstDataPtr)->checkMagicNumber() == 0);
816 (tCon = void2con(tFirstDataPtr)) && (tCon->checkMagicNumber() == 0)){
818 if(aSignal->m_noOfSections > 0){
819 tReturnCode = tCon->receiveSCAN_TABCONF(aSignal,
820 ptr[0].p, ptr[0].sz);
823 tCon->receiveSCAN_TABCONF(aSignal,
824 tDataPtr + ScanTabConf::SignalLength,
825 tLen - ScanTabConf::SignalLength);
827 if (tReturnCode != -1 && tWaitState == WAIT_SCAN)
834 case GSN_SCAN_TABREF:
836 tFirstDataPtr = int2void(tFirstData);
837 if (tFirstDataPtr == 0)
goto InvalidSignal;
839 tCon = void2con(tFirstDataPtr);
841 assert(tFirstDataPtr != 0 &&
842 void2con(tFirstDataPtr)->checkMagicNumber() == 0);
844 if (tCon->checkMagicNumber() == 0){
845 tReturnCode = tCon->receiveSCAN_TABREF(aSignal);
846 if (tReturnCode != -1 && tWaitState == WAIT_SCAN){
853 case GSN_KEYINFO20: {
854 tFirstDataPtr = int2void(tFirstData);
856 if (tFirstDataPtr && (tRec = void2rec(tFirstDataPtr)) &&
857 tRec->checkMagicNumber() && (tCon = tRec->getTransaction()) &&
858 tCon->checkState_TransId(&((
const KeyInfo20*)tDataPtr)->transId1)){
860 Uint32 len = ((
const KeyInfo20*)tDataPtr)->keyLen;
861 Uint32 info = ((
const KeyInfo20*)tDataPtr)->scanInfo_Node;
863 if(aSignal->m_noOfSections > 0 && len == ptr[0].sz){
864 com = tRec->execKEYINFO20(info, ptr[0].p, len);
865 }
else if(len == tLen - KeyInfo20::HeaderLength){
866 com = tRec->execKEYINFO20(info, tDataPtr+KeyInfo20::HeaderLength, len);
872 tNewState = (((WaitSignalType) tWaitState) == WAIT_SCAN ?
873 (Uint32) NO_WAIT : tWaitState);
890 tFirstDataPtr = int2void(tFirstData);
891 if (tFirstDataPtr == 0)
goto InvalidSignal;
893 tIndexOp = void2rec_iop(tFirstDataPtr);
894 if (tIndexOp->checkMagicNumber() == 0) {
895 tCon = tIndexOp->theNdbCon;
897 if (tCon->theSendStatus == NdbTransaction::sendTC_OP) {
898 tReturnCode = tIndexOp->receiveTCINDXREF(aSignal);
899 if (tReturnCode != -1) {
900 completedTransaction(tCon);
909 case GSN_API_REGCONF:
910 case GSN_CONNECT_REP:
912 case GSN_NODE_FAILREP:
916 for (Uint32
i = NdbNodeBitmask::find_first(rep->theNodes);
917 i != NdbNodeBitmask::NotFound;
920 report_node_failure(
i);
923 NdbDictInterface::execSignal(&theDictionary->m_receiver, aSignal, ptr);
926 case GSN_NF_COMPLETEREP:
933 case GSN_TAKE_OVERTCCONF:
934 abortTransactionsAfterNodeFailure(tFirstData);
936 case GSN_ALLOC_NODEID_CONF:
940 Uint32 nodeId = rep->nodeId;
941 connected(numberToRef(theNdbBlockNumber, nodeId));
945 tFirstDataPtr = NULL;
949 if (tNewState != tWaitState)
962 t_waiter->signal(tNewState);
970 ndbout_c(
"Ndbif: Error Ndb::handleReceivedSignal "
971 "(tFirstDataPtr=%p, GSN=%d, theImpl->theWaiter.m_state=%d)"
972 " sender = (Block: %d Node: %d)",
976 refToBlock(aSignal->theSendersBlockRef),
977 refToNode(aSignal->theSendersBlockRef));
979 #ifdef NDB_NO_DROPPED_SIGNAL
998 Uint32 tTransArrayIndex = aCon->theTransArrayIndex;
999 Uint32 tNoSentTransactions = theNoOfSentTransactions;
1000 Uint32 tNoCompletedTransactions = theNoOfCompletedTransactions;
1001 if ((tNoSentTransactions > 0) && (aCon->theListState == NdbTransaction::InSendList) &&
1002 (tTransArrayIndex < tNoSentTransactions)) {
1003 NdbTransaction* tMoveCon = theSentTransactionsArray[tNoSentTransactions - 1];
1005 theCompletedTransactionsArray[tNoCompletedTransactions] = aCon;
1006 aCon->theTransArrayIndex = tNoCompletedTransactions;
1007 if (tMoveCon != aCon) {
1008 tMoveCon->theTransArrayIndex = tTransArrayIndex;
1009 theSentTransactionsArray[tTransArrayIndex] = tMoveCon;
1011 theSentTransactionsArray[tNoSentTransactions - 1] = NULL;
1012 theNoOfCompletedTransactions = tNoCompletedTransactions + 1;
1014 theNoOfSentTransactions = tNoSentTransactions - 1;
1015 aCon->theListState = NdbTransaction::InCompletedList;
1016 aCon->handleExecuteCompletion();
1017 if ((theMinNoOfEventsToWakeUp != 0) &&
1018 (theNoOfCompletedTransactions >= theMinNoOfEventsToWakeUp)) {
1019 theMinNoOfEventsToWakeUp = 0;
1020 theImpl->theWaiter.signal(NO_WAIT);
1024 ndbout <<
"theNoOfSentTransactions = " << (int) theNoOfSentTransactions;
1025 ndbout <<
" theListState = " << (int) aCon->theListState;
1026 ndbout <<
" theTransArrayIndex = " << aCon->theTransArrayIndex;
1027 ndbout << endl << flush;
1029 printState(
"completedTransaction abort");
1041 Ndb::reportCallback(
NdbTransaction** aCopyArray, Uint32 aNoOfCompletedTrans)
1044 if (aNoOfCompletedTrans > 0) {
1045 for (i = 0; i < aNoOfCompletedTrans; i++) {
1046 void* anyObject = aCopyArray[
i]->theCallbackObject;
1047 NdbAsynchCallback aCallback = aCopyArray[
i]->theCallbackFunction;
1049 if (aCallback != NULL) {
1050 if (aCopyArray[i]->theReturnStatus == NdbTransaction::ReturnFailure) {
1053 (*aCallback)(tResult, aCopyArray[
i], anyObject);
1068 check_send_timeout();
1070 Uint32 tNoCompletedTransactions = theNoOfCompletedTransactions;
1071 if (tNoCompletedTransactions > 0) {
1072 for (i = 0; i < tNoCompletedTransactions; i++) {
1073 aCopyArray[
i] = theCompletedTransactionsArray[
i];
1074 if (aCopyArray[i]->theListState != NdbTransaction::InCompletedList) {
1075 ndbout <<
"pollCompleted error ";
1076 ndbout << (int) aCopyArray[i]->theListState << endl;
1079 theCompletedTransactionsArray[
i] = NULL;
1080 aCopyArray[
i]->theListState = NdbTransaction::NotInList;
1083 theNoOfCompletedTransactions = 0;
1084 return tNoCompletedTransactions;
1088 Ndb::check_send_timeout()
1090 Uint32 timeout = theImpl->get_ndbapi_config_parameters().m_waitfor_timeout;
1091 NDB_TICKS current_time = NdbTick_CurrentMillisecond();
1092 assert(current_time >= the_last_check_time);
1093 if (current_time - the_last_check_time > 1000) {
1094 the_last_check_time = current_time;
1095 Uint32 no_of_sent = theNoOfSentTransactions;
1096 for (Uint32 i = 0; i < no_of_sent; i++) {
1098 if ((current_time - a_con->theStartTransTime) > timeout)
1101 a_con->printState();
1102 Uint32 t1 = (Uint32) a_con->theTransactionId;
1103 Uint32 t2 = a_con->theTransactionId >> 32;
1104 ndbout_c(
"4012 [%.8x %.8x]", t1, t2);
1107 a_con->theReleaseOnClose =
true;
1108 a_con->theError.
code = 4012;
1109 a_con->setOperationErrorCodeAbort(4012);
1111 a_con->theCompletionStatus = NdbTransaction::CompletedFailure;
1112 a_con->handleExecuteCompletion();
1113 remove_sent_list(i);
1114 insert_completed_list(a_con);
1123 Ndb::remove_sent_list(Uint32 list_index)
1125 Uint32 last_index = theNoOfSentTransactions - 1;
1126 if (list_index < last_index) {
1128 theSentTransactionsArray[list_index] = t_con;
1130 theNoOfSentTransactions = last_index;
1131 theSentTransactionsArray[last_index] = 0;
1137 Uint32 no_of_comp = theNoOfCompletedTransactions;
1138 theCompletedTransactionsArray[no_of_comp] = a_con;
1139 theNoOfCompletedTransactions = no_of_comp + 1;
1140 a_con->theListState = NdbTransaction::InCompletedList;
1141 a_con->theTransArrayIndex = no_of_comp;
1148 Uint32 no_of_sent = theNoOfSentTransactions;
1149 theSentTransactionsArray[no_of_sent] = a_con;
1150 theNoOfSentTransactions = no_of_sent + 1;
1151 a_con->theListState = NdbTransaction::InSendList;
1152 a_con->theTransArrayIndex = no_of_sent;
1162 Ndb::sendPrepTrans(
int forceSend)
1180 theCachedMinDbNodeVersion = theImpl->m_transporter_facade->getMinDbNodeVersion();
1181 Uint32 no_of_prep_trans = theNoOfPreparedTransactions;
1182 for (i = 0; i < no_of_prep_trans; i++) {
1184 thePreparedTransactionsArray[
i] = NULL;
1186 if ((theImpl->getNodeSequence(node_id) == a_con->theNodeSequence) &&
1187 (theImpl->get_node_alive(node_id) || theImpl->get_node_stopping(node_id)))
1197 if (theImpl->check_send_size(node_id, a_con->get_send_size())) {
1198 if (a_con->doSend() == 0) {
1199 NDB_TICKS current_time = NdbTick_CurrentMillisecond();
1200 a_con->theStartTransTime = current_time;
1209 TRACE_DEBUG(
"Send problem even after checking node status");
1220 if (a_con->theSendStatus == NdbTransaction::sendOperations) {
1221 a_con->setOperationErrorCodeAbort(4021);
1223 TRACE_DEBUG(
"Send buffer full and sendOperations");
1225 a_con->setOperationErrorCodeAbort(4026);
1227 TRACE_DEBUG(
"Send buffer full, set state to Aborted");
1232 a_con->printState();
1238 TRACE_DEBUG(
"The node was stone dead, inform about abort");
1239 a_con->setOperationErrorCodeAbort(4025);
1240 a_con->theReleaseOnClose =
true;
1241 a_con->theTransactionIsStarted =
false;
1244 a_con->theReturnStatus = NdbTransaction::ReturnFailure;
1245 a_con->theCompletionStatus = NdbTransaction::CompletedFailure;
1246 a_con->handleExecuteCompletion();
1247 insert_completed_list(a_con);
1249 theNoOfPreparedTransactions = 0;
1250 theImpl->do_forceSend(forceSend);
1262 Ndb::waitCompletedTransactions(
int aMilliSecondsToWait,
1263 int noOfEventsToWaitFor,
1266 theImpl->theWaiter.set_node(0);
1267 theImpl->theWaiter.set_state(WAIT_TRANS);
1274 int waitTime = aMilliSecondsToWait;
1275 NDB_TICKS currTime = NdbTick_CurrentMillisecond();
1276 NDB_TICKS maxTime = currTime + (NDB_TICKS)waitTime;
1277 theMinNoOfEventsToWakeUp = noOfEventsToWaitFor;
1278 const int maxsleep = aMilliSecondsToWait > 10 ? 10 : aMilliSecondsToWait;
1279 theImpl->incClientStat(Ndb::WaitExecCompleteCount, 1);
1281 poll_guard->wait_for_input(maxsleep);
1282 if (theNoOfCompletedTransactions >= (Uint32)noOfEventsToWaitFor) {
1285 theMinNoOfEventsToWakeUp = noOfEventsToWaitFor;
1286 waitTime = (int)(maxTime - NdbTick_CurrentMillisecond());
1287 }
while (waitTime > 0);
1301 sendPrepTrans(forceSend);
1324 sendPrepTrans(forceSend);
1325 return poll_trans(aMillisecondNumber, minNoOfEventsToWakeup, &pg);
1329 Ndb::poll_trans(
int aMillisecondNumber,
int minNoOfEventsToWakeup,
1333 Uint32 tNoCompletedTransactions;
1334 if ((minNoOfEventsToWakeup <= 0) ||
1335 ((Uint32)minNoOfEventsToWakeup > theNoOfSentTransactions)) {
1336 minNoOfEventsToWakeup = theNoOfSentTransactions;
1338 if ((theNoOfCompletedTransactions < (Uint32)minNoOfEventsToWakeup) &&
1339 (aMillisecondNumber > 0)) {
1340 waitCompletedTransactions(aMillisecondNumber, minNoOfEventsToWakeup, pg);
1341 tNoCompletedTransactions = pollCompleted(tConArray);
1343 tNoCompletedTransactions = pollCompleted(tConArray);
1345 theMinNoOfEventsToWakeUp = 0;
1346 pg->unlock_and_signal();
1347 reportCallback(tConArray, tNoCompletedTransactions);
1348 return tNoCompletedTransactions;
1368 return poll_trans(aMillisecondNumber, minNoOfEventsToWakeup, &pg);
1372 Ndb::sendRecSignal(Uint16 node_id,
1376 Uint32 *ret_conn_seq)
1389 Uint32 read_conn_seq;
1390 Uint32 send_size = 1;
1398 theImpl->incClientStat(WaitMetaRequestCount, 1);
1400 read_conn_seq= theImpl->getNodeSequence(node_id);
1402 *ret_conn_seq= read_conn_seq;
1403 if ((theImpl->get_node_alive(node_id)) &&
1404 ((read_conn_seq == conn_seq) ||
1406 if (theImpl->check_send_size(node_id, send_size)) {
1407 return_code = theImpl->sendSignal(aSignal, node_id);
1408 if (return_code != -1) {
1409 return poll_guard.wait_n_unlock(WAITFOR_RESPONSE_TIMEOUT,node_id,
1418 if ((theImpl->get_node_stopping(node_id)) &&
1419 ((read_conn_seq == conn_seq) ||
1431 NdbTransaction::sendTC_COMMIT_ACK(
NdbImpl * impl,
1433 Uint32 transId1, Uint32 transId2,
1436 ndbout_c(
"Sending TC_COMMIT_ACK(0x%.8x, 0x%.8x) to -> %d",
1441 aSignal->theTrace = TestOrd::TraceAPI;
1442 aSignal->theReceiversBlockNumber = refToBlock(aTCRef);
1443 aSignal->theVerId_signalNumber = GSN_TC_COMMIT_ACK;
1444 aSignal->theLength = 2;
1446 Uint32 * dataPtr = aSignal->getDataPtrSend();
1447 dataPtr[0] = transId1;
1448 dataPtr[1] = transId2;
1453 NdbImpl::send_event_report(
bool has_lock,
1454 Uint32 *data, Uint32 length)
1457 aSignal.theTrace = TestOrd::TraceAPI;
1458 aSignal.theReceiversBlockNumber = CMVMI;
1459 aSignal.theVerId_signalNumber = GSN_EVENT_REP;
1460 aSignal.theLength = length;
1461 memcpy((
char *)aSignal.getDataPtrSend(), (
char *)data, length*4);
1470 m_ndb_cluster_connection.init_get_next_node(node_iter);
1471 while ((tNode= m_ndb_cluster_connection.get_next_node(node_iter)))
1473 if(get_node_alive(tNode))
1478 raw_sendSignal(&aSignal, tNode);
1493 Ndb::lookupTransactionFromOperation(
const TcKeyConf * conf)
1495 assert(TcKeyConf::getNoOfOperations(conf->confInfo) > 0);
1496 Uint32 opPtr = conf->operations[0].apiOperationPtr;
1497 void * voidptr = int2void(opPtr);
1503 return rec->getTransaction();