20 #define DBTUP_DEBUG_CPP
22 #include <RefConvert.hpp>
23 #include <ndb_limits.h>
25 #include <signaldata/DropTab.hpp>
26 #include <signaldata/DumpStateOrd.hpp>
27 #include <signaldata/EventReport.hpp>
30 #include <signaldata/DbinfoScan.hpp>
31 #include <signaldata/TransIdAI.hpp>
39 void Dbtup::execDEBUG_SIG(
Signal* signal)
43 regPagePtr.i = signal->theData[0];
44 c_page_pool.
getPtr(regPagePtr);
52 clock_gettime(CLOCK_REALTIME, tp);
59 clock_gettime(CLOCK_REALTIME, &theStopTime);
60 timer_count = (double)(1000000*((
double)theStopTime.tv_sec - (
double)tp->tv_sec)) +
61 (
double)((double)((
double)theStopTime.tv_nsec - (double)tp->tv_nsec)/(double)1000);
62 return (
int)timer_count;
72 void Dbtup::execDBINFO_SCANREQ(
Signal* signal)
82 case Ndbinfo::POOLS_TABLEID:
88 c_scanLockPool.getUsed(),
89 c_scanLockPool.getSize(),
90 c_scanLockPool.getEntrySize(),
91 c_scanLockPool.getUsedHi(),
92 { CFG_DB_NO_LOCAL_SCANS,CFG_DB_BATCH_SIZE,0,0 }},
94 c_scanOpPool.getUsed(),
95 c_scanOpPool.getSize(),
96 c_scanOpPool.getEntrySize(),
97 c_scanOpPool.getUsedHi(),
98 { CFG_DB_NO_LOCAL_SCANS,0,0,0 }},
104 { CFG_DB_NO_TRIGGERS,0,0,0 }},
106 c_storedProcPool.getUsed(),
107 c_storedProcPool.getSize(),
108 c_storedProcPool.getEntrySize(),
109 c_storedProcPool.getUsedHi(),
110 { CFG_DB_NO_LOCAL_SCANS,0,0,0 }},
112 c_buildIndexPool.getUsed(),
113 c_buildIndexPool.getSize(),
114 c_buildIndexPool.getEntrySize(),
115 c_buildIndexPool.getUsedHi(),
118 c_operation_pool.getUsed(),
119 c_operation_pool.getSize(),
120 c_operation_pool.getEntrySize(),
121 c_operation_pool.getUsedHi(),
122 { CFG_DB_NO_LOCAL_OPS,CFG_DB_NO_OPS,0,0 }},
127 m_pages_allocated_max,
128 { CFG_DB_DATA_MEM,0,0,0 }},
129 { NULL, 0,0,0,0, { 0,0,0,0 }}
132 const size_t num_config_params =
133 sizeof(pools[0].config_params) /
sizeof(pools[0].config_params[0]);
134 Uint32 pool =
cursor->data[0];
135 BlockNumber bn = blockToMain(number());
136 while(pools[pool].poolname)
140 row.write_uint32(getOwnNodeId());
141 row.write_uint32(bn);
142 row.write_uint32(instance());
143 row.write_string(pools[pool].poolname);
145 row.write_uint64(pools[pool].used);
146 row.write_uint64(pools[pool].total);
147 row.write_uint64(pools[pool].used_hi);
148 row.write_uint64(pools[pool].entry_size);
149 for (
size_t i = 0;
i < num_config_params;
i++)
150 row.write_uint32(pools[pool].config_params[
i]);
151 ndbinfo_send_row(signal, req, row, rl);
153 if (rl.need_break(req))
156 ndbinfo_send_scan_break(signal, req, rl, pool);
162 case Ndbinfo::TEST_TABLEID:
164 Uint32 counter =
cursor->data[0];
165 BlockNumber bn = blockToMain(number());
166 while(counter < 1000)
170 row.write_uint32(getOwnNodeId());
171 row.write_uint32(bn);
172 row.write_uint32(instance());
173 row.write_uint32(counter);
174 Uint64 counter2 = counter;
175 counter2 = counter2 << 32;
176 row.write_uint64(counter2);
177 ndbinfo_send_row(signal, req, row, rl);
179 if (rl.need_break(req))
182 ndbinfo_send_scan_break(signal, req, rl, counter);
192 ndbinfo_send_scan_conf(signal, req, rl);
196 static Uint32 fc_left = 0, fc_right = 0, fc_remove = 0;
200 Dbtup::execDUMP_STATE_ORD(
Signal* signal)
202 Uint32
type = signal->theData[0];
208 req->primaryTableId = 2;
209 req->secondaryTableId = RNIL;
211 req->userRef = DBDICT_REF;
212 sendSignal(cownref, GSN_REL_TABMEMREQ, signal,
213 RelTabMemReq::SignalLength, JBB);
218 req->primaryTableId = 4;
219 req->secondaryTableId = 5;
221 req->userRef = DBDICT_REF;
222 sendSignal(cownref, GSN_REL_TABMEMREQ, signal,
223 RelTabMemReq::SignalLength, JBB);
228 req->primaryTableId = 6;
229 req->secondaryTableId = 8;
231 req->userRef = DBDICT_REF;
232 sendSignal(cownref, GSN_REL_TABMEMREQ, signal,
233 RelTabMemReq::SignalLength, JBB);
238 req->primaryTableId = 2;
239 req->secondaryTableId = RNIL;
241 req->userRef = DBDICT_REF;
242 sendSignal(cownref, GSN_DROP_TABFILEREQ, signal,
243 DropTabFileReq::SignalLength, JBB);
248 req->primaryTableId = 4;
249 req->secondaryTableId = 5;
251 req->userRef = DBDICT_REF;
252 sendSignal(cownref, GSN_DROP_TABFILEREQ, signal,
253 DropTabFileReq::SignalLength, JBB);
258 req->primaryTableId = 6;
259 req->secondaryTableId = 8;
261 req->userRef = DBDICT_REF;
262 sendSignal(cownref, GSN_DROP_TABFILEREQ, signal,
263 DropTabFileReq::SignalLength, JBB);
268 if (type == DumpStateOrd::EnableUndoDelayDataWrite) {
269 ndbout <<
"Dbtup:: delay write of datapages for table = "
270 << dumpState->args[1]<< endl;
271 c_errorInsert4000TableId = dumpState->args[1];
272 SET_ERROR_INSERT_VALUE(4000);
277 if (type == 1211 || type == 1212 || type == 1213){
278 Uint32 seed = (Uint32)time(0);
279 if (signal->getLength() > 1)
280 seed = signal->theData[1];
281 ndbout_c(
"Startar modul test av Page Manager (seed: 0x%x)", seed);
285 const Uint32 LOOPS = 1000;
290 for(Uint32
i = 0;
i<LOOPS;
i++){
293 Uint32 c = (rand() % 3);
295 m_ctx.m_mm.get_resource_limit(RG_DATAMEM, rl);
296 const Uint32 free = rl.m_max - rl.m_curr;
303 alloc = 1 + (rand() % (free - 1));
305 if(chunks.size() == 0 && c == 0){
310 ndbout_c(
"loop=%d case=%d free=%d alloc=%d",
i, c, free, alloc);
315 alloc = 2 + (sum_conf >> 3) + (sum_conf >> 4);
319 const int ch = rand() % chunks.size();
320 Chunk chunk = chunks[ch];
322 returnCommonArea(chunk.pageId, chunk.pageCount);
335 allocConsPages(alloc, chunk.pageCount, chunk.pageId);
336 ndbrequire(chunk.pageCount <= alloc);
337 if(chunk.pageCount != 0){
338 chunks.push_back(chunk);
339 if(chunk.pageCount != alloc) {
341 ndbout_c(
" Tried to allocate %d - only allocated %d - free: %d",
342 alloc, chunk.pageCount, free);
345 ndbout_c(
" Failed to alloc %d pages with %d pages free",
349 sum_conf += chunk.pageCount;
350 Uint32 tot = fc_left + fc_right + fc_remove;
355 for(Uint32
i = 0;
i<chunk.pageCount;
i++){
357 pagePtr.i = chunk.pageId +
i;
358 c_page_pool.
getPtr(pagePtr);
361 if(alloc == 1 && free > 0)
363 ndbrequire(chunk.pageCount == alloc);
369 while(chunks.size() > 0){
370 Chunk chunk = chunks.back();
371 returnCommonArea(chunk.pageId, chunk.pageCount);
372 chunks.erase(chunks.size() - 1);
375 ndbout_c(
"Got %u%% of requested allocs, loops : %u 100*avg: %u max: %u",
376 (100 * sum_conf) / sum_req, sum_loop, 100*sum_loop / LOOPS,
381 if (signal->theData[0] == DumpStateOrd::SchemaResourceSnapshot)
384 Uint64 defaultValueWords= 0;
385 if (DefaultValuesFragment.i != RNIL)
386 defaultValueWords= calculate_used_var_words(DefaultValuesFragment.p);
387 Uint32 defaultValueWordsHi= (Uint32) (defaultValueWords >> 32);
388 Uint32 defaultValueWordsLo= (Uint32) (defaultValueWords & 0xFFFFFFFF);
389 RSS_OP_SNAPSHOT_SAVE(defaultValueWordsHi);
390 RSS_OP_SNAPSHOT_SAVE(defaultValueWordsLo);
392 RSS_OP_SNAPSHOT_SAVE(cnoOfFreeFragoprec);
393 RSS_OP_SNAPSHOT_SAVE(cnoOfFreeFragrec);
394 RSS_OP_SNAPSHOT_SAVE(cnoOfFreeTabDescrRec);
396 RSS_AP_SNAPSHOT_SAVE2(c_storedProcPool, c_storedProcCountNonAPI);
400 if (signal->theData[0] == DumpStateOrd::SchemaResourceCheckLeak)
403 Uint64 defaultValueWords= 0;
404 if (DefaultValuesFragment.i != RNIL)
405 defaultValueWords= calculate_used_var_words(DefaultValuesFragment.p);
406 Uint32 defaultValueWordsHi= (Uint32) (defaultValueWords >> 32);
407 Uint32 defaultValueWordsLo= (Uint32) (defaultValueWords & 0xFFFFFFFF);
408 RSS_OP_SNAPSHOT_CHECK(defaultValueWordsHi);
409 RSS_OP_SNAPSHOT_CHECK(defaultValueWordsLo);
411 RSS_OP_SNAPSHOT_CHECK(cnoOfFreeFragoprec);
412 RSS_OP_SNAPSHOT_CHECK(cnoOfFreeFragrec);
413 RSS_OP_SNAPSHOT_CHECK(cnoOfFreeTabDescrRec);
415 RSS_AP_SNAPSHOT_CHECK2(c_storedProcPool, c_storedProcCountNonAPI);
423 void Dbtup::execMEMCHECKREQ(
Signal* signal)
425 TablerecPtr regTabPtr;
427 ptrCheckGuard(regTabPtr, cnoOfTablerec, tablerec);
428 if(tablerec && regTabPtr.p->tableStatus == DEFINED)
429 validate_page(regTabPtr.p, 0);
435 Uint32* data = &signal->theData[0];
438 BlockReference blockref = signal->theData[0];
440 for (i = 0; i < 25; i++) {
444 for (i = 0; i < 16; i++) {
445 regPagePtr.i = cfreepageList[
i];
447 while (regPagePtr.i != RNIL) {
449 ptrCheckGuard(regPagePtr, cnoOfPage, cpage);
450 regPagePtr.i = regPagePtr.p->next_page;
454 sendSignal(blockref, GSN_MEMCHECKCONF, signal, 25, JBB);
463 void Dbtup::printoutTuplePage(Uint32 fragid, Uint32 pageid, Uint32 printLimit)
466 FragrecordPtr tmpFragP;
467 TablerecPtr tmpTableP;
469 c_page_pool.
getPtr(tmpPageP, pageid);
472 ptrCheckGuard(tmpFragP, cnoOfFragrec, fragrecord);
474 tmpTableP.i = tmpFragP.p->fragTableId;
475 ptrCheckGuard(tmpTableP, cnoOfTablerec, tablerec);
477 ndbout <<
"Fragid: " << fragid <<
" Pageid: " << pageid << endl
478 <<
"----------------------------------------" << endl;
480 ndbout <<
"PageHead : ";
488 out <<
"[Operationrec " << hex << &op;
490 out <<
" [fragmentPtr " << hex << op.fragmentPtr <<
"]";
492 out <<
" [op_type " << dec << op.op_struct.op_type <<
"]";
493 out <<
" [delete_insert_flag " << dec;
494 out << op.op_struct.delete_insert_flag <<
"]";
496 out <<
" [tuple_state " << dec << op.op_struct.tuple_state <<
"]";
497 out <<
" [trans_state " << dec << op.op_struct.trans_state <<
"]";
498 out <<
" [in_active_list " << dec << op.op_struct.in_active_list <<
"]";
500 out <<
" [prevActiveOp " << hex << op.prevActiveOp <<
"]";
501 out <<
" [nextActiveOp " << hex << op.nextActiveOp <<
"]";
503 out <<
" [tupVersion " << hex << op.tupVersion <<
"]";
504 out <<
" [m_tuple_location " << op.m_tuple_location <<
"]";
505 out <<
" [m_copy_tuple_location " << op.m_copy_tuple_location <<
"]";
512 operator<<(NdbOut& out,
const Dbtup::Th& th)
515 out <<
"[Th " << hex << &th;
516 out <<
" [op " << hex << th.data[i++] <<
"]";
517 out <<
" [version " << hex << (Uint16)th.data[i++] <<
"]";
529 operator<<(NdbOut& out,
const Local_key & key)
531 out <<
"[ m_page_no: " << dec << key.m_page_no
532 <<
" m_file_no: " << dec << key.m_file_no
533 <<
" m_page_idx: " << dec << key.m_page_idx <<
"]";
541 out <<
"[ null_words: " << (Uint32)off.m_null_words
542 <<
" null off: " << (Uint32)off.m_null_offset
543 <<
" disk_off: " << off.m_disk_ref_offset
544 <<
" fixheadsz: " << off.m_fix_header_size
545 <<
" max_var_off: " << off.m_max_var_offset
554 out <<
"[ total_rec_size: " << tab.total_rec_size
555 <<
" checksum: " << !!(tab.m_bits & Dbtup::Tablerec::TR_Checksum)
557 <<
" disk: " << tab.m_no_of_disk_attributes
558 <<
" mm: " << tab.m_offsets[Dbtup::MM]
559 <<
" [ fix: " << tab.m_attributes[Dbtup::MM].m_no_of_fixsize
560 <<
" var: " << tab.m_attributes[Dbtup::MM].m_no_of_varsize <<
"]"
562 <<
" dd: " << tab.m_offsets[Dbtup::DD]
563 <<
" [ fix: " << tab.m_attributes[Dbtup::DD].m_no_of_fixsize
564 <<
" var: " << tab.m_attributes[Dbtup::DD].m_no_of_varsize <<
"]"
573 memcpy(&word, &off, 4);
577 #include "AttributeOffset.hpp"
583 memcpy(&word, &off, 4);
584 out <<
"[ offset: " << AttributeOffset::getOffset(word)
585 <<
" nullpos: " << AttributeOffset::getNullFlagPos(word);
586 if(AttributeOffset::getCharsetFlag(word))
587 out <<
" charset: %d" << AttributeOffset::getCharsetPos(word);