22 #include <ndb_limits.h>
23 #include "DblqhCommon.hpp"
25 #define DEBUG(x) { ndbout << "LQH::" << x << endl; }
27 void Dblqh::initData()
30 c_master_node_id = RNIL;
33 caddfragrecFileSize = ZADDFRAGREC_FILE_SIZE;
34 cgcprecFileSize = ZGCPREC_FILE_SIZE;
35 chostFileSize = MAX_NDB_NODES;
36 clcpFileSize = ZNO_CONCURRENT_LCP;
41 clogPartFileSize = lpinfo.partCount;
43 cpageRefFileSize = ZPAGE_REF_FILE_SIZE;
46 ctcConnectrecFileSize = 0;
47 ctcNodeFailrecFileSize = MAX_NDB_NODES;
48 cTransactionDeadlockDetectionTimeout = 100;
56 logFileOperationRecord = 0;
66 cLqhTimeOutCheckCount = 0;
71 cmaxLogFilesInPageZero = 40;
76 logMBytesInitDone = 0;
77 m_startup_report_frequency = 0;
79 c_active_add_frag_ptr_i = RNIL;
80 for (Uint32
i = 0;
i < 1024;
i++) {
81 ctransidHash[
i] = RNIL;
84 c_last_force_lcp_time = 0;
85 c_free_mb_force_lcp_limit = 16;
86 c_free_mb_tail_problem_limit = 4;
88 cTotalLqhKeyReqCount = 0;
90 c_max_redo_lag_counter = 3;
92 c_max_parallel_scans_per_frag = 32;
95 void Dblqh::initRecords()
98 addFragRecord = (AddFragRecord*)
allocRecord(
"AddFragRecord",
99 sizeof(AddFragRecord),
100 caddfragrecFileSize);
106 hostRecord = (HostRecord*)
allocRecord(
"HostRecord",
114 for(Uint32
i = 0;
i<clcpFileSize;
i++){
115 new (&lcpRecord[
i])LcpRecord();
118 logPartRecord = (LogPartRecord*)
allocRecord(
"LogPartRecord",
119 sizeof(LogPartRecord),
122 logFileRecord = (LogFileRecord*)
allocRecord(
"LogFileRecord",
123 sizeof(LogFileRecord),
126 logFileOperationRecord = (LogFileOperationRecord*)
128 sizeof(LogFileOperationRecord),
132 AllocChunk chunks[16];
133 const Uint32 chunkcnt = allocChunks(chunks, 16, RG_FILE_BUFFERS,
134 clogPageFileSize, CFG_DB_REDO_BUFFER);
138 m_shared_page_pool.
getPtr(pagePtr, chunks[0].ptrI);
139 logPageRecord = (LogPageRecord*)pagePtr.p;
142 cfirstfreeLogPage = RNIL;
143 clogPageFileSize = 0;
145 for (Int32
i = chunkcnt - 1;
i >= 0;
i--)
147 const Uint32 cnt = chunks[
i].cnt;
148 ndbrequire(cnt != 0);
151 m_shared_page_pool.
getPtr(pagePtr, chunks[
i].ptrI);
152 LogPageRecord * base = (LogPageRecord*)pagePtr.p;
153 ndbrequire(base >= logPageRecord);
154 const Uint32 ptrI = Uint32(base - logPageRecord);
156 for (Uint32 j = 0; j<cnt; j++)
159 base[j].logPageWord[ZNEXT_PAGE] = ptrI + j + 1;
160 base[j].logPageWord[ZPOS_IN_FREE_LIST]= 1;
161 base[j].logPageWord[ZPOS_IN_WRITING]= 0;
164 base[cnt-1].logPageWord[ZNEXT_PAGE] = cfirstfreeLogPage;
165 cfirstfreeLogPage = ptrI;
167 clogPageCount += cnt;
168 if (ptrI + cnt > clogPageFileSize)
169 clogPageFileSize = ptrI + cnt;
171 cnoOfLogPages = clogPageCount;
174 #ifndef NO_REDO_PAGE_CACHE
175 m_redo_page_cache.m_pool.set((RedoCacheLogPageRecord*)logPageRecord,
177 m_redo_page_cache.m_hash.setSize(63);
179 const Uint32 * base = (Uint32*)logPageRecord;
180 const RedoCacheLogPageRecord* tmp1 = (RedoCacheLogPageRecord*)logPageRecord;
181 ndbrequire(&base[ZPOS_PAGE_NO] == &tmp1->m_page_no);
182 ndbrequire(&base[ZPOS_PAGE_FILE_NO] == &tmp1->m_file_no);
185 #ifndef NO_REDO_OPEN_FILE_CACHE
186 m_redo_open_file_cache.m_pool.set(logFileRecord, clogFileFileSize);
189 pageRefRecord = (PageRefRecord*)
allocRecord(
"PageRefRecord",
190 sizeof(PageRefRecord),
193 c_scanRecordPool.
setSize(cscanrecFileSize);
194 c_scanTakeOverHash.
setSize(64);
200 tcConnectionrec = (TcConnectionrec*)
allocRecord(
"TcConnectionrec",
201 sizeof(TcConnectionrec),
202 ctcConnectrecFileSize);
204 m_commitAckMarkerPool.
setSize(ctcConnectrecFileSize);
205 m_commitAckMarkerHash.
setSize(1024);
207 tcNodeFailRecord = (TcNodeFailRecord*)
allocRecord(
"TcNodeFailRecord",
208 sizeof(TcNodeFailRecord),
209 ctcNodeFailrecFileSize);
229 bat[1].nrr = clogPageFileSize;
230 bat[1].ClusterSize =
sizeof(LogPageRecord);
231 bat[1].bits.q = ZTWOLOG_PAGE_SIZE;
236 Dblqh::getParam(
const char*
name, Uint32* count)
238 if (name != NULL && count != NULL)
245 if (strcmp(name,
"FragmentInfoPool") == 0)
253 const Uint32 TC_BLOCKS_PER_NODE = 1;
254 *count= ((MAX_NDB_NODES -1) * TC_BLOCKS_PER_NODE) + 10;
263 m_reserved_scans(c_scanRecordPool),
264 c_lcp_waiting_fragments(c_fragment_pool),
265 c_lcp_restoring_fragments(c_fragment_pool),
266 c_lcp_complete_fragments(c_fragment_pool),
267 m_commitAckMarkerHash(m_commitAckMarkerPool),
268 c_scanTakeOverHash(c_scanRecordPool)
270 BLOCK_CONSTRUCTOR(
Dblqh);
272 addRecSignal(GSN_PACKED_SIGNAL, &Dblqh::execPACKED_SIGNAL);
273 addRecSignal(GSN_DEBUG_SIG, &Dblqh::execDEBUG_SIG);
274 addRecSignal(GSN_ATTRINFO, &Dblqh::execATTRINFO);
275 addRecSignal(GSN_KEYINFO, &Dblqh::execKEYINFO);
276 addRecSignal(GSN_LQHKEYREQ, &Dblqh::execLQHKEYREQ);
277 addRecSignal(GSN_LQHKEYREF, &Dblqh::execLQHKEYREF);
278 addRecSignal(GSN_COMMIT, &Dblqh::execCOMMIT);
279 addRecSignal(GSN_COMPLETE, &Dblqh::execCOMPLETE);
280 addRecSignal(GSN_LQHKEYCONF, &Dblqh::execLQHKEYCONF);
282 addRecSignal(GSN_TESTSIG, &Dblqh::execTESTSIG);
284 addRecSignal(GSN_CONTINUEB, &Dblqh::execCONTINUEB);
285 addRecSignal(GSN_START_RECREQ, &Dblqh::execSTART_RECREQ);
286 addRecSignal(GSN_START_RECCONF, &Dblqh::execSTART_RECCONF);
287 addRecSignal(GSN_EXEC_FRAGREQ, &Dblqh::execEXEC_FRAGREQ);
288 addRecSignal(GSN_EXEC_FRAGCONF, &Dblqh::execEXEC_FRAGCONF);
289 addRecSignal(GSN_EXEC_FRAGREF, &Dblqh::execEXEC_FRAGREF);
290 addRecSignal(GSN_START_EXEC_SR, &Dblqh::execSTART_EXEC_SR);
291 addRecSignal(GSN_EXEC_SRREQ, &Dblqh::execEXEC_SRREQ);
292 addRecSignal(GSN_EXEC_SRCONF, &Dblqh::execEXEC_SRCONF);
294 addRecSignal(GSN_ALTER_TAB_REQ, &Dblqh::execALTER_TAB_REQ);
296 addRecSignal(GSN_SIGNAL_DROPPED_REP, &Dblqh::execSIGNAL_DROPPED_REP,
true);
299 addRecSignal(GSN_CREATE_TRIG_IMPL_REQ, &Dblqh::execCREATE_TRIG_IMPL_REQ);
300 addRecSignal(GSN_CREATE_TRIG_IMPL_CONF, &Dblqh::execCREATE_TRIG_IMPL_CONF);
301 addRecSignal(GSN_CREATE_TRIG_IMPL_REF, &Dblqh::execCREATE_TRIG_IMPL_REF);
303 addRecSignal(GSN_DROP_TRIG_IMPL_REQ, &Dblqh::execDROP_TRIG_IMPL_REQ);
304 addRecSignal(GSN_DROP_TRIG_IMPL_CONF, &Dblqh::execDROP_TRIG_IMPL_CONF);
305 addRecSignal(GSN_DROP_TRIG_IMPL_REF, &Dblqh::execDROP_TRIG_IMPL_REF);
307 addRecSignal(GSN_BUILD_INDX_IMPL_REF, &Dblqh::execBUILD_INDX_IMPL_REF);
308 addRecSignal(GSN_BUILD_INDX_IMPL_CONF, &Dblqh::execBUILD_INDX_IMPL_CONF);
310 addRecSignal(GSN_DUMP_STATE_ORD, &Dblqh::execDUMP_STATE_ORD);
311 addRecSignal(GSN_NODE_FAILREP, &Dblqh::execNODE_FAILREP);
312 addRecSignal(GSN_CHECK_LCP_STOP, &Dblqh::execCHECK_LCP_STOP);
313 addRecSignal(GSN_SEND_PACKED, &Dblqh::execSEND_PACKED,
true);
314 addRecSignal(GSN_TUP_ATTRINFO, &Dblqh::execTUP_ATTRINFO);
315 addRecSignal(GSN_READ_CONFIG_REQ, &Dblqh::execREAD_CONFIG_REQ,
true);
316 addRecSignal(GSN_LQHFRAGREQ, &Dblqh::execLQHFRAGREQ);
317 addRecSignal(GSN_LQHADDATTREQ, &Dblqh::execLQHADDATTREQ);
318 addRecSignal(GSN_TUP_ADD_ATTCONF, &Dblqh::execTUP_ADD_ATTCONF);
319 addRecSignal(GSN_TUP_ADD_ATTRREF, &Dblqh::execTUP_ADD_ATTRREF);
320 addRecSignal(GSN_ACCFRAGCONF, &Dblqh::execACCFRAGCONF);
321 addRecSignal(GSN_ACCFRAGREF, &Dblqh::execACCFRAGREF);
322 addRecSignal(GSN_TUPFRAGCONF, &Dblqh::execTUPFRAGCONF);
323 addRecSignal(GSN_TUPFRAGREF, &Dblqh::execTUPFRAGREF);
324 addRecSignal(GSN_TAB_COMMITREQ, &Dblqh::execTAB_COMMITREQ);
325 addRecSignal(GSN_ACCSEIZECONF, &Dblqh::execACCSEIZECONF);
326 addRecSignal(GSN_ACCSEIZEREF, &Dblqh::execACCSEIZEREF);
327 addRecSignal(GSN_READ_NODESCONF, &Dblqh::execREAD_NODESCONF);
328 addRecSignal(GSN_READ_NODESREF, &Dblqh::execREAD_NODESREF);
329 addRecSignal(GSN_STTOR, &Dblqh::execSTTOR);
330 addRecSignal(GSN_NDB_STTOR, &Dblqh::execNDB_STTOR);
331 addRecSignal(GSN_TUPSEIZECONF, &Dblqh::execTUPSEIZECONF);
332 addRecSignal(GSN_TUPSEIZEREF, &Dblqh::execTUPSEIZEREF);
333 addRecSignal(GSN_ACCKEYCONF, &Dblqh::execACCKEYCONF);
334 addRecSignal(GSN_ACCKEYREF, &Dblqh::execACCKEYREF);
335 addRecSignal(GSN_TUPKEYCONF, &Dblqh::execTUPKEYCONF);
336 addRecSignal(GSN_TUPKEYREF, &Dblqh::execTUPKEYREF);
337 addRecSignal(GSN_ABORT, &Dblqh::execABORT);
338 addRecSignal(GSN_ABORTREQ, &Dblqh::execABORTREQ);
339 addRecSignal(GSN_COMMITREQ, &Dblqh::execCOMMITREQ);
340 addRecSignal(GSN_COMPLETEREQ, &Dblqh::execCOMPLETEREQ);
342 addRecSignal(GSN_MEMCHECKREQ, &Dblqh::execMEMCHECKREQ);
344 addRecSignal(GSN_SCAN_FRAGREQ, &Dblqh::execSCAN_FRAGREQ);
345 addRecSignal(GSN_SCAN_NEXTREQ, &Dblqh::execSCAN_NEXTREQ);
346 addRecSignal(GSN_ACC_SCANCONF, &Dblqh::execACC_SCANCONF);
347 addRecSignal(GSN_ACC_SCANREF, &Dblqh::execACC_SCANREF);
348 addRecSignal(GSN_NEXT_SCANCONF, &Dblqh::execNEXT_SCANCONF);
349 addRecSignal(GSN_NEXT_SCANREF, &Dblqh::execNEXT_SCANREF);
350 addRecSignal(GSN_STORED_PROCCONF, &Dblqh::execSTORED_PROCCONF);
351 addRecSignal(GSN_STORED_PROCREF, &Dblqh::execSTORED_PROCREF);
352 addRecSignal(GSN_COPY_FRAGREQ, &Dblqh::execCOPY_FRAGREQ);
353 addRecSignal(GSN_COPY_FRAGREF, &Dblqh::execCOPY_FRAGREF);
354 addRecSignal(GSN_COPY_FRAGCONF, &Dblqh::execCOPY_FRAGCONF);
355 addRecSignal(GSN_COPY_ACTIVEREQ, &Dblqh::execCOPY_ACTIVEREQ);
356 addRecSignal(GSN_COPY_STATEREQ, &Dblqh::execCOPY_STATEREQ);
357 addRecSignal(GSN_LQH_TRANSREQ, &Dblqh::execLQH_TRANSREQ);
358 addRecSignal(GSN_TRANSID_AI, &Dblqh::execTRANSID_AI);
359 addRecSignal(GSN_INCL_NODEREQ, &Dblqh::execINCL_NODEREQ);
360 addRecSignal(GSN_LCP_PREPARE_REF, &Dblqh::execLCP_PREPARE_REF);
361 addRecSignal(GSN_LCP_PREPARE_CONF, &Dblqh::execLCP_PREPARE_CONF);
362 addRecSignal(GSN_END_LCPCONF, &Dblqh::execEND_LCPCONF);
364 addRecSignal(GSN_EMPTY_LCP_REQ, &Dblqh::execEMPTY_LCP_REQ);
365 addRecSignal(GSN_LCP_FRAG_ORD, &Dblqh::execLCP_FRAG_ORD);
367 addRecSignal(GSN_START_FRAGREQ, &Dblqh::execSTART_FRAGREQ);
368 addRecSignal(GSN_START_RECREF, &Dblqh::execSTART_RECREF);
369 addRecSignal(GSN_GCP_SAVEREQ, &Dblqh::execGCP_SAVEREQ);
370 addRecSignal(GSN_FSOPENREF, &Dblqh::execFSOPENREF,
true);
371 addRecSignal(GSN_FSOPENCONF, &Dblqh::execFSOPENCONF);
372 addRecSignal(GSN_FSCLOSECONF, &Dblqh::execFSCLOSECONF);
373 addRecSignal(GSN_FSWRITECONF, &Dblqh::execFSWRITECONF);
374 addRecSignal(GSN_FSWRITEREF, &Dblqh::execFSWRITEREF,
true);
375 addRecSignal(GSN_FSREADCONF, &Dblqh::execFSREADCONF);
376 addRecSignal(GSN_FSREADREF, &Dblqh::execFSREADREF,
true);
377 addRecSignal(GSN_ACC_ABORTCONF, &Dblqh::execACC_ABORTCONF);
378 addRecSignal(GSN_TIME_SIGNAL, &Dblqh::execTIME_SIGNAL);
379 addRecSignal(GSN_FSSYNCCONF, &Dblqh::execFSSYNCCONF);
380 addRecSignal(GSN_REMOVE_MARKER_ORD, &Dblqh::execREMOVE_MARKER_ORD);
382 addRecSignal(GSN_CREATE_TAB_REQ, &Dblqh::execCREATE_TAB_REQ);
383 addRecSignal(GSN_CREATE_TAB_REF, &Dblqh::execCREATE_TAB_REF);
384 addRecSignal(GSN_CREATE_TAB_CONF, &Dblqh::execCREATE_TAB_CONF);
386 addRecSignal(GSN_PREP_DROP_TAB_REQ, &Dblqh::execPREP_DROP_TAB_REQ);
387 addRecSignal(GSN_DROP_TAB_REQ, &Dblqh::execDROP_TAB_REQ);
388 addRecSignal(GSN_DROP_TAB_REF, &Dblqh::execDROP_TAB_REF);
389 addRecSignal(GSN_DROP_TAB_CONF, &Dblqh::execDROP_TAB_CONF);
391 addRecSignal(GSN_LQH_ALLOCREQ, &Dblqh::execLQH_ALLOCREQ);
392 addRecSignal(GSN_LQH_WRITELOG_REQ, &Dblqh::execLQH_WRITELOG_REQ);
393 addRecSignal(GSN_TUP_DEALLOCREQ, &Dblqh::execTUP_DEALLOCREQ);
396 addRecSignal(GSN_TUXFRAGCONF, &Dblqh::execTUXFRAGCONF);
397 addRecSignal(GSN_TUXFRAGREF, &Dblqh::execTUXFRAGREF);
398 addRecSignal(GSN_TUX_ADD_ATTRCONF, &Dblqh::execTUX_ADD_ATTRCONF);
399 addRecSignal(GSN_TUX_ADD_ATTRREF, &Dblqh::execTUX_ADD_ATTRREF);
401 addRecSignal(GSN_READ_PSEUDO_REQ, &Dblqh::execREAD_PSEUDO_REQ);
403 addRecSignal(GSN_DEFINE_BACKUP_REF, &Dblqh::execDEFINE_BACKUP_REF);
404 addRecSignal(GSN_DEFINE_BACKUP_CONF, &Dblqh::execDEFINE_BACKUP_CONF);
406 addRecSignal(GSN_BACKUP_FRAGMENT_REF, &Dblqh::execBACKUP_FRAGMENT_REF);
407 addRecSignal(GSN_BACKUP_FRAGMENT_CONF, &Dblqh::execBACKUP_FRAGMENT_CONF);
409 addRecSignal(GSN_RESTORE_LCP_REF, &Dblqh::execRESTORE_LCP_REF);
410 addRecSignal(GSN_RESTORE_LCP_CONF, &Dblqh::execRESTORE_LCP_CONF);
412 addRecSignal(GSN_UPDATE_FRAG_DIST_KEY_ORD,
413 &Dblqh::execUPDATE_FRAG_DIST_KEY_ORD);
415 addRecSignal(GSN_PREPARE_COPY_FRAG_REQ,
416 &Dblqh::execPREPARE_COPY_FRAG_REQ);
418 addRecSignal(GSN_DROP_FRAG_REQ, &Dblqh::execDROP_FRAG_REQ);
419 addRecSignal(GSN_DROP_FRAG_REF, &Dblqh::execDROP_FRAG_REF);
420 addRecSignal(GSN_DROP_FRAG_CONF, &Dblqh::execDROP_FRAG_CONF);
422 addRecSignal(GSN_SUB_GCP_COMPLETE_REP, &Dblqh::execSUB_GCP_COMPLETE_REP);
423 addRecSignal(GSN_FSWRITEREQ,
424 &Dblqh::execFSWRITEREQ);
425 addRecSignal(GSN_DBINFO_SCANREQ, &Dblqh::execDBINFO_SCANREQ);
427 addRecSignal(GSN_FIRE_TRIG_REQ, &Dblqh::execFIRE_TRIG_REQ);
448 init_globals_list(tmp,
sizeof(tmp)/
sizeof(tmp[0]));
456 #ifndef NO_REDO_PAGE_CACHE
457 m_redo_page_cache.m_pool.clear();
460 #ifndef NO_REDO_OPEN_FILE_CACHE
461 m_redo_open_file_cache.m_pool.clear();
466 sizeof(AddFragRecord),
467 caddfragrecFileSize);
486 sizeof(LogPartRecord),
491 sizeof(LogFileRecord),
495 "LogFileOperationRecord",
496 sizeof(LogFileOperationRecord),
501 sizeof(PageRefRecord),
512 sizeof(TcConnectionrec),
513 ctcConnectrecFileSize);
517 sizeof(TcNodeFailRecord),
518 ctcNodeFailrecFileSize);
521 BLOCK_FUNCTIONS(
Dblqh)