Commit 3cd43eb4 authored by unknown's avatar unknown

ndb -

  bug#19141, bug#18575
  
  Maek sure global dict lock is taken during create/drop file/filegroup


storage/ndb/include/kernel/signaldata/DropFilegroup.hpp:
  Fix error code
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
  Fix c_blockState lock for createdrop file/filegroup
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  Fix not master for create/drop file
parent 86b74da6
...@@ -150,6 +150,7 @@ struct DropFileRef { ...@@ -150,6 +150,7 @@ struct DropFileRef {
enum ErrorCode { enum ErrorCode {
NoError = 0, NoError = 0,
Busy = 701, Busy = 701,
NotMaster = 702,
NoSuchFile = 766, NoSuchFile = 766,
DropUndoFileNotSupported = 769, DropUndoFileNotSupported = 769,
InvalidSchemaObjectVersion = 774 InvalidSchemaObjectVersion = 774
......
...@@ -13396,6 +13396,24 @@ Dbdict::execCREATE_FILE_REQ(Signal* signal){ ...@@ -13396,6 +13396,24 @@ Dbdict::execCREATE_FILE_REQ(Signal* signal){
Uint32 requestInfo = req->requestInfo; Uint32 requestInfo = req->requestInfo;
do { do {
if(getOwnNodeId() != c_masterNodeId){
jam();
ref->errorCode = CreateFileRef::NotMaster;
ref->status = 0;
ref->errorKey = 0;
ref->errorLine = __LINE__;
break;
}
if (c_blockState != BS_IDLE){
jam();
ref->errorCode = CreateFileRef::Busy;
ref->status = 0;
ref->errorKey = 0;
ref->errorLine = __LINE__;
break;
}
Ptr<SchemaTransaction> trans_ptr; Ptr<SchemaTransaction> trans_ptr;
if (! c_Trans.seize(trans_ptr)){ if (! c_Trans.seize(trans_ptr)){
ref->errorCode = CreateFileRef::Busy; ref->errorCode = CreateFileRef::Busy;
...@@ -13455,6 +13473,9 @@ Dbdict::execCREATE_FILE_REQ(Signal* signal){ ...@@ -13455,6 +13473,9 @@ Dbdict::execCREATE_FILE_REQ(Signal* signal){
tmp.init<CreateObjRef>(rg, GSN_CREATE_OBJ_REF, trans_key); tmp.init<CreateObjRef>(rg, GSN_CREATE_OBJ_REF, trans_key);
sendSignal(rg, GSN_CREATE_OBJ_REQ, signal, sendSignal(rg, GSN_CREATE_OBJ_REQ, signal,
CreateObjReq::SignalLength, JBB); CreateObjReq::SignalLength, JBB);
c_blockState = BS_CREATE_TAB;
return; return;
} while(0); } while(0);
...@@ -13480,15 +13501,6 @@ Dbdict::execCREATE_FILEGROUP_REQ(Signal* signal){ ...@@ -13480,15 +13501,6 @@ Dbdict::execCREATE_FILEGROUP_REQ(Signal* signal){
Uint32 type = req->objType; Uint32 type = req->objType;
do { do {
Ptr<SchemaTransaction> trans_ptr;
if (! c_Trans.seize(trans_ptr)){
ref->errorCode = CreateFilegroupRef::Busy;
ref->status = 0;
ref->errorKey = 0;
ref->errorLine = __LINE__;
break;
}
if(getOwnNodeId() != c_masterNodeId){ if(getOwnNodeId() != c_masterNodeId){
jam(); jam();
ref->errorCode = CreateFilegroupRef::NotMaster; ref->errorCode = CreateFilegroupRef::NotMaster;
...@@ -13506,6 +13518,15 @@ Dbdict::execCREATE_FILEGROUP_REQ(Signal* signal){ ...@@ -13506,6 +13518,15 @@ Dbdict::execCREATE_FILEGROUP_REQ(Signal* signal){
ref->errorLine = __LINE__; ref->errorLine = __LINE__;
break; break;
} }
Ptr<SchemaTransaction> trans_ptr;
if (! c_Trans.seize(trans_ptr)){
ref->errorCode = CreateFilegroupRef::Busy;
ref->status = 0;
ref->errorKey = 0;
ref->errorLine = __LINE__;
break;
}
const Uint32 trans_key = ++c_opRecordSequence; const Uint32 trans_key = ++c_opRecordSequence;
trans_ptr.p->key = trans_key; trans_ptr.p->key = trans_key;
...@@ -13554,6 +13575,9 @@ Dbdict::execCREATE_FILEGROUP_REQ(Signal* signal){ ...@@ -13554,6 +13575,9 @@ Dbdict::execCREATE_FILEGROUP_REQ(Signal* signal){
tmp.init<CreateObjRef>(rg, GSN_CREATE_OBJ_REF, trans_key); tmp.init<CreateObjRef>(rg, GSN_CREATE_OBJ_REF, trans_key);
sendSignal(rg, GSN_CREATE_OBJ_REQ, signal, sendSignal(rg, GSN_CREATE_OBJ_REQ, signal,
CreateObjReq::SignalLength, JBB); CreateObjReq::SignalLength, JBB);
c_blockState = BS_CREATE_TAB;
return; return;
} while(0); } while(0);
...@@ -13581,6 +13605,22 @@ Dbdict::execDROP_FILE_REQ(Signal* signal) ...@@ -13581,6 +13605,22 @@ Dbdict::execDROP_FILE_REQ(Signal* signal)
Uint32 version = req->file_version; Uint32 version = req->file_version;
do { do {
if(getOwnNodeId() != c_masterNodeId){
jam();
ref->errorCode = DropFileRef::NotMaster;
ref->errorKey = 0;
ref->errorLine = __LINE__;
break;
}
if (c_blockState != BS_IDLE){
jam();
ref->errorCode = DropFileRef::Busy;
ref->errorKey = 0;
ref->errorLine = __LINE__;
break;
}
Ptr<File> file_ptr; Ptr<File> file_ptr;
if (!c_file_hash.find(file_ptr, objId)) if (!c_file_hash.find(file_ptr, objId))
{ {
...@@ -13636,6 +13676,9 @@ Dbdict::execDROP_FILE_REQ(Signal* signal) ...@@ -13636,6 +13676,9 @@ Dbdict::execDROP_FILE_REQ(Signal* signal)
tmp.init<CreateObjRef>(rg, GSN_DROP_OBJ_REF, trans_key); tmp.init<CreateObjRef>(rg, GSN_DROP_OBJ_REF, trans_key);
sendSignal(rg, GSN_DROP_OBJ_REQ, signal, sendSignal(rg, GSN_DROP_OBJ_REQ, signal,
DropObjReq::SignalLength, JBB); DropObjReq::SignalLength, JBB);
c_blockState = BS_CREATE_TAB;
return; return;
} while(0); } while(0);
...@@ -13663,6 +13706,22 @@ Dbdict::execDROP_FILEGROUP_REQ(Signal* signal) ...@@ -13663,6 +13706,22 @@ Dbdict::execDROP_FILEGROUP_REQ(Signal* signal)
Uint32 version = req->filegroup_version; Uint32 version = req->filegroup_version;
do { do {
if(getOwnNodeId() != c_masterNodeId){
jam();
ref->errorCode = DropFilegroupRef::NotMaster;
ref->errorKey = 0;
ref->errorLine = __LINE__;
break;
}
if (c_blockState != BS_IDLE){
jam();
ref->errorCode = DropFilegroupRef::Busy;
ref->errorKey = 0;
ref->errorLine = __LINE__;
break;
}
Ptr<Filegroup> filegroup_ptr; Ptr<Filegroup> filegroup_ptr;
if (!c_filegroup_hash.find(filegroup_ptr, objId)) if (!c_filegroup_hash.find(filegroup_ptr, objId))
{ {
...@@ -13718,6 +13777,9 @@ Dbdict::execDROP_FILEGROUP_REQ(Signal* signal) ...@@ -13718,6 +13777,9 @@ Dbdict::execDROP_FILEGROUP_REQ(Signal* signal)
tmp.init<CreateObjRef>(rg, GSN_DROP_OBJ_REF, trans_key); tmp.init<CreateObjRef>(rg, GSN_DROP_OBJ_REF, trans_key);
sendSignal(rg, GSN_DROP_OBJ_REQ, signal, sendSignal(rg, GSN_DROP_OBJ_REQ, signal,
DropObjReq::SignalLength, JBB); DropObjReq::SignalLength, JBB);
c_blockState = BS_CREATE_TAB;
return; return;
} while(0); } while(0);
...@@ -13892,6 +13954,7 @@ Dbdict::trans_commit_complete_done(Signal* signal, ...@@ -13892,6 +13954,7 @@ Dbdict::trans_commit_complete_done(Signal* signal,
//@todo check api failed //@todo check api failed
sendSignal(trans_ptr.p->m_senderRef, GSN_CREATE_FILEGROUP_CONF, signal, sendSignal(trans_ptr.p->m_senderRef, GSN_CREATE_FILEGROUP_CONF, signal,
CreateFilegroupConf::SignalLength, JBB); CreateFilegroupConf::SignalLength, JBB);
break; break;
} }
case GSN_CREATE_FILE_REQ:{ case GSN_CREATE_FILE_REQ:{
...@@ -13935,6 +13998,7 @@ Dbdict::trans_commit_complete_done(Signal* signal, ...@@ -13935,6 +13998,7 @@ Dbdict::trans_commit_complete_done(Signal* signal,
} }
c_Trans.release(trans_ptr); c_Trans.release(trans_ptr);
ndbrequire(c_blockState == BS_CREATE_TAB);
c_blockState = BS_IDLE; c_blockState = BS_IDLE;
return; return;
} }
...@@ -14047,6 +14111,7 @@ Dbdict::trans_abort_complete_done(Signal* signal, ...@@ -14047,6 +14111,7 @@ Dbdict::trans_abort_complete_done(Signal* signal,
} }
c_Trans.release(trans_ptr); c_Trans.release(trans_ptr);
ndbrequire(c_blockState == BS_CREATE_TAB);
c_blockState = BS_IDLE; c_blockState = BS_IDLE;
return; return;
} }
......
...@@ -4397,7 +4397,7 @@ NdbDictInterface::create_file(const NdbFileImpl & file, ...@@ -4397,7 +4397,7 @@ NdbDictInterface::create_file(const NdbFileImpl & file,
ptr[0].p = (Uint32*)m_buffer.get_data(); ptr[0].p = (Uint32*)m_buffer.get_data();
ptr[0].sz = m_buffer.length() / 4; ptr[0].sz = m_buffer.length() / 4;
int err[] = { CreateFileRef::Busy, 0}; int err[] = { CreateFileRef::Busy, CreateFileRef::NotMaster, 0};
/* /*
Send signal without time-out since creating files can take a very long Send signal without time-out since creating files can take a very long
time if the file is very big. time if the file is very big.
...@@ -4441,7 +4441,7 @@ NdbDictInterface::drop_file(const NdbFileImpl & file){ ...@@ -4441,7 +4441,7 @@ NdbDictInterface::drop_file(const NdbFileImpl & file){
req->file_id = file.m_id; req->file_id = file.m_id;
req->file_version = file.m_version; req->file_version = file.m_version;
int err[] = { DropFileRef::Busy, 0}; int err[] = { DropFileRef::Busy, DropFileRef::NotMaster, 0};
DBUG_RETURN(dictSignal(&tSignal, 0, 0, DBUG_RETURN(dictSignal(&tSignal, 0, 0,
0, // master 0, // master
WAIT_CREATE_INDX_REQ, WAIT_CREATE_INDX_REQ,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment