From: Date: November 13 2007 2:46pm Subject: bk commit into 5.1 tree (lzhou:1.2548) BUG#26498 List-Archive: http://lists.mysql.com/commits/37631 X-Bug: 26498 Message-Id: <200711131346.lADDk0jf003622@dev3-63.dev.cn.tlan> Below is the list of changes that have just been committed into a local 5.1 repository of zhl. When zhl does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-11-13 13:45:42+00:00, lzhou@dev3-63.(none) +17 -0 BUG#26498 Implement two function: 1: Can start a backup using "Backup N". 2: Backup process will stop when backup files exist storage/ndb/include/kernel/ndb_limits.h@stripped, 2007-11-13 13:45:33+00:00, lzhou@dev3-63.(none) +1 -0 Add max backups defination storage/ndb/include/kernel/signaldata/BackupImpl.hpp@stripped, 2007-11-13 13:45:33+00:00, lzhou@dev3-63.(none) +2 -1 Add error code for backup file storage/ndb/include/kernel/signaldata/BackupSignalData.hpp@stripped, 2007-11-13 13:45:33+00:00, lzhou@dev3-63.(none) +2 -1 Add backup variable in BackupReq storage/ndb/include/kernel/signaldata/UtilSequence.hpp@stripped, 2007-11-13 13:45:33+00:00, lzhou@dev3-63.(none) +4 -2 Add new RequestType to set backup id storage/ndb/include/mgmapi/mgmapi.h@stripped, 2007-11-13 13:45:34+00:00, lzhou@dev3-63.(none) +19 -0 Add input backup parameter in ndb_mgm_start_backup function storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp@stripped, 2007-11-13 13:45:34+00:00, lzhou@dev3-63.(none) +2 -0 Add type of 'setVal' when invert type to string storage/ndb/src/kernel/blocks/backup/Backup.cpp@stripped, 2007-11-13 13:45:34+00:00, lzhou@dev3-63.(none) +24 -4 Implement 2 function: Check file status and Backup N. storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp@stripped, 2007-11-13 13:45:34+00:00, lzhou@dev3-63.(none) +53 -1 Implement Backup N. storage/ndb/src/mgmapi/mgmapi.cpp@stripped, 2007-11-13 13:45:34+00:00, lzhou@dev3-63.(none) +15 -2 Add input_backupId and send it to mgm server storage/ndb/src/mgmclient/CommandInterpreter.cpp@stripped, 2007-11-13 13:45:34+00:00, lzhou@dev3-63.(none) +36 -4 Implement backup n. mgm client part storage/ndb/src/mgmsrv/MgmtSrvr.cpp@stripped, 2007-11-13 13:45:34+00:00, lzhou@dev3-63.(none) +10 -3 Add input backup id into BACKUP_REQ storage/ndb/src/mgmsrv/MgmtSrvr.hpp@stripped, 2007-11-13 13:45:34+00:00, lzhou@dev3-63.(none) +1 -1 Modify startBackup declaration. Add input backup id. storage/ndb/src/mgmsrv/Services.cpp@stripped, 2007-11-13 13:45:34+00:00, lzhou@dev3-63.(none) +9 -1 Add input backup id into starbackup function to implement 'backup n' storage/ndb/src/ndbapi/ndberror.c@stripped, 2007-11-13 13:45:34+00:00, lzhou@dev3-63.(none) +1 -0 Add new error message storage/ndb/test/include/NDBT_Test.hpp@stripped, 2007-11-13 13:45:35+00:00, lzhou@dev3-63.(none) +1 -0 Add head file of ndb_limits.h to get MAX_BACKUP storage/ndb/test/ndbapi/testBackup.cpp@stripped, 2007-11-13 13:45:35+00:00, lzhou@dev3-63.(none) +27 -0 Add test case of 'backup n' storage/ndb/test/src/NdbBackup.cpp@stripped, 2007-11-13 13:45:35+00:00, lzhou@dev3-63.(none) +2 -1 Add test case when backup files exist diff -Nrup a/storage/ndb/include/kernel/ndb_limits.h b/storage/ndb/include/kernel/ndb_limits.h --- a/storage/ndb/include/kernel/ndb_limits.h 2006-12-23 19:20:03 +00:00 +++ b/storage/ndb/include/kernel/ndb_limits.h 2007-11-13 13:45:33 +00:00 @@ -27,6 +27,7 @@ #define MAX_NDB_NODES 49 #define MAX_NODES 64 #define UNDEF_NODEGROUP 0xFFFF +#define MAX_BACKUPS 0xFFFFFFFF /** * MAX_API_NODES = MAX_NODES - No of NDB Nodes in use diff -Nrup a/storage/ndb/include/kernel/signaldata/BackupImpl.hpp b/storage/ndb/include/kernel/signaldata/BackupImpl.hpp --- a/storage/ndb/include/kernel/signaldata/BackupImpl.hpp 2006-12-23 19:20:03 +00:00 +++ b/storage/ndb/include/kernel/signaldata/BackupImpl.hpp 2007-11-13 13:45:33 +00:00 @@ -94,7 +94,8 @@ public: FailedInsertTableList = 1346, FailedAllocateTableMem = 1347, FailedToAllocateFileRecord = 1348, - FailedToAllocateAttributeRecord = 1349 + FailedToAllocateAttributeRecord = 1349, + FailedForBackupFilesAleadyExist = 1350 }; private: Uint32 backupId; diff -Nrup a/storage/ndb/include/kernel/signaldata/BackupSignalData.hpp b/storage/ndb/include/kernel/signaldata/BackupSignalData.hpp --- a/storage/ndb/include/kernel/signaldata/BackupSignalData.hpp 2006-12-23 19:20:03 +00:00 +++ b/storage/ndb/include/kernel/signaldata/BackupSignalData.hpp 2007-11-13 13:45:33 +00:00 @@ -35,7 +35,7 @@ class BackupReq { friend bool printBACKUP_REQ(FILE *, const Uint32 *, Uint32, Uint16); public: - STATIC_CONST( SignalLength = 3 ); + STATIC_CONST( SignalLength = 4 ); private: Uint32 senderData; @@ -43,6 +43,7 @@ private: /* & 0x3 - waitCompleted */ Uint32 flags; + Uint32 inputBackupId; }; class BackupData { diff -Nrup a/storage/ndb/include/kernel/signaldata/UtilSequence.hpp b/storage/ndb/include/kernel/signaldata/UtilSequence.hpp --- a/storage/ndb/include/kernel/signaldata/UtilSequence.hpp 2006-12-23 19:20:07 +00:00 +++ b/storage/ndb/include/kernel/signaldata/UtilSequence.hpp 2007-11-13 13:45:33 +00:00 @@ -33,17 +33,19 @@ class UtilSequenceReq { friend bool printUTIL_SEQUENCE_REQ(FILE *, const Uint32 *, Uint32, Uint16); public: - STATIC_CONST( SignalLength = 3 ); + STATIC_CONST( SignalLength = 4 ); enum RequestType { NextVal = 1, // Return uniq value CurrVal = 2, // Read - Create = 3 // Create a sequence + Create = 3, // Create a sequence + SetVal = 4 // Set a new sequence }; private: Uint32 senderData; Uint32 sequenceId; // Number of sequence variable Uint32 requestType; + Uint32 value; }; class UtilSequenceConf { diff -Nrup a/storage/ndb/include/mgmapi/mgmapi.h b/storage/ndb/include/mgmapi/mgmapi.h --- a/storage/ndb/include/mgmapi/mgmapi.h 2007-06-14 10:35:33 +00:00 +++ b/storage/ndb/include/mgmapi/mgmapi.h 2007-11-13 13:45:34 +00:00 @@ -989,6 +989,25 @@ extern "C" { struct ndb_mgm_reply* reply); /** + * Start backup + * + * @param handle NDB management handle. + * @param wait_completed 0: Don't wait for confirmation
+ * 1: Wait for backup to be started
+ * 2: Wait for backup to be completed + * @param backup_id Backup ID is returned from function. + * @param reply Reply message. + * @param input_backupId run as backupId and set next backup id to input_backupId+1. + * @return -1 on error. + * @note backup_id will not be returned if + * wait_completed == 0 + */ + int ndb_mgm_start_backup2(NdbMgmHandle handle, int wait_completed, + unsigned int* backup_id, + struct ndb_mgm_reply* reply, + unsigned int input_backupId); + + /** * Abort backup * * @param handle NDB management handle. diff -Nrup a/storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp b/storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp --- a/storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp 2006-12-23 19:20:11 +00:00 +++ b/storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp 2007-11-13 13:45:34 +00:00 @@ -25,6 +25,8 @@ type2string(UtilSequenceReq::RequestType return "CurrVal"; case UtilSequenceReq::Create: return "Create"; + case UtilSequenceReq::SetVal: + return "SetVal"; default: return "Unknown"; } diff -Nrup a/storage/ndb/src/kernel/blocks/backup/Backup.cpp b/storage/ndb/src/kernel/blocks/backup/Backup.cpp --- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp 2007-06-12 08:38:05 +00:00 +++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp 2007-11-13 13:45:34 +00:00 @@ -1046,6 +1046,7 @@ Backup::execBACKUP_REQ(Signal* signal) const BlockReference senderRef = signal->senderBlockRef(); const Uint32 dataLen32 = req->backupDataLen; // In 32 bit words const Uint32 flags = signal->getLength() > 2 ? req->flags : 2; + const Uint32 input_backupId = signal->getLength() > 3 ? req->inputBackupId : 0; if(getOwnNodeId() != getMasterNodeId()) { jam(); @@ -1090,7 +1091,10 @@ Backup::execBACKUP_REQ(Signal* signal) ptr.p->flags = flags; ptr.p->masterRef = reference(); ptr.p->nodes = c_aliveNodes; - ptr.p->backupId = 0; + if(input_backupId) + ptr.p->backupId = input_backupId; + else + ptr.p->backupId = 0; ptr.p->backupKey[0] = 0; ptr.p->backupKey[1] = 0; ptr.p->backupDataLen = 0; @@ -1101,7 +1105,13 @@ Backup::execBACKUP_REQ(Signal* signal) ptr.p->masterData.gsn = GSN_UTIL_SEQUENCE_REQ; utilReq->senderData = ptr.i; utilReq->sequenceId = BACKUP_SEQUENCE; - utilReq->requestType = UtilSequenceReq::NextVal; + if(input_backupId) { + utilReq->requestType = UtilSequenceReq::SetVal; + utilReq->value = input_backupId; + } + else { + utilReq->requestType = UtilSequenceReq::NextVal; + } sendSignal(DBUTIL_REF, GSN_UTIL_SEQUENCE_REQ, signal, UtilSequenceReq::SignalLength, JBB); } @@ -1183,11 +1193,13 @@ Backup::execUTIL_SEQUENCE_CONF(Signal* s }//if + if(!ptr.p->backupId && conf->requestType != UtilSequenceReq::SetVal) { Uint64 backupId; memcpy(&backupId,conf->sequenceValue,8); ptr.p->backupId= (Uint32)backupId; } + ptr.p->backupKey[0] = (getOwnNodeId() << 16) | (ptr.p->backupId & 0xFFFF); ptr.p->backupKey[1] = NdbTick_CurrentMillisecond(); @@ -2768,8 +2780,7 @@ Backup::openFiles(Signal* signal, Backup req->userReference = reference(); req->fileFlags = FsOpenReq::OM_WRITEONLY | - FsOpenReq::OM_TRUNCATE | - FsOpenReq::OM_CREATE | + FsOpenReq::OM_CREATE_IF_NONE | FsOpenReq::OM_APPEND | FsOpenReq::OM_AUTOSYNC; FsOpenReq::v2_setCount(req->fileNumber, 0xFFFFFFFF); @@ -2881,11 +2892,20 @@ Backup::openFilesReply(Signal* signal, }//if }//for + if (ERROR_INSERTED(10037)) { + jam(); + ptr.p->errorCode = DefineBackupRef::FailedForBackupFilesAleadyExist; + defineBackupRef(signal, ptr); + return; + } /** * Did open succeed for all files */ if(ptr.p->checkError()) { jam(); + if(ptr.p->errorCode == FsRef::fsErrFileExists) + ptr.p->errorCode = DefineBackupRef::FailedForBackupFilesAleadyExist; + defineBackupRef(signal, ptr); return; }//if diff -Nrup a/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp b/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp --- a/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp 2006-12-23 19:20:17 +00:00 +++ b/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp 2007-11-13 13:45:34 +00:00 @@ -171,7 +171,7 @@ DbUtil::execREAD_CONFIG_REQ(Signal* sign c_pagePool.setSize(10); c_preparePool.setSize(1); // one parallel prepare at a time - c_preparedOperationPool.setSize(5); // three hardcoded, two for test + c_preparedOperationPool.setSize(6); // three hardcoded, one for setval, two for test c_operationPool.setSize(64); // 64 parallel operations c_transactionPool.setSize(32); // 16 parallel transactions c_attrMappingPool.setSize(100); @@ -1496,6 +1496,35 @@ DbUtil::hardcodedPrepare() { ptr.p->tckey.requestInfo = requestInfo; ptr.p->tckey.tableSchemaVersion = 1; } + + /** + * Prepare SetSequence (UPDATE) + */ + { + PreparedOperationPtr ptr; + ndbrequire(c_preparedOperationPool.seizeId(ptr, 3)); + ptr.p->keyLen = 1; + ptr.p->rsLen = 0; + ptr.p->tckeyLenInBytes = (TcKeyReq::StaticLength + ptr.p->keyLen + 5) * 4; + ptr.p->keyDataPos = TcKeyReq::StaticLength; + ptr.p->tckey.attrLen = 9; + ptr.p->tckey.tableId = 0; + Uint32 requestInfo = 0; + TcKeyReq::setAbortOption(requestInfo, TcKeyReq::CommitIfFailFree); + TcKeyReq::setOperationType(requestInfo, ZUPDATE); + TcKeyReq::setKeyLength(requestInfo, 1); + TcKeyReq::setAIInTcKeyReq(requestInfo, 5); + TcKeyReq::setInterpretedFlag(requestInfo, 1); + ptr.p->tckey.requestInfo = requestInfo; + ptr.p->tckey.tableSchemaVersion = 1; + + Uint32 * attrInfo = &ptr.p->tckey.distrGroupHashValue; + attrInfo[0] = 0; // IntialReadSize + attrInfo[1] = 3; // InterpretedSize + attrInfo[2] = 0; // FinalUpdateSize + attrInfo[3] = 1; // FinalReadSize + attrInfo[4] = 0; // SubroutineSize + } } void @@ -1516,6 +1545,10 @@ DbUtil::execUTIL_SEQUENCE_REQ(Signal* si case UtilSequenceReq::Create: prepOp = c_preparedOperationPool.getPtr(2); //c_CreateSequence break; + case UtilSequenceReq::SetVal:{ + prepOp = c_preparedOperationPool.getPtr(3); + break; + } default: ndbrequire(false); prepOp = 0; // remove warning @@ -1566,6 +1599,21 @@ DbUtil::execUTIL_SEQUENCE_REQ(Signal* si * it.data = 0; } + if(req->requestType == UtilSequenceReq::SetVal) + { // AttrInfo + ndbrequire(opPtr.p->attrInfo.seize(4)); + AttrInfoBuffer::DataBufferIterator it; + opPtr.p->attrInfo.first(it); + * it.data = Interpreter::LoadConst16(7, req->value); + ndbrequire(opPtr.p->attrInfo.next(it)); + * it.data = Interpreter::Write(1, 7); + ndbrequire(opPtr.p->attrInfo.next(it)) + * it.data = Interpreter::ExitOK(); + + ndbrequire(opPtr.p->attrInfo.next(it)); + AttributeHeader::init(it.data, 1, 0); + } + runTransaction(signal, transPtr); } @@ -1643,6 +1691,9 @@ DbUtil::reportSequence(Signal* signal, c ret->sequenceValue[1] = rsit.data[2]; break; } + case UtilSequenceReq::SetVal: + ok = true; + break; case UtilSequenceReq::Create: ok = true; ret->sequenceValue[0] = 0; @@ -1659,6 +1710,7 @@ DbUtil::reportSequence(Signal* signal, c switch(transP->sequence.requestType) { + case UtilSequenceReq::SetVal: case UtilSequenceReq::CurrVal: case UtilSequenceReq::NextVal:{ if (transP->errorCode == 626) diff -Nrup a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp --- a/storage/ndb/src/mgmapi/mgmapi.cpp 2007-08-29 00:51:05 +00:00 +++ b/storage/ndb/src/mgmapi/mgmapi.cpp 2007-11-13 13:45:34 +00:00 @@ -2029,9 +2029,10 @@ ndb_mgm_start(NdbMgmHandle handle, int n *****************************************************************************/ extern "C" int -ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed, +ndb_mgm_start_backup2(NdbMgmHandle handle, int wait_completed, unsigned int* _backup_id, - struct ndb_mgm_reply* /*reply*/) + struct ndb_mgm_reply*, /*reply*/ + unsigned int input_backupId) { SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_start_backup"); const ParserRow start_backup_reply[] = { @@ -2045,6 +2046,8 @@ ndb_mgm_start_backup(NdbMgmHandle handle Properties args; args.put("completed", wait_completed); + if(input_backupId > 0) + args.put("backupid", input_backupId); const Properties *reply; { // start backup can take some time, set timeout high Uint64 old_timeout= handle->timeout; @@ -2068,6 +2071,16 @@ ndb_mgm_start_backup(NdbMgmHandle handle delete reply; return 0; +} + +extern "C" +int +ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed, + unsigned int* _backup_id, + struct ndb_mgm_reply* /*reply*/) +{ + struct ndb_mgm_reply reply; + return ndb_mgm_start_backup2(handle, wait_completed, _backup_id, &reply, 0); } extern "C" diff -Nrup a/storage/ndb/src/mgmclient/CommandInterpreter.cpp b/storage/ndb/src/mgmclient/CommandInterpreter.cpp --- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp 2007-07-30 09:28:28 +00:00 +++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp 2007-11-13 13:45:34 +00:00 @@ -260,7 +260,7 @@ static const char* helpText = "SHOW CONFIG Print configuration\n" "SHOW PARAMETERS Print configuration parameters\n" #endif -"START BACKUP [NOWAIT | WAIT STARTED | WAIT COMPLETED]\n" +"START BACKUP [] [NOWAIT | WAIT STARTED | WAIT COMPLETED]\n" " Start backup (default WAIT COMPLETED)\n" "ABORT BACKUP Abort backup\n" "SHUTDOWN Shutdown all processes in cluster\n" @@ -324,12 +324,15 @@ static const char* helpTextStartBackup = " NDB Cluster -- Management Client -- Help for START BACKUP command\n" "---------------------------------------------------------------------------\n" "START BACKUP Start a cluster backup\n\n" -"START BACKUP [NOWAIT | WAIT STARTED | WAIT COMPLETED]\n" +"START BACKUP [] [NOWAIT | WAIT STARTED | WAIT COMPLETED]\n" " Start a backup for the cluster.\n" " Each backup gets an ID number that is reported to the\n" " user. This ID number can help you find the backup on the\n" " file system, or ABORT BACKUP if you wish to cancel a \n" -" running backup.\n\n" +" running backup.\n" +" You can also start specified backup using START BACKUP \n\n" +" \n" +" Start a specified backup using as bakcup ID number.\n" " NOWAIT \n" " Start a cluster backup and return immediately.\n" " The management client will return control directly\n" @@ -2604,6 +2607,7 @@ CommandInterpreter::executeStartBackup(c { struct ndb_mgm_reply reply; unsigned int backupId; + unsigned int input_backupId = 0; Vector args; { @@ -2632,6 +2636,31 @@ CommandInterpreter::executeStartBackup(c ndbout_c("Waiting for started, this may take several minutes"); flags = 1; } + else if (sscanf(args[1].c_str(), "%u", &input_backupId) == 1 && input_backupId > 0 && input_backupId < MAX_BACKUPS) + { + // start backup n nowait + if (sz == 3 && args[2] == "NOWAIT") + { + flags = 0; + } + // start backup n; start backup n wait complete + else if ( sz == 2 || (sz == 4 && args[2] == "WAIT" && args[3] =="COMPLETED")) + { + flags = 2; + ndbout_c("Waiting for completed, this may take several minutes"); + } + //start backup n wait started + else if (sz == 4 && args[2] == "WAIT" && args[3] == "STARTED") + { + ndbout_c("Waiting for started, this may take several minutes"); + flags = 1; + } + else + { + invalid_command(parameters); + return -1; + } + } else { invalid_command(parameters); @@ -2651,7 +2680,10 @@ CommandInterpreter::executeStartBackup(c return -1; } } - result = ndb_mgm_start_backup(m_mgmsrv, flags, &backupId, &reply); + if (input_backupId > 0) + result = ndb_mgm_start_backup2(m_mgmsrv, flags, &backupId, &reply, input_backupId); + else + result = ndb_mgm_start_backup(m_mgmsrv, flags, &backupId, &reply); if (result != 0) { ndbout << "Backup failed" << endl; diff -Nrup a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp --- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2007-06-14 09:26:52 +00:00 +++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2007-11-13 13:45:34 +00:00 @@ -2505,7 +2505,7 @@ MgmtSrvr::eventReport(const Uint32 * the ***************************************************************************/ int -MgmtSrvr::startBackup(Uint32& backupId, int waitCompleted) +MgmtSrvr::startBackup(Uint32& backupId, int waitCompleted, Uint32 input_backupId) { SignalSender ss(theFacade); ss.lock(); // lock will be released on exit @@ -2523,8 +2523,15 @@ MgmtSrvr::startBackup(Uint32& backupId, SimpleSignal ssig; BackupReq* req = CAST_PTR(BackupReq, ssig.getDataPtrSend()); - ssig.set(ss, TestOrd::TraceAPI, BACKUP, GSN_BACKUP_REQ, - BackupReq::SignalLength); + if(input_backupId > 0) + { + ssig.set(ss, TestOrd::TraceAPI, BACKUP, GSN_BACKUP_REQ, + BackupReq::SignalLength); + req->inputBackupId = input_backupId; + } + else + ssig.set(ss, TestOrd::TraceAPI, BACKUP, GSN_BACKUP_REQ, + BackupReq::SignalLength - 1); req->senderData = 19; req->backupDataLen = 0; diff -Nrup a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp --- a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp 2007-06-14 09:26:52 +00:00 +++ b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp 2007-11-13 13:45:34 +00:00 @@ -307,7 +307,7 @@ public: /** * Backup functionallity */ - int startBackup(Uint32& backupId, int waitCompleted= 2); + int startBackup(Uint32& backupId, int waitCompleted= 2, Uint32 input_backupId= 0); int abortBackup(Uint32 backupId); int performBackup(Uint32* backupId); diff -Nrup a/storage/ndb/src/mgmsrv/Services.cpp b/storage/ndb/src/mgmsrv/Services.cpp --- a/storage/ndb/src/mgmsrv/Services.cpp 2007-07-11 12:36:40 +00:00 +++ b/storage/ndb/src/mgmsrv/Services.cpp 2007-11-13 13:45:34 +00:00 @@ -189,6 +189,7 @@ ParserRow commands[] = { MGM_CMD("start backup", &MgmApiSession::startBackup, ""), MGM_ARG("completed", Int, Optional ,"Wait until completed"), + MGM_ARG("backupid", Int, Optional ,"User input backup id"), MGM_CMD("abort backup", &MgmApiSession::abortBackup, ""), MGM_ARG("id", Int, Mandatory, "Backup id"), @@ -690,12 +691,19 @@ MgmApiSession::startBackup(Parserprintln("start backup reply"); if(result != 0) diff -Nrup a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c --- a/storage/ndb/src/ndbapi/ndberror.c 2007-06-14 09:26:52 +00:00 +++ b/storage/ndb/src/ndbapi/ndberror.c 2007-11-13 13:45:34 +00:00 @@ -465,6 +465,7 @@ ErrorBundle ErrorCodes[] = { { 1347, DMEC, AE, "Backup failed to allocate table memory (check configuration)" }, { 1348, DMEC, AE, "Backup failed to allocate file record (check configuration)" }, { 1349, DMEC, AE, "Backup failed to allocate attribute record (check configuration)" }, + { 1350, DMEC, TR, "Backup failed: file already exists (use 'START BACKUP ')" }, { 1329, DMEC, AE, "Backup during software upgrade not supported" }, /** diff -Nrup a/storage/ndb/test/include/NDBT_Test.hpp b/storage/ndb/test/include/NDBT_Test.hpp --- a/storage/ndb/test/include/NDBT_Test.hpp 2007-03-01 09:39:45 +00:00 +++ b/storage/ndb/test/include/NDBT_Test.hpp 2007-11-13 13:45:35 +00:00 @@ -17,6 +17,7 @@ #define NDBT_TEST_HPP #include +#include #include "NDBT_ReturnCodes.h" #include diff -Nrup a/storage/ndb/test/ndbapi/testBackup.cpp b/storage/ndb/test/ndbapi/testBackup.cpp --- a/storage/ndb/test/ndbapi/testBackup.cpp 2006-12-23 19:20:26 +00:00 +++ b/storage/ndb/test/ndbapi/testBackup.cpp 2007-11-13 13:45:35 +00:00 @@ -137,6 +137,19 @@ int runBackupOne(NDBT_Context* ctx, NDBT return NDBT_OK; } +int runBackupRandom(NDBT_Context* ctx, NDBT_Step* step){ + NdbBackup backup(GETNDB(step)->getNodeId()+1); + unsigned backupId = rand() % (MAX_BACKUPS); + + if (backup.start(backupId) == -1){ + return NDBT_FAILED; + } + ndbout << "Started backup " << backupId << endl; + ctx->setProperty("BackupId", backupId); + + return NDBT_OK; +} + int runBackupLoop(NDBT_Context* ctx, NDBT_Step* step){ NdbBackup backup(GETNDB(step)->getNodeId()+1); @@ -470,6 +483,20 @@ TESTCASE("BackupOne", "5. Verify count and content of table\n"){ INITIALIZER(runLoadTable); INITIALIZER(runBackupOne); + INITIALIZER(runDropTablesRestart); + INITIALIZER(runRestoreOne); + VERIFIER(runVerifyOne); + FINALIZER(runClearTable); +} +TESTCASE("BackupRandom", + "Test that backup n and restore works on one table \n" + "1. Load table\n" + "2. Backup\n" + "3. Drop tables and restart \n" + "4. Restore\n" + "5. Verify count and content of table\n"){ + INITIALIZER(runLoadTable); + INITIALIZER(runBackupRandom); INITIALIZER(runDropTablesRestart); INITIALIZER(runRestoreOne); VERIFIER(runVerifyOne); diff -Nrup a/storage/ndb/test/src/NdbBackup.cpp b/storage/ndb/test/src/NdbBackup.cpp --- a/storage/ndb/test/src/NdbBackup.cpp 2006-12-23 19:20:31 +00:00 +++ b/storage/ndb/test/src/NdbBackup.cpp 2007-11-13 13:45:35 +00:00 @@ -350,7 +350,8 @@ FailS_codes[] = { 10025, 10027, 10033, - 10035 + 10035, + 10037 }; int