20 #include <Configuration.hpp>
21 #include <kernel_types.h>
22 #include <TransporterRegistry.hpp>
27 #include <SignalLoggerManager.hpp>
28 #include <FastScheduler.hpp>
30 #define DEBUG(x) { ndbout << "CMVMI::" << x << endl; }
32 #include <signaldata/TestOrd.hpp>
33 #include <signaldata/EventReport.hpp>
34 #include <signaldata/TamperOrd.hpp>
35 #include <signaldata/StartOrd.hpp>
36 #include <signaldata/CloseComReqConf.hpp>
37 #include <signaldata/SetLogLevelOrd.hpp>
38 #include <signaldata/EventSubscribeReq.hpp>
39 #include <signaldata/DumpStateOrd.hpp>
40 #include <signaldata/DisconnectRep.hpp>
41 #include <signaldata/EnableCom.hpp>
42 #include <signaldata/RouteOrd.hpp>
43 #include <signaldata/DbinfoScan.hpp>
44 #include <signaldata/Sync.hpp>
45 #include <signaldata/AllocMem.hpp>
46 #include <signaldata/NodeStateSignalData.hpp>
47 #include <signaldata/GetConfig.hpp>
49 #include <EventLogger.hpp>
50 #include <TimeQueue.hpp>
53 #include <SafeCounter.hpp>
55 #define ZREPORT_MEMORY_USAGE 1000
59 extern int simulate_error_during_shutdown;
62 Uint32 g_acc_pages_used[1 + MAX_NDBMT_LQH_WORKERS];
64 extern void mt_set_section_chunk_size();
68 ,subscribers(subscriberPool)
70 BLOCK_CONSTRUCTOR(
Cmvmi);
72 Uint32 long_sig_buffer_size;
74 m_ctx.m_config.getOwnConfigIterator();
77 ndb_mgm_get_int_parameter(p, CFG_DB_LONG_SIGNAL_BUFFER,
78 &long_sig_buffer_size);
86 long_sig_buffer_size= long_sig_buffer_size /
sizeof(
SectionSegment);
87 g_sectionSegmentPool.
setSize(long_sig_buffer_size,
88 true,
true,
true,CFG_DB_LONG_SIGNAL_BUFFER);
90 mt_set_section_chunk_size();
93 addRecSignal(GSN_CONNECT_REP, &Cmvmi::execCONNECT_REP);
94 addRecSignal(GSN_DISCONNECT_REP, &Cmvmi::execDISCONNECT_REP);
96 addRecSignal(GSN_NDB_TAMPER, &Cmvmi::execNDB_TAMPER,
true);
97 addRecSignal(GSN_SET_LOGLEVELORD, &Cmvmi::execSET_LOGLEVELORD);
98 addRecSignal(GSN_EVENT_REP, &Cmvmi::execEVENT_REP);
99 addRecSignal(GSN_STTOR, &Cmvmi::execSTTOR);
100 addRecSignal(GSN_READ_CONFIG_REQ, &Cmvmi::execREAD_CONFIG_REQ);
101 addRecSignal(GSN_CLOSE_COMREQ, &Cmvmi::execCLOSE_COMREQ);
102 addRecSignal(GSN_ENABLE_COMREQ, &Cmvmi::execENABLE_COMREQ);
103 addRecSignal(GSN_OPEN_COMREQ, &Cmvmi::execOPEN_COMREQ);
104 addRecSignal(GSN_TEST_ORD, &Cmvmi::execTEST_ORD);
106 addRecSignal(GSN_TAMPER_ORD, &Cmvmi::execTAMPER_ORD);
107 addRecSignal(GSN_STOP_ORD, &Cmvmi::execSTOP_ORD);
108 addRecSignal(GSN_START_ORD, &Cmvmi::execSTART_ORD);
109 addRecSignal(GSN_EVENT_SUBSCRIBE_REQ,
110 &Cmvmi::execEVENT_SUBSCRIBE_REQ);
112 addRecSignal(GSN_DUMP_STATE_ORD, &Cmvmi::execDUMP_STATE_ORD);
114 addRecSignal(GSN_TESTSIG, &Cmvmi::execTESTSIG);
115 addRecSignal(GSN_NODE_START_REP, &Cmvmi::execNODE_START_REP,
true);
117 addRecSignal(GSN_CONTINUEB, &Cmvmi::execCONTINUEB);
118 addRecSignal(GSN_ROUTE_ORD, &Cmvmi::execROUTE_ORD);
119 addRecSignal(GSN_DBINFO_SCANREQ, &Cmvmi::execDBINFO_SCANREQ);
121 addRecSignal(GSN_SYNC_REQ, &Cmvmi::execSYNC_REQ,
true);
122 addRecSignal(GSN_SYNC_REF, &Cmvmi::execSYNC_REF);
123 addRecSignal(GSN_SYNC_CONF, &Cmvmi::execSYNC_CONF);
125 addRecSignal(GSN_ALLOC_MEM_REF, &Cmvmi::execALLOC_MEM_REF);
126 addRecSignal(GSN_ALLOC_MEM_CONF, &Cmvmi::execALLOC_MEM_CONF);
128 addRecSignal(GSN_GET_CONFIG_REQ, &Cmvmi::execGET_CONFIG_REQ);
130 subscriberPool.setSize(5);
131 c_syncReqPool.setSize(5);
134 for(
unsigned j = 0; j<LogLevel::LOGLEVEL_CATEGORIES; j++){
136 if(!ndb_mgm_get_int_parameter(db, CFG_MIN_LOGLEVEL+j, &logLevel)){
137 clogLevel.setLogLevel((LogLevel::EventCategory)j,
143 for(ndb_mgm_first(iter); ndb_mgm_valid(iter); ndb_mgm_next(iter)){
148 ndbrequire(!ndb_mgm_get_int_parameter(iter,CFG_NODE_ID, &nodeId));
149 ndbrequire(!ndb_mgm_get_int_parameter(iter,CFG_TYPE_OF_SECTION,&nodeType));
153 c_dbNodes.set(nodeId);
161 setNodeInfo(nodeId).m_type = nodeType;
164 setNodeInfo(getOwnNodeId()).m_connected =
true;
165 setNodeInfo(getOwnNodeId()).m_version = ndbGetOwnVersion();
166 setNodeInfo(getOwnNodeId()).m_mysql_version = NDB_MYSQL_VERSION_D;
168 c_memusage_report_frequency = 0;
170 m_start_time = NdbTick_CurrentMillisecond() / 1000;
172 bzero(g_acc_pages_used,
sizeof(g_acc_pages_used));
178 m_shared_page_pool.clear();
183 extern Uint32 MAX_RECEIVED_SIGNALS;
186 void Cmvmi::execNDB_TAMPER(
Signal* signal)
189 SET_ERROR_INSERT_VALUE(signal->theData[0]);
190 if(ERROR_INSERTED(9999)){
191 CRASH_INSERTION(9999);
194 if(ERROR_INSERTED(9998)){
195 while(
true) NdbSleep_SecSleep(1);
198 if(ERROR_INSERTED(9997)){
203 if(ERROR_INSERTED(9996)){
204 simulate_error_during_shutdown= SIGSEGV;
208 if(ERROR_INSERTED(9995)){
209 simulate_error_during_shutdown= SIGSEGV;
210 kill(getpid(), SIGABRT);
215 if (signal->theData[0] == 9003)
217 if (MAX_RECEIVED_SIGNALS < 1024)
219 MAX_RECEIVED_SIGNALS = 1024;
223 MAX_RECEIVED_SIGNALS = 1 + (rand() % 128);
225 ndbout_c(
"MAX_RECEIVED_SIGNALS: %d", MAX_RECEIVED_SIGNALS);
226 CLEAR_ERROR_INSERT_VALUE;
231 static Uint32 blocks[] =
256 Cmvmi::execSYNC_REQ(
Signal* signal)
261 if (!c_syncReqPool.
seize(ptr))
266 tmp.m_senderRef = req.senderRef;
267 tmp.m_senderData = req.senderData;
268 tmp.m_prio = req.prio;
269 tmp.m_error = SyncRef::SR_OUT_OF_MEMORY;
270 sendSYNC_REP(signal, ptr);
274 ptr.p->m_senderRef = req.senderRef;
275 ptr.p->m_senderData = req.senderData;
276 ptr.p->m_prio = req.prio;
280 out->senderRef = reference();
281 out->senderData = ptr.i;
282 out->prio = ptr.p->m_prio;
284 for (i = 0; blocks[
i] != 0; i++)
286 sendSignal(blocks[i], GSN_SYNC_REQ, signal, SyncReq::SignalLength,
287 JobBufferLevel(ptr.p->m_prio));
293 Cmvmi::execSYNC_CONF(
Signal* signal)
299 c_syncReqPool.
getPtr(ptr, conf.senderData);
300 ndbrequire(ptr.p->m_cnt > 0);
302 if (ptr.p->m_cnt == 0)
306 sendSYNC_REP(signal, ptr);
312 Cmvmi::execSYNC_REF(
Signal* signal)
318 c_syncReqPool.
getPtr(ptr, ref.senderData);
319 ndbrequire(ptr.p->m_cnt > 0);
322 if (ptr.p->m_error == 0)
325 ptr.p->m_error = ref.errorCode;
328 if (ptr.p->m_cnt == 0)
332 sendSYNC_REP(signal, ptr);
340 if (ptr.p->m_error == 0)
344 conf->senderRef = reference();
345 conf->senderData = ptr.p->m_senderData;
346 sendSignal(ptr.p->m_senderRef, GSN_SYNC_CONF, signal,
347 SyncConf::SignalLength,
348 JobBufferLevel(ptr.p->m_prio));
354 ref->senderRef = reference();
355 ref->senderData = ptr.p->m_senderData;
356 ref->errorCode = ptr.p->m_error;
357 sendSignal(ptr.p->m_senderRef, GSN_SYNC_REF, signal, SyncRef::SignalLength,
358 JobBufferLevel(ptr.p->m_prio));
362 void Cmvmi::execSET_LOGLEVELORD(
Signal* signal)
365 LogLevel::EventCategory category;
369 for(
unsigned int i = 0; i<llOrd->noOfEntries; i++){
370 category = (LogLevel::EventCategory)(llOrd->theData[i] >> 16);
371 level = llOrd->theData[
i] & 0xFFFF;
384 STATIC_CONST( HeaderLength = 3 );
388 struct SavedEventBuffer
391 m_read_pos = m_write_pos = 0;
397 void init(Uint32 bytes) {
402 Uint32 words = bytes / 4;
403 m_data =
new Uint32[words];
406 m_buffer_len = words;
416 void alloc(Uint32 len);
418 void save(
const Uint32 * theData, Uint32 len);
425 } m_saved_event_buffer;
428 SavedEventBuffer::alloc(Uint32 len)
430 assert(m_buffer_len > 0);
432 while (free() <= len)
437 SavedEventBuffer::free()
const
439 if (m_write_pos == m_read_pos)
441 else if (m_write_pos > m_read_pos)
442 return (m_buffer_len - m_write_pos) + m_read_pos;
444 return m_read_pos - m_write_pos;
448 SavedEventBuffer::purge()
450 const Uint32 * ptr = m_data + m_read_pos;
452 Uint32 len = SavedEvent::HeaderLength + header->m_len;
453 m_read_pos = (m_read_pos + len) % m_buffer_len;
457 SavedEventBuffer::save(
const Uint32 * theData, Uint32 len)
459 if (m_buffer_len == 0)
462 Uint32 total = len + SavedEvent::HeaderLength;
467 s.m_seq = m_sequence++;
468 s.m_time = (Uint32)time(0);
469 const Uint32 * src = (
const Uint32*)&s;
470 Uint32 * dst = m_data + m_write_pos;
472 Uint32 remain = m_buffer_len - m_write_pos;
475 memcpy(dst, src, 4 * SavedEvent::HeaderLength);
476 memcpy(dst+SavedEvent::HeaderLength, theData, 4*len);
480 memcpy(s.m_data, theData, 4 * len);
481 memcpy(dst, src, 4 * remain);
482 memcpy(m_data, src + remain, 4 * (total - remain));
484 m_write_pos = (m_write_pos + total) % m_buffer_len;
488 SavedEventBuffer::startScan()
490 m_scan_pos = m_read_pos;
494 SavedEventBuffer::scan(
SavedEvent* _dst, Uint32 filter[])
496 Uint32 * dst = (Uint32*)_dst;
497 while (m_scan_pos != m_write_pos)
499 const Uint32 * ptr = m_data + m_scan_pos;
501 assert(s->m_len <= 25);
502 Uint32 total = s->m_len + SavedEvent::HeaderLength;
503 if (m_scan_pos + total <= m_buffer_len)
505 memcpy(dst, s, 4 * total);
509 Uint32 remain = m_buffer_len - m_scan_pos;
510 memcpy(dst, s, 4 * remain);
511 memcpy(dst + remain, m_data, 4 * (total - remain));
513 m_scan_pos = (m_scan_pos + total) % m_buffer_len;
519 void Cmvmi::execEVENT_REP(
Signal* signal)
530 Uint32 nodeId= eventReport->getNodeId();
533 nodeId= refToNode(signal->getSendersBlockRef());
540 nodeId= getOwnNodeId();
543 eventReport->setNodeId(nodeId);
552 LogLevel::EventCategory eventCategory;
555 if (EventLoggerBase::event_lookup(eventType,eventCategory,threshold,severity,textF))
559 for(subscribers.
first(ptr); ptr.i != RNIL; subscribers.
next(ptr)){
560 if(ptr.p->logLevel.getLogLevel(eventCategory) < threshold){
564 sendSignal(ptr.p->blockRef, GSN_EVENT_REP, signal, signal->
length(), JBB);
567 m_saved_event_buffer.save(signal->theData, signal->getLength());
569 if(clogLevel.
getLogLevel(eventCategory) < threshold){
574 g_eventLogger->
log(eventReport->getEventType(),
575 signal->theData, signal->getLength(), 0, 0);
581 Cmvmi::execEVENT_SUBSCRIBE_REQ(
Signal * signal){
583 Uint32 senderRef = signal->getSendersBlockRef();
586 DBUG_ENTER(
"Cmvmi::execEVENT_SUBSCRIBE_REQ");
591 for(subscribers.
first(ptr); ptr.i != RNIL; subscribers.
next(ptr)){
592 if(ptr.p->blockRef == subReq->
blockRef)
600 if(subscribers.
seize(ptr) ==
false){
601 sendSignal(senderRef, GSN_EVENT_SUBSCRIBE_REF, signal, 1, JBB);
604 ptr.p->logLevel.clear();
617 LogLevel::EventCategory category;
620 category = (LogLevel::EventCategory)(subReq->theData[i] >> 16);
621 level = subReq->theData[
i] & 0xFFFF;
622 ptr.p->logLevel.setLogLevel(category, level);
623 DBUG_PRINT(
"info",(
"entry %d: level=%d, category= %d", i, level, category));
627 signal->theData[0] = ptr.i;
628 sendSignal(senderRef, GSN_EVENT_SUBSCRIBE_CONF, signal, 1, JBB);
633 Cmvmi::cancelSubscription(NodeId nodeId){
636 subscribers.
first(ptr);
638 while(ptr.i != RNIL){
640 BlockReference blockRef = ptr.p->blockRef;
642 subscribers.
next(ptr);
644 if(refToNode(blockRef) == nodeId){
650 void Cmvmi::sendSTTORRY(
Signal* signal)
653 signal->theData[3] = 1;
654 signal->theData[4] = 3;
655 signal->theData[5] = 8;
656 signal->theData[6] = 255;
657 sendSignal(NDBCNTR_REF, GSN_STTORRY, signal, 7, JBB);
661 static Uint32 f_accpages = 0;
664 static Uint32 f_read_config_ref = 0;
665 static Uint32 f_read_config_data = 0;
668 Cmvmi::execREAD_CONFIG_REQ(
Signal* signal)
674 Uint32 ref = req->senderRef;
675 Uint32 senderData = req->senderData;
678 m_ctx.m_config.getOwnConfigIterator();
682 void* ptr = m_ctx.m_mm.get_memroot();
686 f_accpages = compute_acc_32kpages(p);
688 Uint32 eventlog = 4096;
689 ndb_mgm_get_int_parameter(p, CFG_DB_EVENTLOG_BUFFER_SIZE, &eventlog);
690 m_saved_event_buffer.init(eventlog);
692 c_memusage_report_frequency = 0;
693 ndb_mgm_get_int_parameter(p, CFG_DB_MEMREPORT_FREQUENCY,
694 &c_memusage_report_frequency);
696 Uint32 late_alloc = 1;
697 ndb_mgm_get_int_parameter(p, CFG_DB_LATE_ALLOC,
702 f_read_config_ref = ref;
703 f_read_config_data = senderData;
708 req->senderRef = reference();
709 req->requestInfo = AllocMemReq::RT_MAP;
710 if (m_ctx.m_config.lockPagesInMainMemory())
712 req->requestInfo |= AllocMemReq::RT_MEMLOCK;
717 sendSignal(NDBFS_REF, GSN_ALLOC_MEM_REQ, signal,
718 AllocMemReq::SignalLength, JBB);
728 NodeState::ST_ILLEGAL_TYPE);
729 rep->nodeState = newState;
730 rep->nodeState.masterNodeId = 0;
731 rep->nodeState.setNodeGroup(0);
732 sendSignal(QMGR_REF, GSN_NODE_STATE_REP, signal,
733 NodeStateRep::SignalLength, JBB);
738 init_global_page_pool();
741 conf->senderRef = reference();
742 conf->senderData = senderData;
743 sendSignal(ref, GSN_READ_CONFIG_CONF, signal,
744 ReadConfigConf::SignalLength, JBB);
748 Cmvmi::init_global_page_pool()
755 void* ptr = m_ctx.m_mm.get_memroot();
759 ndbrequire(m_ctx.m_mm.get_resource_limit(RG_DISK_PAGE_BUFFER, rl));
763 Uint32 cnt = rl.m_max;
764 m_ctx.m_mm.alloc_pages(RG_DISK_PAGE_BUFFER, &ptrI, &cnt, 1);
766 for (Uint32 i = 0; i<cnt; i++)
769 m_shared_page_pool.
getPtr(pagePtr, ptrI + i);
770 m_global_page_pool.
release(pagePtr);
776 void Cmvmi::execSTTOR(
Signal* signal)
778 Uint32 theStartPhase = signal->theData[1];
781 if (theStartPhase == 1){
784 if (m_ctx.m_config.lockPagesInMainMemory())
792 int res = NdbMem_MemLockAll(1);
797 "Failed to memlock pages, error: %d (%s)",
798 errno, strerror(errno));
799 g_eventLogger->
warning(
"%s", buf);
804 g_eventLogger->
info(
"Using locked memory");
812 Uint32 db_watchdog_interval = 0;
814 m_ctx.m_config.getOwnConfigIterator();
815 ndb_mgm_get_int_parameter(p, CFG_DB_WATCHDOG_INTERVAL,
816 &db_watchdog_interval);
817 ndbrequire(db_watchdog_interval);
818 update_watch_dog_timer(db_watchdog_interval);
824 signal->theData[0] = ZREPORT_MEMORY_USAGE;
825 signal->theData[1] = 0;
826 signal->theData[2] = 0;
827 signal->theData[3] = 0;
828 execCONTINUEB(signal);
832 }
else if (theStartPhase == 3) {
834 globalData.activateSendPacked = 1;
836 }
else if (theStartPhase == 8){
838 if (ERROR_INSERTED(9004))
840 Uint32 len = signal->getLength();
841 Uint32 db = c_dbNodes.
find(0);
842 if (db == getOwnNodeId())
843 db = c_dbNodes.
find(db);
844 Uint32 i = c_error_9000_nodes_mask.
find(0);
846 memcpy(tmp, signal->theData,
sizeof(tmp));
847 signal->theData[0] =
i;
848 sendSignal(calcQmgrBlockRef(db),GSN_API_FAILREQ, signal, 1, JBA);
849 ndbout_c(
"stopping %u using %u", i, db);
850 CLEAR_ERROR_INSERT_VALUE;
851 memcpy(signal->theData, tmp,
sizeof(tmp));
852 sendSignalWithDelay(reference(), GSN_STTOR,
862 void Cmvmi::execCLOSE_COMREQ(
Signal* signal)
869 const BlockReference userRef = closeCom->xxxBlockRef;
870 Uint32 requestType = closeCom->requestType;
871 Uint32 failNo = closeCom->failNo;
875 for (
unsigned i = 0; i < MAX_NODES; i++)
885 signal->theData[1] =
i;
886 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
888 globalTransporterRegistry.setIOState(i, HaltIO);
892 if (requestType != CloseComReqConf::RT_NO_REPLY)
894 ndbassert((requestType == CloseComReqConf::RT_API_FAILURE) ||
895 ((requestType == CloseComReqConf::RT_NODE_FAILURE) &&
899 closeComConf->xxxBlockRef = userRef;
900 closeComConf->requestType = requestType;
901 closeComConf->failNo = failNo;
907 sendSignal(QMGR_REF, GSN_CLOSE_COMCONF, signal, 19, JBA);
911 void Cmvmi::execOPEN_COMREQ(
Signal* signal)
916 const BlockReference userRef = signal->theData[0];
917 Uint32 tStartingNode = signal->theData[1];
918 Uint32 tData2 = signal->theData[2];
921 const Uint32 len = signal->getLength();
925 if (! ((ERROR_INSERTED(9000) || ERROR_INSERTED(9002))
926 && c_error_9000_nodes_mask.
get(tStartingNode)))
929 globalTransporterRegistry.
do_connect(tStartingNode);
930 globalTransporterRegistry.setIOState(tStartingNode, HaltIO);
936 signal->theData[1] = tStartingNode;
937 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
941 for(
unsigned int i = 1; i < MAX_NODES; i++ )
944 if (i != getOwnNodeId() &&
getNodeInfo(i).m_type == tData2)
949 if ((ERROR_INSERTED(9000) || ERROR_INSERTED(9002))
950 && c_error_9000_nodes_mask.
get(i))
954 globalTransporterRegistry.setIOState(i, HaltIO);
957 signal->theData[1] =
i;
958 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
966 signal->theData[0] = tStartingNode;
967 signal->theData[1] = tData2;
968 sendSignal(userRef, GSN_OPEN_COMCONF, signal, len - 1,JBA);
972 void Cmvmi::execENABLE_COMREQ(
Signal* signal)
978 Uint32 senderRef = enableComReq->m_senderRef;
979 Uint32 senderData = enableComReq->m_senderData;
980 Uint32 nodes[NodeBitmask::Size];
981 MEMCOPY_NO_WORDS(nodes, enableComReq->m_nodeIds, NodeBitmask::Size);
984 Uint32 search_from = 0;
988 if (tStartingNode == NodeBitmask::NotFound)
990 search_from = tStartingNode + 1;
992 globalTransporterRegistry.setIOState(tStartingNode, NoHalt);
999 signal->theData[1] = tStartingNode;
1003 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 4, JBB);
1008 enableComConf->m_senderRef = reference();
1009 enableComConf->m_senderData = senderData;
1010 MEMCOPY_NO_WORDS(enableComConf->m_nodeIds, nodes, NodeBitmask::Size);
1011 sendSignal(senderRef, GSN_ENABLE_COMCONF, signal,
1012 EnableComConf::SignalLength, JBA);
1015 void Cmvmi::execDISCONNECT_REP(
Signal *signal)
1018 const Uint32 hostId = rep->nodeId;
1026 sendSignal(QMGR_REF, GSN_DISCONNECT_REP, signal,
1027 DisconnectRep::SignalLength, JBA);
1029 cancelSubscription(hostId);
1032 signal->theData[1] = hostId;
1033 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
1036 void Cmvmi::execCONNECT_REP(
Signal *signal){
1037 const Uint32 hostId = signal->theData[0];
1042 globalData.m_nodeInfo[hostId].
m_version = 0;
1048 signal->theData[0] = hostId;
1049 if (ERROR_INSERTED(9005))
1051 sendSignalWithDelay(QMGR_REF, GSN_CONNECT_REP, signal, 50, 1);
1055 sendSignal(QMGR_REF, GSN_CONNECT_REP, signal, 1, JBA);
1063 globalTransporterRegistry.setIOState(hostId, NoHalt);
1070 signal->theData[1] = hostId;
1071 signal->header.theLength = 2;
1073 execEVENT_REP(signal);
1078 modifySignalLogger(
bool allBlocks, BlockNumber bno,
1079 TestOrd::Command cmd,
1080 TestOrd::SignalLoggerSpecification spec){
1088 case TestOrd::InputSignals:
1089 logMode = SignalLoggerManager::LogIn;
1091 case TestOrd::OutputSignals:
1092 logMode = SignalLoggerManager::LogOut;
1094 case TestOrd::InputOutputSignals:
1095 logMode = SignalLoggerManager::LogInOut;
1104 globalSignalLoggers.logOn(allBlocks, bno, logMode);
1107 globalSignalLoggers.logOff(allBlocks, bno, logMode);
1109 case TestOrd::Toggle:
1110 globalSignalLoggers.logToggle(allBlocks, bno, logMode);
1112 case TestOrd::KeepUnchanged:
1116 globalSignalLoggers.flushSignalLog();
1121 Cmvmi::execTEST_ORD(
Signal * signal){
1127 TestOrd::Command cmd;
1133 TestOrd::TraceSpecification traceSpec;
1135 testOrd->getTraceCommand(cmd, traceSpec);
1136 unsigned long traceVal = traceSpec;
1137 unsigned long currentTraceVal = globalSignalLoggers.getTrace();
1140 currentTraceVal |= traceVal;
1143 currentTraceVal &= (~traceVal);
1145 case TestOrd::Toggle:
1146 currentTraceVal ^= traceVal;
1148 case TestOrd::KeepUnchanged:
1152 globalSignalLoggers.setTrace(currentTraceVal);
1159 TestOrd::SignalLoggerSpecification logSpec;
1161 unsigned int loggers = testOrd->getNoOfSignalLoggerCommands();
1163 if(loggers == (
unsigned)~0){
1164 testOrd->getSignalLoggerCommand(0, bno, cmd, logSpec);
1165 modifySignalLogger(
true, bno, cmd, logSpec);
1167 for(
unsigned int i = 0; i<loggers; i++){
1168 testOrd->getSignalLoggerCommand(i, bno, cmd, logSpec);
1169 modifySignalLogger(
false, bno, cmd, logSpec);
1178 testOrd->getTestCommand(cmd);
1185 SET_GLOBAL_TEST_OFF;
1188 case TestOrd::Toggle:{
1189 TOGGLE_GLOBAL_TEST_FLAG;
1192 case TestOrd::KeepUnchanged:
1196 globalSignalLoggers.flushSignalLog();
1202 void Cmvmi::execSTOP_ORD(
Signal* signal)
1205 globalData.theRestartFlag = perform_stop;
1209 Cmvmi::execSTART_ORD(
Signal* signal) {
1214 if(StopReq::getPerformRestart(tmp)){
1219 NdbRestartType type = NRT_Default;
1220 if(StopReq::getNoStart(tmp) && StopReq::getInitialStart(tmp))
1221 type = NRT_NoStart_InitialStart;
1222 if(StopReq::getNoStart(tmp) && !StopReq::getInitialStart(tmp))
1223 type = NRT_NoStart_Restart;
1224 if(!StopReq::getNoStart(tmp) && StopReq::getInitialStart(tmp))
1225 type = NRT_DoStart_InitialStart;
1226 if(!StopReq::getNoStart(tmp)&&!StopReq::getInitialStart(tmp))
1227 type = NRT_DoStart_Restart;
1228 NdbShutdown(0, NST_Restart, type);
1231 if(globalData.theRestartFlag == system_started){
1240 if(globalData.theRestartFlag == perform_stop){
1253 for(
unsigned int i = 1; i < MAX_NODES; i++ )
1263 sendSignal(QMGR_REF, GSN_START_ORD, signal, 1, JBA);
1272 globalData.theRestartFlag = system_started;
1282 for(
unsigned int i = 1; i < MAX_NODES; i++ )
1287 globalTransporterRegistry.setIOState(i, HaltIO);
1291 CRASH_INSERTION(9994);
1296 sendSignal(NDBCNTR_REF, GSN_START_ORD, signal, 1, JBA);
1301 void Cmvmi::execTAMPER_ORD(
Signal* signal)
1308 Uint32 errNo = tamperOrd->errorNo;
1313 signal->theData[0] = 0;
1314 for (Uint32 i = 0; blocks[
i] != 0; i++)
1316 sendSignal(blocks[i], GSN_NDB_TAMPER, signal, 1, JBB);
1321 Uint32 tuserblockref = 0;
1328 tuserblockref = QMGR_REF;
1330 else if (errNo < 2000)
1336 tuserblockref = NDBCNTR_REF;
1338 else if (errNo < 3000)
1344 tuserblockref = NDBFS_REF;
1346 else if (errNo < 4000)
1352 tuserblockref = DBACC_REF;
1354 else if (errNo < 5000)
1360 tuserblockref = DBTUP_REF;
1362 else if (errNo < 6000)
1368 tuserblockref = DBLQH_REF;
1370 else if (errNo < 7000)
1376 tuserblockref = DBDICT_REF;
1378 else if (errNo < 8000)
1384 tuserblockref = DBDIH_REF;
1386 else if (errNo < 9000)
1392 tuserblockref = DBTC_REF;
1394 else if (errNo < 10000)
1400 tuserblockref = CMVMI_REF;
1402 else if (errNo < 11000)
1405 tuserblockref = BACKUP_REF;
1407 else if (errNo < 12000)
1412 else if (errNo < 13000)
1415 tuserblockref = DBTUX_REF;
1417 else if (errNo < 14000)
1420 tuserblockref = SUMA_REF;
1422 else if (errNo < 15000)
1425 tuserblockref = DBDICT_REF;
1427 else if (errNo < 16000)
1430 tuserblockref = LGMAN_REF;
1432 else if (errNo < 17000)
1435 tuserblockref = TSMAN_REF;
1437 else if (errNo < 18000)
1440 tuserblockref = DBSPJ_REF;
1442 else if (errNo < 19000)
1445 tuserblockref = TRIX_REF;
1447 else if (errNo < 30000)
1455 else if (errNo < 40000)
1466 signal->theData[0] = 5;
1467 signal->theData[1] = errNo;
1468 signal->theData[2] = 0;
1469 sendSignal(DBDIH_REF, GSN_DIHNDBTAMPER, signal, 3, JBB);
1472 else if (errNo < 50000)
1480 signal->theData[0] = 5;
1481 signal->theData[1] = errNo;
1482 signal->theData[2] = 0;
1483 sendSignal(DBDIH_REF, GSN_DIHNDBTAMPER, signal, 3, JBB);
1487 ndbassert(tuserblockref != 0);
1488 if (tuserblockref != 0)
1490 signal->theData[0] = errNo;
1491 sendSignal(tuserblockref, GSN_NDB_TAMPER, signal, 1, JBB);
1497 class RefSignalTest {
1514 recurse(
char * buf,
int loops,
int arg){
1515 char * tmp = (
char*)alloca(arg);
1516 printf(
"tmp = %p\n", tmp);
1517 for(iii = 0; iii<arg; iii += 1024){
1518 tmp[iii] = (iii % 23 + (arg & iii));
1524 return tmp[arg/loops] + recurse(tmp, loops - 1, arg);
1527 #define check_block(block,val) \
1528 (((val) >= DumpStateOrd::_ ## block ## Min) && ((val) <= DumpStateOrd::_ ## block ## Max))
1531 Cmvmi::execDUMP_STATE_ORD(
Signal* signal)
1534 Uint32 val = signal->theData[0];
1535 if (val >= DumpStateOrd::OneBlockOnly)
1537 if (check_block(
Backup, val))
1539 sendSignal(BACKUP_REF, GSN_DUMP_STATE_ORD, signal, signal->
length(), JBB);
1541 else if (check_block(TC, val))
1544 else if (check_block(LQH, val))
1546 sendSignal(DBLQH_REF, GSN_DUMP_STATE_ORD, signal, signal->
length(), JBB);
1551 for (Uint32 i = 0; blocks[
i] != 0; i++)
1553 sendSignal(blocks[i], GSN_DUMP_STATE_ORD, signal, signal->
length(), JBB);
1560 if(signal->theData[0] == 13){
1563 int len = (10*1024*1024);
1564 if(signal->getLength() > 1)
1565 loop = signal->theData[1];
1566 if(signal->getLength() > 2)
1567 len = signal->theData[2];
1569 ndbout_c(
"recurse(%d loop, %dkb per recurse)", loop, len/1024);
1570 int a = recurse(0, loop, len);
1571 ndbout_c(
"after...%d", a);
1576 Uint32 arg = dumpState->args[0];
1577 if (arg == DumpStateOrd::CmvmiDumpConnections){
1578 for(
unsigned int i = 1; i < MAX_NODES; i++ ){
1579 const char* nodeTypeStr =
"";
1585 nodeTypeStr =
"API";
1588 nodeTypeStr =
"MGM";
1594 nodeTypeStr =
"<UNKNOWN>";
1597 if(nodeTypeStr == 0)
1603 globalTransporterRegistry.getPerformStateString(i));
1607 if (arg == DumpStateOrd::CmvmiDumpSubscriptions)
1610 subscribers.
first(ptr);
1611 g_eventLogger->
info(
"List subscriptions:");
1612 while(ptr.i != RNIL)
1614 g_eventLogger->
info(
"Subscription: %u, nodeId: %u, ref: 0x%x",
1615 ptr.i, refToNode(ptr.p->blockRef), ptr.p->blockRef);
1616 for(Uint32 i = 0; i < LogLevel::LOGLEVEL_CATEGORIES; i++)
1618 Uint32 level = ptr.p->logLevel.getLogLevel((LogLevel::EventCategory)i);
1619 g_eventLogger->
info(
"Category %u Level %u", i, level);
1621 subscribers.
next(ptr);
1625 if (arg == DumpStateOrd::CmvmiDumpLongSignalMemory){
1626 infoEvent(
"Cmvmi: g_sectionSegmentPool size: %d free: %d",
1627 g_sectionSegmentPool.getSize(),
1628 g_sectionSegmentPool.getNoOfFree());
1631 if (dumpState->args[0] == DumpStateOrd::DumpPageMemory)
1633 const Uint32 len = signal->getLength();
1637 signal->theData[1] = 0;
1638 signal->theData[2] = ~0;
1639 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 3, JBB);
1642 reportDMUsage(signal, 0);
1643 reportIMUsage(signal, 0);
1650 Uint32 result_ref = signal->theData[1];
1651 reportDMUsage(signal, 0, result_ref);
1652 reportIMUsage(signal, 0, result_ref);
1656 Uint32
id = signal->theData[1];
1658 if (m_ctx.m_mm.get_resource_limit(
id, rl))
1660 if (rl.m_min || rl.m_curr || rl.m_max)
1662 infoEvent(
"Resource %d min: %d max: %d curr: %d",
1663 id, rl.m_min, rl.m_max, rl.m_curr);
1666 signal->theData[0] = 1000;
1667 signal->theData[1] =
id+1;
1668 signal->theData[2] = ~0;
1669 sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, 3, JBB);
1673 if (arg == DumpStateOrd::CmvmiSchedulerExecutionTimer)
1675 Uint32 exec_time = signal->theData[1];
1676 globalEmulatorData.theConfiguration->schedulerExecutionTimer(exec_time);
1678 if (arg == DumpStateOrd::CmvmiSchedulerSpinTimer)
1680 Uint32 spin_time = signal->theData[1];
1681 globalEmulatorData.theConfiguration->schedulerSpinTimer(spin_time);
1683 if (arg == DumpStateOrd::CmvmiRealtimeScheduler)
1685 bool realtime_on = signal->theData[1];
1686 globalEmulatorData.theConfiguration->realtimeScheduler(realtime_on);
1688 if (arg == DumpStateOrd::CmvmiExecuteLockCPU)
1691 if (arg == DumpStateOrd::CmvmiMaintLockCPU)
1694 if (arg == DumpStateOrd::CmvmiSetRestartOnErrorInsert)
1696 if(signal->getLength() == 1)
1698 Uint32 val = (Uint32)NRT_NoStart_Restart;
1700 m_ctx.m_config.getOwnConfigIterator();
1703 if(!ndb_mgm_get_int_parameter(p, CFG_DB_STOP_ON_ERROR_INSERT, &val))
1705 m_ctx.m_config.setRestartOnErrorInsert(val);
1710 m_ctx.m_config.setRestartOnErrorInsert(signal->theData[1]);
1714 if (arg == DumpStateOrd::CmvmiTestLongSigWithDelay) {
1716 Uint32 testType = dumpState->args[1];
1717 Uint32 loopCount = dumpState->args[2];
1718 Uint32 print = dumpState->args[3];
1719 const unsigned len0 = 11;
1720 const unsigned len1 = 123;
1723 for (i = 0; i < len0; i++)
1725 for (i = 0; i < len1; i++)
1727 Uint32* sig = signal->getDataPtrSend();
1728 sig[0] = reference();
1741 sendSignal(reference(), GSN_TESTSIG, signal, 8, JBB, ptr, 2);
1744 if (arg == DumpStateOrd::DumpEventLog)
1746 Uint32 result_ref = signal->theData[1];
1747 m_saved_event_buffer.startScan();
1751 rep->setEventType(NDB_LE_SavedEvent);
1752 rep->setNodeId(getOwnNodeId());
1753 while (m_saved_event_buffer.scan(&s, 0))
1757 signal->theData[1] = s.m_len;
1758 signal->theData[2] = s.m_seq;
1759 signal->theData[3] = s.m_time;
1763 memcpy(signal->theData+4, s.m_data, 4*s.m_len);
1764 sendSignal(result_ref, GSN_EVENT_REP, signal, 4 + s.m_len, JBB);
1770 ptr[0].p = s.m_data;
1771 ptr[0].sz = s.m_len;
1772 sendSignal(result_ref, GSN_EVENT_REP, signal, 4, JBB, ptr, 1);
1775 signal->theData[1] = 0;
1776 sendSignal(result_ref, GSN_EVENT_REP, signal, 2, JBB);
1780 if (arg == DumpStateOrd::CmvmiTestLongSig)
1783 Uint32 numArgs= signal->
length() - 1;
1784 memmove(signal->getDataPtrSend(),
1785 signal->getDataPtrSend() + 1,
1787 sendSignal(reference(), GSN_TESTSIG, signal, numArgs, JBB);
1791 if (arg == 9000 || arg == 9002)
1793 SET_ERROR_INSERT_VALUE(arg);
1794 for (Uint32 i = 1; i<signal->getLength(); i++)
1795 c_error_9000_nodes_mask.
set(signal->theData[i]);
1800 CLEAR_ERROR_INSERT_VALUE;
1801 if (signal->getLength() == 1 || signal->theData[1])
1803 for (Uint32 i = 0; i<MAX_NODES; i++)
1805 if (c_error_9000_nodes_mask.
get(i))
1807 signal->theData[0] = 0;
1808 signal->theData[1] =
i;
1813 c_error_9000_nodes_mask.
clear();
1816 if (arg == 9004 && signal->getLength() == 2)
1818 SET_ERROR_INSERT_VALUE(9004);
1819 c_error_9000_nodes_mask.
clear();
1820 c_error_9000_nodes_mask.
set(signal->theData[1]);
1823 if (arg == 9004 && signal->getLength() == 2)
1825 SET_ERROR_INSERT_VALUE(9004);
1826 c_error_9000_nodes_mask.
clear();
1827 c_error_9000_nodes_mask.
set(signal->theData[1]);
1839 tmp.init<RefSignalTest>(CMVMI, GSN_TESTSIG, 13);
1840 tmp.setWaitingFor(3);
1841 ndbrequire(!tmp.done());
1842 ndbout_c(
"Allocted");
1844 ndbrequire(!handle.done());
1847 tmp.clearWaitingFor(3);
1848 ndbrequire(tmp.done());
1849 ndbout_c(
"Deallocted");
1851 ndbrequire(handle.done());
1874 bool block = (arg == 9992);
1875 for (Uint32
n = 1;
n < signal->getLength();
n++)
1877 Uint32 nodeId = signal->theData[
n];
1880 (nodeId < MAX_NODES))
1884 ndbout_c(
"CMVMI : Blocking receive from node %u", nodeId);
1886 globalTransporterRegistry.blockReceive(nodeId);
1890 ndbout_c(
"CMVMI : Unblocking receive from node %u", nodeId);
1892 globalTransporterRegistry.unblockReceive(nodeId);
1897 ndbout_c(
"CMVMI : Ignoring dump %u for node %u",
1905 if (signal->getLength() > 1)
1907 pattern = signal->theData[1];
1908 ndbout_c(
"CMVMI : Blocking receive from all ndbds matching pattern -%s-",
1909 ((pattern == 1)?
"Other side":
"Unknown"));
1912 for (Uint32 node = 1; node < MAX_NDB_NODES; node++)
1914 if (globalTransporterRegistry.is_connected(node))
1918 if (!globalTransporterRegistry.isBlocked(node))
1927 if ((getOwnNodeId() & 1) != (node & 1))
1938 ndbout_c(
"CMVMI : Blocking receive from node %u", node);
1939 globalTransporterRegistry.blockReceive(node);
1947 for (Uint32 node = 0; node < MAX_NODES; node++)
1949 if (globalTransporterRegistry.isBlocked(node))
1951 ndbout_c(
"CMVMI : Unblocking receive from node %u", node);
1952 globalTransporterRegistry.unblockReceive(node);
1960 Uint32 delay = 1000;
1961 switch(signal->getLength()){
1965 delay = signal->theData[1];
1968 Uint32 dmin = signal->theData[1];
1969 Uint32 dmax = signal->theData[2];
1970 delay = dmin + (rand() % (dmax - dmin));
1975 signal->theData[0] = 9999;
1978 execNDB_TAMPER(signal);
1980 else if (delay < 10)
1982 sendSignal(reference(), GSN_NDB_TAMPER, signal, 1, JBB);
1986 sendSignalWithDelay(reference(), GSN_NDB_TAMPER, signal, delay, 1);
1990 if (signal->theData[0] == 666)
1994 if (signal->getLength() > 1)
1995 mb = signal->theData[1];
1997 Uint64 bytes = Uint64(mb) * 1024 * 1024;
1999 req->senderData = 666;
2000 req->senderRef = reference();
2001 req->requestInfo = AllocMemReq::RT_EXTEND;
2002 req->bytes_hi = Uint32(bytes >> 32);
2003 req->bytes_lo = Uint32(bytes);
2004 sendSignal(NDBFS_REF, GSN_ALLOC_MEM_REQ, signal,
2005 AllocMemReq::SignalLength, JBB);
2010 Cmvmi::execALLOC_MEM_REF(
Signal* signal)
2015 if (ref->senderData == 0)
2023 Cmvmi::execALLOC_MEM_CONF(
Signal* signal)
2028 if (conf->senderData == 0)
2032 init_global_page_pool();
2035 conf->senderRef = reference();
2036 conf->senderData = f_read_config_data;
2037 sendSignal(f_read_config_ref, GSN_READ_CONFIG_CONF, signal,
2038 ReadConfigConf::SignalLength, JBB);
2043 void Cmvmi::execDBINFO_SCANREQ(
Signal *signal)
2052 switch(req.tableId){
2053 case Ndbinfo::TRANSPORTERS_TABLEID:
2056 Uint32 rnode =
cursor->data[0];
2060 while(rnode < MAX_NODES)
2068 row.write_uint32(getOwnNodeId());
2069 row.write_uint32(rnode);
2070 row.write_uint32(globalTransporterRegistry.getPerformState(rnode));
2071 ndbinfo_send_row(signal, req, row, rl);
2081 if (rl.need_break(req))
2084 ndbinfo_send_scan_break(signal, req, rl, rnode);
2091 case Ndbinfo::RESOURCES_TABLEID:
2094 Uint32 resource_id =
cursor->data[0];
2097 while(m_ctx.m_mm.get_resource_limit(resource_id, resource_limit))
2101 row.write_uint32(getOwnNodeId());
2102 row.write_uint32(resource_id);
2104 row.write_uint32(resource_limit.m_min);
2105 row.write_uint32(resource_limit.m_curr);
2106 row.write_uint32(resource_limit.m_max);
2107 row.write_uint32(0);
2108 ndbinfo_send_row(signal, req, row, rl);
2111 if (rl.need_break(req))
2114 ndbinfo_send_scan_break(signal, req, rl, resource_id);
2121 case Ndbinfo::NODES_TABLEID:
2125 const Uint32 start_level = nodeState.
startLevel;
2126 const NDB_TICKS uptime = (NdbTick_CurrentMillisecond()/1000) - m_start_time;
2127 Uint32 generation = m_ctx.m_config.get_config_generation();
2130 row.write_uint32(getOwnNodeId());
2132 row.write_uint64(uptime);
2133 row.write_uint32(start_level);
2135 nodeState.starting.startPhase : 0);
2136 row.write_uint32(generation);
2137 ndbinfo_send_row(signal, req, row, rl);
2141 case Ndbinfo::POOLS_TABLEID:
2146 m_ctx.m_mm.get_resource_limit(RG_DATAMEM, res_limit);
2148 const Uint32 tup_pages_used = res_limit.m_curr - f_accpages;
2149 const Uint32 tup_pages_total = res_limit.m_min - f_accpages;
2158 { CFG_DB_DATA_MEM,0,0,0 }},
2159 { NULL, 0,0,0,0,{ 0,0,0,0 }}
2162 static const size_t num_config_params =
2163 sizeof(pools[0].config_params)/
sizeof(pools[0].config_params[0]);
2164 Uint32 pool =
cursor->data[0];
2165 BlockNumber bn = blockToMain(number());
2166 while(pools[pool].poolname)
2170 row.write_uint32(getOwnNodeId());
2171 row.write_uint32(bn);
2172 row.write_uint32(instance());
2173 row.write_string(pools[pool].poolname);
2175 row.write_uint64(pools[pool].used);
2176 row.write_uint64(pools[pool].total);
2177 row.write_uint64(pools[pool].used_hi);
2178 row.write_uint64(pools[pool].entry_size);
2179 for (
size_t i = 0; i < num_config_params; i++)
2180 row.write_uint32(pools[pool].config_params[i]);
2181 ndbinfo_send_row(signal, req, row, rl);
2183 if (rl.need_break(req))
2186 ndbinfo_send_scan_break(signal, req, rl, pool);
2196 ndbinfo_send_scan_conf(signal, req, rl);
2201 Cmvmi::execNODE_START_REP(
Signal* signal)
2204 if (ERROR_INSERTED(9002) && signal->theData[0] == getOwnNodeId())
2206 signal->theData[0] = 9001;
2207 execDUMP_STATE_ORD(signal);
2212 BLOCK_FUNCTIONS(
Cmvmi)
2220 Uint32* sigData = signal->getDataPtrSend();
2221 const Uint32 sigLength = 6;
2222 const Uint32 sectionWords = 240;
2223 Uint32 sectionData[ sectionWords ];
2225 for (Uint32 i = 0; i < sectionWords; i++)
2226 sectionData[ i ] = i;
2228 const Uint32 secCount = 1;
2230 ptr[0].sz = sectionWords;
2231 ptr[0].p = §ionData[0];
2233 for (Uint32 i = 0; i < numSigs; i++)
2235 sigData[0] = variant;
2240 sigData[5] = sectionWords;
2244 DEBUG(
"Starting linear fragmented send (" << i + 1
2245 <<
"/" << numSigs <<
")");
2249 sendFragmentedSignal(rg,
2262 DEBUG(
"Starting segmented fragmented send (" << i + 1
2263 <<
"/" << numSigs <<
")");
2265 ndbrequire(
import(segPtr, sectionData, sectionWords));
2268 sendFragmentedSignal(rg,
2281 Cmvmi::testNodeFailureCleanupCallback(
Signal* signal, Uint32 data, Uint32 elementsCleaned)
2283 DEBUG(
"testNodeFailureCleanupCallback");
2284 DEBUG(
"Data : " << data
2285 <<
" elementsCleaned : " << elementsCleaned);
2287 debugPrintFragmentCounts();
2289 Uint32 variant = data & 0xffff;
2290 Uint32 testType = (data >> 16) & 0xffff;
2292 DEBUG(
"Sending trigger(" << testType
2293 <<
") variant " << variant
2294 <<
" to self to cleanup any fragments that arrived "
2295 <<
"before send was cancelled");
2297 Uint32* sigData = signal->getDataPtrSend();
2298 sigData[0] = variant;
2299 sigData[1] = testType;
2300 sendSignal(reference(), GSN_TESTSIG, signal, 2, JBB);
2306 Cmvmi::testFragmentedCleanup(
Signal* signal,
SectionHandle* handle, Uint32 testType, Uint32 variant)
2308 DEBUG(
"TestType " << testType <<
" variant " << variant);
2309 debugPrintFragmentCounts();
2318 const Uint32 NUM_VARIANTS = 4;
2319 if (variant >= NUM_VARIANTS)
2321 DEBUG(
"Unsupported variant");
2322 releaseSections(*handle);
2341 const Uint32 sectionWords = 240;
2342 Uint32 sectionData[ sectionWords ];
2344 for (Uint32 i = 0; i < sectionWords; i++)
2345 sectionData[ i ] = i;
2347 const Uint32 secCount = 1;
2349 ptr[0].sz = sectionWords;
2350 ptr[0].p = §ionData[0];
2354 Uint32* sigData = signal->getDataPtrSend();
2355 const Uint32 sigLength = 6;
2356 const Uint32 numPartialSigs = 4;
2361 for (Uint32 i = 0; i < numPartialSigs; i++)
2364 sigData[0] = variant;
2369 sigData[5] = sectionWords;
2371 FragmentSendInfo fsi;
2373 DEBUG(
"Sending first fragment to self");
2384 DEBUG(
"Cancelling remainder to free internal section");
2385 fsi.m_status = FragmentSendInfo::SendCancelled;
2393 sigData[0] = variant;
2396 DEBUG(
"Sending node fail trigger to self");
2397 sendSignal(me, GSN_TESTSIG, signal, 2, JBB);
2404 releaseSections(*handle);
2411 BlockReference senderRef = signal->getSendersBlockRef();
2412 Uint32 sendingNode = refToNode(senderRef);
2418 DEBUG(
"Starting fragmented send using continueB back to self");
2421 startFragmentedSend(signal, variant, 6, sender);
2423 debugPrintFragmentCounts();
2425 Uint32 cbData= (((Uint32) 33) << 16) | variant;
2426 Callback cb = { safe_cast(&Cmvmi::testNodeFailureCleanupCallback),
2429 Callback* cbPtr = NULL;
2431 bool passCallback = variant & 1;
2435 DEBUG(
"Running simBlock failure code WITH CALLBACK for node "
2441 DEBUG(
"Running simBlock failure code IMMEDIATELY (no callback) for node "
2443 cbPtr = &TheEmptyCallback;
2448 DEBUG(
"Elements cleaned by call : " << elementsCleaned);
2450 debugPrintFragmentCounts();
2454 DEBUG(
"Variant " << variant <<
" manually executing callback");
2456 testNodeFailureCleanupCallback(signal,
2473 Uint32 sendingNode = refToNode(signal->getSendersBlockRef());
2474 DEBUG(
"Running simBlock failure code for node " << sendingNode);
2478 DEBUG(
"Elements cleaned : " << elementsCleaned);
2481 ndbrequire(debugPrintFragmentCounts() == 0);
2486 DEBUG(
"Starting to send fragmented continueB to all nodes inc. self : ");
2489 unsigned nodeId = 0;
2490 while((nodeId = c_dbNodes.
find(nodeId+1)) != BitmaskImpl::NotFound)
2492 DEBUG(
"Node " << nodeId);
2495 startFragmentedSend(signal, variant, 8, allNodes);
2497 debugPrintFragmentCounts();
2499 Uint32 cbData= (((Uint32) 34) << 16) | variant;
2500 Callback cb = { safe_cast(&Cmvmi::testNodeFailureCleanupCallback),
2503 Callback* cbPtr = NULL;
2505 bool passCallback = variant & 2;
2509 DEBUG(
"Running simBlock failure code for self WITH CALLBACK ("
2510 << getOwnNodeId() <<
")");
2515 DEBUG(
"Running simBlock failure code for self IMMEDIATELY (no callback) ("
2516 << getOwnNodeId() <<
")");
2517 cbPtr= &TheEmptyCallback;
2530 DEBUG(
"Elements cleaned : " << elementsCleaned);
2532 debugPrintFragmentCounts();
2540 DEBUG(
"Variant " << variant <<
" manually executing callback");
2542 testNodeFailureCleanupCallback(signal,
2555 DEBUG(
"Elements cleaned " << elementsCleaned);
2560 debugPrintFragmentCounts();
2562 DEBUG(
"Variant " << variant <<
" completed.");
2564 if (++variant < NUM_VARIANTS)
2566 DEBUG(
"Re-executing with variant " << variant);
2567 Uint32* sigData = signal->getDataPtrSend();
2568 sigData[0] = variant;
2570 sendSignal(reference(), GSN_TESTSIG, signal, 2, JBB);
2584 static Uint32 g_print;
2597 Cmvmi::execTESTSIG(
Signal* signal){
2609 Uint32 ref = signal->theData[0];
2610 Uint32 testType = signal->theData[1];
2611 Uint32 fragmentLength = signal->theData[2];
2612 g_print = signal->theData[3];
2614 Uint32 * secSizes = &signal->theData[5];
2624 ndbout_c(
"-- Fixed section --");
2625 for(i = 0; i<signal->
length(); i++){
2626 fprintf(stdout,
"H'0x%.8x ", signal->theData[i]);
2627 if(((i + 1) % 6) == 0)
2628 fprintf(stdout,
"\n");
2630 fprintf(stdout,
"\n");
2632 for(i = 0; i<handle.m_cnt; i++){
2634 ndbout_c(
"-- Section %d --", i);
2635 handle.getSection(ptr, i);
2636 ndbrequire(ptr.p != 0);
2638 ndbrequire(ptr.sz == secSizes[i]);
2645 for(i = 0; i<handle.m_cnt; i++){
2647 handle.getSection(ptr, i);
2648 ndbrequire(ptr.p != 0);
2649 ndbrequire(ptr.sz == secSizes[i]);
2655 if (testType == 20) {
2656 if (signal->theData[4] == 0) {
2657 releaseSections(handle);
2660 signal->theData[4]--;
2661 sendSignalWithDelay(reference(), GSN_TESTSIG, signal, 100, 8, &handle);
2666 ndbout_c(
"TestType=%u signal->theData[4]=%u, sendersBlockRef=%u ref=%u\n",
2667 testType, signal->theData[4], signal->getSendersBlockRef(), ref);
2674 if ((testType >= 30) &&
2677 testFragmentedCleanup(signal, &handle, testType, ref);
2681 if(signal->getSendersBlockRef() == ref){
2685 if((testType % 2) == 1){
2686 signal->theData[4] = 1;
2690 signal->theData[1] --;
2691 signal->theData[4] = rg.m_nodes.count();
2698 sendSignal(ref, GSN_TESTSIG, signal, signal->
length(), JBB,
2703 sendSignal(rg, GSN_TESTSIG, signal, signal->
length(), JBB,
2709 const Uint32 secs = handle.m_cnt;
2710 for(i = 0; i<secs; i++){
2712 handle.getSection(sptr, i);
2713 ptr[
i].sz = sptr.sz;
2714 ptr[
i].p =
new Uint32[sptr.sz];
2715 copy(ptr[i].p, sptr);
2720 sendSignal(ref, GSN_TESTSIG, signal, signal->
length(), JBB, ptr, secs);
2723 sendSignal(rg, GSN_TESTSIG, signal, signal->
length(), JBB, ptr, secs);
2725 for(Uint32 i = 0; i<secs; i++){
2728 releaseSections(handle);
2744 FragmentSendInfo fragSend;
2756 while(fragSend.m_status != FragmentSendInfo::SendComplete){
2759 ndbout_c(
"Sending fragment %d", count);
2768 const Uint32 secs = handle.m_cnt;
2769 for(i = 0; i<secs; i++){
2771 handle.getSection(sptr, i);
2772 ptr[
i].sz = sptr.sz;
2773 ptr[
i].p =
new Uint32[sptr.sz];
2774 copy(ptr[i].p, sptr);
2786 FragmentSendInfo fragSend;
2798 while(fragSend.m_status != FragmentSendInfo::SendComplete){
2801 ndbout_c(
"Sending fragment %d", count);
2805 for(i = 0; i<secs; i++){
2808 releaseSections(handle);
2815 Callback m_callBack;
2816 m_callBack.m_callbackFunction =
2817 safe_cast(&Cmvmi::sendFragmentedComplete);
2821 m_callBack.m_callbackData = 9;
2822 sendFragmentedSignal(ref,
2823 GSN_TESTSIG, signal, signal->
length(), JBB,
2829 m_callBack.m_callbackData = 10;
2830 sendFragmentedSignal(rg,
2831 GSN_TESTSIG, signal, signal->
length(), JBB,
2842 const Uint32 secs = handle.m_cnt;
2843 memset(g_test, 0,
sizeof(g_test));
2844 for(i = 0; i<secs; i++){
2846 handle.getSection(sptr, i);
2847 g_test[
i].sz = sptr.sz;
2848 g_test[
i].p =
new Uint32[sptr.sz];
2849 copy(g_test[i].p, sptr);
2852 releaseSections(handle);
2854 Callback m_callBack;
2855 m_callBack.m_callbackFunction =
2856 safe_cast(&Cmvmi::sendFragmentedComplete);
2860 m_callBack.m_callbackData = 11;
2861 sendFragmentedSignal(ref,
2862 GSN_TESTSIG, signal, signal->
length(), JBB,
2868 m_callBack.m_callbackData = 12;
2869 sendFragmentedSignal(rg,
2870 GSN_TESTSIG, signal, signal->
length(), JBB,
2889 FragmentSendInfo fragSend;
2901 while(fragSend.m_status != FragmentSendInfo::SendComplete){
2904 ndbout_c(
"Sending fragment %d", count);
2909 ndbout_c(
"Free sections : %u\n", g_sectionSegmentPool.getNoOfFree());
2910 releaseSections(handle);
2916 releaseSections(handle);
2917 ndbrequire(signal->getNoOfSections() == 0);
2918 Uint32 loop = signal->theData[9];
2920 signal->theData[9] --;
2921 sendSignal(CMVMI_REF, GSN_TESTSIG, signal, signal->
length(), JBB);
2924 sendSignal(ref, GSN_TESTSIG, signal, signal->
length(), JBB);
2928 releaseSections(handle);
2929 Uint32 count = signal->theData[8];
2930 signal->theData[10] = count * rg.m_nodes.count();
2931 for(i = 0; i<count; i++){
2932 sendSignal(rg, GSN_TESTSIG, signal, signal->
length(), JBB);
2944 Cmvmi::sendFragmentedComplete(
Signal* signal, Uint32 data, Uint32 returnCode){
2946 ndbout_c(
"sendFragmentedComplete: %d", data);
2947 if(data == 11 || data == 12){
2948 for(Uint32 i = 0; i<3; i++){
2949 if(g_test[i].p != 0)
2950 delete[] g_test[
i].p;
2957 calc_percent(Uint32 used, Uint32 total)
2959 return (total ? (used * 100)/total : 0);
2964 sum_array(
const Uint32 array[],
unsigned sz)
2967 for (
unsigned i = 0; i < sz; i++)
2983 check_threshold(Uint32 last, Uint32 now)
2985 assert(last <= 100 && now <= 100);
2987 static const Uint32 thresholds[] = { 100, 99, 90, 80, 0 };
2990 for (
size_t i = 0; i < NDB_ARRAY_SIZE(thresholds); i++)
2992 if (now >= thresholds[i])
2994 passed = thresholds[
i];
2998 assert(passed <= 100);
3008 Cmvmi::execCONTINUEB(
Signal* signal)
3010 switch(signal->theData[0]){
3011 case ZREPORT_MEMORY_USAGE:
3014 Uint32 cnt = signal->theData[1];
3015 Uint32 tup_percent_last = signal->theData[2];
3016 Uint32 acc_percent_last = signal->theData[3];
3021 m_ctx.m_mm.get_resource_limit(RG_DATAMEM, rl);
3023 const Uint32 tup_pages_used = rl.m_curr - f_accpages;
3024 const Uint32 tup_pages_total = rl.m_min - f_accpages;
3025 const Uint32 tup_percent_now = calc_percent(tup_pages_used,
3029 if ((passed = check_threshold(tup_percent_last, tup_percent_now)) != -1)
3032 reportDMUsage(signal, tup_percent_now >= tup_percent_last ? 1 : -1);
3033 tup_percent_last = passed;
3039 const Uint32 acc_pages_used =
3040 sum_array(g_acc_pages_used, NDB_ARRAY_SIZE(g_acc_pages_used));
3041 const Uint32 acc_pages_total = f_accpages * 4;
3042 const Uint32 acc_percent_now = calc_percent(acc_pages_used,
3046 if ((passed = check_threshold(acc_percent_last, acc_percent_now)) != -1)
3049 reportIMUsage(signal, acc_percent_now >= acc_percent_last ? 1 : -1);
3050 acc_percent_last = passed;
3055 if(c_memusage_report_frequency &&
3056 cnt + 1 == c_memusage_report_frequency)
3059 reportDMUsage(signal, 0);
3060 reportIMUsage(signal, 0);
3068 signal->theData[0] = ZREPORT_MEMORY_USAGE;
3069 signal->theData[1] = cnt;
3070 signal->theData[2] = tup_percent_last;
3071 signal->theData[3] = acc_percent_last;
3072 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 4);
3079 Cmvmi::reportDMUsage(
Signal* signal,
int incDec, BlockReference ref)
3082 m_ctx.m_mm.get_resource_limit(RG_DATAMEM, rl);
3084 const Uint32 tup_pages_used = rl.m_curr - f_accpages;
3085 const Uint32 tup_pages_total = rl.m_min - f_accpages;
3088 signal->theData[1] = incDec;
3090 signal->theData[3] = tup_pages_used;
3091 signal->theData[4] = tup_pages_total;
3092 signal->theData[5] = DBTUP;
3093 sendSignal(ref, GSN_EVENT_REP, signal, 6, JBB);
3098 Cmvmi::reportIMUsage(
Signal* signal,
int incDec, BlockReference ref)
3100 const Uint32 acc_pages_used =
3101 sum_array(g_acc_pages_used, NDB_ARRAY_SIZE(g_acc_pages_used));
3104 signal->theData[1] = incDec;
3105 signal->theData[2] = 8192;
3106 signal->theData[3] = acc_pages_used;
3107 signal->theData[4] = f_accpages * 4;
3108 signal->theData[5] = DBACC;
3109 sendSignal(ref, GSN_EVENT_REP, signal, 6, JBB);
3122 Cmvmi::execROUTE_ORD(
Signal* signal)
3133 Uint32 dstRef = ord->dstRef;
3134 Uint32 srcRef = ord->srcRef;
3135 Uint32 gsn = ord->gsn;
3138 Uint32 nodeId = refToNode(dstRef);
3140 if (likely((nodeId == 0) ||
3144 Uint32 secCount = handle.m_cnt;
3145 ndbrequire(secCount >= 1 && secCount <= 3);
3152 Uint32 sigLen = handle.m_ptr[0].sz;
3153 ndbrequire(sigLen <= 25);
3154 copy(signal->theData, handle.m_ptr[0]);
3157 for (Uint32 i = 0; i < secCount - 1; i++)
3158 handle.m_ptr[i] = handle.m_ptr[i+1];
3161 sendSignal(dstRef, gsn, signal, sigLen, JBB, &handle);
3164 handle.m_ptr[0] = save;
3165 releaseSections(handle);
3169 releaseSections(handle);
3171 gsn, srcRef, dstRef);
3175 void Cmvmi::execGET_CONFIG_REQ(
Signal *signal)
3181 Uint32 retRef = req->senderRef;
3183 if (retRef != signal->header.theSendersBlockRef)
3185 error = GetConfigRef::WrongSender;
3188 if (req->nodeId != getOwnNodeId())
3190 error = GetConfigRef::WrongNodeId;
3193 const Uint32 config_length = m_ctx.m_config.m_clusterConfigPacked.length();
3194 if (config_length == 0)
3196 error = GetConfigRef::NoConfig;
3204 sendSignal(retRef, GSN_GET_CONFIG_REF, signal,
3205 GetConfigRef::SignalLength, JBB);
3209 const Uint32 nSections= 1;
3211 ptr[0].p = (Uint32*)(m_ctx.m_config.m_clusterConfigPacked.get_data());
3212 ptr[0].sz = (config_length + 3) / 4;
3216 conf->configLength = config_length;
3218 sendFragmentedSignal(retRef,
3219 GSN_GET_CONFIG_CONF,
3221 GetConfigConf::SignalLength,