18 #include <my_global.h>
21 #include <ndb_version.h>
24 #include <Bitmask.hpp>
26 #include <signaldata/NodeFailRep.hpp>
27 #include <signaldata/ReadNodesConf.hpp>
29 #include <signaldata/DihScanTab.hpp>
30 #include <signaldata/ScanFrag.hpp>
32 #include <signaldata/GetTabInfo.hpp>
33 #include <signaldata/DictTabInfo.hpp>
34 #include <signaldata/ListTables.hpp>
36 #include <signaldata/FsOpenReq.hpp>
37 #include <signaldata/FsAppendReq.hpp>
38 #include <signaldata/FsCloseReq.hpp>
39 #include <signaldata/FsConf.hpp>
40 #include <signaldata/FsRef.hpp>
41 #include <signaldata/FsRemoveReq.hpp>
43 #include <signaldata/BackupImpl.hpp>
44 #include <signaldata/BackupSignalData.hpp>
45 #include <signaldata/BackupContinueB.hpp>
46 #include <signaldata/EventReport.hpp>
48 #include <signaldata/UtilSequence.hpp>
50 #include <signaldata/CreateTrigImpl.hpp>
51 #include <signaldata/DropTrigImpl.hpp>
52 #include <signaldata/FireTrigOrd.hpp>
53 #include <signaldata/TrigAttrInfo.hpp>
54 #include <AttributeHeader.hpp>
56 #include <signaldata/WaitGCP.hpp>
57 #include <signaldata/LCP.hpp>
58 #include <signaldata/BackupLockTab.hpp>
59 #include <signaldata/DumpStateOrd.hpp>
61 #include <signaldata/DumpStateOrd.hpp>
63 #include <signaldata/DbinfoScan.hpp>
64 #include <signaldata/TransIdAI.hpp>
67 #include <dbtup/Dbtup.hpp>
69 static NDB_TICKS startTime;
72 #define DEBUG_OUT(x) ndbout << x << endl
80 static Uint32 g_TypeOfStart = NodeState::ST_ILLEGAL_TYPE;
82 #define SEND_BACKUP_STARTED_FLAG(A) (((A) & 0x3) > 0)
83 #define SEND_BACKUP_COMPLETED_FLAG(A) (((A) & 0x3) > 1)
86 Backup::execSTTOR(
Signal* signal)
90 const Uint32 startphase = signal->theData[1];
91 const Uint32 typeOfStart = signal->theData[7];
95 m_curr_disk_write_speed = c_defaults.m_disk_write_speed_sr;
96 m_overflow_disk_write = 0;
97 m_reset_disk_speed_time = NdbTick_CurrentMillisecond();
98 m_reset_delay_used = Backup::DISK_SPEED_CHECK_DELAY;
99 signal->theData[0] = BackupContinueB::RESET_DISK_SPEED_COUNTER;
100 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
101 Backup::DISK_SPEED_CHECK_DELAY, 1);
103 if (startphase == 3) {
105 g_TypeOfStart = typeOfStart;
106 signal->theData[0] = reference();
107 sendSignal(NDBCNTR_REF, GSN_READ_NODESREQ, signal, 1, JBB);
113 m_curr_disk_write_speed = c_defaults.m_disk_write_speed;
116 if(startphase == 7 && g_TypeOfStart == NodeState::ST_INITIAL_START &&
117 c_masterNodeId == getOwnNodeId() && !isNdbMtLqh()){
119 createSequence(signal);
128 Backup::execREAD_NODESCONF(
Signal* signal)
133 c_aliveNodes.
clear();
136 for (Uint32
i = 0;
i<MAX_NDB_NODES;
i++) {
143 ndbrequire(c_nodes.
seize(node));
156 c_masterNodeId = conf->masterNodeId;
157 ndbrequire(count == conf->noOfNodes);
162 Backup::sendSTTORRY(
Signal* signal)
164 signal->theData[0] = 0;
165 signal->theData[3] = 1;
166 signal->theData[4] = 3;
167 signal->theData[5] = 7;
168 signal->theData[6] = 255;
169 BlockReference cntrRef = !isNdbMtLqh() ? NDBCNTR_REF : BACKUP_REF;
170 sendSignal(cntrRef, GSN_STTORRY, signal, 7, JBB);
174 Backup::createSequence(
Signal* signal)
178 req->senderData = RNIL;
179 req->sequenceId = NDB_BACKUP_SEQUENCE;
180 req->requestType = UtilSequenceReq::Create;
182 sendSignal(DBUTIL_REF, GSN_UTIL_SEQUENCE_REQ,
183 signal, UtilSequenceReq::SignalLength, JBB);
187 Backup::execCONTINUEB(
Signal* signal)
190 const Uint32 Tdata0 = signal->theData[0];
191 const Uint32 Tdata1 = signal->theData[1];
192 const Uint32 Tdata2 = signal->theData[2];
195 case BackupContinueB::RESET_DISK_SPEED_COUNTER:
207 int delay_time = m_reset_delay_used;
208 NDB_TICKS curr_time = NdbTick_CurrentMillisecond();
209 int sig_delay = int(curr_time - m_reset_disk_speed_time);
211 m_words_written_this_period = m_overflow_disk_write;
212 m_overflow_disk_write = 0;
213 m_reset_disk_speed_time = curr_time;
215 if (sig_delay > delay_time + 10)
216 delay_time = Backup::DISK_SPEED_CHECK_DELAY - 10;
217 else if (sig_delay < delay_time - 10)
218 delay_time = Backup::DISK_SPEED_CHECK_DELAY + 10;
220 delay_time = Backup::DISK_SPEED_CHECK_DELAY - (sig_delay - delay_time);
221 m_reset_delay_used= delay_time;
222 signal->theData[0] = BackupContinueB::RESET_DISK_SPEED_COUNTER;
223 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, delay_time, 1);
225 ndbout <<
"Signal delay was = " << sig_delay;
226 ndbout <<
" Current time = " << curr_time << endl;
227 ndbout <<
" Delay time will be = " << delay_time << endl << endl;
231 case BackupContinueB::BACKUP_FRAGMENT_INFO:
234 const Uint32 ptr_I = Tdata1;
235 Uint32 tabPtr_I = Tdata2;
236 Uint32 fragPtr_I = signal->theData[3];
238 BackupRecordPtr ptr LINT_SET_PTR;
239 c_backupPool.
getPtr(ptr, ptr_I);
241 ptr.p->tables.getPtr(tabPtr, tabPtr_I);
243 if (fragPtr_I != tabPtr.p->fragments.getSize())
247 tabPtr.p->fragments.getPtr(fragPtr, fragPtr_I);
249 BackupFilePtr filePtr LINT_SET_PTR;
250 ptr.p->files.getPtr(filePtr, ptr.p->ctlFilePtr);
254 if (!filePtr.p->operation.dataBuffer.getWritePtr(&dst, sz))
256 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 4);
262 fragInfo->SectionType = htonl(BackupFormat::FRAGMENT_INFO);
263 fragInfo->SectionLength = htonl(sz);
264 fragInfo->TableId = htonl(fragPtr.p->tableId);
265 fragInfo->FragmentNo = htonl(fragPtr_I);
266 fragInfo->NoOfRecordsLow = htonl((Uint32)(fragPtr.p->noOfRecords & 0xFFFFFFFF));
267 fragInfo->NoOfRecordsHigh = htonl((Uint32)(fragPtr.p->noOfRecords >> 32));
268 fragInfo->FilePosLow = htonl(0);
269 fragInfo->FilePosHigh = htonl(0);
271 filePtr.p->operation.dataBuffer.updateWritePtr(sz);
276 if (fragPtr_I == tabPtr.p->fragments.getSize())
279 req->m_senderRef = reference();
280 req->m_tableId = tabPtr.p->tableId;
281 req->m_lock_unlock = BackupLockTab::UNLOCK_TABLE;
282 req->m_backup_state = BackupLockTab::BACKUP_FRAGMENT_INFO;
283 req->m_backupRecordPtr_I = ptr_I;
284 req->m_tablePtr_I = tabPtr_I;
285 sendSignal(DBDICT_REF, GSN_BACKUP_LOCK_TAB_REQ, signal,
286 BackupLockTab::SignalLength, JBB);
290 signal->theData[0] = BackupContinueB::BACKUP_FRAGMENT_INFO;
291 signal->theData[1] = ptr_I;
292 signal->theData[2] = tabPtr_I;
293 signal->theData[3] = fragPtr_I;
294 sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB);
297 case BackupContinueB::START_FILE_THREAD:
298 case BackupContinueB::BUFFER_UNDERFLOW:
301 BackupFilePtr filePtr LINT_SET_PTR;
302 c_backupFilePool.
getPtr(filePtr, Tdata1);
303 checkFile(signal, filePtr);
307 case BackupContinueB::BUFFER_FULL_SCAN:
310 BackupFilePtr filePtr LINT_SET_PTR;
311 c_backupFilePool.
getPtr(filePtr, Tdata1);
316 case BackupContinueB::BUFFER_FULL_FRAG_COMPLETE:
319 BackupFilePtr filePtr LINT_SET_PTR;
320 c_backupFilePool.
getPtr(filePtr, Tdata1);
321 fragmentCompleted(signal, filePtr);
325 case BackupContinueB::BUFFER_FULL_META:
328 BackupRecordPtr ptr LINT_SET_PTR;
329 c_backupPool.
getPtr(ptr, Tdata1);
331 BackupFilePtr filePtr LINT_SET_PTR;
332 ptr.p->files.getPtr(filePtr, ptr.p->ctlFilePtr);
337 TablePtr tabPtr LINT_SET_PTR;
340 DEBUG_OUT(
"Backup - Buffer full - "
343 <<
" (sz: " << buf.getUsableSize()
344 <<
" getMinRead: " << buf.getMinRead()
345 <<
") - tableId = " << tabPtr.p->tableId);
347 signal->theData[0] = BackupContinueB::BUFFER_FULL_META;
348 signal->theData[1] = Tdata1;
349 signal->theData[2] = Tdata2;
350 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 3);
354 TablePtr tabPtr LINT_SET_PTR;
357 req->senderRef = reference();
358 req->senderData = ptr.i;
359 req->requestType = GetTabInfoReq::RequestById |
360 GetTabInfoReq::LongSignalConf;
361 req->tableId = tabPtr.p->tableId;
362 req->schemaTransId = 0;
363 sendSignal(DBDICT_REF, GSN_GET_TABINFOREQ, signal,
364 GetTabInfoReq::SignalLength, JBB);
367 case BackupContinueB::ZDELAY_SCAN_NEXT:
368 if (ERROR_INSERTED(10039))
371 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 300,
372 signal->getLength());
378 CLEAR_ERROR_INSERT_VALUE;
379 ndbout_c(
"Resuming backup");
381 Uint32 filePtr_I = Tdata1;
382 BackupFilePtr filePtr;
383 c_backupFilePool.
getPtr(filePtr, filePtr_I);
385 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
387 findTable(ptr, tabPtr, filePtr.p->tableId);
389 tabPtr.p->fragments.getPtr(fragPtr, filePtr.p->fragmentNo);
391 BlockReference lqhRef = 0;
392 if (ptr.p->is_lcp()) {
393 lqhRef = calcInstanceBlockRef(DBLQH);
395 const Uint32 instanceKey = fragPtr.p->lqhInstanceKey;
396 ndbrequire(instanceKey != 0);
397 lqhRef = numberToRef(DBLQH, instanceKey, getOwnNodeId());
400 memmove(signal->theData, signal->theData + 2,
401 4*ScanFragNextReq::SignalLength);
403 sendSignal(lqhRef, GSN_SCAN_NEXTREQ, signal,
404 ScanFragNextReq::SignalLength, JBB);
413 Backup::execBACKUP_LOCK_TAB_CONF(
Signal *signal)
417 BackupRecordPtr ptr LINT_SET_PTR;
418 c_backupPool.
getPtr(ptr, conf->m_backupRecordPtr_I);
420 ptr.p->tables.getPtr(tabPtr, conf->m_tablePtr_I);
422 switch(conf->m_backup_state) {
423 case BackupLockTab::BACKUP_FRAGMENT_INFO:
426 ptr.p->tables.next(tabPtr);
427 if (tabPtr.i == RNIL)
434 signal->theData[0] = BackupContinueB::BACKUP_FRAGMENT_INFO;
435 signal->theData[1] = ptr.i;
436 signal->theData[2] = tabPtr.i;
437 signal->theData[3] = 0;
438 sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB);
441 case BackupLockTab::GET_TABINFO_CONF:
447 defineBackupRef(signal, ptr, conf->errorCode);
451 ptr.p->tables.next(tabPtr);
455 case BackupLockTab::CLEANUP:
458 ptr.p->tables.next(tabPtr);
459 cleanupNextTable(signal, ptr, tabPtr);
468 Backup::execBACKUP_LOCK_TAB_REF(
Signal *signal)
480 switch (signal->theData[0]) {
481 case DumpStateOrd::BackupStatus:
483 BlockReference result_ref = CMVMI_REF;
484 if (signal->
length() == 2)
485 result_ref = signal->theData[1];
489 for(c_backups.
first(ptr); ptr.i != RNIL; c_backups.
next(ptr))
491 if (!ptr.p->is_lcp())
493 reportStatus(signal, ptr, result_ref);
498 reportStatus(signal, ptr, result_ref);
508 if(signal->theData[0] == 20){
510 c_defaults.m_dataBufferSize = (signal->theData[1] * 1024 * 1024);
513 c_defaults.m_logBufferSize = (signal->theData[2] * 1024 * 1024);
516 c_defaults.m_minWriteSize = signal->theData[3] * 1024;
519 c_defaults.m_maxWriteSize = signal->theData[4] * 1024;
522 infoEvent(
"Backup: data: %d log: %d min: %d max: %d",
523 c_defaults.m_dataBufferSize,
524 c_defaults.m_logBufferSize,
525 c_defaults.m_minWriteSize,
526 c_defaults.m_maxWriteSize);
529 if(signal->theData[0] == 21){
531 req->senderData = 23;
532 req->backupDataLen = 0;
533 sendSignal(reference(), GSN_BACKUP_REQ,signal,BackupReq::SignalLength, JBB);
534 startTime = NdbTick_CurrentMillisecond();
538 if(signal->theData[0] == 22){
539 const Uint32 seq = signal->theData[1];
541 req->userReference = reference();
542 req->userPointer = 23;
544 req->ownDirectory = 1;
545 FsOpenReq::setVersion(req->fileNumber, 2);
546 FsOpenReq::setSuffix(req->fileNumber, FsOpenReq::S_CTL);
547 FsOpenReq::v2_setSequence(req->fileNumber, seq);
548 FsOpenReq::v2_setNodeId(req->fileNumber, getOwnNodeId());
549 sendSignal(NDBFS_REF, GSN_FSREMOVEREQ, signal,
550 FsRemoveReq::SignalLength, JBA);
554 if(signal->theData[0] == 23){
559 for(c_backups.
first(ptr); ptr.i != RNIL; c_backups.
next(ptr)){
560 infoEvent(
"BackupRecord %d: BackupId: %u MasterRef: %x ClientRef: %x",
561 ptr.i, ptr.p->backupId, ptr.p->masterRef, ptr.p->clientRef);
562 infoEvent(
" State: %d", ptr.p->slaveState.getState());
564 for(ptr.p->files.first(filePtr); filePtr.i != RNIL;
565 ptr.p->files.next(filePtr)){
567 infoEvent(
" file %d: type: %d flags: H'%x",
568 filePtr.i, filePtr.p->fileType,
573 ndbout_c(
"m_curr_disk_write_speed: %u m_words_written_this_period: %u m_overflow_disk_write: %u",
574 m_curr_disk_write_speed, m_words_written_this_period, m_overflow_disk_write);
575 ndbout_c(
"m_reset_delay_used: %u m_reset_disk_speed_time: %llu",
576 m_reset_delay_used, (Uint64)m_reset_disk_speed_time);
577 for(c_backups.
first(ptr); ptr.i != RNIL; c_backups.
next(ptr))
579 ndbout_c(
"BackupRecord %u: BackupId: %u MasterRef: %x ClientRef: %x",
580 ptr.i, ptr.p->backupId, ptr.p->masterRef, ptr.p->clientRef);
581 ndbout_c(
" State: %u", ptr.p->slaveState.getState());
582 ndbout_c(
" noOfByte: %llu noOfRecords: %llu",
583 ptr.p->noOfBytes, ptr.p->noOfRecords);
584 ndbout_c(
" noOfLogBytes: %llu noOfLogRecords: %llu",
585 ptr.p->noOfLogBytes, ptr.p->noOfLogRecords);
586 ndbout_c(
" errorCode: %u", ptr.p->errorCode);
588 for(ptr.p->files.first(filePtr); filePtr.i != RNIL;
589 ptr.p->files.next(filePtr))
591 ndbout_c(
" file %u: type: %u flags: H'%x tableId: %u fragmentId: %u",
592 filePtr.i, filePtr.p->fileType, filePtr.p->m_flags,
593 filePtr.p->tableId, filePtr.p->fragmentNo);
595 if (ptr.p->slaveState.getState() == SCANNING && ptr.p->dataFilePtr != RNIL)
597 c_backupFilePool.
getPtr(filePtr, ptr.p->dataFilePtr);
602 bool ready = op.dataBuffer.
getReadPtr(&tmp, &sz, &eof);
603 ndbout_c(
"ready: %s eof: %s", ready ?
"TRUE" :
"FALSE", eof ?
"TRUE" :
"FALSE");
608 if(signal->theData[0] == 24){
613 infoEvent(
"BackupPool: %d BackupFilePool: %d TablePool: %d",
614 c_backupPool.getSize(), c_backupFilePool.getSize(),
616 infoEvent(
"AttrPool: %d TriggerPool: %d FragmentPool: %d",
617 c_backupPool.getSize(), c_backupFilePool.getSize(),
620 c_pagePool.getSize());
623 if(signal->getLength() == 2 && signal->theData[1] == 2424)
629 ndbrequire(c_backups.
first(lcp));
631 ndbrequire(c_backupPool.getSize() == c_backupPool.getNoOfFree() + 1);
632 if(lcp.p->tables.isEmpty())
635 ndbrequire(c_fragmentPool.getSize() == c_fragmentPool.getNoOfFree());
636 ndbrequire(c_triggerPool.getSize() == c_triggerPool.getNoOfFree());
638 ndbrequire(c_backupFilePool.getSize() == c_backupFilePool.getNoOfFree() + 1);
640 c_backupFilePool.
getPtr(lcp_file, lcp.p->dataFilePtr);
641 ndbrequire(c_pagePool.getSize() ==
642 c_pagePool.getNoOfFree() +
643 lcp_file.p->pages.getSize());
647 if(signal->theData[0] == DumpStateOrd::DumpBackup)
650 infoEvent(
"Compressed Backup: %d", c_defaults.m_compressed_backup);
651 infoEvent(
"Compressed LCP: %d", c_defaults.m_compressed_lcp);
654 if(signal->theData[0] == DumpStateOrd::DumpBackupSetCompressed)
656 c_defaults.m_compressed_backup= signal->theData[1];
657 infoEvent(
"Compressed Backup: %d", c_defaults.m_compressed_backup);
660 if(signal->theData[0] == DumpStateOrd::DumpBackupSetCompressedLCP)
662 c_defaults.m_compressed_lcp= signal->theData[1];
663 infoEvent(
"Compressed LCP: %d", c_defaults.m_compressed_lcp);
666 if (signal->theData[0] == DumpStateOrd::BackupErrorInsert)
668 if (signal->getLength() == 1)
669 ndbout_c(
"BACKUP: setting error %u", signal->theData[1]);
671 ndbout_c(
"BACKUP: setting error %u, %u",
672 signal->theData[1], signal->theData[2]);
673 SET_ERROR_INSERT_VALUE2(signal->theData[1], signal->theData[2]);
677 void Backup::execDBINFO_SCANREQ(
Signal *signal)
687 case Ndbinfo::POOLS_TABLEID:
692 c_backupPool.getUsed(),
693 c_backupPool.getSize(),
694 c_backupPool.getEntrySize(),
695 c_backupPool.getUsedHi(),
696 { CFG_DB_PARALLEL_BACKUPS,0,0,0 }},
698 c_backupFilePool.getUsed(),
699 c_backupFilePool.getSize(),
700 c_backupFilePool.getEntrySize(),
701 c_backupFilePool.getUsedHi(),
702 { CFG_DB_PARALLEL_BACKUPS,0,0,0 }},
708 { CFG_DB_PARALLEL_BACKUPS,
710 CFG_DB_NO_ORDERED_INDEXES,
711 CFG_DB_NO_UNIQUE_HASH_INDEXES }},
713 c_triggerPool.getUsed(),
714 c_triggerPool.getSize(),
715 c_triggerPool.getEntrySize(),
716 c_triggerPool.getUsedHi(),
717 { CFG_DB_PARALLEL_BACKUPS,
719 CFG_DB_NO_ORDERED_INDEXES,
720 CFG_DB_NO_UNIQUE_HASH_INDEXES }},
722 c_fragmentPool.getUsed(),
723 c_fragmentPool.getSize(),
724 c_fragmentPool.getEntrySize(),
725 c_fragmentPool.getUsedHi(),
727 CFG_DB_NO_ORDERED_INDEXES,
728 CFG_DB_NO_UNIQUE_HASH_INDEXES,0 }},
730 c_pagePool.getUsed(),
731 c_pagePool.getSize(),
732 c_pagePool.getEntrySize(),
733 c_pagePool.getUsedHi(),
735 CFG_DB_BACKUP_DATA_BUFFER_MEM,0,0 }},
736 { NULL, 0,0,0,0, { 0,0,0,0 }}
739 const size_t num_config_params =
740 sizeof(pools[0].config_params) /
sizeof(pools[0].config_params[0]);
741 Uint32 pool =
cursor->data[0];
742 BlockNumber bn = blockToMain(number());
743 while(pools[pool].poolname)
747 row.write_uint32(getOwnNodeId());
748 row.write_uint32(bn);
749 row.write_uint32(instance());
750 row.write_string(pools[pool].poolname);
752 row.write_uint64(pools[pool].used);
753 row.write_uint64(pools[pool].total);
754 row.write_uint64(pools[pool].used_hi);
755 row.write_uint64(pools[pool].entry_size);
756 for (
size_t i = 0;
i < num_config_params;
i++)
757 row.write_uint32(pools[pool].config_params[
i]);
758 ndbinfo_send_row(signal, req, row, rl);
760 if (rl.need_break(req))
763 ndbinfo_send_scan_break(signal, req, rl, pool);
773 ndbinfo_send_scan_conf(signal, req, rl);
777 Backup::findTable(
const BackupRecordPtr & ptr,
778 TablePtr & tabPtr, Uint32 tableId)
const
780 for(ptr.p->tables.first(tabPtr);
782 ptr.p->tables.next(tabPtr)) {
784 if(tabPtr.p->tableId == tableId){
794 static Uint32 xps(Uint64 x, Uint64 ms)
797 float fs = float(ms);
799 if(ms == 0 || x == 0) {
804 return ((Uint32)(1000.0f * (fx + fs/2.1f))) / ((Uint32)fs);
808 Number(Uint64 r) { val = r;}
809 Number & operator=(Uint64 r) { val = r;
return *
this; }
814 operator<< (NdbOut & out,
const Number & val){
817 while(val.val > loop){
844 Uint32 tmp = (Uint32)((val.val + (loop >> 1)) / loop);
858 Backup::execBACKUP_CONF(
Signal* signal)
863 ndbout_c(
"Backup %u has started", conf->backupId);
872 ndbout_c(
"Backup (%u) has NOT started %d", ref->senderData, ref->errorCode);
876 Backup::execBACKUP_COMPLETE_REP(
Signal* signal)
881 startTime = NdbTick_CurrentMillisecond() - startTime;
883 ndbout_c(
"Backup %u has completed", rep->backupId);
885 rep->noOfBytesLow + (((Uint64)rep->noOfBytesHigh) << 32);
886 const Uint64 records =
887 rep->noOfRecordsLow + (((Uint64)rep->noOfRecordsHigh) << 32);
889 Number rps = xps(records, startTime);
890 Number bps = xps(bytes, startTime);
893 <<
Number(records) <<
" rows "
894 <<
Number(bytes) <<
" bytes " << startTime <<
" ms ] "
896 << rps <<
" row/s & " << bps <<
"b/s" << endl;
898 bps = xps(rep->noOfLogBytes, startTime);
899 rps = xps(rep->noOfLogRecords, startTime);
902 <<
Number(rep->noOfLogRecords) <<
" log records "
903 <<
Number(rep->noOfLogBytes) <<
" bytes " << startTime <<
" ms ] "
905 << rps <<
" records/s & " << bps <<
"b/s" << endl;
910 Backup::execBACKUP_ABORT_REP(
Signal* signal)
915 ndbout_c(
"Backup %u has been aborted %d", rep->backupId, rep->reason);
919 TriggerEvent::TE_INSERT,
920 TriggerEvent::TE_UPDATE,
921 TriggerEvent::TE_DELETE
925 Backup::validSlaveTransitions[] = {
950 Backup::validSlaveTransitionsCount =
951 sizeof(Backup::validSlaveTransitions) /
sizeof(
Backup::State);
954 Backup::CompoundState::setState(State newState){
956 const State currState = state;
957 for(
unsigned i = 0;
i<noOfValidTransitions;
i+= 2) {
959 if(validTransitions[
i] == currState &&
960 validTransitions[
i+1] == newState){
969 if (newState == INITIAL)
970 abortState = INITIAL;
971 if(newState == ABORTING && currState != ABORTING) {
973 abortState = currState;
977 if (newState != currState) {
978 ndbout_c(
"%u: Old state = %u, new state = %u, abort state = %u",
979 id, currState, newState, abortState);
985 Backup::CompoundState::forceState(
State newState)
987 const State currState = state;
988 if (newState == INITIAL)
989 abortState = INITIAL;
990 if(newState == ABORTING && currState != ABORTING) {
992 abortState = currState;
996 if (newState != currState) {
997 ndbout_c(
"%u: FORCE: Old state = %u, new state = %u, abort state = %u",
998 id, currState, newState, abortState);
1006 triggerIds[0] = ILLEGAL_TRIGGER_ID;
1007 triggerIds[1] = ILLEGAL_TRIGGER_ID;
1008 triggerIds[2] = ILLEGAL_TRIGGER_ID;
1009 triggerAllocated[0] =
false;
1010 triggerAllocated[1] =
false;
1011 triggerAllocated[2] =
false;
1020 Backup::execNODE_FAILREP(
Signal* signal)
1026 bool doStuff =
false;
1032 Uint32 theFailedNodes[NdbNodeBitmask::Size];
1033 for (Uint32
i = 0;
i < NdbNodeBitmask::Size;
i++)
1034 theFailedNodes[
i] = rep->theNodes[
i];
1036 c_masterNodeId = new_master_node_id;
1039 for(c_nodes.
first(nodePtr); nodePtr.i != RNIL; c_nodes.
next(nodePtr)) {
1042 if(nodePtr.p->alive){
1044 ndbrequire(c_aliveNodes.
get(nodePtr.p->nodeId));
1048 ndbrequire(!c_aliveNodes.
get(nodePtr.p->nodeId));
1050 nodePtr.p->alive = 0;
1051 c_aliveNodes.
clear(nodePtr.p->nodeId);
1061 ndbout_c(
"****************** Node fail rep ******************");
1064 NodeId newCoordinator = c_masterNodeId;
1065 BackupRecordPtr ptr;
1066 for(c_backups.
first(ptr); ptr.i != RNIL; c_backups.
next(ptr)) {
1072 for(
unsigned i = 1;
i < MAX_NDB_NODES;
i++) {
1078 ndbassert(elementsCleaned == 0);
1079 (void) elementsCleaned;
1085 Backup::verifyNodesAlive(BackupRecordPtr ptr,
1089 for (Uint32
i = 0;
i < MAX_NDB_NODES;
i++) {
1091 if(aNodeBitMask.
get(
i)) {
1092 if(!c_aliveNodes.
get(
i)){
1094 ptr.p->setErrorCode(AbortBackupOrd::BackupFailureDueToNodeFail);
1100 ptr.p->setErrorCode(AbortBackupOrd::IncompatibleVersions);
1112 Uint32 theFailedNodes[NdbNodeBitmask::Size])
1115 mask.
assign(2, theFailedNodes);
1121 for(c_nodes.
first(nodePtr); nodePtr.i != RNIL; c_nodes.
next(nodePtr)) {
1125 if (ptr.p->nodes.get(nodePtr.p->nodeId)) {
1127 ptr.p->nodes.clear(nodePtr.p->nodeId);
1138 if(mask.
get(refToNode(ptr.p->masterRef)))
1143 ptr.p->masterRef = reference();
1144 ptr.p->nodes.clear();
1145 ptr.p->nodes.set(getOwnNodeId());
1146 ptr.p->setErrorCode(AbortBackupOrd::BackupFailureDueToNodeFail);
1147 switch(ptr.p->m_gsn){
1148 case GSN_DEFINE_BACKUP_REQ:
1149 case GSN_START_BACKUP_REQ:
1150 case GSN_BACKUP_FRAGMENT_REQ:
1151 case GSN_STOP_BACKUP_REQ:
1153 ptr.p->masterData.gsn = ptr.p->m_gsn;
1154 ptr.p->masterData.sendCounter = ptr.p->nodes;
1156 case GSN_DEFINE_BACKUP_REF:
1157 case GSN_DEFINE_BACKUP_CONF:
1158 case GSN_START_BACKUP_REF:
1159 case GSN_START_BACKUP_CONF:
1160 case GSN_BACKUP_FRAGMENT_REF:
1161 case GSN_BACKUP_FRAGMENT_CONF:
1162 case GSN_STOP_BACKUP_REF:
1163 case GSN_STOP_BACKUP_CONF:
1164 ptr.p->masterData.gsn = GSN_DEFINE_BACKUP_REQ;
1165 masterAbort(signal, ptr);
1167 case GSN_ABORT_BACKUP_ORD:
1172 else if (newCoord == getOwnNodeId())
1178 CRASH_INSERTION((10001));
1180 ndbout_c(
"**** Master: Node failed: Master id = %u",
1181 refToNode(ptr.p->masterRef));
1184 Uint32 gsn, len, pos;
1188 ptr.p->nodes.bitANDC(mask);
1189 switch(ptr.p->masterData.gsn){
1190 case GSN_DEFINE_BACKUP_REQ:
1193 ref->backupPtr = ptr.i;
1194 ref->backupId = ptr.p->backupId;
1195 ref->errorCode = AbortBackupOrd::BackupFailureDueToNodeFail;
1196 gsn= GSN_DEFINE_BACKUP_REF;
1197 len= DefineBackupRef::SignalLength;
1198 pos= Uint32(&ref->nodeId - signal->getDataPtr());
1201 case GSN_START_BACKUP_REQ:
1204 ref->backupPtr = ptr.i;
1205 ref->backupId = ptr.p->backupId;
1206 ref->errorCode = AbortBackupOrd::BackupFailureDueToNodeFail;
1207 gsn= GSN_START_BACKUP_REF;
1208 len= StartBackupRef::SignalLength;
1209 pos= Uint32(&ref->nodeId - signal->getDataPtr());
1212 case GSN_BACKUP_FRAGMENT_REQ:
1215 ref->backupPtr = ptr.i;
1216 ref->backupId = ptr.p->backupId;
1217 ref->errorCode = AbortBackupOrd::BackupFailureDueToNodeFail;
1218 gsn= GSN_BACKUP_FRAGMENT_REF;
1219 len= BackupFragmentRef::SignalLength;
1220 pos= Uint32(&ref->nodeId - signal->getDataPtr());
1223 case GSN_STOP_BACKUP_REQ:
1226 ref->backupPtr = ptr.i;
1227 ref->backupId = ptr.p->backupId;
1228 ref->errorCode = AbortBackupOrd::BackupFailureDueToNodeFail;
1229 ref->nodeId = getOwnNodeId();
1230 gsn= GSN_STOP_BACKUP_REF;
1231 len= StopBackupRef::SignalLength;
1232 pos= Uint32(&ref->nodeId - signal->getDataPtr());
1235 case GSN_WAIT_GCP_REQ:
1236 case GSN_DROP_TRIG_IMPL_REQ:
1237 case GSN_CREATE_TRIG_IMPL_REQ:
1238 case GSN_ALTER_TRIG_IMPL_REQ:
1239 ptr.p->setErrorCode(AbortBackupOrd::BackupFailureDueToNodeFail);
1241 case GSN_UTIL_SEQUENCE_REQ:
1242 case GSN_UTIL_LOCK_REQ:
1248 for(Uint32
i = 0; (
i = mask.
find(
i+1)) != NdbNodeBitmask::NotFound; )
1250 signal->theData[pos] =
i;
1251 sendSignal(reference(), gsn, signal, len, JBB);
1253 ndbout_c(
"sending %d to self from %d", gsn,
i);
1262 CRASH_INSERTION((10021));
1266 Backup::execINCL_NODEREQ(
Signal* signal)
1270 const Uint32 senderRef = signal->theData[0];
1271 const Uint32 inclNode = signal->theData[1];
1274 for(c_nodes.
first(node); node.i != RNIL; c_nodes.
next(node)) {
1276 const Uint32 nodeId = node.p->nodeId;
1277 if(inclNode == nodeId){
1280 ndbrequire(node.p->alive == 0);
1281 ndbrequire(!c_aliveNodes.
get(nodeId));
1284 c_aliveNodes.
set(nodeId);
1289 signal->theData[0] = inclNode;
1290 signal->theData[1] = reference();
1291 sendSignal(senderRef, GSN_INCL_NODECONF, signal, 2, JBB);
1306 const Uint32 senderData = req->senderData;
1307 const BlockReference senderRef = signal->senderBlockRef();
1308 const Uint32 dataLen32 = req->backupDataLen;
1309 const Uint32
flags = signal->getLength() > 2 ? req->flags : 2;
1310 const Uint32 input_backupId = signal->getLength() > 3 ? req->inputBackupId : 0;
1312 if (getOwnNodeId() != getMasterNodeId())
1315 sendBackupRef(senderRef, flags, signal, senderData,
1316 BackupRef::IAmNotMaster);
1320 if (c_defaults.m_diskless)
1323 sendBackupRef(senderRef, flags, signal, senderData,
1324 BackupRef::CannotBackupDiskless);
1331 sendBackupRef(senderRef, flags, signal, senderData,
1332 BackupRef::BackupDefinitionNotImplemented);
1337 dumpUsedResources();
1343 c_backups.
seize(ptr);
1347 sendBackupRef(senderRef, flags, signal, senderData,
1348 BackupRef::OutOfBackupRecord);
1352 ndbrequire(ptr.p->tables.isEmpty());
1355 ptr.p->errorCode = 0;
1356 ptr.p->clientRef = senderRef;
1357 ptr.p->clientData = senderData;
1358 ptr.p->flags =
flags;
1359 ptr.p->masterRef = reference();
1360 ptr.p->nodes = c_aliveNodes;
1364 ptr.p->backupId = input_backupId;
1369 ptr.p->backupId = 0;
1371 ptr.p->backupKey[0] = 0;
1372 ptr.p->backupKey[1] = 0;
1373 ptr.p->backupDataLen = 0;
1374 ptr.p->masterData.errorCode = 0;
1376 ptr.p->masterData.sequence.retriesLeft = 3;
1377 sendUtilSequenceReq(signal, ptr);
1381 Backup::sendUtilSequenceReq(
Signal* signal, BackupRecordPtr ptr, Uint32 delay)
1386 ptr.p->masterData.gsn = GSN_UTIL_SEQUENCE_REQ;
1387 utilReq->senderData = ptr.i;
1388 utilReq->sequenceId = NDB_BACKUP_SEQUENCE;
1390 if (ptr.p->backupId)
1393 utilReq->requestType = UtilSequenceReq::SetVal;
1394 utilReq->value = ptr.p->backupId;
1399 utilReq->requestType = UtilSequenceReq::NextVal;
1405 sendSignal(DBUTIL_REF, GSN_UTIL_SEQUENCE_REQ,
1406 signal, UtilSequenceReq::SignalLength, JBB);
1411 sendSignalWithDelay(DBUTIL_REF, GSN_UTIL_SEQUENCE_REQ,
1412 signal, delay, UtilSequenceReq::SignalLength);
1417 Backup::execUTIL_SEQUENCE_REF(
Signal* signal)
1420 BackupRecordPtr ptr LINT_SET_PTR;
1422 ptr.i = utilRef->senderData;
1423 c_backupPool.
getPtr(ptr);
1424 ndbrequire(ptr.p->masterData.gsn == GSN_UTIL_SEQUENCE_REQ);
1426 if (utilRef->errorCode == UtilSequenceRef::TCError)
1429 if (ptr.p->masterData.sequence.retriesLeft > 0)
1432 infoEvent(
"BACKUP: retrying sequence on error %u",
1433 utilRef->TCErrorCode);
1434 ptr.p->masterData.sequence.retriesLeft--;
1435 sendUtilSequenceReq(signal, ptr, 300);
1439 warningEvent(
"BACKUP: aborting due to sequence error (%u, %u)",
1441 utilRef->TCErrorCode);
1443 sendBackupRef(signal, ptr, BackupRef::SequenceFailure);
1447 Backup::sendBackupRef(
Signal* signal, BackupRecordPtr ptr, Uint32 errorCode)
1450 sendBackupRef(ptr.p->clientRef, ptr.p->flags, signal,
1451 ptr.p->clientData, errorCode);
1452 cleanup(signal, ptr);
1456 Backup::sendBackupRef(BlockReference senderRef, Uint32
flags,
Signal *signal,
1457 Uint32 senderData, Uint32 errorCode)
1460 if (SEND_BACKUP_STARTED_FLAG(flags))
1464 ref->senderData = senderData;
1465 ref->errorCode = errorCode;
1466 ref->masterRef = numberToRef(BACKUP, getMasterNodeId());
1467 sendSignal(senderRef, GSN_BACKUP_REF, signal, BackupRef::SignalLength, JBB);
1470 if (errorCode != BackupRef::IAmNotMaster)
1474 signal->theData[1] = senderRef;
1475 signal->theData[2] = errorCode;
1476 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 3, JBB);
1481 Backup::execUTIL_SEQUENCE_CONF(
Signal* signal)
1487 if(conf->requestType == UtilSequenceReq::Create)
1490 sendSTTORRY(signal);
1494 BackupRecordPtr ptr LINT_SET_PTR;
1495 ptr.i = conf->senderData;
1496 c_backupPool.
getPtr(ptr);
1498 ndbrequire(ptr.p->masterData.gsn == GSN_UTIL_SEQUENCE_REQ);
1500 if (ptr.p->checkError())
1503 sendBackupRef(signal, ptr, ptr.p->errorCode);
1507 if (ERROR_INSERTED(10023))
1509 sendBackupRef(signal, ptr, 323);
1514 if(!ptr.p->backupId && conf->requestType != UtilSequenceReq::SetVal)
1517 memcpy(&backupId,conf->sequenceValue,8);
1518 ptr.p->backupId= (Uint32)backupId;
1521 ptr.p->backupKey[0] = (getOwnNodeId() << 16) | (ptr.p->backupId & 0xFFFF);
1522 ptr.p->backupKey[1] = Uint32(NdbTick_CurrentMillisecond());
1524 ptr.p->masterData.gsn = GSN_UTIL_LOCK_REQ;
1525 Mutex mutex(signal, c_mutexMgr, ptr.p->masterData.m_defineBackupMutex);
1526 Callback c = { safe_cast(&Backup::defineBackupMutex_locked), ptr.i };
1527 ndbrequire(mutex.lock(c));
1533 Backup::defineBackupMutex_locked(
Signal* signal, Uint32 ptrI, Uint32 retVal){
1535 ndbrequire(retVal == 0);
1537 BackupRecordPtr ptr LINT_SET_PTR;
1539 c_backupPool.
getPtr(ptr);
1541 ndbrequire(ptr.p->masterData.gsn == GSN_UTIL_LOCK_REQ);
1543 ptr.p->masterData.gsn = GSN_UTIL_LOCK_REQ;
1544 Mutex mutex(signal, c_mutexMgr, ptr.p->masterData.m_dictCommitTableMutex);
1545 Callback c = { safe_cast(&Backup::dictCommitTableMutex_locked), ptr.i };
1546 ndbrequire(mutex.lock(c));
1550 Backup::dictCommitTableMutex_locked(
Signal* signal, Uint32 ptrI,Uint32 retVal)
1553 ndbrequire(retVal == 0);
1558 BackupRecordPtr ptr LINT_SET_PTR;
1560 c_backupPool.
getPtr(ptr);
1562 ndbrequire(ptr.p->masterData.gsn == GSN_UTIL_LOCK_REQ);
1564 if (ERROR_INSERTED(10031)) {
1565 ptr.p->setErrorCode(331);
1568 if (ptr.p->checkError())
1576 Mutex mutex1(signal, c_mutexMgr, ptr.p->masterData.m_dictCommitTableMutex);
1581 Mutex mutex2(signal, c_mutexMgr, ptr.p->masterData.m_defineBackupMutex);
1585 sendBackupRef(signal, ptr, ptr.p->errorCode);
1599 Backup::haveAllSignals(BackupRecordPtr ptr, Uint32 gsn, Uint32 nodeId)
1601 ndbrequire(ptr.p->masterRef == reference());
1602 ndbrequire(ptr.p->masterData.gsn == gsn);
1603 ndbrequire(!ptr.p->masterData.sendCounter.done());
1604 ndbrequire(ptr.p->masterData.sendCounter.isWaitingFor(nodeId));
1606 ptr.p->masterData.sendCounter.clearWaitingFor(nodeId);
1607 return ptr.p->masterData.sendCounter.done();
1617 req->backupId = ptr.p->backupId;
1618 req->clientRef = ptr.p->clientRef;
1619 req->clientData = ptr.p->clientData;
1620 req->senderRef = reference();
1621 req->backupPtr = ptr.i;
1622 req->backupKey[0] = ptr.p->backupKey[0];
1623 req->backupKey[1] = ptr.p->backupKey[1];
1624 req->nodes = ptr.p->nodes;
1625 req->backupDataLen = ptr.p->backupDataLen;
1626 req->flags = ptr.p->flags;
1628 ptr.p->masterData.gsn = GSN_DEFINE_BACKUP_REQ;
1629 ptr.p->masterData.sendCounter = ptr.p->nodes;
1630 BlockNumber backupBlockNo = numberToBlock(BACKUP, instanceKey(ptr));
1632 sendSignal(rg, GSN_DEFINE_BACKUP_REQ, signal,
1633 DefineBackupReq::SignalLength, JBB);
1638 const Uint32 len = ptr.p->backupDataLen;
1654 Backup::execDEFINE_BACKUP_REF(
Signal* signal)
1660 const Uint32 ptrI = ref->backupPtr;
1662 const Uint32 nodeId = ref->nodeId;
1664 BackupRecordPtr ptr LINT_SET_PTR;
1665 c_backupPool.
getPtr(ptr, ptrI);
1667 ptr.p->setErrorCode(ref->errorCode);
1672 Backup::execDEFINE_BACKUP_CONF(
Signal* signal)
1677 const Uint32 ptrI = conf->backupPtr;
1679 const Uint32 nodeId = refToNode(signal->senderBlockRef());
1681 BackupRecordPtr ptr LINT_SET_PTR;
1682 c_backupPool.
getPtr(ptr, ptrI);
1684 if (ERROR_INSERTED(10024))
1686 ptr.p->setErrorCode(324);
1695 if (!haveAllSignals(ptr, GSN_DEFINE_BACKUP_REQ, nodeId)) {
1704 Mutex mutex1(signal, c_mutexMgr, ptr.p->masterData.m_dictCommitTableMutex);
1709 Mutex mutex2(signal, c_mutexMgr, ptr.p->masterData.m_defineBackupMutex);
1713 if(ptr.p->checkError())
1716 masterAbort(signal, ptr);
1720 CRASH_INSERTION((10034));
1730 ptr.p->tables.first(tabPtr);
1741 Backup::createAttributeMask(TablePtr tabPtr,
1745 for (Uint32
i = 0;
i<tabPtr.p->noOfAttributes;
i++)
1750 Backup::sendCreateTrig(
Signal* signal,
1751 BackupRecordPtr ptr, TablePtr tabPtr)
1758 for(Uint32 j=0; j<3; j++) {
1762 if(!ptr.p->triggers.seize(trigPtr)) {
1764 ptr.p->m_gsn = GSN_START_BACKUP_REF;
1766 ref->backupPtr = ptr.i;
1767 ref->backupId = ptr.p->backupId;
1768 ref->errorCode = StartBackupRef::FailedToAllocateTriggerRecord;
1769 ref->nodeId = getOwnNodeId();
1770 sendSignal(ptr.p->masterRef, GSN_START_BACKUP_REF, signal,
1771 StartBackupRef::SignalLength, JBB);
1775 const Uint32 triggerId= trigPtr.i;
1776 tabPtr.p->triggerIds[j] = triggerId;
1777 tabPtr.p->triggerAllocated[j] =
true;
1778 trigPtr.p->backupPtr = ptr.i;
1779 trigPtr.p->tableId = tabPtr.p->tableId;
1780 trigPtr.p->tab_ptr_i = tabPtr.i;
1781 trigPtr.p->logEntry = 0;
1782 trigPtr.p->event = j;
1783 trigPtr.p->maxRecordSize = 4096;
1784 trigPtr.p->operation =
1785 &ptr.p->files.getPtr(ptr.p->logFilePtr)->operation;
1786 trigPtr.p->operation->noOfBytes = 0;
1787 trigPtr.p->operation->noOfRecords = 0;
1788 trigPtr.p->errorCode = 0;
1794 ptr.p->slaveData.gsn = GSN_CREATE_TRIG_IMPL_REQ;
1795 ptr.p->slaveData.trigSendCounter = 3;
1796 ptr.p->slaveData.createTrig.tableId = tabPtr.p->tableId;
1798 req->senderRef = reference();
1799 req->receiverRef = reference();
1800 req->senderData = ptr.i;
1801 req->requestType = 0;
1804 createAttributeMask(tabPtr, attrMask);
1806 req->tableId = tabPtr.p->tableId;
1807 req->tableVersion = 0;
1808 req->indexId = RNIL;
1809 req->indexVersion = 0;
1823 if(ptr.p->flags & BackupReq::USE_UNDO_LOG)
1824 TriggerInfo::setTriggerType(ti, TriggerType::SUBSCRIPTION_BEFORE);
1826 TriggerInfo::setTriggerType(ti, TriggerType::SUBSCRIPTION);
1827 TriggerInfo::setTriggerActionTime(ti, TriggerActionTime::TA_DETACHED);
1828 TriggerInfo::setMonitorReplicas(ti,
true);
1829 TriggerInfo::setMonitorAllAttributes(ti,
false);
1831 for (
int i=0;
i < 3;
i++) {
1832 req->triggerId = tabPtr.p->triggerIds[
i];
1835 TriggerInfo::setTriggerEvent(ti2, triggerEventValues[
i]);
1836 req->triggerInfo = ti2;
1839 ptr[0].p = attrMask.rep.data;
1840 ptr[0].sz = attrMask.getSizeInWords();
1842 sendSignal(DBTUP_REF, GSN_CREATE_TRIG_IMPL_REQ,
1843 signal, CreateTrigImplReq::SignalLength, JBB, ptr ,1);
1854 const Uint32 ptrI = conf->senderData;
1855 const Uint32 tableId = conf->tableId;
1857 TriggerInfo::getTriggerEvent(conf->triggerInfo);
1860 c_backupPool.
getPtr(ptr, ptrI);
1868 ndbrequire(ptr.p->slaveData.gsn == GSN_CREATE_TRIG_IMPL_REQ);
1869 ndbrequire(ptr.p->slaveData.trigSendCounter.done() ==
false);
1870 ndbrequire(ptr.p->slaveData.createTrig.tableId == tableId);
1873 ndbrequire(findTable(ptr, tabPtr, tableId));
1874 ndbrequire(type < 3);
1886 const Uint32 ptrI = ref->senderData;
1887 const Uint32 tableId = ref->tableId;
1890 c_backupPool.
getPtr(ptr, ptrI);
1898 ndbrequire(ptr.p->slaveData.gsn == GSN_CREATE_TRIG_IMPL_REQ);
1899 ndbrequire(ptr.p->slaveData.trigSendCounter.done() ==
false);
1900 ndbrequire(ptr.p->slaveData.createTrig.tableId == tableId);
1902 ptr.p->setErrorCode(ref->errorCode);
1910 CRASH_INSERTION(10003);
1915 ptr.p->slaveData.trigSendCounter--;
1916 if(ptr.p->slaveData.trigSendCounter.done() ==
false){
1921 if (ERROR_INSERTED(10025))
1923 ptr.p->errorCode = 325;
1926 if(ptr.p->checkError()) {
1928 ptr.p->m_gsn = GSN_START_BACKUP_REF;
1930 ref->backupPtr = ptr.i;
1931 ref->backupId = ptr.p->backupId;
1932 ref->errorCode = ptr.p->errorCode;
1933 ref->nodeId = getOwnNodeId();
1934 sendSignal(ptr.p->masterRef, GSN_START_BACKUP_REF, signal,
1935 StartBackupRef::SignalLength, JBB);
1940 ndbrequire(findTable(ptr, tabPtr, ptr.p->slaveData.createTrig.tableId));
1945 ptr.p->tables.next(tabPtr);
1946 if(tabPtr.i != RNIL){
1948 sendCreateTrig(signal, ptr, tabPtr);
1957 ptr.p->m_gsn = GSN_START_BACKUP_CONF;
1959 conf->backupPtr = ptr.i;
1960 conf->backupId = ptr.p->backupId;
1961 sendSignal(ptr.p->masterRef, GSN_START_BACKUP_CONF, signal,
1962 StartBackupConf::SignalLength, JBB);
1974 ptr.p->masterData.startBackup.tablePtr = tabPtr.i;
1977 req->backupId = ptr.p->backupId;
1978 req->backupPtr = ptr.i;
1987 ptr.p->masterData.gsn = GSN_START_BACKUP_REQ;
1988 ptr.p->masterData.sendCounter = ptr.p->nodes;
1989 BlockNumber backupBlockNo = numberToBlock(BACKUP, instanceKey(ptr));
1991 sendSignal(rg, GSN_START_BACKUP_REQ, signal,
1992 StartBackupReq::SignalLength, JBB);
1996 Backup::execSTART_BACKUP_REF(
Signal* signal)
2001 const Uint32 ptrI = ref->backupPtr;
2003 const Uint32 nodeId = ref->nodeId;
2005 BackupRecordPtr ptr LINT_SET_PTR;
2006 c_backupPool.
getPtr(ptr, ptrI);
2008 ptr.p->setErrorCode(ref->errorCode);
2013 Backup::execSTART_BACKUP_CONF(
Signal* signal)
2018 const Uint32 ptrI = conf->backupPtr;
2020 const Uint32 nodeId = refToNode(signal->senderBlockRef());
2022 BackupRecordPtr ptr LINT_SET_PTR;
2023 c_backupPool.
getPtr(ptr, ptrI);
2032 CRASH_INSERTION((10004));
2034 if (!haveAllSignals(ptr, GSN_START_BACKUP_REQ, nodeId)) {
2039 if (ERROR_INSERTED(10026))
2041 ptr.p->errorCode = 326;
2044 if(ptr.p->checkError()){
2046 masterAbort(signal, ptr);
2053 if (SEND_BACKUP_STARTED_FLAG(ptr.p->flags))
2056 conf->backupId = ptr.p->backupId;
2057 conf->senderData = ptr.p->clientData;
2058 conf->nodes = ptr.p->nodes;
2059 sendSignal(ptr.p->clientRef, GSN_BACKUP_CONF, signal,
2060 BackupConf::SignalLength, JBB);
2064 signal->theData[1] = ptr.p->clientRef;
2065 signal->theData[2] = ptr.p->backupId;
2066 ptr.p->nodes.copyto(NdbNodeBitmask::Size, signal->theData+3);
2067 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 3+NdbNodeBitmask::Size, JBB);
2072 ptr.p->masterData.gsn = GSN_WAIT_GCP_REQ;
2073 ptr.p->masterData.waitGCP.startBackup =
true;
2076 waitGCPReq->senderRef = reference();
2077 waitGCPReq->senderData = ptr.i;
2080 if (ERROR_INSERTED(10041))
2082 sendSignalWithDelay(DBDIH_REF, GSN_WAIT_GCP_REQ, signal, 10*1000, WaitGCPReq::SignalLength);
2085 sendSignal(DBDIH_REF, GSN_WAIT_GCP_REQ, signal,
2086 WaitGCPReq::SignalLength,JBB);
2090 Backup::execWAIT_GCP_REF(
Signal* signal)
2094 CRASH_INSERTION((10006));
2097 const Uint32 ptrI = ref->senderData;
2099 BackupRecordPtr ptr LINT_SET_PTR;
2100 c_backupPool.
getPtr(ptr, ptrI);
2102 ndbrequire(ptr.p->masterRef == reference());
2103 ndbrequire(ptr.p->masterData.gsn == GSN_WAIT_GCP_REQ);
2106 req->senderRef = reference();
2107 req->senderData = ptr.i;
2109 sendSignal(DBDIH_REF, GSN_WAIT_GCP_REQ, signal,
2110 WaitGCPReq::SignalLength,JBB);
2117 CRASH_INSERTION((10007));
2120 const Uint32 ptrI = conf->senderData;
2121 const Uint32 gcp = conf->gci_hi;
2124 c_backupPool.
getPtr(ptr, ptrI);
2126 ndbrequire(ptr.p->masterRef == reference());
2127 ndbrequire(ptr.p->masterData.gsn == GSN_WAIT_GCP_REQ);
2129 if(ptr.p->checkError()) {
2131 masterAbort(signal, ptr);
2135 if(ptr.p->masterData.waitGCP.startBackup) {
2137 CRASH_INSERTION((10008));
2138 ptr.p->startGCP = gcp;
2139 ptr.p->masterData.sendCounter= 0;
2140 ptr.p->masterData.gsn = GSN_BACKUP_FRAGMENT_REQ;
2145 if(gcp >= ptr.p->startGCP + 3)
2147 CRASH_INSERTION((10009));
2148 ptr.p->stopGCP = gcp;
2154 sendStopBackup(signal, ptr);
2162 req->senderRef = reference();
2163 req->senderData = ptr.i;
2165 sendSignal(DBDIH_REF, GSN_WAIT_GCP_REQ, signal,
2166 WaitGCPReq::SignalLength,JBB);
2182 req->backupPtr = ptr.i;
2183 req->backupId = ptr.p->backupId;
2186 Uint32 idleNodes = nodes.
count();
2187 Uint32 saveIdleNodes = idleNodes;
2188 ndbrequire(idleNodes > 0);
2191 ptr.p->tables.first(tabPtr);
2192 for(; tabPtr.i != RNIL && idleNodes > 0; ptr.p->tables.next(tabPtr)) {
2196 const Uint32 fragCount = frags.
getSize();
2198 for(Uint32
i = 0; i<fragCount && idleNodes > 0;
i++) {
2200 tabPtr.p->fragments.getPtr(fragPtr,
i);
2201 const Uint32 nodeId = fragPtr.p->node;
2202 if(fragPtr.p->scanning != 0) {
2204 ndbrequire(nodes.
get(nodeId));
2205 nodes.
clear(nodeId);
2207 }
else if(fragPtr.p->scanned == 0 && nodes.
get(nodeId)){
2209 fragPtr.p->scanning = 1;
2210 nodes.
clear(nodeId);
2213 req->tableId = tabPtr.p->tableId;
2214 req->fragmentNo =
i;
2217 ptr.p->masterData.sendCounter++;
2218 BlockReference ref = numberToRef(BACKUP, instanceKey(ptr), nodeId);
2219 sendSignal(ref, GSN_BACKUP_FRAGMENT_REQ, signal,
2220 BackupFragmentReq::SignalLength, JBB);
2225 if(idleNodes != saveIdleNodes){
2234 ptr.p->masterData.gsn = GSN_WAIT_GCP_REQ;
2235 ptr.p->masterData.waitGCP.startBackup =
false;
2238 req->senderRef = reference();
2239 req->senderData = ptr.i;
2241 sendSignal(DBDIH_REF, GSN_WAIT_GCP_REQ, signal,
2242 WaitGCPReq::SignalLength, JBB);
2247 Backup::execBACKUP_FRAGMENT_CONF(
Signal* signal)
2251 CRASH_INSERTION((10010));
2254 const Uint32 ptrI = conf->backupPtr;
2256 const Uint32 tableId = conf->tableId;
2257 const Uint32 fragmentNo = conf->fragmentNo;
2258 const Uint32 nodeId = refToNode(signal->senderBlockRef());
2259 const Uint64 noOfBytes =
2260 conf->noOfBytesLow + (((Uint64)conf->noOfBytesHigh) << 32);
2261 const Uint64 noOfRecords =
2262 conf->noOfRecordsLow + (((Uint64)conf->noOfRecordsHigh) << 32);
2264 BackupRecordPtr ptr LINT_SET_PTR;
2265 c_backupPool.
getPtr(ptr, ptrI);
2267 ptr.p->noOfBytes += noOfBytes;
2268 ptr.p->noOfRecords += noOfRecords;
2269 ptr.p->masterData.sendCounter--;
2272 ndbrequire(findTable(ptr, tabPtr, tableId));
2274 tabPtr.p->noOfRecords += noOfRecords;
2276 FragmentPtr fragPtr;
2277 tabPtr.p->fragments.getPtr(fragPtr, fragmentNo);
2279 fragPtr.p->noOfRecords = noOfRecords;
2281 ndbrequire(fragPtr.p->scanned == 0);
2282 ndbrequire(fragPtr.p->scanning == 1);
2283 ndbrequire(fragPtr.p->node == nodeId);
2285 fragPtr.p->scanned = 1;
2286 fragPtr.p->scanning = 0;
2288 if (ERROR_INSERTED(10028))
2290 ptr.p->errorCode = 328;
2293 if(ptr.p->checkError())
2295 if(ptr.p->masterData.sendCounter.done())
2298 masterAbort(signal, ptr);
2305 nodes.
clear(getOwnNodeId());
2310 rep->backupId = ptr.p->backupId;
2311 rep->backupPtr = ptr.i;
2312 rep->tableId = tableId;
2313 rep->fragmentNo = fragmentNo;
2314 rep->noOfTableRowsLow = (Uint32)(tabPtr.p->noOfRecords & 0xFFFFFFFF);
2315 rep->noOfTableRowsHigh = (Uint32)(tabPtr.p->noOfRecords >> 32);
2316 rep->noOfFragmentRowsLow = (Uint32)(noOfRecords & 0xFFFFFFFF);
2317 rep->noOfFragmentRowsHigh = (Uint32)(noOfRecords >> 32);
2318 BlockNumber backupBlockNo = numberToBlock(BACKUP, instanceKey(ptr));
2320 sendSignal(rg, GSN_BACKUP_FRAGMENT_COMPLETE_REP, signal,
2321 BackupFragmentCompleteRep::SignalLength, JBB);
2328 Backup::execBACKUP_FRAGMENT_REF(
Signal* signal)
2332 CRASH_INSERTION((10011));
2335 const Uint32 ptrI = ref->backupPtr;
2337 const Uint32 nodeId = ref->nodeId;
2339 BackupRecordPtr ptr LINT_SET_PTR;
2340 c_backupPool.
getPtr(ptr, ptrI);
2343 ptr.p->tables.first(tabPtr);
2344 for(; tabPtr.i != RNIL; ptr.p->tables.next(tabPtr)) {
2346 FragmentPtr fragPtr;
2348 const Uint32 fragCount = frags.
getSize();
2350 for(Uint32
i = 0;
i<fragCount;
i++) {
2352 tabPtr.p->fragments.getPtr(fragPtr,
i);
2353 if(fragPtr.p->scanning != 0 && nodeId == fragPtr.p->node)
2356 ndbrequire(fragPtr.p->scanned == 0);
2357 fragPtr.p->scanned = 1;
2358 fragPtr.p->scanning = 0;
2366 ptr.p->masterData.sendCounter--;
2367 ptr.p->setErrorCode(ref->errorCode);
2369 if(ptr.p->masterData.sendCounter.done())
2372 masterAbort(signal, ptr);
2378 ord->backupId = ptr.p->backupId;
2379 ord->backupPtr = ptr.i;
2380 ord->requestType = AbortBackupOrd::LogBufferFull;
2381 ord->senderData= ptr.i;
2386 Backup::execBACKUP_FRAGMENT_COMPLETE_REP(
Signal* signal)
2392 BackupRecordPtr ptr LINT_SET_PTR;
2393 c_backupPool.
getPtr(ptr, rep->backupPtr);
2396 ndbrequire(findTable(ptr, tabPtr, rep->tableId));
2398 tabPtr.p->noOfRecords =
2399 rep->noOfTableRowsLow + (((Uint64)rep->noOfTableRowsHigh) << 32);
2401 FragmentPtr fragPtr;
2402 tabPtr.p->fragments.getPtr(fragPtr, rep->fragmentNo);
2404 fragPtr.p->noOfRecords =
2405 rep->noOfFragmentRowsLow + (((Uint64)rep->noOfFragmentRowsHigh) << 32);
2418 ptr.p->slaveData.gsn = GSN_DROP_TRIG_IMPL_REQ;
2420 if (ptr.p->slaveData.dropTrig.tableId == RNIL) {
2422 if(ptr.p->tables.count())
2423 ptr.p->tables.first(tabPtr);
2433 ndbrequire(findTable(ptr, tabPtr, ptr.p->slaveData.dropTrig.tableId));
2434 ptr.p->tables.next(tabPtr);
2436 if (tabPtr.i != RNIL) {
2444 if(ptr.p->checkError())
2448 ptr.p->errorCode = 0;
2454 ptr.p->files.getPtr(filePtr, ptr.p->logFilePtr);
2457 ndbrequire(filePtr.p->operation.dataBuffer.getWritePtr(&dst, 1));
2459 filePtr.p->operation.dataBuffer.updateWritePtr(1);
2464 ptr.p->files.getPtr(filePtr, ptr.p->ctlFilePtr);
2470 ndbrequire(filePtr.p->operation.dataBuffer.getWritePtr(&dst, gcpSz));
2475 gcp->SectionType = htonl(BackupFormat::GCP_ENTRY);
2476 gcp->SectionLength = htonl(gcpSz);
2477 gcp->StartGCP = htonl(ptr.p->startGCP);
2478 gcp->StopGCP = htonl(ptr.p->stopGCP - 1);
2479 filePtr.p->operation.dataBuffer.updateWritePtr(gcpSz);
2483 if (ptr.p->tables.first(tabPtr))
2486 signal->theData[0] = BackupContinueB::BACKUP_FRAGMENT_INFO;
2487 signal->theData[1] = ptr.i;
2488 signal->theData[2] = tabPtr.i;
2489 signal->theData[3] = 0;
2490 sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB);
2508 ptr.p->slaveData.gsn = GSN_DROP_TRIG_IMPL_REQ;
2509 ptr.p->slaveData.trigSendCounter = 0;
2510 req->senderRef = reference();
2511 req->senderData = ptr.i;
2512 req->requestType = 0;
2513 req->tableId = tabPtr.p->tableId;
2514 req->tableVersion = 0;
2515 req->indexId = RNIL;
2516 req->indexVersion = 0;
2517 req->receiverRef = reference();
2521 if(ptr.p->flags & BackupReq::USE_UNDO_LOG)
2522 TriggerInfo::setTriggerType(ti, TriggerType::SUBSCRIPTION_BEFORE);
2524 TriggerInfo::setTriggerType(ti, TriggerType::SUBSCRIPTION);
2525 TriggerInfo::setTriggerActionTime(ti, TriggerActionTime::TA_DETACHED);
2526 TriggerInfo::setMonitorReplicas(ti,
true);
2527 TriggerInfo::setMonitorAllAttributes(ti,
false);
2529 ptr.p->slaveData.dropTrig.tableId = tabPtr.p->tableId;
2530 req->tableId = tabPtr.p->tableId;
2532 for (
int i = 0;
i < 3;
i++) {
2533 Uint32
id = tabPtr.p->triggerIds[
i];
2534 req->triggerId =
id;
2537 TriggerInfo::setTriggerEvent(ti2, triggerEventValues[
i]);
2538 req->triggerInfo = ti2;
2540 sendSignal(DBTUP_REF, GSN_DROP_TRIG_IMPL_REQ,
2541 signal, DropTrigImplReq::SignalLength, JBB);
2542 ptr.p->slaveData.trigSendCounter ++;
2547 Backup::execDROP_TRIG_IMPL_REF(
Signal* signal)
2552 const Uint32 ptrI = ref->senderData;
2554 BackupRecordPtr ptr LINT_SET_PTR;
2555 c_backupPool.
getPtr(ptr, ptrI);
2557 if(ref->triggerId != ~(Uint32) 0)
2559 ndbout <<
"ERROR DROPPING TRIGGER: " << ref->triggerId;
2560 ndbout <<
" Err: " << ref->errorCode << endl << endl;
2563 dropTrigReply(signal, ptr);
2567 Backup::execDROP_TRIG_IMPL_CONF(
Signal* signal)
2572 const Uint32 ptrI = conf->senderData;
2574 BackupRecordPtr ptr LINT_SET_PTR;
2575 c_backupPool.
getPtr(ptr, ptrI);
2577 dropTrigReply(signal, ptr);
2581 Backup::dropTrigReply(
Signal* signal, BackupRecordPtr ptr)
2583 CRASH_INSERTION((10012));
2585 ndbrequire(ptr.p->slaveData.gsn == GSN_DROP_TRIG_IMPL_REQ);
2586 ndbrequire(ptr.p->slaveData.trigSendCounter.done() ==
false);
2589 ptr.p->slaveData.trigSendCounter--;
2590 if(ptr.p->slaveData.trigSendCounter.done() ==
false){
2604 Backup::execSTOP_BACKUP_REF(
Signal* signal)
2609 const Uint32 ptrI = ref->backupPtr;
2611 const Uint32 nodeId = ref->nodeId;
2613 BackupRecordPtr ptr LINT_SET_PTR;
2614 c_backupPool.
getPtr(ptr, ptrI);
2616 ptr.p->setErrorCode(ref->errorCode);
2617 stopBackupReply(signal, ptr, nodeId);
2621 Backup::sendStopBackup(
Signal* signal, BackupRecordPtr ptr)
2626 stop->backupPtr = ptr.i;
2627 stop->backupId = ptr.p->backupId;
2628 stop->startGCP = ptr.p->startGCP;
2629 stop->stopGCP = ptr.p->stopGCP;
2631 ptr.p->masterData.gsn = GSN_STOP_BACKUP_REQ;
2632 ptr.p->masterData.sendCounter = ptr.p->nodes;
2633 BlockNumber backupBlockNo = numberToBlock(BACKUP, instanceKey(ptr));
2635 sendSignal(rg, GSN_STOP_BACKUP_REQ, signal,
2636 StopBackupReq::SignalLength, JBB);
2640 Backup::execSTOP_BACKUP_CONF(
Signal* signal)
2645 const Uint32 ptrI = conf->backupPtr;
2647 const Uint32 nodeId = refToNode(signal->senderBlockRef());
2649 BackupRecordPtr ptr LINT_SET_PTR;
2650 c_backupPool.
getPtr(ptr, ptrI);
2652 ptr.p->noOfLogBytes += conf->noOfLogBytes;
2653 ptr.p->noOfLogRecords += conf->noOfLogRecords;
2655 stopBackupReply(signal, ptr, nodeId);
2659 Backup::stopBackupReply(
Signal* signal, BackupRecordPtr ptr, Uint32 nodeId)
2661 CRASH_INSERTION((10013));
2663 if (!haveAllSignals(ptr, GSN_STOP_BACKUP_REQ, nodeId)) {
2668 sendAbortBackupOrd(signal, ptr, AbortBackupOrd::BackupComplete);
2670 if(!ptr.p->checkError() && ptr.p->masterData.errorCode == 0)
2672 if (SEND_BACKUP_COMPLETED_FLAG(ptr.p->flags))
2675 rep->backupId = ptr.p->backupId;
2676 rep->senderData = ptr.p->clientData;
2677 rep->startGCP = ptr.p->startGCP;
2678 rep->stopGCP = ptr.p->stopGCP;
2679 rep->noOfBytesLow = (Uint32)(ptr.p->noOfBytes & 0xFFFFFFFF);
2680 rep->noOfRecordsLow = (Uint32)(ptr.p->noOfRecords & 0xFFFFFFFF);
2681 rep->noOfBytesHigh = (Uint32)(ptr.p->noOfBytes >> 32);
2682 rep->noOfRecordsHigh = (Uint32)(ptr.p->noOfRecords >> 32);
2683 rep->noOfLogBytes = Uint32(ptr.p->noOfLogBytes);
2684 rep->noOfLogRecords = Uint32(ptr.p->noOfLogRecords);
2685 rep->nodes = ptr.p->nodes;
2686 sendSignal(ptr.p->clientRef, GSN_BACKUP_COMPLETE_REP, signal,
2687 BackupCompleteRep::SignalLength, JBB);
2691 signal->theData[1] = ptr.p->clientRef;
2692 signal->theData[2] = ptr.p->backupId;
2693 signal->theData[3] = ptr.p->startGCP;
2694 signal->theData[4] = ptr.p->stopGCP;
2695 signal->theData[5] = (Uint32)(ptr.p->noOfBytes & 0xFFFFFFFF);
2696 signal->theData[6] = (Uint32)(ptr.p->noOfRecords & 0xFFFFFFFF);
2697 signal->theData[7] = (Uint32)(ptr.p->noOfLogBytes & 0xFFFFFFFF);
2698 signal->theData[8] = (Uint32)(ptr.p->noOfLogRecords & 0xFFFFFFFF);
2699 ptr.p->nodes.copyto(NdbNodeBitmask::Size, signal->theData+9);
2700 signal->theData[9+NdbNodeBitmask::Size] = (Uint32)(ptr.p->noOfBytes >> 32);
2701 signal->theData[10+NdbNodeBitmask::Size] = (Uint32)(ptr.p->noOfRecords >> 32);
2702 signal->theData[11+NdbNodeBitmask::Size] = (Uint32)(ptr.p->noOfLogBytes >> 32);
2703 signal->theData[12+NdbNodeBitmask::Size] = (Uint32)(ptr.p->noOfLogRecords >> 32);
2704 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 13+NdbNodeBitmask::Size, JBB);
2708 masterAbort(signal, ptr);
2713 Backup::initReportStatus(
Signal *signal, BackupRecordPtr ptr)
2715 Uint64 now = NdbTick_CurrentMillisecond() / 1000;
2716 ptr.p->m_next_report = now + m_backup_report_frequency;
2720 Backup::checkReportStatus(
Signal *signal, BackupRecordPtr ptr)
2722 if (m_backup_report_frequency == 0)
2725 Uint64 now = NdbTick_CurrentMillisecond() / 1000;
2726 if (now > ptr.p->m_next_report)
2728 reportStatus(signal, ptr);
2729 ptr.p->m_next_report = now + m_backup_report_frequency;
2734 Backup::reportStatus(
Signal* signal, BackupRecordPtr ptr,
2737 const int signal_length = 11;
2740 for (
int i= 1;
i < signal_length;
i++)
2741 signal->theData[
i] = 0;
2743 if (ptr.i == RNIL ||
2744 (ptr.p->m_gsn == 0 &&
2745 ptr.p->masterData.gsn == 0))
2747 sendSignal(ref, GSN_EVENT_REP, signal, signal_length, JBB);
2750 signal->theData[1] = ptr.p->clientRef;
2751 signal->theData[2] = ptr.p->backupId;
2753 if (ptr.p->dataFilePtr == RNIL)
2755 sendSignal(ref, GSN_EVENT_REP, signal, signal_length, JBB);
2759 BackupFilePtr dataFilePtr LINT_SET_PTR;
2760 ptr.p->files.getPtr(dataFilePtr, ptr.p->dataFilePtr);
2761 signal->theData[3] = (Uint32)(dataFilePtr.p->operation.m_bytes_total & 0xFFFFFFFF);
2762 signal->theData[4] = (Uint32)(dataFilePtr.p->operation.m_bytes_total >> 32);
2763 signal->theData[5] = (Uint32)(dataFilePtr.p->operation.m_records_total & 0xFFFFFFFF);
2764 signal->theData[6] = (Uint32)(dataFilePtr.p->operation.m_records_total >> 32);
2766 if (ptr.p->logFilePtr == RNIL)
2768 sendSignal(ref, GSN_EVENT_REP, signal, signal_length, JBB);
2772 BackupFilePtr logFilePtr LINT_SET_PTR;
2773 ptr.p->files.getPtr(logFilePtr, ptr.p->logFilePtr);
2774 signal->theData[7] = (Uint32)(logFilePtr.p->operation.m_bytes_total & 0xFFFFFFFF);
2775 signal->theData[8] = (Uint32)(logFilePtr.p->operation.m_bytes_total >> 32);
2776 signal->theData[9] = (Uint32)(logFilePtr.p->operation.m_records_total & 0xFFFFFFFF);
2777 signal->theData[10]= (Uint32)(logFilePtr.p->operation.m_records_total >> 32);
2779 sendSignal(ref, GSN_EVENT_REP, signal, signal_length, JBB);
2788 Backup::masterAbort(
Signal* signal, BackupRecordPtr ptr)
2792 ndbout_c(
"************ masterAbort");
2795 ndbassert(ptr.p->masterRef == reference());
2797 if(ptr.p->masterData.errorCode != 0)
2803 if (SEND_BACKUP_COMPLETED_FLAG(ptr.p->flags))
2806 rep->backupId = ptr.p->backupId;
2807 rep->senderData = ptr.p->clientData;
2808 rep->reason = ptr.p->errorCode;
2809 sendSignal(ptr.p->clientRef, GSN_BACKUP_ABORT_REP, signal,
2810 BackupAbortRep::SignalLength, JBB);
2813 signal->theData[1] = ptr.p->clientRef;
2814 signal->theData[2] = ptr.p->backupId;
2815 signal->theData[3] = ptr.p->errorCode;
2816 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 4, JBB);
2818 ndbrequire(ptr.p->errorCode);
2819 ptr.p->masterData.errorCode = ptr.p->errorCode;
2822 ord->backupId = ptr.p->backupId;
2823 ord->backupPtr = ptr.i;
2824 ord->senderData= ptr.i;
2825 BlockNumber backupBlockNo = numberToBlock(BACKUP, instanceKey(ptr));
2828 switch(ptr.p->masterData.gsn){
2829 case GSN_DEFINE_BACKUP_REQ:
2830 ord->requestType = AbortBackupOrd::BackupFailure;
2831 sendSignal(rg, GSN_ABORT_BACKUP_ORD, signal,
2832 AbortBackupOrd::SignalLength, JBB);
2834 case GSN_CREATE_TRIG_IMPL_REQ:
2835 case GSN_START_BACKUP_REQ:
2836 case GSN_ALTER_TRIG_REQ:
2837 case GSN_WAIT_GCP_REQ:
2838 case GSN_BACKUP_FRAGMENT_REQ:
2840 ptr.p->stopGCP= ptr.p->startGCP + 1;
2841 sendStopBackup(signal, ptr);
2843 case GSN_UTIL_SEQUENCE_REQ:
2844 case GSN_UTIL_LOCK_REQ:
2847 case GSN_DROP_TRIG_IMPL_REQ:
2848 case GSN_STOP_BACKUP_REQ:
2854 Backup::abort_scan(
Signal * signal, BackupRecordPtr ptr)
2857 ord->backupId = ptr.p->backupId;
2858 ord->backupPtr = ptr.i;
2859 ord->senderData= ptr.i;
2860 ord->requestType = AbortBackupOrd::AbortScan;
2863 ptr.p->tables.first(tabPtr);
2864 for(; tabPtr.i != RNIL; ptr.p->tables.next(tabPtr)) {
2866 FragmentPtr fragPtr;
2868 const Uint32 fragCount = frags.
getSize();
2870 for(Uint32
i = 0;
i<fragCount;
i++) {
2872 tabPtr.p->fragments.getPtr(fragPtr,
i);
2873 const Uint32 nodeId = fragPtr.p->node;
2874 if(fragPtr.p->scanning != 0 && ptr.p->nodes.get(nodeId)) {
2877 BlockReference ref = numberToRef(BACKUP, instanceKey(ptr), nodeId);
2878 sendSignal(ref, GSN_ABORT_BACKUP_ORD, signal,
2879 AbortBackupOrd::SignalLength, JBB);
2892 Backup::defineBackupRef(
Signal* signal, BackupRecordPtr ptr, Uint32 errCode)
2895 ptr.p->setErrorCode(errCode);
2899 if (ptr.p->ctlFilePtr == RNIL) {
2900 ptr.p->m_gsn = GSN_DEFINE_BACKUP_REF;
2901 ndbrequire(ptr.p->errorCode != 0);
2903 ref->backupId = ptr.p->backupId;
2904 ref->backupPtr = ptr.i;
2905 ref->errorCode = ptr.p->errorCode;
2906 ref->nodeId = getOwnNodeId();
2907 sendSignal(ptr.p->masterRef, GSN_DEFINE_BACKUP_REF, signal,
2908 DefineBackupRef::SignalLength, JBB);
2912 BackupFilePtr filePtr LINT_SET_PTR;
2913 ptr.p->files.getPtr(filePtr, ptr.p->ctlFilePtr);
2914 if (filePtr.p->m_flags & BackupFile::BF_LCP_META)
2917 ndbrequire(! (filePtr.p->m_flags & BackupFile::BF_FILE_THREAD));
2918 filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_LCP_META;
2919 if (filePtr.p->m_flags & BackupFile::BF_OPEN)
2921 closeFile(signal, ptr, filePtr);
2926 ndbrequire(filePtr.p->m_flags == 0);
2929 FragmentPtr fragPtr;
2931 ndbrequire(ptr.p->tables.first(tabPtr));
2932 tabPtr.p->fragments.getPtr(fragPtr, 0);
2935 ref->senderData = ptr.p->clientData;
2936 ref->senderRef = reference();
2937 ref->tableId = tabPtr.p->tableId;
2938 ref->fragmentId = fragPtr.p->fragmentId;
2939 ref->errorCode = errCode;
2940 sendSignal(ptr.p->masterRef, GSN_LCP_PREPARE_REF,
2941 signal, LcpPrepareRef::SignalLength, JBB);
2945 ptr.p->m_gsn = GSN_DEFINE_BACKUP_REF;
2946 ndbrequire(ptr.p->errorCode != 0);
2949 ref->backupId = ptr.p->backupId;
2950 ref->backupPtr = ptr.i;
2951 ref->errorCode = ptr.p->errorCode;
2952 ref->nodeId = getOwnNodeId();
2953 sendSignal(ptr.p->masterRef, GSN_DEFINE_BACKUP_REF, signal,
2954 DefineBackupRef::SignalLength, JBB);
2965 const Uint32 ptrI = req->backupPtr;
2966 const Uint32 backupId = req->backupId;
2967 const BlockReference senderRef = req->senderRef;
2969 if(senderRef == reference()){
2974 c_backupPool.
getPtr(ptr, ptrI);
2978 dumpUsedResources();
2980 if(!c_backups.
seizeId(ptr, ptrI)) {
2986 CRASH_INSERTION((10014));
2988 ptr.p->m_gsn = GSN_DEFINE_BACKUP_REQ;
2989 ptr.p->slaveState.forceState(INITIAL);
2990 ptr.p->slaveState.setState(DEFINING);
2991 ptr.p->slaveData.dropTrig.tableId = RNIL;
2992 ptr.p->errorCode = 0;
2993 ptr.p->clientRef = req->clientRef;
2994 ptr.p->clientData = req->clientData;
2995 if(senderRef == reference())
2996 ptr.p->flags = req->flags;
2998 ptr.p->flags = req->flags & ~((Uint32)BackupReq::WAITCOMPLETED);
3002 ptr.p->masterRef = senderRef;
3003 ptr.p->nodes = req->nodes;
3004 ptr.p->backupId = backupId;
3005 ptr.p->backupKey[0] = req->backupKey[0];
3006 ptr.p->backupKey[1] = req->backupKey[1];
3007 ptr.p->backupDataLen = req->backupDataLen;
3008 ptr.p->masterData.errorCode = 0;
3009 ptr.p->noOfBytes = 0;
3010 ptr.p->noOfRecords = 0;
3011 ptr.p->noOfLogBytes = 0;
3012 ptr.p->noOfLogRecords = 0;
3014 ptr.p->startGCP = 0;
3021 Uint32 noOfPages[] = {
3022 NO_OF_PAGES_META_FILE,
3026 const Uint32 maxInsert[] = {
3027 MAX_WORDS_META_FILE,
3029 16 * (MAX_TUPLE_SIZE_IN_WORDS + 128 ),
3031 Uint32 minWrite[] = {
3036 Uint32 maxWrite[] = {
3042 minWrite[1] = c_defaults.m_minWriteSize;
3043 maxWrite[1] = c_defaults.m_maxWriteSize;
3044 noOfPages[1] = (c_defaults.m_logBufferSize +
sizeof(
Page32) - 1) /
3046 minWrite[2] = c_defaults.m_minWriteSize;
3047 maxWrite[2] = c_defaults.m_maxWriteSize;
3048 noOfPages[2] = (c_defaults.m_dataBufferSize +
sizeof(
Page32) - 1) /
3051 if (ptr.p->is_lcp())
3053 noOfPages[2] = (c_defaults.m_lcp_buffer_size +
sizeof(
Page32) - 1) /
3057 ptr.p->ctlFilePtr = ptr.p->logFilePtr = ptr.p->dataFilePtr = RNIL;
3059 for(Uint32
i = 0;
i<3;
i++) {
3061 if(ptr.p->is_lcp() &&
i != 2)
3066 if(!ptr.p->files.seize(files[
i])) {
3068 defineBackupRef(signal, ptr,
3069 DefineBackupRef::FailedToAllocateFileRecord);
3073 files[
i].p->tableId = RNIL;
3074 files[
i].p->backupPtr = ptr.i;
3075 files[
i].p->filePointer = RNIL;
3076 files[
i].p->m_flags = 0;
3077 files[
i].p->errorCode = 0;
3079 if(ERROR_INSERTED(10035) || files[i].p->pages.seize(noOfPages[i]) ==
false)
3082 DEBUG_OUT(
"Failed to seize " << noOfPages[i] <<
" pages");
3083 defineBackupRef(signal, ptr, DefineBackupRef::FailedToAllocateBuffers);
3087 files[
i].p->pages.getPtr(pagePtr, 0);
3089 const char *
msg = files[
i].p->
3090 operation.dataBuffer.setup((Uint32*)pagePtr.p,
3091 noOfPages[i] * (
sizeof(
Page32) >> 2),
3098 defineBackupRef(signal, ptr, DefineBackupRef::FailedToSetupFsBuffers);
3104 files[
i].p->fileType = BackupFormat::CTL_FILE;
3105 ptr.p->ctlFilePtr = files[
i].i;
3108 if(ptr.p->flags & BackupReq::USE_UNDO_LOG)
3109 files[
i].p->fileType = BackupFormat::UNDO_FILE;
3111 files[
i].p->fileType = BackupFormat::LOG_FILE;
3112 ptr.p->logFilePtr = files[
i].i;
3115 files[
i].p->fileType = BackupFormat::DATA_FILE;
3116 ptr.p->dataFilePtr = files[
i].i;
3118 files[
i].p->operation.m_bytes_total = 0;
3119 files[
i].p->operation.m_records_total = 0;
3122 initReportStatus(signal, ptr);
3124 if (!verifyNodesAlive(ptr, ptr.p->nodes)) {
3126 defineBackupRef(signal, ptr, DefineBackupRef::Undefined);
3129 if (ERROR_INSERTED(10027)) {
3131 defineBackupRef(signal, ptr, 327);
3135 if(ptr.p->backupDataLen == 0) {
3144 getFragmentInfoDone(signal, ptr);
3162 req->senderRef = reference();
3163 req->senderData = ptr.i;
3165 req->setTableType(0);
3166 sendSignal(DBDICT_REF, GSN_LIST_TABLES_REQ, signal,
3167 ListTablesReq::SignalLength, JBB);
3174 Uint32 fragInfo = signal->header.m_fragmentInfo;
3176 Uint32 noOfTables = conf->noOfTables;
3179 c_backupPool.
getPtr(ptr, conf->senderData);
3182 signal->header.m_fragmentInfo = 0;
3186 const Uint32 listTablesDataSizeInWords = (
sizeof(
ListTablesData) + 3) / 4;
3188 handle.getSection(tableDataPtr, ListTablesConf::TABLE_DATA);
3190 tableDataReader(tableDataPtr, getSectionSegmentPool());
3192 tableDataReader.reset();
3193 for(
unsigned int i = 0;
i<noOfTables;
i++) {
3195 tableDataReader.getWords((Uint32 *)<d, listTablesDataSizeInWords);
3196 Uint32 tableId = ltd.getTableId();
3197 Uint32 tableType = ltd.getTableType();
3198 Uint32 state= ltd.getTableState();
3200 if (! (DictTabInfo::isTable(tableType) ||
3201 DictTabInfo::isIndex(tableType) ||
3202 DictTabInfo::isFilegroup(tableType) ||
3203 DictTabInfo::isFile(tableType)
3204 || DictTabInfo::isHashMap(tableType)
3211 if (state != DictTabInfo::StateOnline)
3218 ptr.p->tables.seize(tabPtr);
3219 if(tabPtr.i == RNIL) {
3221 defineBackupRef(signal, ptr, DefineBackupRef::FailedToAllocateTables);
3222 releaseSections(handle);
3225 tabPtr.p->tableId = tableId;
3226 tabPtr.p->tableType = tableType;
3230 releaseSections(handle);
3236 if ((fragInfo == 1) || (fragInfo == 2))
3251 req->userReference = reference();
3253 FsOpenReq::OM_WRITEONLY |
3254 FsOpenReq::OM_CREATE_IF_NONE |
3255 FsOpenReq::OM_APPEND |
3256 FsOpenReq::OM_AUTOSYNC;
3258 if (c_defaults.m_compressed_backup)
3259 req->fileFlags |= FsOpenReq::OM_GZ;
3261 FsOpenReq::v2_setCount(req->fileNumber, 0xFFFFFFFF);
3262 req->auto_sync_size = c_defaults.m_disk_synch_size;
3266 c_backupFilePool.
getPtr(filePtr, ptr.p->ctlFilePtr);
3267 filePtr.p->m_flags |= BackupFile::BF_OPENING;
3269 req->userPointer = filePtr.i;
3270 FsOpenReq::setVersion(req->fileNumber, 2);
3271 FsOpenReq::setSuffix(req->fileNumber, FsOpenReq::S_CTL);
3272 FsOpenReq::v2_setSequence(req->fileNumber, ptr.p->backupId);
3273 FsOpenReq::v2_setNodeId(req->fileNumber, getOwnNodeId());
3274 sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA);
3279 c_backupFilePool.
getPtr(filePtr, ptr.p->logFilePtr);
3280 filePtr.p->m_flags |= BackupFile::BF_OPENING;
3283 if(ptr.p->flags & BackupReq::USE_UNDO_LOG)
3286 req->userPointer = filePtr.i;
3287 FsOpenReq::setVersion(req->fileNumber, 2);
3288 FsOpenReq::setSuffix(req->fileNumber, FsOpenReq::S_LOG);
3289 FsOpenReq::v2_setSequence(req->fileNumber, ptr.p->backupId);
3290 FsOpenReq::v2_setNodeId(req->fileNumber, getOwnNodeId());
3291 sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA);
3296 c_backupFilePool.
getPtr(filePtr, ptr.p->dataFilePtr);
3297 filePtr.p->m_flags |= BackupFile::BF_OPENING;
3299 if (c_defaults.m_o_direct)
3300 req->fileFlags |= FsOpenReq::OM_DIRECT;
3301 if (c_defaults.m_compressed_backup)
3302 req->fileFlags |= FsOpenReq::OM_GZ;
3303 req->userPointer = filePtr.i;
3304 FsOpenReq::setVersion(req->fileNumber, 2);
3305 FsOpenReq::setSuffix(req->fileNumber, FsOpenReq::S_DATA);
3306 FsOpenReq::v2_setSequence(req->fileNumber, ptr.p->backupId);
3307 FsOpenReq::v2_setNodeId(req->fileNumber, getOwnNodeId());
3308 FsOpenReq::v2_setCount(req->fileNumber, 0);
3309 sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA);
3322 c_backupFilePool.
getPtr(filePtr, userPtr);
3325 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
3326 ptr.p->setErrorCode(ref->errorCode);
3331 Backup::execFSOPENCONF(
Signal* signal)
3337 const Uint32 userPtr = conf->userPointer;
3338 const Uint32 filePointer = conf->filePointer;
3340 BackupFilePtr filePtr LINT_SET_PTR;
3341 c_backupFilePool.
getPtr(filePtr, userPtr);
3342 filePtr.p->filePointer = filePointer;
3344 BackupRecordPtr ptr LINT_SET_PTR;
3345 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
3347 ndbrequire(! (filePtr.p->m_flags & BackupFile::BF_OPEN));
3348 filePtr.p->m_flags |= BackupFile::BF_OPEN;
3361 ndbrequire(filePtr.p->m_flags & BackupFile::BF_OPENING);
3362 filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_OPENING;
3363 filePtr.p->m_flags |= BackupFile::BF_OPEN;
3367 for(ptr.p->files.first(filePtr); filePtr.i!=RNIL;ptr.p->files.next(filePtr))
3370 if(filePtr.p->m_flags & BackupFile::BF_OPENING) {
3376 if (ERROR_INSERTED(10037)) {
3382 ptr.p->errorCode = DefineBackupRef::FailedInsertFileHeader;
3383 defineBackupRef(signal, ptr);
3389 if(ptr.p->checkError())
3392 if(ptr.p->errorCode == FsRef::fsErrFileExists)
3395 ptr.p->errorCode = DefineBackupRef::FailedForBackupFilesAleadyExist;
3397 defineBackupRef(signal, ptr);
3401 if(!ptr.p->is_lcp())
3406 ptr.p->files.getPtr(filePtr, ptr.p->ctlFilePtr);
3407 if(!insertFileHeader(BackupFormat::CTL_FILE, ptr.p, filePtr.p)) {
3409 defineBackupRef(signal, ptr, DefineBackupRef::FailedInsertFileHeader);
3414 if(ptr.p->flags & BackupReq::USE_UNDO_LOG)
3415 logfiletype = BackupFormat::UNDO_FILE;
3417 logfiletype = BackupFormat::LOG_FILE;
3419 ptr.p->files.getPtr(filePtr, ptr.p->logFilePtr);
3420 if(!insertFileHeader(logfiletype, ptr.p, filePtr.p)) {
3422 defineBackupRef(signal, ptr, DefineBackupRef::FailedInsertFileHeader);
3426 ptr.p->files.getPtr(filePtr, ptr.p->dataFilePtr);
3427 if(!insertFileHeader(BackupFormat::DATA_FILE, ptr.p, filePtr.p)) {
3429 defineBackupRef(signal, ptr, DefineBackupRef::FailedInsertFileHeader);
3435 ptr.p->files.getPtr(filePtr, ptr.p->dataFilePtr);
3436 if(!insertFileHeader(BackupFormat::LCP_FILE, ptr.p, filePtr.p)) {
3438 defineBackupRef(signal, ptr, DefineBackupRef::FailedInsertFileHeader);
3442 ptr.p->ctlFilePtr = ptr.p->dataFilePtr;
3448 if (!ptr.p->is_lcp())
3451 ptr.p->files.getPtr(filePtr, ptr.p->ctlFilePtr);
3452 filePtr.p->m_flags |= BackupFile::BF_FILE_THREAD;
3454 signal->theData[0] = BackupContinueB::START_FILE_THREAD;
3455 signal->theData[1] = filePtr.i;
3456 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 2);
3461 filePtr.p->m_flags |= BackupFile::BF_LCP_META;
3467 FsBuffer & buf = filePtr.p->operation.dataBuffer;
3471 ptr.p->tables.count() - 1;
3477 defineBackupRef(signal, ptr, DefineBackupRef::FailedInsertTableList);
3483 tl->SectionType = htonl(BackupFormat::TABLE_LIST);
3484 tl->SectionLength = htonl(sz);
3488 for(ptr.p->tables.first(tabPtr);
3490 ptr.p->tables.next(tabPtr)){
3492 tl->TableIds[count] = htonl(tabPtr.p->tableId);
3496 buf.updateWritePtr(sz);
3501 ndbrequire(ptr.p->tables.first(tabPtr));
3503 signal->theData[0] = BackupContinueB::BUFFER_FULL_META;
3504 signal->theData[1] = ptr.i;
3505 signal->theData[2] = tabPtr.i;
3506 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 3);
3512 BackupRecord * ptrP,
3514 FsBuffer & buf = filePtrP->operation.dataBuffer;
3526 ndbrequire(
sizeof(header->Magic) ==
sizeof(BACKUP_MAGIC));
3527 memcpy(header->Magic, BACKUP_MAGIC,
sizeof(BACKUP_MAGIC));
3528 header->BackupVersion = htonl(NDB_BACKUP_VERSION);
3529 header->SectionType = htonl(BackupFormat::FILE_HEADER);
3530 header->SectionLength = htonl(sz - 3);
3531 header->FileType = htonl(ft);
3532 header->BackupId = htonl(ptrP->backupId);
3533 header->BackupKey_0 = htonl(ptrP->backupKey[0]);
3534 header->BackupKey_1 = htonl(ptrP->backupKey[1]);
3535 header->ByteOrder = 0x12345678;
3536 header->NdbVersion = htonl(NDB_VERSION_D);
3537 header->MySQLVersion = htonl(NDB_MYSQL_VERSION_D);
3539 buf.updateWritePtr(sz);
3544 Backup::execGET_TABINFOREF(
Signal* signal)
3548 const Uint32 senderData = ref->senderData;
3549 BackupRecordPtr ptr LINT_SET_PTR;
3550 c_backupPool.
getPtr(ptr, senderData);
3552 defineBackupRef(signal, ptr, ref->errorCode);
3556 Backup::execGET_TABINFO_CONF(
Signal* signal)
3567 const Uint32 len = conf->totalLen;
3568 const Uint32 senderData = conf->senderData;
3569 const Uint32 tableType = conf->tableType;
3570 const Uint32 tableId = conf->tableId;
3572 BackupRecordPtr ptr LINT_SET_PTR;
3573 c_backupPool.
getPtr(ptr, senderData);
3577 handle.getSection(dictTabInfoPtr, GetTabInfoConf::DICT_TAB_INFO);
3578 ndbrequire(dictTabInfoPtr.sz == len);
3581 ndbrequire(findTable(ptr, tabPtr, tableId));
3583 BackupFilePtr filePtr LINT_SET_PTR;
3584 ptr.p->files.getPtr(filePtr, ptr.p->ctlFilePtr);
3585 FsBuffer & buf = filePtr.p->operation.dataBuffer;
3588 Uint32 dstLen = len + 3;
3592 ptr.p->setErrorCode(DefineBackupRef::FailedAllocateTableMem);
3593 releaseSections(handle);
3594 defineBackupRef(signal, ptr);
3602 desc->SectionType = htonl(BackupFormat::TABLE_DESCRIPTION);
3603 desc->SectionLength = htonl(len + 3);
3604 desc->TableType = htonl(tableType);
3607 copy(dst, dictTabInfoPtr);
3608 buf.updateWritePtr(dstLen);
3612 releaseSections(handle);
3614 if(ptr.p->checkError()) {
3616 defineBackupRef(signal, ptr);
3620 if (!DictTabInfo::isTable(tabPtr.p->tableType))
3624 TablePtr tmp = tabPtr;
3625 ptr.p->tables.next(tabPtr);
3626 ptr.p->tables.release(tmp);
3634 defineBackupRef(signal, ptr);
3638 if(!ptr.p->is_lcp())
3642 req->m_senderRef = reference();
3643 req->m_tableId = tabPtr.p->tableId;
3645 req->m_backup_state = BackupLockTab::GET_TABINFO_CONF;
3646 req->m_backupRecordPtr_I = ptr.i;
3647 req->m_tablePtr_I = tabPtr.i;
3648 sendSignal(DBDICT_REF, GSN_BACKUP_LOCK_TAB_REQ, signal,
3649 BackupLockTab::SignalLength, JBB);
3650 if (ERROR_INSERTED(10038))
3654 ord->backupId = ptr.p->backupId;
3655 ord->backupPtr = ptr.i;
3656 ord->requestType = AbortBackupOrd::ClientAbort;
3657 ord->senderData= ptr.p->clientData;
3658 sendSignal(ptr.p->masterRef, GSN_ABORT_BACKUP_ORD, signal,
3659 AbortBackupOrd::SignalLength, JBB);
3664 ptr.p->tables.next(tabPtr);
3672 if(tabPtr.i == RNIL)
3686 ndbrequire(ptr.p->tables.first(tabPtr));
3688 req->senderRef = reference();
3689 req->senderData = ptr.i;
3690 req->tableId = tabPtr.p->tableId;
3691 req->schemaTransId = 0;
3692 sendSignal(DBDIH_REF, GSN_DIH_SCAN_TAB_REQ, signal,
3693 DihScanTabReq::SignalLength, JBB);
3700 signal->theData[0] = BackupContinueB::BUFFER_FULL_META;
3701 signal->theData[1] = ptr.i;
3702 signal->theData[2] = tabPtr.i;
3703 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 3);
3711 const Uint32 * tabdescptr,
3720 stat = SimpleProperties::unpack(it, &tmpTab,
3721 DictTabInfo::TableMapping,
3722 DictTabInfo::TableMappingSize,
3724 ndbrequire(stat == SimpleProperties::Break);
3726 bool lcp = ptr.p->is_lcp();
3728 ndbrequire(tabPtr.p->tableId == tmpTab.TableId);
3729 ndbrequire(lcp || (tabPtr.p->tableType == tmpTab.TableType));
3738 tabPtr.p->noOfRecords = 0;
3739 tabPtr.p->schemaVersion = tmpTab.TableVersion;
3740 tabPtr.p->triggerIds[0] = ILLEGAL_TRIGGER_ID;
3741 tabPtr.p->triggerIds[1] = ILLEGAL_TRIGGER_ID;
3742 tabPtr.p->triggerIds[2] = ILLEGAL_TRIGGER_ID;
3743 tabPtr.p->triggerAllocated[0] =
false;
3744 tabPtr.p->triggerAllocated[1] =
false;
3745 tabPtr.p->triggerAllocated[2] =
false;
3747 tabPtr.p->noOfAttributes = tmpTab.NoOfAttributes;
3748 tabPtr.p->maxRecordSize = 1;
3749 bzero(tabPtr.p->attrInfo,
sizeof(tabPtr.p->attrInfo));
3751 Uint32 *list = tabPtr.p->attrInfo + 1;
3762 tmpTab.NoOfAttributes);
3768 for(Uint32
i = 0;
i<tmpTab.NoOfAttributes;
i++) {
3771 stat = SimpleProperties::unpack(it, &tmp,
3772 DictTabInfo::AttributeMapping,
3773 DictTabInfo::AttributeMappingSize,
3776 ndbrequire(stat == SimpleProperties::Break);
3779 if(lcp && tmp.AttributeStorageType == NDB_STORAGETYPE_DISK)
3785 if (tmp.AttributeArrayType != NDB_ARRAYTYPE_FIXED)
3788 if (tmp.AttributeNullableFlag)
3791 if (tmp.AttributeSize == 0)
3793 tabPtr.p->maxRecordSize += (tmp.AttributeArraySize + 31) >> 5;
3797 const Uint32 arr = tmp.AttributeArraySize;
3798 const Uint32 sz = 1 << tmp.AttributeSize;
3799 const Uint32 sz32 = (sz * arr + 31) >> 5;
3801 tabPtr.p->maxRecordSize += sz32;
3805 tabPtr.p->attrInfoLen = Uint32(list - tabPtr.p->attrInfo);
3809 Dbtup* tup = (
Dbtup*)globalData.getBlock(DBTUP, instance());
3810 tabPtr.p->maxRecordSize = 1 + tup->get_max_lcp_record_size(tmpTab.TableId);
3815 tabPtr.p->maxRecordSize += 1 + ((tmpTab.NoOfAttributes + null + 31) >> 5);
3816 tabPtr.p->maxRecordSize += (2 * varsize + 3) / 4;
3827 const Uint32 fragCount = conf->fragmentCount;
3828 const Uint32 tableId = conf->tableId;
3829 const Uint32 senderData = conf->senderData;
3830 const Uint32 scanCookie = conf->scanCookie;
3831 ndbrequire(conf->reorgFlag == 0);
3834 c_backupPool.
getPtr(ptr, senderData);
3837 ndbrequire(findTable(ptr, tabPtr, tableId));
3839 tabPtr.p->m_scan_cookie = scanCookie;
3840 ndbrequire(tabPtr.p->fragments.seize(fragCount) !=
false);
3841 for(Uint32
i = 0;
i<fragCount;
i++) {
3844 tabPtr.p->fragments.getPtr(fragPtr,
i);
3845 fragPtr.p->scanned = 0;
3846 fragPtr.p->scanning = 0;
3847 fragPtr.p->tableId = tableId;
3848 fragPtr.p->fragmentId =
i;
3849 fragPtr.p->lqhInstanceKey = 0;
3850 fragPtr.p->node = 0;
3856 if(ptr.p->tables.next(tabPtr)) {
3859 req->senderRef = reference();
3860 req->senderData = ptr.i;
3861 req->tableId = tabPtr.p->tableId;
3862 req->schemaTransId = 0;
3863 sendSignal(DBDIH_REF, GSN_DIH_SCAN_TAB_REQ, signal,
3864 DihScanTabReq::SignalLength, JBB);
3868 ptr.p->tables.first(tabPtr);
3869 getFragmentInfo(signal, ptr, tabPtr, 0);
3873 Backup::getFragmentInfo(
Signal* signal,
3874 BackupRecordPtr ptr, TablePtr tabPtr, Uint32 fragNo)
3878 for(; tabPtr.i != RNIL; ptr.p->tables.next(tabPtr)) {
3880 const Uint32 fragCount = tabPtr.p->fragments.getSize();
3881 for(; fragNo < fragCount; fragNo ++) {
3883 FragmentPtr fragPtr;
3884 tabPtr.p->fragments.getPtr(fragPtr, fragNo);
3886 if(fragPtr.p->scanned == 0 && fragPtr.p->scanning == 0) {
3889 req->senderRef = reference();
3890 req->senderData = ptr.i;
3891 req->tableId = tabPtr.p->tableId;
3892 req->fragId = fragNo;
3893 req->scanCookie = tabPtr.p->m_scan_cookie;
3894 sendSignal(DBDIH_REF, GSN_DIH_SCAN_GET_NODES_REQ, signal,
3895 DihScanGetNodesReq::SignalLength, JBB);
3901 rep->tableId = tabPtr.p->tableId;
3902 rep->scanCookie = tabPtr.p->m_scan_cookie;
3903 sendSignal(DBDIH_REF, GSN_DIH_SCAN_TAB_COMPLETE_REP, signal,
3904 DihScanTabCompleteRep::SignalLength, JBB);
3910 getFragmentInfoDone(signal, ptr);
3914 Backup::execDIH_SCAN_GET_NODES_CONF(
Signal* signal)
3919 const Uint32 senderData = conf->senderData;
3920 const Uint32 nodeCount = conf->count;
3921 const Uint32 tableId = conf->tableId;
3922 const Uint32 fragNo = conf->fragId;
3923 const Uint32 instanceKey = conf->instanceKey;
3925 ndbrequire(nodeCount > 0 && nodeCount <= MAX_REPLICAS);
3927 BackupRecordPtr ptr LINT_SET_PTR;
3928 c_backupPool.
getPtr(ptr, senderData);
3931 ndbrequire(findTable(ptr, tabPtr, tableId));
3933 FragmentPtr fragPtr;
3934 tabPtr.p->fragments.getPtr(fragPtr, fragNo);
3935 fragPtr.p->lqhInstanceKey = instanceKey;
3937 fragPtr.p->node = conf->nodes[0];
3939 getFragmentInfo(signal, ptr, tabPtr, fragNo + 1);
3943 Backup::getFragmentInfoDone(
Signal* signal, BackupRecordPtr ptr)
3945 ptr.p->m_gsn = GSN_DEFINE_BACKUP_CONF;
3946 ptr.p->slaveState.setState(DEFINED);
3948 conf->backupPtr = ptr.i;
3949 conf->backupId = ptr.p->backupId;
3950 sendSignal(ptr.p->masterRef, GSN_DEFINE_BACKUP_CONF, signal,
3951 DefineBackupConf::SignalLength, JBB);
3965 CRASH_INSERTION((10015));
3968 const Uint32 ptrI = req->backupPtr;
3971 c_backupPool.
getPtr(ptr, ptrI);
3973 ptr.p->slaveState.setState(STARTED);
3974 ptr.p->m_gsn = GSN_START_BACKUP_REQ;
3980 for(ptr.p->files.first(filePtr); filePtr.i!=RNIL;ptr.p->files.next(filePtr))
3983 if(! (filePtr.p->m_flags & BackupFile::BF_FILE_THREAD))
3986 filePtr.p->m_flags |= BackupFile::BF_FILE_THREAD;
3987 signal->theData[0] = BackupContinueB::START_FILE_THREAD;
3988 signal->theData[1] = filePtr.i;
3989 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 2);
3997 ndbrequire(ptr.p->tables.first(tabPtr));
3998 sendCreateTrig(signal, ptr, tabPtr);
4012 CRASH_INSERTION((10016));
4014 const Uint32 ptrI = req->backupPtr;
4016 const Uint32 tableId = req->tableId;
4017 const Uint32 fragNo = req->fragmentNo;
4018 const Uint32 count = req->count;
4024 c_backupPool.
getPtr(ptr, ptrI);
4026 ptr.p->slaveState.setState(SCANNING);
4027 ptr.p->m_gsn = GSN_BACKUP_FRAGMENT_REQ;
4033 c_backupFilePool.
getPtr(filePtr, ptr.p->dataFilePtr);
4035 ndbrequire(filePtr.p->backupPtr == ptrI);
4036 ndbrequire(filePtr.p->m_flags ==
4037 (BackupFile::BF_OPEN | BackupFile::BF_FILE_THREAD));
4043 ndbrequire(findTable(ptr, tabPtr, tableId));
4049 tabPtr.p->fragments.getPtr(fragPtr, fragNo);
4051 ndbrequire(fragPtr.p->scanned == 0);
4052 ndbrequire(fragPtr.p->scanning == 0 ||
4053 refToNode(ptr.p->masterRef) == getOwnNodeId());
4058 if(filePtr.p->tableId != tableId) {
4060 filePtr.p->operation.init(tabPtr);
4061 filePtr.p->tableId = tableId;
4067 if(!filePtr.p->operation.newFragment(tableId, fragPtr.p->fragmentId)) {
4069 req->count = count + 1;
4070 sendSignalWithDelay(reference(), GSN_BACKUP_FRAGMENT_REQ, signal, 50,
4072 ptr.p->slaveState.setState(STARTED);
4079 fragPtr.p->scanning = 1;
4080 filePtr.p->fragmentNo = fragPtr.p->fragmentId;
4081 filePtr.p->m_retry_count = 0;
4098 filePtr.p->m_flags |= BackupFile::BF_SCAN_THREAD;
4102 const Uint32 parallelism = 16;
4104 req->senderData = filePtr.i;
4105 req->resultRef = reference();
4106 req->schemaVersion = table.schemaVersion;
4107 req->fragmentNoKeyLen = fragPtr.p->fragmentId;
4108 req->requestInfo = 0;
4109 req->savePointId = 0;
4110 req->tableId = table.tableId;
4111 ScanFragReq::setReadCommittedFlag(req->requestInfo, 1);
4112 ScanFragReq::setLockMode(req->requestInfo, 0);
4113 ScanFragReq::setHoldLockFlag(req->requestInfo, 0);
4114 ScanFragReq::setKeyinfoFlag(req->requestInfo, 0);
4115 ScanFragReq::setTupScanFlag(req->requestInfo, 1);
4116 if (ptr.p->is_lcp())
4118 ScanFragReq::setScanPrio(req->requestInfo, 1);
4119 ScanFragReq::setNoDiskFlag(req->requestInfo, 1);
4120 ScanFragReq::setLcpScanFlag(req->requestInfo, 1);
4123 req->transId2 = (BACKUP << 20) + (getOwnNodeId() << 8);
4124 req->clientOpPtr= filePtr.i;
4125 req->batch_size_rows= parallelism;
4126 req->batch_size_bytes= 0;
4127 BlockReference lqhRef = 0;
4128 if (ptr.p->is_lcp()) {
4129 lqhRef = calcInstanceBlockRef(DBLQH);
4131 const Uint32 instanceKey = fragPtr.p->lqhInstanceKey;
4132 ndbrequire(instanceKey != 0);
4133 lqhRef = numberToRef(DBLQH, instanceKey, getOwnNodeId());
4136 Uint32 attrInfo[25];
4137 attrInfo[0] = table.attrInfoLen;
4142 memcpy(attrInfo + 5, table.
attrInfo, 4*table.attrInfoLen);
4144 ptr[0].p = attrInfo;
4145 ptr[0].sz = 5 + table.attrInfoLen;
4149 sendSignal(lqhRef, GSN_SCAN_FRAGREQ, signal,
4150 ScanFragReq::SignalLength, JBB, ptr, 1);
4156 ndbrequire(
import(handle.m_ptr[0], ptr[0].p, ptr[0].sz));
4158 sendSignalWithDelay(lqhRef, GSN_SCAN_FRAGREQ, signal,
4159 delay, ScanFragReq::SignalLength, &handle);
4175 const Uint32 filePtrI = signal->theData[0];
4178 Uint32 dataLen = signal->
length() - 3;
4181 c_backupFilePool.
getPtr(filePtr, filePtrI);
4188 Uint32 * dst = op.dst;
4189 if (signal->getNoOfSections() == 0)
4192 const Uint32 * src = &signal->theData[3];
4193 * dst = htonl(dataLen);
4194 memcpy(dst + 1, src, 4*dataLen);
4201 handle.getSection(dataPtr, 0);
4202 dataLen = dataPtr.sz;
4204 * dst = htonl(dataLen);
4205 copy(dst + 1, dataPtr);
4206 releaseSections(handle);
4209 op.attrSzTotal += dataLen;
4210 ndbrequire(dataLen < op.maxRecordSize);
4212 op.finished(dataLen);
4221 maxRecordSize = ptr.p->maxRecordSize;
4229 const Uint32 sz = headSz + 16 * maxRecordSize;
4231 ndbrequire(sz < dataBuffer.getMaxWrite());
4232 if(dataBuffer.getWritePtr(&tmp, sz)) {
4237 head->SectionType = htonl(BackupFormat::FRAGMENT_HEADER);
4238 head->SectionLength = htonl(headSz);
4239 head->TableId = htonl(tableId);
4240 head->FragmentNo = htonl(fragNo);
4241 head->ChecksumType = htonl(0);
4243 opNoDone = opNoConf = opLen = 0;
4244 newRecord(tmp + headSz);
4246 scanStop = (tmp + headSz);
4256 Backup::OperationRecord::fragComplete(Uint32 tableId, Uint32 fragNo,
bool fill_record)
4260 Uint32 sz = footSz + 1;
4265 if (!dataBuffer.getWritePtr(&tmp, sz))
4269 if ((UintPtr)new_tmp & (
sizeof(
Page32)-1))
4273 new_tmp = (Uint32 *)(((UintPtr)new_tmp +
sizeof(
Page32)-1) &
4274 ~(UintPtr)(
sizeof(
Page32)-1));
4276 sz = Uint32(new_tmp - tmp);
4280 if(dataBuffer.getWritePtr(&tmp, sz)) {
4286 foot->SectionType = htonl(BackupFormat::FRAGMENT_FOOTER);
4287 foot->SectionLength = htonl(footSz);
4288 foot->TableId = htonl(tableId);
4289 foot->FragmentNo = htonl(fragNo);
4290 foot->NoOfRecords = htonl(Uint32(noOfRecords));
4291 foot->Checksum = htonl(0);
4293 if (sz != footSz + 1)
4296 memset(tmp, 0, (sz - footSz - 1) * 4);
4297 *tmp = htonl(BackupFormat::EMPTY_ENTRY);
4299 *tmp = htonl(sz - footSz - 1);
4302 dataBuffer.updateWritePtr(sz);
4312 ndbrequire(16 * maxRecordSize < dataBuffer.getMaxWrite());
4313 if(dataBuffer.getWritePtr(&tmp, 16 * maxRecordSize))
4316 opNoDone = opNoConf = opLen = 0;
4326 Backup::OperationRecord::closeScan()
4328 opNoDone = opNoConf = opLen = 0;
4333 Backup::OperationRecord::scanConf(Uint32 noOfOps, Uint32 total_len)
4335 const Uint32 done = Uint32(opNoDone-opNoConf);
4337 ndbrequire(noOfOps == done);
4338 ndbrequire(opLen == total_len);
4339 opNoConf = opNoDone;
4341 const Uint32 len = Uint32(scanStop - scanStart);
4342 ndbrequire(len < dataBuffer.getMaxWrite());
4343 dataBuffer.updateWritePtr(len);
4344 noOfBytes += (len << 2);
4345 m_bytes_total += (len << 2);
4350 Backup::execSCAN_FRAGREF(
Signal* signal)
4356 const Uint32 filePtrI = ref->senderData;
4357 BackupFilePtr filePtr LINT_SET_PTR;
4358 c_backupFilePool.
getPtr(filePtr, filePtrI);
4360 Uint32 errCode = ref->errorCode;
4361 if (filePtr.p->errorCode == 0)
4365 case ScanFragRef::ZSCAN_BOOK_ACC_OP_ERROR:
4366 case ScanFragRef::NO_TC_CONNECT_ERROR:
4367 case ScanFragRef::ZTOO_MANY_ACTIVE_SCAN_ERROR:
4372 filePtr.p->errorCode = errCode;
4376 if (filePtr.p->errorCode == 0)
4379 filePtr.p->m_retry_count++;
4380 if (filePtr.p->m_retry_count == 10)
4383 filePtr.p->errorCode = errCode;
4387 if (filePtr.p->errorCode != 0)
4390 filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_SCAN_THREAD;
4391 backupFragmentRef(signal, filePtr);
4399 BackupRecordPtr ptr;
4400 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
4402 ndbrequire(findTable(ptr, tabPtr, filePtr.p->tableId));
4403 FragmentPtr fragPtr;
4404 tabPtr.p->fragments.getPtr(fragPtr, filePtr.p->fragmentNo);
4410 Backup::execSCAN_FRAGCONF(
Signal* signal)
4414 CRASH_INSERTION((10017));
4418 const Uint32 filePtrI = conf->senderData;
4419 BackupFilePtr filePtr LINT_SET_PTR;
4420 c_backupFilePool.
getPtr(filePtr, filePtrI);
4422 OperationRecord & op = filePtr.p->operation;
4424 op.scanConf(conf->completedOps, conf->total_len);
4425 const Uint32 completed = conf->fragmentCompleted;
4426 if(completed != 2) {
4433 fragmentCompleted(signal, filePtr);
4437 Backup::fragmentCompleted(
Signal* signal, BackupFilePtr filePtr)
4441 if(filePtr.p->errorCode != 0)
4444 filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_SCAN_THREAD;
4445 backupFragmentRef(signal, filePtr);
4449 BackupRecordPtr ptr LINT_SET_PTR;
4450 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
4452 OperationRecord & op = filePtr.p->operation;
4453 if(!op.fragComplete(filePtr.p->tableId, filePtr.p->fragmentNo,
4454 c_defaults.m_o_direct))
4457 signal->theData[0] = BackupContinueB::BUFFER_FULL_FRAG_COMPLETE;
4458 signal->theData[1] = filePtr.i;
4459 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 50, 2);
4463 filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_SCAN_THREAD;
4465 if (ptr.p->is_lcp())
4467 ptr.p->slaveState.setState(STOPPING);
4468 filePtr.p->operation.dataBuffer.eof();
4473 conf->backupId = ptr.p->backupId;
4474 conf->backupPtr = ptr.i;
4475 conf->tableId = filePtr.p->tableId;
4476 conf->fragmentNo = filePtr.p->fragmentNo;
4477 conf->noOfRecordsLow = (Uint32)(op.noOfRecords & 0xFFFFFFFF);
4478 conf->noOfRecordsHigh = (Uint32)(op.noOfRecords >> 32);
4479 conf->noOfBytesLow = (Uint32)(op.noOfBytes & 0xFFFFFFFF);
4480 conf->noOfBytesHigh = (Uint32)(op.noOfBytes >> 32);
4481 sendSignal(ptr.p->masterRef, GSN_BACKUP_FRAGMENT_CONF, signal,
4482 BackupFragmentConf::SignalLength, JBB);
4484 ptr.p->m_gsn = GSN_BACKUP_FRAGMENT_CONF;
4485 ptr.p->slaveState.setState(STARTED);
4491 Backup::backupFragmentRef(
Signal * signal, BackupFilePtr filePtr)
4493 BackupRecordPtr ptr LINT_SET_PTR;
4494 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
4496 ptr.p->m_gsn = GSN_BACKUP_FRAGMENT_REF;
4499 ref->backupId = ptr.p->backupId;
4500 ref->backupPtr = ptr.i;
4501 ref->nodeId = getOwnNodeId();
4502 ref->errorCode = filePtr.p->errorCode;
4503 sendSignal(ptr.p->masterRef, GSN_BACKUP_FRAGMENT_REF, signal,
4504 BackupFragmentRef::SignalLength, JBB);
4511 BlockReference lqhRef = 0;
4514 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
4515 if (ptr.p->is_lcp()) {
4516 lqhRef = calcInstanceBlockRef(DBLQH);
4519 ndbrequire(findTable(ptr, tabPtr, filePtr.p->tableId));
4521 tabPtr.p->fragments.getPtr(fragPtr, filePtr.p->fragmentNo);
4522 const Uint32 instanceKey = fragPtr.p->lqhInstanceKey;
4523 lqhRef = numberToRef(DBLQH, instanceKey, getOwnNodeId());
4527 if(filePtr.p->errorCode != 0)
4536 req->senderData = filePtr.i;
4537 req->requestInfo = ScanFragNextReq::ZCLOSE;
4539 req->transId2 = (BACKUP << 20) + (getOwnNodeId() << 8);
4540 sendSignal(lqhRef, GSN_SCAN_NEXTREQ, signal,
4541 ScanFragNextReq::SignalLength, JBB);
4549 req->senderData = filePtr.i;
4550 req->requestInfo = 0;
4552 req->transId2 = (BACKUP << 20) + (getOwnNodeId() << 8);
4553 req->batch_size_rows= 16;
4554 req->batch_size_bytes= 0;
4556 if (ERROR_INSERTED(10039) &&
4557 filePtr.p->tableId >= 2 &&
4558 filePtr.p->operation.noOfRecords > 0)
4560 ndbout_c(
"halting backup for table %d fragment: %d after %llu records",
4562 filePtr.p->fragmentNo,
4563 filePtr.p->operation.noOfRecords);
4564 memmove(signal->theData+2, signal->theData,
4565 4*ScanFragNextReq::SignalLength);
4566 signal->theData[0] = BackupContinueB::ZDELAY_SCAN_NEXT;
4567 signal->theData[1] = filePtr.i;
4568 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
4569 300, 2+ScanFragNextReq::SignalLength);
4572 if(ERROR_INSERTED(10032))
4573 sendSignalWithDelay(lqhRef, GSN_SCAN_NEXTREQ, signal,
4574 100, ScanFragNextReq::SignalLength);
4575 else if(ERROR_INSERTED(10033))
4577 SET_ERROR_INSERT_VALUE(10032);
4578 sendSignalWithDelay(lqhRef, GSN_SCAN_NEXTREQ, signal,
4579 10000, ScanFragNextReq::SignalLength);
4582 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
4584 ord->backupId = ptr.p->backupId;
4585 ord->backupPtr = ptr.i;
4586 ord->requestType = AbortBackupOrd::FileOrScanError;
4587 ord->senderData= ptr.i;
4588 sendSignal(ptr.p->masterRef, GSN_ABORT_BACKUP_ORD, signal,
4589 AbortBackupOrd::SignalLength, JBB);
4592 else if (ERROR_INSERTED(10042) && filePtr.p->tableId ==c_error_insert_extra)
4594 sendSignalWithDelay(lqhRef, GSN_SCAN_NEXTREQ, signal,
4595 10, ScanFragNextReq::SignalLength);
4600 sendSignal(lqhRef, GSN_SCAN_NEXTREQ, signal,
4601 ScanFragNextReq::SignalLength, JBB);
4607 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
4608 if (!ptr.p->is_lcp())
4609 checkReportStatus(signal, ptr);
4614 signal->theData[0] = BackupContinueB::BUFFER_FULL_SCAN;
4615 signal->theData[1] = filePtr.i;
4616 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 50, 2);
4620 Backup::execFSAPPENDREF(
Signal* signal)
4627 const Uint32 errCode = ref->errorCode;
4629 BackupFilePtr filePtr LINT_SET_PTR;
4630 c_backupFilePool.
getPtr(filePtr, filePtrI);
4632 filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_FILE_THREAD;
4633 filePtr.p->errorCode = errCode;
4635 checkFile(signal, filePtr);
4639 Backup::execFSAPPENDCONF(
Signal* signal)
4643 CRASH_INSERTION((10018));
4646 const Uint32 filePtrI = signal->theData[0];
4647 const Uint32 bytes = signal->theData[1];
4649 BackupFilePtr filePtr LINT_SET_PTR;
4650 c_backupFilePool.
getPtr(filePtr, filePtrI);
4652 OperationRecord & op = filePtr.p->operation;
4654 op.dataBuffer.updateReadPtr(bytes >> 2);
4656 checkFile(signal, filePtr);
4679 Backup::ready_to_write(
bool ready, Uint32 sz,
bool eof,
BackupFile *fileP)
4682 ndbout <<
"ready_to_write: ready = " << ready <<
" eof = " << eof;
4683 ndbout <<
" sz = " << sz << endl;
4684 ndbout <<
"words this period = " << m_words_written_this_period;
4685 ndbout << endl <<
"overflow disk write = " << m_overflow_disk_write;
4686 ndbout << endl <<
"Current Millisecond is = ";
4687 ndbout << NdbTick_CurrentMillisecond() << endl;
4689 if ((ready || eof) &&
4690 m_words_written_this_period <= m_curr_disk_write_speed)
4703 m_words_written_this_period += sz;
4704 overflow = m_words_written_this_period - m_curr_disk_write_speed;
4706 m_overflow_disk_write = overflow;
4708 ndbout <<
"Will write with " << endl;
4716 ndbout <<
"Will not write now" << endl << endl;
4723 Backup::checkFile(
Signal* signal, BackupFilePtr filePtr)
4730 OperationRecord & op = filePtr.p->operation;
4734 bool ready = op.dataBuffer.getReadPtr(&tmp, &sz, &eof);
4736 ndbout <<
"Ptr to data = " << hex << tmp << endl;
4738 BackupRecordPtr ptr LINT_SET_PTR;
4739 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
4741 if (ERROR_INSERTED(10036))
4744 filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_FILE_THREAD;
4745 filePtr.p->errorCode = 2810;
4746 ptr.p->setErrorCode(2810);
4748 if(ptr.p->m_gsn == GSN_STOP_BACKUP_REQ)
4751 closeFile(signal, ptr, filePtr);
4756 if(filePtr.p->errorCode != 0)
4759 ptr.p->setErrorCode(filePtr.p->errorCode);
4761 if(ptr.p->m_gsn == GSN_STOP_BACKUP_REQ)
4764 closeFile(signal, ptr, filePtr);
4769 if (!ready_to_write(ready, sz, eof, filePtr.p))
4772 signal->theData[0] = BackupContinueB::BUFFER_UNDERFLOW;
4773 signal->theData[1] = filePtr.i;
4774 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 20, 2);
4782 req->filePointer = filePtr.p->filePointer;
4783 req->userPointer = filePtr.i;
4784 req->userReference = reference();
4788 req->synch_flag = 0;
4790 sendSignal(NDBFS_REF, GSN_FSAPPENDREQ, signal,
4791 FsAppendReq::SignalLength, JBA);
4795 Uint32 flags = filePtr.p->m_flags;
4796 filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_FILE_THREAD;
4798 ndbrequire(flags & BackupFile::BF_OPEN);
4799 ndbrequire(flags & BackupFile::BF_FILE_THREAD);
4801 closeFile(signal, ptr, filePtr);
4819 Uint32 trigger_id = signal->theData[0];
4820 Uint32 frag_id = signal->theData[1];
4825 c_triggerPool.
getPtr(trigPtr, trigger_id);
4828 tabPtr.p->fragments.getPtr(fragPtr, frag_id);
4829 if (fragPtr.p->node != getOwnNodeId()) {
4837 signal->theData[0] = result;
4841 Backup::get_log_buffer(
Signal* signal,
4842 TriggerPtr trigPtr, Uint32 sz)
4845 if(ERROR_INSERTED(10030))
4853 FsBuffer & buf = trigPtr.p->operation->dataBuffer;
4862 if (unlikely(dst == 0))
4864 Uint32 save[TrigAttrInfo::StaticLength];
4865 memcpy(save, signal->getDataPtr(), 4*TrigAttrInfo::StaticLength);
4866 BackupRecordPtr ptr LINT_SET_PTR;
4867 c_backupPool.
getPtr(ptr, trigPtr.p->backupPtr);
4868 trigPtr.p->errorCode = AbortBackupOrd::LogBufferFull;
4870 ord->backupId = ptr.p->backupId;
4871 ord->backupPtr = ptr.i;
4872 ord->requestType = AbortBackupOrd::LogBufferFull;
4873 ord->senderData= ptr.i;
4874 sendSignal(ptr.p->masterRef, GSN_ABORT_BACKUP_ORD, signal,
4875 AbortBackupOrd::SignalLength, JBB);
4877 memcpy(signal->getDataPtrSend(), save, 4*TrigAttrInfo::StaticLength);
4883 logEntry->Length = 0;
4884 logEntry->TableId = htonl(trigPtr.p->tableId);
4886 if(trigPtr.p->event==0)
4887 logEntry->TriggerEvent= htonl(TriggerEvent::TE_INSERT);
4888 else if(trigPtr.p->event==1)
4889 logEntry->TriggerEvent= htonl(TriggerEvent::TE_UPDATE);
4890 else if(trigPtr.p->event==2)
4891 logEntry->TriggerEvent= htonl(TriggerEvent::TE_DELETE);
4893 ndbout <<
"Bad Event: " << trigPtr.p->event << endl;
4904 CRASH_INSERTION((10019));
4909 c_triggerPool.
getPtr(trigPtr, trg->getTriggerId());
4910 ndbrequire(trigPtr.p->event != ILLEGAL_TRIGGER_ID);
4912 if(trigPtr.p->errorCode != 0) {
4918 c_backupPool.
getPtr(ptr, trigPtr.p->backupPtr);
4920 if(ptr.p->flags & BackupReq::USE_UNDO_LOG) {
4921 if(trg->getAttrInfoType() == TrigAttrInfo::AFTER_VALUES) {
4930 if(trg->getAttrInfoType() == TrigAttrInfo::BEFORE_VALUES) {
4943 Uint32 sz = trigPtr.p->maxRecordSize;
4944 logEntry = trigPtr.p->logEntry = get_log_buffer(signal, trigPtr, sz);
4945 if (unlikely(logEntry == 0))
4951 ndbrequire(logEntry->TableId == htonl(trigPtr.p->tableId));
4955 const Uint32 pos = logEntry->Length;
4956 const Uint32 dataLen = signal->
length() - TrigAttrInfo::StaticLength;
4957 memcpy(&logEntry->Data[pos], trg->getData(), dataLen << 2);
4959 logEntry->Length = pos + dataLen;
4968 const Uint32 gci = trg->getGCI();
4969 const Uint32 trI = trg->getTriggerId();
4970 const Uint32 fragId = trg->fragId;
4973 c_triggerPool.
getPtr(trigPtr, trI);
4975 ndbrequire(trigPtr.p->event != ILLEGAL_TRIGGER_ID);
4978 c_backupPool.
getPtr(ptr, trigPtr.p->backupPtr);
4980 if(trigPtr.p->errorCode != 0) {
4983 releaseSections(handle);
4987 if (signal->getNoOfSections())
4994 tabPtr.p->fragments.getPtr(fragPtr, fragId);
4995 if (fragPtr.p->node != getOwnNodeId())
4998 trigPtr.p->logEntry = 0;
4999 releaseSections(handle);
5004 handle.getSection(dataPtr[0], 0);
5005 handle.getSection(dataPtr[1], 1);
5006 handle.getSection(dataPtr[2], 2);
5016 if(ptr.p->flags & BackupReq::USE_UNDO_LOG) {
5017 trigPtr.p->logEntry = get_log_buffer(signal,
5018 trigPtr, dataPtr[0].sz + dataPtr[1].sz + 2);
5019 if (unlikely(trigPtr.p->logEntry == 0))
5022 releaseSections(handle);
5025 copy(trigPtr.p->logEntry->Data, dataPtr[0]);
5026 copy(trigPtr.p->logEntry->Data+dataPtr[0].sz, dataPtr[1]);
5027 trigPtr.p->logEntry->Length = dataPtr[0].sz + dataPtr[1].sz;
5031 trigPtr.p->logEntry = get_log_buffer(signal,
5032 trigPtr, dataPtr[0].sz + dataPtr[2].sz + 1);
5033 if (unlikely(trigPtr.p->logEntry == 0))
5036 releaseSections(handle);
5039 copy(trigPtr.p->logEntry->Data, dataPtr[0]);
5040 copy(trigPtr.p->logEntry->Data+dataPtr[0].sz, dataPtr[2]);
5041 trigPtr.p->logEntry->Length = dataPtr[0].sz + dataPtr[2].sz;
5044 releaseSections(handle);
5047 ndbrequire(trigPtr.p->logEntry != 0);
5048 Uint32 len = trigPtr.p->logEntry->Length;
5049 trigPtr.p->logEntry->FragId = htonl(fragId);
5051 if(gci != ptr.p->currGCP)
5054 trigPtr.p->logEntry->TriggerEvent|= htonl(0x10000);
5055 trigPtr.p->logEntry->Data[len] = htonl(gci);
5057 ptr.p->currGCP = gci;
5060 Uint32 datalen = len;
5062 trigPtr.p->logEntry->Length = htonl(len);
5064 if(ptr.p->flags & BackupReq::USE_UNDO_LOG)
5069 trigPtr.p->logEntry->Data[datalen] = htonl(len);
5072 Uint32 entryLength = len +1;
5073 if(ptr.p->flags & BackupReq::USE_UNDO_LOG)
5076 ndbrequire(entryLength <= trigPtr.p->operation->dataBuffer.getMaxWrite());
5077 trigPtr.p->operation->dataBuffer.updateWritePtr(entryLength);
5078 trigPtr.p->logEntry = 0;
5081 const Uint32 entryByteLength = entryLength << 2;
5082 trigPtr.p->operation->noOfBytes += entryByteLength;
5083 trigPtr.p->operation->m_bytes_total += entryByteLength;
5084 trigPtr.p->operation->noOfRecords += 1;
5085 trigPtr.p->operation->m_records_total += 1;
5090 Backup::sendAbortBackupOrd(
Signal* signal, BackupRecordPtr ptr,
5095 ord->backupId = ptr.p->backupId;
5096 ord->backupPtr = ptr.i;
5097 ord->requestType = requestType;
5098 ord->senderData= ptr.i;
5100 for(c_nodes.
first(node); node.i != RNIL; c_nodes.
next(node)) {
5102 const Uint32 nodeId = node.p->nodeId;
5103 if(node.p->alive && ptr.p->nodes.get(nodeId)) {
5105 BlockReference ref = numberToRef(BACKUP, instanceKey(ptr), nodeId);
5106 sendSignal(ref, GSN_ABORT_BACKUP_ORD, signal,
5107 AbortBackupOrd::SignalLength, JBB);
5123 CRASH_INSERTION((10020));
5125 const Uint32 ptrI = req->backupPtr;
5127 const Uint32 startGCP = req->startGCP;
5128 const Uint32 stopGCP = req->stopGCP;
5133 ndbrequire(stopGCP > startGCP);
5139 c_backupPool.
getPtr(ptr, ptrI);
5141 ptr.p->slaveState.setState(STOPPING);
5142 ptr.p->m_gsn = GSN_STOP_BACKUP_REQ;
5143 ptr.p->startGCP= startGCP;
5144 ptr.p->stopGCP= stopGCP;
5160 for(ptr.p->files.first(filePtr); filePtr.i!=RNIL; ptr.p->files.next(filePtr))
5162 if(! (filePtr.p->m_flags & BackupFile::BF_OPEN))
5171 if(filePtr.p->m_flags & BackupFile::BF_CLOSING)
5177 filePtr.p->operation.dataBuffer.eof();
5178 if(filePtr.p->m_flags & BackupFile::BF_FILE_THREAD)
5182 ndbout_c(
"Close files fileRunning == 1, filePtr.i=%u", filePtr.i);
5188 closeFile(sig, ptr, filePtr);
5194 closeFilesDone(sig, ptr);
5199 Backup::closeFile(
Signal* signal, BackupRecordPtr ptr, BackupFilePtr filePtr)
5201 ndbrequire(filePtr.p->m_flags & BackupFile::BF_OPEN);
5202 ndbrequire(! (filePtr.p->m_flags & BackupFile::BF_OPENING));
5203 ndbrequire(! (filePtr.p->m_flags & BackupFile::BF_CLOSING));
5204 filePtr.p->m_flags |= BackupFile::BF_CLOSING;
5207 req->filePointer = filePtr.p->filePointer;
5208 req->userPointer = filePtr.i;
5209 req->userReference = reference();
5212 if (ptr.p->errorCode)
5214 FsCloseReq::setRemoveFileFlag(req->fileFlag, 1);
5218 ndbout_c(
"***** a FSCLOSEREQ filePtr.i = %u flags: %x",
5219 filePtr.i, filePtr.p->m_flags);
5221 sendSignal(NDBFS_REF, GSN_FSCLOSEREQ, signal, FsCloseReq::SignalLength, JBA);
5226 Backup::execFSCLOSEREF(
Signal* signal)
5233 BackupFilePtr filePtr LINT_SET_PTR;
5234 c_backupFilePool.
getPtr(filePtr, filePtrI);
5236 BackupRecordPtr ptr LINT_SET_PTR;
5237 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
5240 conf->userPointer = filePtrI;
5242 execFSCLOSECONF(signal);
5246 Backup::execFSCLOSECONF(
Signal* signal)
5251 const Uint32 filePtrI = conf->userPointer;
5253 BackupFilePtr filePtr LINT_SET_PTR;
5254 c_backupFilePool.
getPtr(filePtr, filePtrI);
5257 ndbout_c(
"***** FSCLOSECONF filePtrI = %u", filePtrI);
5260 ndbrequire(filePtr.p->m_flags == (BackupFile::BF_OPEN |
5261 BackupFile::BF_CLOSING));
5264 filePtr.p->m_flags &= ~(Uint32)(BackupFile::BF_OPEN |BackupFile::BF_CLOSING);
5265 filePtr.p->operation.dataBuffer.reset();
5267 BackupRecordPtr ptr LINT_SET_PTR;
5268 c_backupPool.
getPtr(ptr, filePtr.p->backupPtr);
5273 Backup::closeFilesDone(
Signal* signal, BackupRecordPtr ptr)
5279 lcp_close_file_conf(signal, ptr);
5286 if(ptr.p->checkError())
5289 ref->backupPtr = ptr.i;
5290 ref->backupId = ptr.p->backupId;
5291 ref->errorCode = ptr.p->errorCode;
5292 ref->nodeId = getOwnNodeId();
5293 sendSignal(ptr.p->masterRef, GSN_STOP_BACKUP_REF, signal,
5294 StopBackupConf::SignalLength, JBB);
5296 ptr.p->m_gsn = GSN_STOP_BACKUP_REF;
5297 ptr.p->slaveState.setState(CLEANING);
5302 conf->backupId = ptr.p->backupId;
5303 conf->backupPtr = ptr.i;
5305 BackupFilePtr filePtr LINT_SET_PTR;
5306 if(ptr.p->logFilePtr != RNIL)
5308 ptr.p->files.getPtr(filePtr, ptr.p->logFilePtr);
5309 conf->noOfLogBytes= Uint32(filePtr.p->operation.noOfBytes);
5310 conf->noOfLogRecords= Uint32(filePtr.p->operation.noOfRecords);
5314 conf->noOfLogBytes= 0;
5315 conf->noOfLogRecords= 0;
5318 sendSignal(ptr.p->masterRef, GSN_STOP_BACKUP_CONF, signal,
5319 StopBackupConf::SignalLength, JBB);
5321 ptr.p->m_gsn = GSN_STOP_BACKUP_CONF;
5322 ptr.p->slaveState.setState(CLEANING);
5341 const Uint32 backupId = ord->backupId;
5342 const AbortBackupOrd::RequestType requestType =
5343 (AbortBackupOrd::RequestType)ord->requestType;
5344 const Uint32 senderData = ord->senderData;
5347 ndbout_c(
"******** ABORT_BACKUP_ORD ********* nodeId = %u",
5348 refToNode(signal->getSendersBlockRef()));
5349 ndbout_c(
"backupId = %u, requestType = %u, senderData = %u, ",
5350 backupId, requestType, senderData);
5351 dumpUsedResources();
5355 if(requestType == AbortBackupOrd::ClientAbort) {
5356 if (getOwnNodeId() != getMasterNodeId()) {
5360 ndbout_c(
"---- Forward to master nodeId = %u", getMasterNodeId());
5362 BlockReference ref = numberToRef(BACKUP, UserBackupInstanceKey,
5364 sendSignal(ref, GSN_ABORT_BACKUP_ORD,
5365 signal, AbortBackupOrd::SignalLength, JBB);
5369 for(c_backups.
first(ptr); ptr.i != RNIL; c_backups.
next(ptr)) {
5371 if(ptr.p->backupId == backupId && ptr.p->clientData == senderData) {
5381 if (c_backupPool.
findId(senderData)) {
5383 c_backupPool.
getPtr(ptr, senderData);
5387 ndbout_c(
"Backup: abort request type=%u on id=%u,%u not found",
5388 requestType, backupId, senderData);
5394 ptr.p->m_gsn = GSN_ABORT_BACKUP_ORD;
5395 const bool isCoordinator = (ptr.p->masterRef == reference());
5398 switch(requestType){
5403 case AbortBackupOrd::ClientAbort:
5406 case AbortBackupOrd::LogBufferFull:
5409 case AbortBackupOrd::FileOrScanError:
5411 ndbrequire(isCoordinator);
5412 ptr.p->setErrorCode(requestType);
5413 if(ptr.p->masterData.gsn == GSN_BACKUP_FRAGMENT_REQ)
5418 abort_scan(signal, ptr);
5425 case AbortBackupOrd::AbortScan:
5427 ptr.p->setErrorCode(requestType);
5430 case AbortBackupOrd::BackupComplete:
5432 cleanup(signal, ptr);
5434 case AbortBackupOrd::BackupFailure:
5435 case AbortBackupOrd::BackupFailureDueToNodeFail:
5436 case AbortBackupOrd::OkToClean:
5437 case AbortBackupOrd::IncompatibleVersions:
5441 ptr.p->setErrorCode(requestType);
5442 ptr.p->masterData.errorCode = requestType;
5447 ptr.p->masterRef = reference();
5448 ptr.p->nodes.clear();
5449 ptr.p->nodes.set(getOwnNodeId());
5452 ptr.p->stopGCP= ptr.p->startGCP + 1;
5453 sendStopBackup(signal, ptr);
5458 Backup::dumpUsedResources()
5461 BackupRecordPtr ptr;
5463 for(c_backups.
first(ptr); ptr.i != RNIL; c_backups.
next(ptr)) {
5464 ndbout_c(
"Backup id=%u, slaveState.getState = %u, errorCode=%u",
5466 ptr.p->slaveState.getState(),
5470 for(ptr.p->tables.first(tabPtr);
5472 ptr.p->tables.next(tabPtr)) {
5474 for(Uint32 j = 0; j<3; j++) {
5476 TriggerPtr trigPtr LINT_SET_PTR;
5477 if(tabPtr.p->triggerAllocated[j]) {
5479 c_triggerPool.
getPtr(trigPtr, tabPtr.p->triggerIds[j]);
5480 ndbout_c(
"Allocated[%u] Triggerid = %u, event = %u",
5482 tabPtr.p->triggerIds[j],
5488 BackupFilePtr filePtr;
5489 for(ptr.p->files.first(filePtr);
5491 ptr.p->files.next(filePtr)) {
5493 ndbout_c(
"filePtr.i = %u, flags: H'%x ",
5494 filePtr.i, filePtr.p->m_flags);
5500 Backup::cleanup(
Signal* signal, BackupRecordPtr ptr)
5503 ptr.p->tables.first(tabPtr);
5504 cleanupNextTable(signal, ptr, tabPtr);
5508 Backup::cleanupNextTable(
Signal *signal, BackupRecordPtr ptr, TablePtr tabPtr)
5510 if (tabPtr.i != RNIL)
5513 tabPtr.p->fragments.release();
5514 for(Uint32 j = 0; j<3; j++) {
5516 TriggerPtr trigPtr LINT_SET_PTR;
5517 if(tabPtr.p->triggerAllocated[j]) {
5519 c_triggerPool.
getPtr(trigPtr, tabPtr.p->triggerIds[j]);
5520 trigPtr.p->event = ILLEGAL_TRIGGER_ID;
5521 tabPtr.p->triggerAllocated[j] =
false;
5523 tabPtr.p->triggerIds[j] = ILLEGAL_TRIGGER_ID;
5527 req->m_senderRef = reference();
5528 req->m_tableId = tabPtr.p->tableId;
5529 req->m_lock_unlock = BackupLockTab::UNLOCK_TABLE;
5530 req->m_backup_state = BackupLockTab::CLEANUP;
5531 req->m_backupRecordPtr_I = ptr.i;
5532 req->m_tablePtr_I = tabPtr.i;
5533 sendSignal(DBDICT_REF, GSN_BACKUP_LOCK_TAB_REQ, signal,
5534 BackupLockTab::SignalLength, JBB);
5539 BackupFilePtr filePtr;
5540 for(ptr.p->files.first(filePtr);filePtr.i != RNIL;ptr.p->files.next(filePtr))
5543 ndbrequire(filePtr.p->m_flags == 0);
5544 filePtr.p->pages.release();
5547 ptr.p->files.release();
5548 ptr.p->tables.release();
5549 ptr.p->triggers.release();
5550 ptr.p->backupId = ~0;
5556 ptr.p->ctlFilePtr = ptr.p->logFilePtr = ptr.p->dataFilePtr = RNIL;
5558 if(ptr.p->checkError())
5559 removeBackup(signal, ptr);
5567 ptr.p->masterData.gsn = 0;
5574 Backup::removeBackup(
Signal* signal, BackupRecordPtr ptr)
5579 req->userReference = reference();
5580 req->userPointer = ptr.i;
5582 req->ownDirectory = 1;
5583 FsOpenReq::setVersion(req->fileNumber, 2);
5584 FsOpenReq::setSuffix(req->fileNumber, FsOpenReq::S_CTL);
5585 FsOpenReq::v2_setSequence(req->fileNumber, ptr.p->backupId);
5586 FsOpenReq::v2_setNodeId(req->fileNumber, getOwnNodeId());
5587 sendSignal(NDBFS_REF, GSN_FSREMOVEREQ, signal,
5588 FsRemoveReq::SignalLength, JBA);
5592 Backup::execFSREMOVEREF(
Signal* signal)
5599 conf->userPointer = ptrI;
5608 const Uint32 ptrI = conf->userPointer;
5614 c_backupPool.
getPtr(ptr, ptrI);
5620 ptr.p->masterData.gsn = 0;
5634 c_backupPool.
getPtr(ptr, req.backupPtr);
5636 ptr.p->m_gsn = GSN_LCP_PREPARE_REQ;
5640 if (!ptr.p->tables.isEmpty())
5643 ndbrequire(ptr.p->errorCode);
5644 ptr.p->tables.first(tabPtr);
5645 if (tabPtr.p->tableId == req.tableId)
5648 ndbrequire(!tabPtr.p->fragments.empty());
5649 tabPtr.p->fragments.getPtr(fragPtr, 0);
5650 fragPtr.p->fragmentId = req.fragmentId;
5651 defineBackupRef(signal, ptr, ptr.p->errorCode);
5657 tabPtr.p->fragments.release();
5658 ptr.p->tables.release();
5659 ptr.p->errorCode = 0;
5664 if(!ptr.p->tables.seize(tabPtr) || !tabPtr.p->fragments.seize(1))
5666 if(!tabPtr.isNull())
5667 ptr.p->tables.release();
5670 tabPtr.p->tableId = req.tableId;
5671 tabPtr.p->fragments.getPtr(fragPtr, 0);
5672 tabPtr.p->tableType = DictTabInfo::UserTable;
5673 fragPtr.p->fragmentId = req.fragmentId;
5674 fragPtr.p->lcp_no = req.lcpNo;
5675 fragPtr.p->scanned = 0;
5676 fragPtr.p->scanning = 0;
5677 fragPtr.p->tableId = req.tableId;
5679 ptr.p->backupId= req.backupId;
5684 Backup::lcp_close_file_conf(
Signal* signal, BackupRecordPtr ptr)
5689 ndbrequire(ptr.p->tables.first(tabPtr));
5690 Uint32 tableId = tabPtr.p->tableId;
5692 BackupFilePtr filePtr LINT_SET_PTR;
5693 c_backupFilePool.
getPtr(filePtr, ptr.p->dataFilePtr);
5694 ndbrequire(filePtr.p->m_flags == 0);
5696 if (ptr.p->m_gsn == GSN_LCP_PREPARE_REQ)
5699 defineBackupRef(signal, ptr, ptr.p->errorCode);
5703 FragmentPtr fragPtr;
5704 tabPtr.p->fragments.getPtr(fragPtr, 0);
5705 Uint32 fragmentId = fragPtr.p->fragmentId;
5707 tabPtr.p->fragments.release();
5708 ptr.p->tables.release();
5709 ptr.p->errorCode = 0;
5712 conf->backupId = ptr.p->backupId;
5713 conf->backupPtr = ptr.i;
5714 conf->tableId = tableId;
5715 conf->fragmentNo = fragmentId;
5716 conf->noOfRecordsLow = 0;
5717 conf->noOfRecordsHigh = 0;
5718 conf->noOfBytesLow = 0;
5719 conf->noOfBytesHigh = 0;
5720 sendSignal(ptr.p->masterRef, GSN_BACKUP_FRAGMENT_CONF, signal,
5721 BackupFragmentConf::SignalLength, JBB);
5728 req->userReference = reference();
5730 FsOpenReq::OM_WRITEONLY |
5731 FsOpenReq::OM_TRUNCATE |
5732 FsOpenReq::OM_CREATE |
5733 FsOpenReq::OM_APPEND |
5734 FsOpenReq::OM_AUTOSYNC;
5736 if (c_defaults.m_compressed_lcp)
5737 req->fileFlags |= FsOpenReq::OM_GZ;
5739 if (c_defaults.m_o_direct)
5740 req->fileFlags |= FsOpenReq::OM_DIRECT;
5741 FsOpenReq::v2_setCount(req->fileNumber, 0xFFFFFFFF);
5742 req->auto_sync_size = c_defaults.m_disk_synch_size;
5747 ndbrequire(ptr.p->tables.first(tabPtr));
5748 tabPtr.p->fragments.getPtr(fragPtr, 0);
5754 c_backupFilePool.
getPtr(filePtr, ptr.p->dataFilePtr);
5755 ndbrequire(filePtr.p->m_flags == 0);
5756 filePtr.p->m_flags |= BackupFile::BF_OPENING;
5757 filePtr.p->tableId = RNIL;
5758 req->userPointer = filePtr.i;
5759 FsOpenReq::setVersion(req->fileNumber, 5);
5760 FsOpenReq::setSuffix(req->fileNumber, FsOpenReq::S_DATA);
5761 FsOpenReq::v5_setLcpNo(req->fileNumber, fragPtr.p->lcp_no);
5762 FsOpenReq::v5_setTableId(req->fileNumber, tabPtr.p->tableId);
5763 FsOpenReq::v5_setFragmentId(req->fileNumber, fragPtr.p->fragmentId);
5764 sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA);
5773 ndbrequire(ptr.p->tables.first(tabPtr));
5774 tabPtr.p->fragments.getPtr(fragPtr, 0);
5777 c_backupFilePool.
getPtr(filePtr, ptr.p->dataFilePtr);
5778 ndbrequire(filePtr.p->m_flags ==
5779 (BackupFile::BF_OPEN | BackupFile::BF_LCP_META));
5780 filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_LCP_META;
5782 ptr.p->slaveState.setState(STARTED);
5785 conf->senderData = ptr.p->clientData;
5786 conf->senderRef = reference();
5787 conf->tableId = tabPtr.p->tableId;
5788 conf->fragmentId = fragPtr.p->fragmentId;
5789 sendSignal(ptr.p->masterRef, GSN_LCP_PREPARE_CONF,
5790 signal, LcpPrepareConf::SignalLength, JBB);
5795 filePtr.p->m_flags |= BackupFile::BF_FILE_THREAD;
5797 signal->theData[0] = BackupContinueB::START_FILE_THREAD;
5798 signal->theData[1] = filePtr.i;
5799 signal->theData[2] = __LINE__;
5800 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 3);
5804 Backup::execEND_LCPREQ(
Signal* signal)
5808 BackupRecordPtr ptr LINT_SET_PTR;
5809 c_backupPool.
getPtr(ptr, req->backupPtr);
5810 ndbrequire(ptr.p->backupId == req->backupId);
5812 BackupFilePtr filePtr LINT_SET_PTR;
5813 ptr.p->files.getPtr(filePtr, ptr.p->ctlFilePtr);
5814 ndbrequire(filePtr.p->m_flags == 0);
5816 if (!ptr.p->tables.isEmpty())
5819 ndbrequire(ptr.p->errorCode);
5821 ptr.p->tables.first(tabPtr);
5822 tabPtr.p->fragments.release();
5823 ptr.p->tables.release();
5824 ptr.p->errorCode = 0;
5827 ptr.p->errorCode = 0;
5828 ptr.p->slaveState.setState(CLEANING);
5829 ptr.p->slaveState.setState(INITIAL);
5830 ptr.p->slaveState.setState(DEFINING);
5831 ptr.p->slaveState.setState(DEFINED);
5834 conf->senderData = ptr.p->clientData;
5835 conf->senderRef = reference();
5836 sendSignal(ptr.p->masterRef, GSN_END_LCPCONF,
5837 signal, EndLcpConf::SignalLength, JBB);