21 #include <ndb_limits.h>
22 #include <SimulatedBlock.hpp>
24 #include "FsBuffer.hpp"
25 #include "BackupFormat.hpp"
27 #include <NodeBitmask.hpp>
28 #include <SimpleProperties.hpp>
31 #include <DLFifoList.hpp>
32 #include <DLCFifoList.hpp>
33 #include <SignalCounter.hpp>
34 #include <blocks/mutexes.hpp>
54 void execSTTOR(
Signal* signal);
55 void execREAD_CONFIG_REQ(
Signal* signal);
57 void execREAD_NODESCONF(
Signal* signal);
58 void execNODE_FAILREP(
Signal* signal);
59 void execINCL_NODEREQ(
Signal* signal);
60 void execCONTINUEB(
Signal* signal);
66 void execBACKUP_CONF(
Signal* signal);
67 void execBACKUP_ABORT_REP(
Signal* signal);
68 void execBACKUP_COMPLETE_REP(
Signal* signal);
74 void execBACKUP_DATA(
Signal* signal);
77 void execBACKUP_FRAGMENT_COMPLETE_REP(
Signal* signal);
79 void execBACKUP_STATUS_REQ(
Signal* signal);
87 void execSCAN_FRAGREF(
Signal* signal);
88 void execSCAN_FRAGCONF(
Signal* signal);
101 void execGET_TABINFOREF(
Signal* signal);
102 void execGET_TABINFO_CONF(
Signal* signal);
105 void execDROP_TRIG_IMPL_REF(
Signal* signal);
106 void execDROP_TRIG_IMPL_CONF(
Signal* signal);
112 void execDIH_SCAN_GET_NODES_CONF(
Signal* signal);
118 void execFSOPENCONF(
Signal* signal);
120 void execFSCLOSEREF(
Signal* signal);
121 void execFSCLOSECONF(
Signal* signal);
123 void execFSAPPENDREF(
Signal* signal);
124 void execFSAPPENDCONF(
Signal* signal);
126 void execFSREMOVEREF(
Signal* signal);
133 void execABORT_BACKUP_REQ(
Signal* signal);
135 void execDEFINE_BACKUP_REF(
Signal* signal);
136 void execDEFINE_BACKUP_CONF(
Signal* signal);
138 void execSTART_BACKUP_REF(
Signal* signal);
139 void execSTART_BACKUP_CONF(
Signal* signal);
141 void execBACKUP_FRAGMENT_REF(
Signal* signal);
142 void execBACKUP_FRAGMENT_CONF(
Signal* signal);
144 void execSTOP_BACKUP_REF(
Signal* signal);
145 void execSTOP_BACKUP_CONF(
Signal* signal);
147 void execBACKUP_STATUS_CONF(
Signal* signal);
149 void execUTIL_SEQUENCE_REF(
Signal* signal);
150 void execUTIL_SEQUENCE_CONF(
Signal* signal);
152 void execWAIT_GCP_REF(
Signal* signal);
154 void execBACKUP_LOCK_TAB_CONF(
Signal *signal);
155 void execBACKUP_LOCK_TAB_REF(
Signal *signal);
158 void execLCP_FRAGMENT_REQ(
Signal*);
159 void execEND_LCPREQ(
Signal* signal);
161 void execDBINFO_SCANREQ(
Signal *signal);
164 void defineBackupMutex_locked(
Signal* signal, Uint32 ptrI,Uint32 retVal);
165 void dictCommitTableMutex_locked(
Signal* signal, Uint32 ptrI,Uint32 retVal);
172 union { Uint32 prevList; Uint32 nextPool; };
176 #define BACKUP_WORDS_PER_PAGE 8191
179 Uint32 data[BACKUP_WORDS_PER_PAGE];
193 Uint8 lqhInstanceKey;
212 Uint32 schemaVersion;
214 Uint32 m_scan_cookie;
215 Uint32 triggerIds[3];
216 bool triggerAllocated[3];
217 Uint32 maxRecordSize;
219 Uint32 noOfAttributes;
228 union { Uint32 nextPool; Uint32 prevList; };
245 bool fragComplete(Uint32 tableId, Uint32 fragNo,
bool fill_record);
251 bool scanConf(Uint32 noOfOps, Uint32 opLen);
258 void finished(Uint32 len);
274 Uint32 maxRecordSize;
280 Uint64 m_records_total;
281 Uint64 m_bytes_total;
288 union { Uint32 nextPool; Uint32 nextList; };
293 BlockNumber number()
const {
return backup.number(); }
295 void progError(
int line,
int cause,
const char *
extra) {
305 Uint32 maxRecordSize;
311 union { Uint32 nextPool; Uint32 nextList; };
320 : operation(backup), pages(pp) { m_retry_count = 0; }
326 Uint32 m_retry_count;
333 union { Uint32 prevList; Uint32 nextPool; };
339 ,BF_FILE_THREAD = 0x8
340 ,BF_SCAN_THREAD = 0x10
363 static const Uint32 validSlaveTransitionsCount;
364 static const Uint32 validMasterTransitionsCount;
365 static const State validSlaveTransitions[];
366 static const State validMasterTransitions[];
372 Uint32 count, Uint32 _id)
374 , validTransitions(valid),
375 noOfValidTransitions(count), id(_id)
381 void setState(
State s);
382 State getState()
const {
return state;}
383 State getAbortState()
const {
return abortState;}
385 void forceState(
State s);
387 BlockNumber number()
const {
return backup.number(); }
389 void progError(
int line,
int cause,
const char *
extra) {
399 const State * validTransitions;
400 const Uint32 noOfValidTransitions;
415 : slaveState(b, validSlaveTransitions, validSlaveTransitionsCount,1)
416 , tables(tp), triggers(trp), files(bp)
417 , ctlFilePtr(RNIL), logFilePtr(RNIL), dataFilePtr(RNIL)
418 , masterData(b), backup(b)
430 Uint64 m_next_report;
448 Uint64 noOfLogRecords;
461 Uint32 backupDataLen;
504 union { Uint32 prevList; Uint32 nextPool; };
506 void setErrorCode(Uint32 errCode){
511 bool checkError()
const {
512 return errorCode != 0;
515 bool is_lcp()
const {
516 return backupDataLen == ~(Uint32)0;
520 BlockNumber number()
const {
return backup.number(); }
522 void progError(
int line,
int cause,
const char *
extra) {
526 friend struct BackupRecord;
530 Uint32 m_dataBufferSize;
531 Uint32 m_logBufferSize;
532 Uint32 m_minWriteSize;
533 Uint32 m_maxWriteSize;
534 Uint32 m_lcp_buffer_size;
536 Uint32 m_disk_write_speed_sr;
537 Uint32 m_disk_write_speed;
538 Uint32 m_disk_synch_size;
541 Uint32 m_compressed_backup;
542 Uint32 m_compressed_lcp;
549 NodeId c_masterNodeId;
558 Uint32 m_curr_disk_write_speed;
559 Uint32 m_words_written_this_period;
560 Uint32 m_overflow_disk_write;
561 Uint32 m_reset_delay_used;
562 NDB_TICKS m_reset_disk_speed_time;
563 static const int DISK_SPEED_CHECK_DELAY = 100;
565 STATIC_CONST(NO_OF_PAGES_META_FILE =
566 (2*MAX_WORDS_META_FILE + BACKUP_WORDS_PER_PAGE - 1) /
567 BACKUP_WORDS_PER_PAGE);
569 Uint32 m_backup_report_frequency;
628 bool executeDirect =
false);
647 Uint32 theFailedNodes[NdbNodeBitmask::Size]);
651 NodeId getMasterNodeId()
const {
return c_masterNodeId; }
652 bool findTable(
const BackupRecordPtr &, TablePtr &, Uint32 tableId)
const;
656 void sendBackupRef(
Signal* signal, BackupRecordPtr ptr, Uint32 errorCode);
657 void sendBackupRef(BlockReference ref, Uint32
flags,
Signal *signal,
658 Uint32 senderData, Uint32 errorCode);
659 void dumpUsedResources();
660 void cleanup(
Signal*, BackupRecordPtr ptr);
661 void abort_scan(
Signal*, BackupRecordPtr ptr);
662 void removeBackup(
Signal*, BackupRecordPtr ptr);
664 void sendUtilSequenceReq(
Signal*, BackupRecordPtr ptr, Uint32 delay = 0);
670 void initReportStatus(
Signal* signal, BackupRecordPtr ptr);
672 void checkReportStatus(
Signal* signal, BackupRecordPtr ptr);
674 void reportStatus(
Signal* signal, BackupRecordPtr ptr,
675 BlockReference ref = CMVMI_REF);
677 void sendSTTORRY(
Signal*);
678 void createSequence(
Signal* signal);
683 void lcp_close_file_conf(
Signal* signal, BackupRecordPtr);
684 void read_lcp_descriptor(
Signal*, BackupRecordPtr, TablePtr);
686 bool ready_to_write(
bool ready, Uint32 sz,
bool eof,
BackupFile *fileP);
689 BackupRecordPtr ptr, TablePtr tabPtr);
690 void cleanupNextTable(
Signal *signal, BackupRecordPtr ptr, TablePtr tabPtr);
698 STATIC_CONST( UserBackupInstanceKey = 1 );
699 Uint32 instanceKey(BackupRecordPtr ptr) {
700 return ptr.p->is_lcp() ? instance() : UserBackupInstanceKey;
714 Backup::OperationRecord::finished(Uint32 len)