===== storage/ndb/include/kernel/GlobalSignalNumbers.h 1.29 vs edited ===== --- 1.29/storage/ndb/include/kernel/GlobalSignalNumbers.h 2007-01-24 13:03:34 +08:00 +++ edited/storage/ndb/include/kernel/GlobalSignalNumbers.h 2007-01-23 13:57:22 +08:00 @@ -23,7 +23,7 @@ * * When adding a new signal, remember to update MAX_GSN and SignalNames.cpp */ -const GlobalSignalNumber MAX_GSN = 730; +const GlobalSignalNumber MAX_GSN = 731; struct GsnName { GlobalSignalNumber gsn; @@ -968,6 +968,9 @@ #define GSN_DROP_OBJ_REQ 728 #define GSN_DROP_OBJ_REF 729 #define GSN_DROP_OBJ_CONF 730 + +/* send to Ndbfs and get whether exceed max open files*/ +#define GSN_OPEN_FILES_REQ 731 #define GSN_ALLOC_EXTENT_REQ 68 #define GSN_FREE_EXTENT_REQ 69 ===== storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp 1.3 vs edited ===== --- 1.3/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp 2007-01-24 13:03:34 +08:00 +++ edited/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp 2007-01-23 11:06:59 +08:00 @@ -160,7 +160,8 @@ FilenameAlreadyExists = 760, OutOfFileRecords = 751, InvalidFileType = 750, - NotSupportedWhenDiskless = 775 + NotSupportedWhenDiskless = 775, + OutOfMaxOpenFiles = 779 }; Uint32 senderData; ===== storage/ndb/src/common/debugger/signaldata/Makefile.am 1.8 vs edited ===== --- 1.8/storage/ndb/src/common/debugger/signaldata/Makefile.am 2007-01-24 13:03:34 +08:00 +++ edited/storage/ndb/src/common/debugger/signaldata/Makefile.am 2007-01-23 15:53:50 +08:00 @@ -24,7 +24,7 @@ SumaImpl.cpp NdbSttor.cpp CreateFragmentation.cpp \ UtilLock.cpp TuxMaint.cpp AccLock.cpp \ LqhTrans.cpp ReadNodesConf.cpp CntrStart.cpp \ - ScanFrag.cpp + ScanFrag.cpp MaxOpenFiles.cpp include $(top_srcdir)/storage/ndb/config/common.mk.am include $(top_srcdir)/storage/ndb/config/type_ndbapi.mk.am ===== storage/ndb/src/common/debugger/signaldata/SignalNames.cpp 1.14 vs edited ===== --- 1.14/storage/ndb/src/common/debugger/signaldata/SignalNames.cpp 2007-01-24 13:03:34 +08:00 +++ edited/storage/ndb/src/common/debugger/signaldata/SignalNames.cpp 2007-01-23 13:53:03 +08:00 @@ -622,6 +622,7 @@ ,{ GSN_DROP_OBJ_REQ, "DROP_OBJ_REQ" } ,{ GSN_DROP_OBJ_REF, "DROP_OBJ_REF" } ,{ GSN_DROP_OBJ_CONF, "DROP_OBJ_CONF" } + ,{ GSN_OPEN_FILES_REQ, "OPEN_FILES_REQ" } ,{ GSN_LCP_PREPARE_REQ, "LCP_PREPARE_REQ" } ,{ GSN_LCP_PREPARE_REF, "LCP_PREPARE_REF" } ===== storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 1.107 vs edited ===== --- 1.107/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2007-01-24 13:03:35 +08:00 +++ edited/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2007-01-24 12:25:18 +08:00 @@ -19,6 +19,7 @@ #define DBDICT_C #include "Dbdict.hpp" +#include #include #include @@ -84,6 +85,7 @@ #include #include +#include #include #define ZNOT_FOUND 626 @@ -14069,6 +14071,26 @@ SchemaFile::TableEntry *objEntry = getTableEntry(xsf, objId); create_obj->objVersion = create_obj_inc_schema_version(objEntry->m_tableVersion); + } + + /* + * bug#24521, to avoid Ndbd crashed in Ndbfs block when exceed max open files + */ + if (type == NdbDictionary::Object::Tablespace || + type == NdbDictionary::Object::LogfileGroup || + type == NdbDictionary::Object::Datafile || + type == NdbDictionary::Object::Undofile) { + Uint32 * theData = signal->getDataPtrSend(); + MaxOpenFilesReq * const req = (MaxOpenFilesReq*)theData; + EXECUTE_DIRECT(NDBFS, GSN_OPEN_FILES_REQ, signal, + MaxOpenFilesReq::SignalLength); + if (req->objType == Uint32(-1)) { + ref->errorCode = CreateFileRef::OutOfMaxOpenFiles; + ref->status = 0; + ref->errorKey = 0; + ref->errorLine = __LINE__; + break; + } } NodeReceiverGroup rg(DBDICT, trans_ptr.p->m_nodes); ===== storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp 1.31 vs edited ===== --- 1.31/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp 2007-01-24 13:03:35 +08:00 +++ edited/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp 2007-01-24 12:25:15 +08:00 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -71,6 +72,7 @@ addRecSignal(GSN_CONTINUEB, &Ndbfs::execCONTINUEB); addRecSignal(GSN_FSAPPENDREQ, &Ndbfs::execFSAPPENDREQ); addRecSignal(GSN_FSREMOVEREQ, &Ndbfs::execFSREMOVEREQ); + addRecSignal(GSN_OPEN_FILES_REQ, &Ndbfs::execOPENFILESREQ); // Set send signals } @@ -1086,6 +1088,24 @@ } } }//Ndbfs::execDUMP_STATE_ORD() + +/* +* This function for GSN_OPEN_FILES_REQ is used to get whether exceed +* max open files limitation, and MUST be called by EXECUTE_DIRECT +* in: signal with theData[0] related to MaxOpenFilesReq +* out: set req->objType to Uint32(-1) to stand for exceeded +*/ +void +Ndbfs::execOPENFILESREQ(Signal* signal) +{ + Uint32 * theData = signal->getDataPtrSend(); + MaxOpenFilesReq * const req = (MaxOpenFilesReq*)theData; + ndbrequire(req->objType != Uint32(-1)); + if (theIdleFiles.size() <= 1 && theFiles.size()+1 >= m_maxFiles) + { + req->objType = Uint32(-1); + } +} const char* Ndbfs::get_filename(Uint32 fd) const ===== storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp 1.7 vs edited ===== --- 1.7/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp 2007-01-24 13:03:35 +08:00 +++ edited/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp 2007-01-23 13:37:44 +08:00 @@ -53,6 +53,7 @@ void execFSREMOVEREQ(Signal* signal); void execSTTOR(Signal* signal); void execCONTINUEB(Signal* signal); + void execOPENFILESREQ(Signal* signal); bool scanningInProgress; Uint16 newId(); ===== storage/ndb/src/ndbapi/ndberror.c 1.77 vs edited ===== --- 1.77/storage/ndb/src/ndbapi/ndberror.c 2007-01-24 13:03:35 +08:00 +++ edited/storage/ndb/src/ndbapi/ndberror.c 2007-01-23 10:59:37 +08:00 @@ -424,6 +424,7 @@ { 776, DMEC, AE, "Index created on temporary table must itself be temporary" }, { 777, DMEC, AE, "Cannot create a temporary index on a non-temporary table" }, { 778, DMEC, AE, "A temporary table or index must be specified as not logging" }, + { 779, DMEC, CE, "Out of max open files, check MaxNoOfOpenFiles & InitialNoOfOpenFiles" }, /** * FunctionNotImplemented ===== New file: storage/ndb/include/kernel/signaldata/MaxOpenFiles.hpp ===== --- /dev/null 2006-11-28 22:00:11 +08:00 +++ bug24521-5.1-new-ndb-bj/storage/ndb/include/kernel/signaldata/MaxOpenFiles.hpp 2007-01-23 12:57:35 +08:00 @@ -0,0 +1,44 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef MAX_OPEN_FILES_HPP +#define MAX_OPEN_FILES_HPP + +#include "SignalData.hpp" + +class MaxOpenFilesReq { + /** + * Sender(s) + */ + friend class Dbdict; + + /** + * Receiver(s) + */ + friend class Ndbfs; + + friend bool printOPEN_FILES_REQ(FILE *, + const Uint32 *, Uint32, Uint16); +public: + STATIC_CONST( SignalLength = 3 ); + +private: + Uint32 senderRef; + Uint32 senderData; + Uint32 objType; +}; + +#endif ===== New file: storage/ndb/src/common/debugger/signaldata/MaxOpenFiles.cpp ===== --- /dev/null 2006-11-28 22:00:11 +08:00 +++ bug24521-5.1-new-ndb-bj/storage/ndb/src/common/debugger/signaldata/MaxOpenFiles.cpp 2007-01-23 12:57:58 +08:00 @@ -0,0 +1,28 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include + +bool +printOPEN_FILES_REQ(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) { + const MaxOpenFilesReq * const sig = (MaxOpenFilesReq *)theData; + fprintf(output, " senderRef: %x\n", sig->senderRef); + fprintf(output, " senderData: %x\n", sig->senderData); + fprintf(output, " objType: %x\n", sig->objType); + return true; +} +