#At file:///home/jonas/src/telco-6.2/ based on revid:jonas@stripped
2964 Jonas Oreland 2009-08-21
ndb - bug#36702
Handle cluster crash during create file{group}
modified:
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp
storage/ndb/test/ndbapi/testDict.cpp
=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2009-05-26 18:53:34 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2009-08-21 09:35:23 +0000
@@ -41,6 +41,7 @@
#include <signaldata/FsOpenReq.hpp>
#include <signaldata/FsReadWriteReq.hpp>
#include <signaldata/FsRef.hpp>
+#include <signaldata/FsRemoveReq.hpp>
#include <signaldata/GetTabInfo.hpp>
#include <signaldata/GetTableId.hpp>
#include <signaldata/HotSpareRep.hpp>
@@ -1707,6 +1708,8 @@ Dbdict::Dbdict(Block_context& ctx):
addRecSignal(GSN_FSWRITECONF, &Dbdict::execFSWRITECONF);
addRecSignal(GSN_FSREADCONF, &Dbdict::execFSREADCONF);
addRecSignal(GSN_FSREADREF, &Dbdict::execFSREADREF, true);
+ addRecSignal(GSN_FSREMOVEREF, &Dbdict::execFSREMOVEREF, true);
+ addRecSignal(GSN_FSREMOVECONF, &Dbdict::execFSREMOVECONF);
addRecSignal(GSN_LQHFRAGCONF, &Dbdict::execLQHFRAGCONF);
addRecSignal(GSN_LQHADDATTCONF, &Dbdict::execLQHADDATTCONF);
addRecSignal(GSN_LQHADDATTREF, &Dbdict::execLQHADDATTREF);
@@ -3611,7 +3614,12 @@ Dbdict::restartDropObj(Signal* signal,
case DictTabInfo::LogfileGroup:{
jam();
Ptr<Filegroup> fg_ptr;
- ndbrequire(c_filegroup_hash.find(fg_ptr, tableId));
+ if (!c_filegroup_hash.find(fg_ptr, tableId))
+ {
+ jam();
+ restartDropObj_updateSchemaFile(signal, dropObjPtr);
+ return;
+ }
dropObjPtr.p->m_obj_ptr_i = fg_ptr.i;
dropObjPtr.p->m_vt_index = 3;
break;
@@ -3620,7 +3628,20 @@ Dbdict::restartDropObj(Signal* signal,
jam();
Ptr<File> file_ptr;
dropObjPtr.p->m_vt_index = 2;
- ndbrequire(c_file_hash.find(file_ptr, tableId));
+ if (!c_file_hash.find(file_ptr, tableId))
+ {
+ jam();
+ /**
+ * We need to read it, to be able to delete it
+ */
+ c_readTableRecord.no_of_words = entry->m_info_words;
+ c_readTableRecord.pageId = 0;
+ c_readTableRecord.m_callback.m_callbackData = dropObjPtr.p->key;
+ c_readTableRecord.m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::restartDropObj_readObjConf);
+ startReadTableFile(signal, tableId);
+ return;
+ }
dropObjPtr.p->m_obj_ptr_i = file_ptr.i;
break;
}
@@ -3628,7 +3649,20 @@ Dbdict::restartDropObj(Signal* signal,
jam();
Ptr<File> file_ptr;
dropObjPtr.p->m_vt_index = 4;
- ndbrequire(c_file_hash.find(file_ptr, tableId));
+ if (!c_file_hash.find(file_ptr, tableId))
+ {
+ jam();
+ /**
+ * We need to read it, to be able to delete it
+ */
+ c_readTableRecord.no_of_words = entry->m_info_words;
+ c_readTableRecord.pageId = 0;
+ c_readTableRecord.m_callback.m_callbackData = dropObjPtr.p->key;
+ c_readTableRecord.m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::restartDropObj_readObjConf);
+ startReadTableFile(signal, tableId);
+ return;
+ }
dropObjPtr.p->m_obj_ptr_i = file_ptr.i;
/**
@@ -3656,6 +3690,98 @@ Dbdict::restartDropObj(Signal* signal,
(signal, dropObjPtr.p);
else
execute(signal, dropObjPtr.p->m_callback, 0);
+
+ return;
+}
+
+void
+Dbdict::restartDropObj_readObjConf(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, callbackData));
+
+ if (returnCode)
+ {
+ jam();
+ /**
+ * File not found
+ */
+ignore:
+ restartDropObj_updateSchemaFile(signal, dropObjPtr);
+ return;
+ }
+
+ /**
+ * This is "dead"-code, so it's "ok" to hard-code it to undo/data-file
+ * dead == 6.4 has schema transactions. differerent framework
+ */
+
+
+ PageRecordPtr pageRecPtr;
+ c_pageRecordArray.getPtr(pageRecPtr, c_readTableRecord.pageId);
+
+ Uint32 sz = c_readTableRecord.no_of_words;
+ SimplePropertiesLinearReader it(pageRecPtr.p->word+ZPAGE_HEADER_SIZE, sz);
+
+ DictFilegroupInfo::File f; f.init();
+ SimpleProperties::UnpackStatus status;
+ status = SimpleProperties::unpack(it, &f,
+ DictFilegroupInfo::FileMapping,
+ DictFilegroupInfo::FileMappingSize,
+ true, true);
+
+ if(status != SimpleProperties::Eof)
+ {
+ jam();
+ goto ignore;
+ }
+
+ // dead -> hard-coded rm
+ FsRemoveReq * req = (FsRemoveReq*)signal->getDataPtrSend();
+ req->directory = 0;
+ req->userReference = reference();
+ req->userPointer = dropObjPtr.p->key;
+ memset(req->fileNumber, 0, sizeof(req->fileNumber));
+ FsOpenReq::setVersion(req->fileNumber, 4); // Version 4 = specified filename
+
+ switch(dropObjPtr.p->m_obj_type){
+ case DictTabInfo::Datafile:
+ jam();
+ FsOpenReq::v4_setBasePath(req->fileNumber, FsOpenReq::BP_DD_DF);
+ break;
+ case DictTabInfo::Undofile:
+ jam();
+ FsOpenReq::v4_setBasePath(req->fileNumber, FsOpenReq::BP_DD_UF);
+ break;
+ }
+
+ LinearSectionPtr ptr[3];
+ ptr[0].p = (Uint32*)f.FileName;
+ ptr[0].sz = ((strlen(f.FileName) + 1) + 3) / 4;
+ sendSignal(NDBFS_REF, GSN_FSREMOVEREQ, signal, FsRemoveReq::SignalLength,
+ JBB, ptr, 1);
+}
+
+void
+Dbdict::execFSREMOVEREF(Signal* signal)
+{
+ FsRef* ref = (FsRef*)signal->getDataPtr();
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, ref->userPointer));
+ restartDropObj_updateSchemaFile(signal, dropObjPtr);
+}
+
+void
+Dbdict::execFSREMOVECONF(Signal* signal)
+{
+ FsConf* conf = (FsConf*)signal->getDataPtr();
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, conf->userPointer));
+ restartDropObj_updateSchemaFile(signal, dropObjPtr);
}
void
@@ -3721,6 +3847,24 @@ Dbdict::restartDropObj_commit_start_done
execute(signal, dropObjPtr.p->m_callback, 0);
}
+void
+Dbdict::restartDropObj_updateSchemaFile(Signal* signal,
+ DropObjRecordPtr dropObjPtr)
+{
+
+ ndbout_c("NOT FOUND ignoring");
+ Uint32 objId = dropObjPtr.p->m_obj_id;
+ XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ SchemaFile::TableEntry objEntry = * getTableEntry(xsf, objId);
+ objEntry.m_tableState = SchemaFile::DROP_TABLE_COMMITTED;
+
+ Callback callback;
+ callback.m_callbackData = dropObjPtr.p->key;
+ callback.m_callbackFunction =
+ safe_cast(&Dbdict::restartDropObj_commit_complete_done);
+
+ updateSchemaState(signal, objId, &objEntry, &callback);
+}
void
Dbdict::restartDropObj_commit_complete_done(Signal* signal,
@@ -15967,8 +16111,19 @@ Dbdict::createObj_commit(Signal * signal
if (ERROR_INSERTED(6016))
{
jam();
- NodeReceiverGroup rg(CMVMI, c_aliveNodes);
signal->theData[0] = 9999;
+ NdbNodeBitmask mask = c_aliveNodes;
+ if (c_masterNodeId == getOwnNodeId())
+ {
+ jam();
+ mask.clear(getOwnNodeId());
+ sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, 1000, 1);
+ if (mask.isclear())
+ {
+ return;
+ }
+ }
+ NodeReceiverGroup rg(CMVMI, mask);
sendSignal(rg, GSN_NDB_TAMPER, signal, 1, JBB);
return;
}
@@ -17054,8 +17209,20 @@ Dbdict::create_file_commit_start(Signal*
if (ERROR_INSERTED(6017))
{
jam();
- NodeReceiverGroup rg(CMVMI, c_aliveNodes);
signal->theData[0] = 9999;
+
+ NdbNodeBitmask mask = c_aliveNodes;
+ if (c_masterNodeId == getOwnNodeId())
+ {
+ jam();
+ mask.clear(getOwnNodeId());
+ sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, 1000, 1);
+ if (mask.isclear())
+ {
+ return;
+ }
+ }
+ NodeReceiverGroup rg(CMVMI, mask);
sendSignal(rg, GSN_NDB_TAMPER, signal, 1, JBB);
return;
}
=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2009-05-26 18:53:34 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2009-08-21 09:35:23 +0000
@@ -703,6 +703,8 @@ private:
void execFSREADCONF(Signal* signal);
void execFSREADREF(Signal* signal);
void execFSWRITECONF(Signal* signal);
+ void execFSREMOVEREF(Signal*);
+ void execFSREMOVECONF(Signal*);
void execNDB_STTOR(Signal* signal);
void execREAD_CONFIG_REQ(Signal* signal);
void execSTTOR(Signal* signal);
@@ -2583,11 +2585,13 @@ private:
void restartDropTab_complete(Signal*, Uint32 callback, Uint32);
void restartDropObj(Signal*, Uint32, const SchemaFile::TableEntry *);
+ void restartDropObj_readObjConf(Signal*, Uint32, Uint32);
void restartDropObj_prepare_start_done(Signal*, Uint32, Uint32);
void restartDropObj_prepare_complete_done(Signal*, Uint32, Uint32);
void restartDropObj_commit_start_done(Signal*, Uint32, Uint32);
void restartDropObj_commit_complete_done(Signal*, Uint32, Uint32);
-
+ void restartDropObj_updateSchemaFile(Signal*, DropObjRecordPtr);
+
void restart_checkSchemaStatusComplete(Signal*, Uint32 callback, Uint32);
void restart_writeSchemaConf(Signal*, Uint32 callbackData, Uint32);
void masterRestart_checkSchemaStatusComplete(Signal*, Uint32, Uint32);
=== modified file 'storage/ndb/test/ndbapi/testDict.cpp'
--- a/storage/ndb/test/ndbapi/testDict.cpp 2009-05-26 18:53:34 +0000
+++ b/storage/ndb/test/ndbapi/testDict.cpp 2009-08-21 09:35:23 +0000
@@ -3289,7 +3289,8 @@ runDropDDObjects(NDBT_Context* ctx, NDBT
case NdbDictionary::Object::UserTable:
tableFound = list.elements[i].name;
if(tableFound != 0){
- if(strcmp(tableFound, "ndb_apply_status") != 0 &&
+ if(strcmp(list.elements[i].database, "TEST_DB") == 0 &&
+ strcmp(tableFound, "ndb_apply_status") != 0 &&
strcmp(tableFound, "NDB$BLOB_2_3") != 0 &&
strcmp(tableFound, "ndb_schema") != 0){
if(pDict->dropTable(tableFound) != 0){
@@ -3421,6 +3422,126 @@ testDropDDObjectsSetup(NDBT_Context* ctx
}
int
+runBug36072(NDBT_Context* ctx, NDBT_Step* step)
+{
+ Ndb* pNdb = GETNDB(step);
+ NdbDictionary::Dictionary* pDict = pNdb->getDictionary();
+ NdbRestarter res;
+
+ int err[] = { 6016, 6017 };
+ for (Uint32 i = 0; i<2; i++)
+ {
+ int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
+
+ if (res.dumpStateAllNodes(val2, 2))
+ return NDBT_FAILED;
+
+ if (res.insertErrorInAllNodes(932)) // arbit
+ return NDBT_FAILED;
+
+ if (res.insertErrorInAllNodes(err[i]))
+ return NDBT_FAILED;
+
+ NdbDictionary::LogfileGroup lg;
+ lg.setName("DEFAULT-LG");
+ lg.setUndoBufferSize(8*1024*1024);
+
+ NdbDictionary::Undofile uf;
+ uf.setPath("undofile01.dat");
+ uf.setSize(5*1024*1024);
+ uf.setLogfileGroup("DEFAULT-LG");
+
+ int r = pDict->createLogfileGroup(lg);
+ if (i != 0)
+ {
+ if (r)
+ {
+ ndbout << __LINE__ << " : " << pDict->getNdbError() << endl;
+ return NDBT_FAILED;
+ }
+ pDict->createUndofile(uf);
+ }
+
+ if (res.waitClusterNoStart())
+ return NDBT_FAILED;
+
+ res.startAll();
+ if (res.waitClusterStarted())
+ return NDBT_FAILED;
+
+ if (i == 0)
+ {
+ NdbDictionary::LogfileGroup lg2 = pDict->getLogfileGroup("DEFAULT-LG");
+ NdbError err= pDict->getNdbError();
+ if( (int) err.classification == (int) ndberror_cl_none)
+ {
+ ndbout << __LINE__ << " : " << pDict->getNdbError() << endl;
+ return NDBT_FAILED;
+ }
+
+ if (pDict->createLogfileGroup(lg) != 0)
+ {
+ ndbout << __LINE__ << endl;
+ return NDBT_FAILED;
+ }
+ }
+ else
+ {
+ NdbDictionary::Undofile uf2 = pDict->getUndofile(0, "undofile01.dat");
+ NdbError err= pDict->getNdbError();
+ if( (int) err.classification == (int) ndberror_cl_none)
+ {
+ ndbout << __LINE__ << endl;
+ return NDBT_FAILED;
+ }
+
+ if (pDict->createUndofile(uf) != 0)
+ {
+ ndbout << __LINE__ << " : " << pDict->getNdbError() << endl;
+ return NDBT_FAILED;
+ }
+ }
+
+ {
+ NdbDictionary::LogfileGroup lg2 = pDict->getLogfileGroup("DEFAULT-LG");
+ NdbError err= pDict->getNdbError();
+ if( (int) err.classification != (int) ndberror_cl_none)
+ {
+ ndbout << __LINE__ << " : " << pDict->getNdbError() << endl;
+ return NDBT_FAILED;
+ }
+
+ if (pDict->dropLogfileGroup(lg2))
+ {
+ ndbout << __LINE__ << " : " << pDict->getNdbError() << endl;
+ return NDBT_FAILED;
+ }
+ }
+ }
+
+ return NDBT_OK;
+}
+
+int
+restartClusterInitial(NDBT_Context* ctx, NDBT_Step* step)
+{
+ NdbRestarter res;
+
+ res.restartAll(NdbRestarter::NRRF_INITIAL |
+ NdbRestarter::NRRF_NOSTART |
+ NdbRestarter::NRRF_ABORT);
+ if (res.waitClusterNoStart())
+ return NDBT_FAILED;
+
+ res.startAll();
+ if (res.waitClusterStarted())
+ return NDBT_FAILED;
+
+ return NDBT_OK;
+}
+
+
+int
DropDDObjectsVerify(NDBT_Context* ctx, NDBT_Step* step){
//Purpose is to verify test DropDDObjects worked
Uint32 i = 0;
@@ -3649,6 +3770,12 @@ TESTCASE("Bug24631",
""){
INITIALIZER(runBug24631);
}
+TESTCASE("Bug36702", "")
+{
+ INITIALIZER(runDropDDObjects);
+ INITIALIZER(runBug36072);
+ FINALIZER(restartClusterInitial);
+}
TESTCASE("Bug29186",
""){
INITIALIZER(runBug29186);
Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20090821093523-b01c9nxwnp97x204.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-6.2 branch (jonas:2964) Bug#36702 | Jonas Oreland | 21 Aug |