summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2006-02-02 23:27:06 +0300
committerunknown <konstantin@mysql.com>2006-02-02 23:27:06 +0300
commitd297a221fe57486f0fd82e0cf3e7b0e923adee93 (patch)
tree8b23d2acce88a26d289057d5119ca3944903d88f /storage
parent5610e9ab8296f661b144bc64702bb612d2038050 (diff)
parent333b1f8594922647278808a4c114c16695551343 (diff)
downloadmariadb-git-d297a221fe57486f0fd82e0cf3e7b0e923adee93.tar.gz
Merge mysql.com:/home/kostja/mysql/tmp_merge
into mysql.com:/home/kostja/mysql/mysql-5.1-merge BitKeeper/etc/ignore: auto-union configure.in: Auto merged libmysql/libmysql.c: Auto merged mysql-test/ndb/ndbcluster.sh: Auto merged mysql-test/r/rpl_sp.result: Auto merged mysql-test/r/sp-error.result: Auto merged mysql-test/r/sp.result: Auto merged mysql-test/r/type_float.result: Auto merged mysql-test/t/rpl_sp.test: Auto merged mysql-test/t/sp-error.test: Auto merged mysql-test/t/sp.test: Auto merged sql/field.cc: Auto merged sql/item_func.cc: Auto merged sql/mysqld.cc: Auto merged sql/protocol.cc: Auto merged sql/sp_head.cc: Auto merged sql/sp_head.h: Auto merged sql/sql_acl.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged sql/table.h: Auto merged storage/myisam/ft_update.c: Auto merged storage/ndb/include/logger/LogHandler.hpp: Auto merged storage/ndb/include/logger/Logger.hpp: Auto merged storage/ndb/include/mgmapi/mgmapi.h: Auto merged storage/ndb/include/mgmcommon/ConfigRetriever.hpp: Auto merged storage/ndb/src/common/logger/FileLogHandler.cpp: Auto merged storage/ndb/src/common/logger/LogHandler.cpp: Auto merged storage/ndb/src/common/logger/Logger.cpp: Auto merged storage/ndb/src/common/logger/SysLogHandler.cpp: Auto merged storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp: Auto merged storage/ndb/src/common/util/SocketServer.cpp: Auto merged storage/ndb/src/kernel/main.cpp: Auto merged storage/ndb/src/kernel/vm/Configuration.cpp: Auto merged storage/ndb/src/kernel/vm/Configuration.hpp: Auto merged storage/ndb/src/mgmapi/mgmapi.cpp: Auto merged storage/ndb/src/mgmclient/CommandInterpreter.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.hpp: Auto merged storage/ndb/src/mgmsrv/Services.cpp: Auto merged storage/ndb/src/mgmsrv/Services.hpp: Auto merged storage/ndb/src/mgmsrv/main.cpp: Auto merged storage/ndb/tools/ndb_size.pl: Auto merged zlib/Makefile.am: Auto merged mysql-test/r/information_schema.result: SCCS merged mysql-test/t/information_schema.test: Manual merge. sql/ha_archive.cc: Manual merge. sql/share/errmsg.txt: SCCS merged tests/mysql_client_test.c: Manual merge.
Diffstat (limited to 'storage')
-rw-r--r--storage/myisam/ft_update.c4
-rw-r--r--storage/ndb/include/logger/LogHandler.hpp13
-rw-r--r--storage/ndb/include/logger/Logger.hpp5
-rw-r--r--storage/ndb/include/mgmapi/mgmapi.h16
-rw-r--r--storage/ndb/include/mgmcommon/ConfigRetriever.hpp3
-rw-r--r--storage/ndb/src/common/logger/FileLogHandler.cpp17
-rw-r--r--storage/ndb/src/common/logger/LogHandler.cpp29
-rw-r--r--storage/ndb/src/common/logger/Logger.cpp11
-rw-r--r--storage/ndb/src/common/logger/SysLogHandler.cpp1
-rw-r--r--storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp3
-rw-r--r--storage/ndb/src/common/util/SocketServer.cpp2
-rw-r--r--storage/ndb/src/kernel/main.cpp5
-rw-r--r--storage/ndb/src/kernel/vm/Configuration.cpp3
-rw-r--r--storage/ndb/src/kernel/vm/Configuration.hpp2
-rw-r--r--storage/ndb/src/mgmapi/mgmapi.cpp19
-rw-r--r--storage/ndb/src/mgmclient/CommandInterpreter.cpp23
-rw-r--r--storage/ndb/src/mgmsrv/MgmtSrvr.cpp153
-rw-r--r--storage/ndb/src/mgmsrv/MgmtSrvr.hpp11
-rw-r--r--storage/ndb/src/mgmsrv/Services.cpp15
-rw-r--r--storage/ndb/src/mgmsrv/Services.hpp1
-rw-r--r--storage/ndb/src/mgmsrv/main.cpp61
-rw-r--r--storage/ndb/tools/ndb_size.pl2
22 files changed, 325 insertions, 74 deletions
diff --git a/storage/myisam/ft_update.c b/storage/myisam/ft_update.c
index a280a98cf90..1ec91b41218 100644
--- a/storage/myisam/ft_update.c
+++ b/storage/myisam/ft_update.c
@@ -174,6 +174,10 @@ int _mi_ft_cmp(MI_INFO *info, uint keynr, const byte *rec1, const byte *rec2)
FT_SEG_ITERATOR ftsi1, ftsi2;
CHARSET_INFO *cs=info->s->keyinfo[keynr].seg->charset;
DBUG_ENTER("_mi_ft_cmp");
+#ifndef MYSQL_HAS_TRUE_CTYPE_IMPLEMENTATION
+ if (cs->mbmaxlen > 1)
+ DBUG_RETURN(THOSE_TWO_DAMN_KEYS_ARE_REALLY_DIFFERENT);
+#endif
_mi_ft_segiterator_init(info, keynr, rec1, &ftsi1);
_mi_ft_segiterator_init(info, keynr, rec2, &ftsi2);
diff --git a/storage/ndb/include/logger/LogHandler.hpp b/storage/ndb/include/logger/LogHandler.hpp
index 7df6ad864e5..8b9aa43d7a9 100644
--- a/storage/ndb/include/logger/LogHandler.hpp
+++ b/storage/ndb/include/logger/LogHandler.hpp
@@ -126,6 +126,18 @@ public:
void setErrorCode(int code);
/**
+ * Returns the error string.
+ */
+ char* getErrorStr();
+
+ /**
+ * Sets the error string.
+ *
+ * @param str the error string.
+ */
+ void setErrorStr(char* str);
+
+ /**
* Parse logstring parameters
*
* @param params list of parameters, formatted as "param=value",
@@ -195,6 +207,7 @@ private:
const char* m_pDateTimeFormat;
int m_errorCode;
+ char* m_errorStr;
// for handling repeated messages
unsigned m_count_repeated_messages;
diff --git a/storage/ndb/include/logger/Logger.hpp b/storage/ndb/include/logger/Logger.hpp
index ee762098fb6..3414468d42d 100644
--- a/storage/ndb/include/logger/Logger.hpp
+++ b/storage/ndb/include/logger/Logger.hpp
@@ -178,8 +178,11 @@ public:
* Add a new handler
*
* @param logstring string describing the handler to add
+ * @param err OS errno in event of error
+ * @param len max length of errStr buffer
+ * @param errStr logger error string in event of error
*/
- bool addHandler(const BaseString &logstring);
+ bool addHandler(const BaseString &logstring, int *err, int len, char* errStr);
/**
* Remove a log handler.
diff --git a/storage/ndb/include/mgmapi/mgmapi.h b/storage/ndb/include/mgmapi/mgmapi.h
index 2675502b6ad..9d74be5d603 100644
--- a/storage/ndb/include/mgmapi/mgmapi.h
+++ b/storage/ndb/include/mgmapi/mgmapi.h
@@ -992,6 +992,22 @@ extern "C" {
int ndb_mgm_alloc_nodeid(NdbMgmHandle handle,
unsigned version, int nodetype);
+ /**
+ * End Session
+ *
+ * This function tells the mgm server to free all resources associated with
+ * this connection. It will also close it.
+ *
+ * This differs from just disconnecting as we now synchronously clean up,
+ * so that a quickly restarting server that needs the same node id can
+ * get it when it restarts.
+ *
+ * @param handle NDB management handle
+ * @return 0 on success
+ *
+ * @note you still have to destroy the NdbMgmHandle.
+ */
+ int ndb_mgm_end_session(NdbMgmHandle handle);
/**
* Get the node id of the mgm server we're connected to
diff --git a/storage/ndb/include/mgmcommon/ConfigRetriever.hpp b/storage/ndb/include/mgmcommon/ConfigRetriever.hpp
index c0b877af07d..1b4ecd56f80 100644
--- a/storage/ndb/include/mgmcommon/ConfigRetriever.hpp
+++ b/storage/ndb/include/mgmcommon/ConfigRetriever.hpp
@@ -78,6 +78,7 @@ public:
const char *get_connectstring(char *buf, int buf_sz) const;
NdbMgmHandle get_mgmHandle() { return m_handle; };
NdbMgmHandle* get_mgmHandlePtr() { return &m_handle; };
+ void end_session(bool end) { m_end_session= end; };
Uint32 get_configuration_nodeid() const;
private:
@@ -92,6 +93,8 @@ private:
void setError(ErrorType, const char * errorMsg);
Uint32 _ownNodeId;
+ bool m_end_session;
+
/*
Uint32 m_mgmd_port;
const char *m_mgmd_host;
diff --git a/storage/ndb/src/common/logger/FileLogHandler.cpp b/storage/ndb/src/common/logger/FileLogHandler.cpp
index 8678b999b6f..3d29e63ac1f 100644
--- a/storage/ndb/src/common/logger/FileLogHandler.cpp
+++ b/storage/ndb/src/common/logger/FileLogHandler.cpp
@@ -187,6 +187,7 @@ FileLogHandler::setParam(const BaseString &param, const BaseString &value){
return setMaxSize(value);
if(param == "maxfiles")
return setMaxFiles(value);
+ setErrorStr("Invalid parameter");
return false;
}
@@ -196,16 +197,18 @@ FileLogHandler::setFilename(const BaseString &filename) {
if(m_pLogFile)
delete m_pLogFile;
m_pLogFile = new File_class(filename.c_str(), "a+");
- open();
- return true;
+ return open();
}
bool
FileLogHandler::setMaxSize(const BaseString &size) {
char *end;
long val = strtol(size.c_str(), &end, 0); /* XXX */
- if(size.c_str() == end)
+ if(size.c_str() == end || val < 0)
+ {
+ setErrorStr("Invalid file size");
return false;
+ }
if(end[0] == 'M')
val *= 1024*1024;
if(end[0] == 'k')
@@ -220,8 +223,11 @@ bool
FileLogHandler::setMaxFiles(const BaseString &files) {
char *end;
long val = strtol(files.c_str(), &end, 0);
- if(files.c_str() == end)
+ if(files.c_str() == end || val < 1)
+ {
+ setErrorStr("Invalid maximum number of files");
return false;
+ }
m_maxNoFiles = val;
return true;
@@ -230,6 +236,9 @@ FileLogHandler::setMaxFiles(const BaseString &files) {
bool
FileLogHandler::checkParams() {
if(m_pLogFile == NULL)
+ {
+ setErrorStr("Log file cannot be null.");
return false;
+ }
return true;
}
diff --git a/storage/ndb/src/common/logger/LogHandler.cpp b/storage/ndb/src/common/logger/LogHandler.cpp
index 521bd346fd3..c11f962d4fb 100644
--- a/storage/ndb/src/common/logger/LogHandler.cpp
+++ b/storage/ndb/src/common/logger/LogHandler.cpp
@@ -23,7 +23,8 @@
//
LogHandler::LogHandler() :
m_pDateTimeFormat("%d-%.2d-%.2d %.2d:%.2d:%.2d"),
- m_errorCode(0)
+ m_errorCode(0),
+ m_errorStr(NULL)
{
m_max_repeat_frequency= 3; // repeat messages maximum every 3 seconds
m_count_repeated_messages= 0;
@@ -155,6 +156,19 @@ LogHandler::setErrorCode(int code)
m_errorCode = code;
}
+
+char*
+LogHandler::getErrorStr()
+{
+ return m_errorStr;
+}
+
+void
+LogHandler::setErrorStr(char* str)
+{
+ m_errorStr= str;
+}
+
bool
LogHandler::parseParams(const BaseString &_params) {
Vector<BaseString> v_args;
@@ -165,9 +179,18 @@ LogHandler::parseParams(const BaseString &_params) {
for(size_t i=0; i < v_args.size(); i++) {
Vector<BaseString> v_param_value;
if(v_args[i].split(v_param_value, "=", 2) != 2)
+ {
ret = false;
- else if (!setParam(v_param_value[0], v_param_value[1]))
- ret = false;
+ setErrorStr("Can't find key=value pair.");
+ }
+ else
+ {
+ v_param_value[0].trim(" \t");
+ if (!setParam(v_param_value[0], v_param_value[1]))
+ {
+ ret = false;
+ }
+ }
}
if(!checkParams())
diff --git a/storage/ndb/src/common/logger/Logger.cpp b/storage/ndb/src/common/logger/Logger.cpp
index 4a48236053d..48e084a782b 100644
--- a/storage/ndb/src/common/logger/Logger.cpp
+++ b/storage/ndb/src/common/logger/Logger.cpp
@@ -167,7 +167,7 @@ Logger::addHandler(LogHandler* pHandler)
}
bool
-Logger::addHandler(const BaseString &logstring) {
+Logger::addHandler(const BaseString &logstring, int *err, int len, char* errStr) {
size_t i;
Vector<BaseString> logdest;
Vector<LogHandler *>loghandlers;
@@ -200,9 +200,18 @@ Logger::addHandler(const BaseString &logstring) {
handler = new ConsoleLogHandler();
if(handler == NULL)
+ {
+ snprintf(errStr,len,"Could not create log destination: %s",
+ logdest[i].c_str());
DBUG_RETURN(false);
+ }
if(!handler->parseParams(params))
+ {
+ *err= handler->getErrorCode();
+ if(handler->getErrorStr())
+ strncpy(errStr, handler->getErrorStr(), len);
DBUG_RETURN(false);
+ }
loghandlers.push_back(handler);
}
diff --git a/storage/ndb/src/common/logger/SysLogHandler.cpp b/storage/ndb/src/common/logger/SysLogHandler.cpp
index 5b1b8d85ca7..c7fcb102dd4 100644
--- a/storage/ndb/src/common/logger/SysLogHandler.cpp
+++ b/storage/ndb/src/common/logger/SysLogHandler.cpp
@@ -154,5 +154,6 @@ SysLogHandler::setFacility(const BaseString &facility) {
return true;
}
}
+ setErrorStr("Invalid syslog facility name");
return false;
}
diff --git a/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp
index 3b843b6708b..97de5c7f83d 100644
--- a/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp
+++ b/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp
@@ -52,6 +52,7 @@ ConfigRetriever::ConfigRetriever(const char * _connect_string,
m_version = version;
m_node_type = node_type;
_ownNodeId= 0;
+ m_end_session= true;
m_handle= ndb_mgm_create_handle();
@@ -76,6 +77,8 @@ ConfigRetriever::~ConfigRetriever()
{
DBUG_ENTER("ConfigRetriever::~ConfigRetriever");
if (m_handle) {
+ if(m_end_session)
+ ndb_mgm_end_session(m_handle);
ndb_mgm_disconnect(m_handle);
ndb_mgm_destroy_handle(&m_handle);
}
diff --git a/storage/ndb/src/common/util/SocketServer.cpp b/storage/ndb/src/common/util/SocketServer.cpp
index 15dca2d96b1..481c656b78b 100644
--- a/storage/ndb/src/common/util/SocketServer.cpp
+++ b/storage/ndb/src/common/util/SocketServer.cpp
@@ -42,6 +42,8 @@ SocketServer::~SocketServer() {
delete m_sessions[i].m_session;
}
for(i = 0; i<m_services.size(); i++){
+ if(m_services[i].m_socket)
+ NDB_CLOSE_SOCKET(m_services[i].m_socket);
delete m_services[i].m_service;
}
}
diff --git a/storage/ndb/src/kernel/main.cpp b/storage/ndb/src/kernel/main.cpp
index 2374cce5f35..4bc9fbf76e5 100644
--- a/storage/ndb/src/kernel/main.cpp
+++ b/storage/ndb/src/kernel/main.cpp
@@ -307,8 +307,11 @@ int main(int argc, char** argv)
/**
* We no longer need the mgm connection in this process
* (as we are the angel, not ndb)
+ *
+ * We don't want to purge any allocated resources (nodeid), so
+ * we set that option to false
*/
- theConfig->closeConfiguration();
+ theConfig->closeConfiguration(false);
int status = 0, error_exit = 0, signum = 0;
while(waitpid(child, &status, 0) != child);
diff --git a/storage/ndb/src/kernel/vm/Configuration.cpp b/storage/ndb/src/kernel/vm/Configuration.cpp
index fe7d474b578..771fa6f5fe4 100644
--- a/storage/ndb/src/kernel/vm/Configuration.cpp
+++ b/storage/ndb/src/kernel/vm/Configuration.cpp
@@ -172,7 +172,8 @@ Configuration::~Configuration(){
}
void
-Configuration::closeConfiguration(){
+Configuration::closeConfiguration(bool end_session){
+ m_config_retriever->end_session(end_session);
if (m_config_retriever) {
delete m_config_retriever;
}
diff --git a/storage/ndb/src/kernel/vm/Configuration.hpp b/storage/ndb/src/kernel/vm/Configuration.hpp
index 5043d1f0bee..243ecbee4e7 100644
--- a/storage/ndb/src/kernel/vm/Configuration.hpp
+++ b/storage/ndb/src/kernel/vm/Configuration.hpp
@@ -35,7 +35,7 @@ public:
void fetch_configuration();
void setupConfiguration();
- void closeConfiguration();
+ void closeConfiguration(bool end_session= true);
bool lockPagesInMainMemory() const;
diff --git a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp
index 79284964186..eb93ec88b6f 100644
--- a/storage/ndb/src/mgmapi/mgmapi.cpp
+++ b/storage/ndb/src/mgmapi/mgmapi.cpp
@@ -2321,4 +2321,23 @@ int ndb_mgm_report_event(NdbMgmHandle handle, Uint32 *data, Uint32 length)
DBUG_RETURN(0);
}
+extern "C"
+int ndb_mgm_end_session(NdbMgmHandle handle)
+{
+ DBUG_ENTER("ndb_mgm_end_session");
+ CHECK_HANDLE(handle, 0);
+ CHECK_CONNECTED(handle, 0);
+
+ SocketOutputStream s_output(handle->socket);
+ s_output.println("end session");
+ s_output.println("");
+
+ SocketInputStream in(handle->socket, handle->read_timeout);
+ char buf[32];
+
+ in.gets(buf, sizeof(buf));
+
+ DBUG_RETURN(0);
+}
+
template class Vector<const ParserRow<ParserDummy>*>;
diff --git a/storage/ndb/src/mgmclient/CommandInterpreter.cpp b/storage/ndb/src/mgmclient/CommandInterpreter.cpp
index b398ed46514..5496b2dadc3 100644
--- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp
+++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp
@@ -928,26 +928,21 @@ CommandInterpreter::executeShutdown(char* parameters)
int result = 0;
result = ndb_mgm_stop(m_mgmsrv, 0, 0);
if (result < 0) {
- ndbout << "Shutdown off NDB Cluster storage node(s) failed." << endl;
+ ndbout << "Shutdown of NDB Cluster node(s) failed." << endl;
printError();
return result;
}
- ndbout << result << " NDB Cluster storage node(s) have shutdown." << endl;
+ ndbout << result << " NDB Cluster node(s) have shutdown." << endl;
int mgm_id= 0;
- for(int i=0; i < state->no_of_nodes; i++) {
- if(state->node_states[i].node_type == NDB_MGM_NODE_TYPE_MGM &&
- state->node_states[i].version != 0){
- if (mgm_id == 0)
- mgm_id= state->node_states[i].node_id;
- else {
- ndbout << "Unable to locate management server, "
- << "shutdown manually with <id> STOP"
- << endl;
- return 1;
- }
- }
+ mgm_id= ndb_mgm_get_mgmd_nodeid(m_mgmsrv);
+ if (mgm_id == 0)
+ {
+ ndbout << "Unable to locate management server, "
+ << "shutdown manually with <id> STOP"
+ << endl;
+ return 1;
}
result = ndb_mgm_stop(m_mgmsrv, 1, &mgm_id);
diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp
index cf9965b94e0..b60679f700e 100644
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp
@@ -60,6 +60,9 @@
#include <SignalSender.hpp>
+extern bool g_StopServer;
+extern bool g_RestartServer;
+
//#define MGM_SRV_DEBUG
#ifdef MGM_SRV_DEBUG
#define DEBUG(x) do ndbout << x << endl; while(0)
@@ -179,6 +182,8 @@ MgmtSrvr::startEventLog()
}
const char * tmp;
+ char errStr[100];
+ int err= 0;
BaseString logdest;
char *clusterLog= NdbConfig_ClusterLogFileName(_ownNodeId);
NdbAutoPtr<char> tmp_aptr(clusterLog);
@@ -192,9 +197,17 @@ MgmtSrvr::startEventLog()
logdest.assfmt("FILE:filename=%s,maxsize=1000000,maxfiles=6",
clusterLog);
}
- if(!g_eventLogger.addHandler(logdest)) {
+ errStr[0]='\0';
+ if(!g_eventLogger.addHandler(logdest, &err, sizeof(errStr), errStr)) {
ndbout << "Warning: could not add log destination \""
- << logdest.c_str() << "\"" << endl;
+ << logdest.c_str() << "\". Reason: ";
+ if(err)
+ ndbout << strerror(err);
+ if(err && errStr[0]!='\0')
+ ndbout << ", ";
+ if(errStr[0]!='\0')
+ ndbout << errStr;
+ ndbout << endl;
}
}
@@ -373,7 +386,8 @@ MgmtSrvr::MgmtSrvr(SocketServer *socket_server,
_ownReference(0),
theSignalIdleList(NULL),
theWaitState(WAIT_SUBSCRIBE_CONF),
- m_event_listner(this)
+ m_event_listner(this),
+ m_local_mgm_handle(0)
{
DBUG_ENTER("MgmtSrvr::MgmtSrvr");
@@ -537,6 +551,8 @@ MgmtSrvr::check_start()
bool
MgmtSrvr::start(BaseString &error_string)
{
+ int mgm_connect_result;
+
DBUG_ENTER("MgmtSrvr::start");
if (_props == NULL) {
if (!check_start()) {
@@ -574,6 +590,13 @@ MgmtSrvr::start(BaseString &error_string)
DBUG_RETURN(false);
}
+ if((mgm_connect_result= connect_to_self()) < 0)
+ {
+ ndbout_c("Unable to connect to our own ndb_mgmd (Error %d)",
+ mgm_connect_result);
+ ndbout_c("This is probably a bug.");
+ }
+
TransporterRegistry *reg = theFacade->get_registry();
for(unsigned int i=0;i<reg->m_transporter_interface.size();i++) {
BaseString msg;
@@ -831,9 +854,81 @@ MgmtSrvr::sendVersionReq(int v_nodeId, Uint32 &version, const char **address)
return 0;
}
+int MgmtSrvr::sendStopMgmd(NodeId nodeId,
+ bool abort,
+ bool stop,
+ bool restart,
+ bool nostart,
+ bool initialStart)
+{
+ const char* hostname;
+ Uint32 port;
+ BaseString connect_string;
+
+ {
+ Guard g(m_configMutex);
+ {
+ ndb_mgm_configuration_iterator
+ iter(* _config->m_configValues, CFG_SECTION_NODE);
+
+ if(iter.first()) return SEND_OR_RECEIVE_FAILED;
+ if(iter.find(CFG_NODE_ID, nodeId)) return SEND_OR_RECEIVE_FAILED;
+ if(iter.get(CFG_NODE_HOST, &hostname)) return SEND_OR_RECEIVE_FAILED;
+ }
+ {
+ ndb_mgm_configuration_iterator
+ iter(* _config->m_configValues, CFG_SECTION_NODE);
+
+ if(iter.first()) return SEND_OR_RECEIVE_FAILED;
+ if(iter.find(CFG_NODE_ID, nodeId)) return SEND_OR_RECEIVE_FAILED;
+ if(iter.get(CFG_MGM_PORT, &port)) return SEND_OR_RECEIVE_FAILED;
+ }
+ if( strlen(hostname) == 0 )
+ return SEND_OR_RECEIVE_FAILED;
+ }
+ connect_string.assfmt("%s:%u",hostname,port);
+
+ DBUG_PRINT("info",("connect string: %s",connect_string.c_str()));
+
+ NdbMgmHandle h= ndb_mgm_create_handle();
+ if ( h && connect_string.length() > 0 )
+ {
+ ndb_mgm_set_connectstring(h,connect_string.c_str());
+ if(ndb_mgm_connect(h,1,0,0))
+ {
+ DBUG_PRINT("info",("failed ndb_mgm_connect"));
+ return SEND_OR_RECEIVE_FAILED;
+ }
+ if(!restart)
+ {
+ if(ndb_mgm_stop(h, 1, (const int*)&nodeId) < 0)
+ {
+ return SEND_OR_RECEIVE_FAILED;
+ }
+ }
+ else
+ {
+ int nodes[1];
+ nodes[0]= (int)nodeId;
+ if(ndb_mgm_restart2(h, 1, nodes, initialStart, nostart, abort) < 0)
+ {
+ return SEND_OR_RECEIVE_FAILED;
+ }
+ }
+ }
+ ndb_mgm_destroy_handle(&h);
+
+ return 0;
+}
+
/*
* Common method for handeling all STOP_REQ signalling that
* is used by Stopping, Restarting and Single user commands
+ *
+ * In the event that we need to stop a mgmd, we create a mgm
+ * client connection to that mgmd and stop it that way.
+ * This allows us to stop mgm servers when there isn't any real
+ * distributed communication up.
*/
int MgmtSrvr::sendSTOP_REQ(NodeId nodeId,
@@ -845,6 +940,8 @@ int MgmtSrvr::sendSTOP_REQ(NodeId nodeId,
bool nostart,
bool initialStart)
{
+ int error = 0;
+
stoppedNodes.clear();
SignalSender ss(theFacade);
@@ -883,18 +980,34 @@ int MgmtSrvr::sendSTOP_REQ(NodeId nodeId,
NodeBitmask nodes;
if (nodeId)
{
+ if(nodeId==getOwnNodeId())
{
- int r;
- if((r = okToSendTo(nodeId, true)) != 0)
- return r;
+ if(restart)
+ g_RestartServer= true;
+ g_StopServer= true;
+ return 0;
}
+ if(getNodeType(nodeId) == NDB_MGM_NODE_TYPE_NDB)
{
+ int r;
+ if((r= okToSendTo(nodeId, true)) != 0)
+ return r;
if (ss.sendSignal(nodeId, &ssig) != SEND_OK)
return SEND_OR_RECEIVE_FAILED;
}
+ else if(getNodeType(nodeId) == NDB_MGM_NODE_TYPE_MGM)
+ {
+ error= sendStopMgmd(nodeId, abort, stop, restart, nostart, initialStart);
+ if(error==0)
+ stoppedNodes.set(nodeId);
+ return error;
+ }
+ else
+ return WRONG_PROCESS_TYPE;
nodes.set(nodeId);
}
else
+ {
while(getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB))
{
if(okToSendTo(nodeId, true) == 0)
@@ -904,9 +1017,17 @@ int MgmtSrvr::sendSTOP_REQ(NodeId nodeId,
nodes.set(nodeId);
}
}
+ nodeId= 0;
+ while(getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_MGM))
+ {
+ if(nodeId==getOwnNodeId())
+ continue;
+ if(sendStopMgmd(nodeId, abort, stop, restart, nostart, initialStart)==0)
+ stoppedNodes.set(nodeId);
+ }
+ }
// now wait for the replies
- int error = 0;
while (!nodes.isclear())
{
SimpleSignal *signal = ss.waitFor();
@@ -2552,9 +2673,23 @@ void MgmtSrvr::transporter_connect(NDB_SOCKET_TYPE sockfd)
}
}
-int MgmtSrvr::set_connect_string(const char *str)
+int MgmtSrvr::connect_to_self(void)
{
- return ndb_mgm_set_connectstring(m_config_retriever->get_mgmHandle(),str);
+ int r= 0;
+ m_local_mgm_handle= ndb_mgm_create_handle();
+ snprintf(m_local_mgm_connect_string,sizeof(m_local_mgm_connect_string),
+ "localhost:%u",getPort());
+ ndb_mgm_set_connectstring(m_local_mgm_handle, m_local_mgm_connect_string);
+
+ if((r= ndb_mgm_connect(m_local_mgm_handle, 0, 0, 0)) < 0)
+ {
+ ndb_mgm_destroy_handle(&m_local_mgm_handle);
+ return r;
+ }
+ // TransporterRegistry now owns this NdbMgmHandle and will destroy it.
+ theFacade->get_registry()->set_mgm_handle(m_local_mgm_handle);
+
+ return 0;
}
diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp
index ec6ab47bc2a..20e6ff1bc43 100644
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp
@@ -466,7 +466,7 @@ public:
int getConnectionDbParameter(int node1, int node2, int param,
int *value, BaseString& msg);
- int set_connect_string(const char *str);
+ int connect_to_self(void);
void transporter_connect(NDB_SOCKET_TYPE sockfd);
@@ -482,6 +482,13 @@ private:
int send(SignalSender &ss, SimpleSignal &ssig, Uint32 node, Uint32 node_type);
+ int sendStopMgmd(NodeId nodeId,
+ bool abort,
+ bool stop,
+ bool restart,
+ bool nostart,
+ bool initialStart);
+
int sendSTOP_REQ(NodeId nodeId,
NodeBitmask &stoppedNodes,
Uint32 singleUserNodeId,
@@ -625,6 +632,8 @@ private:
// signal arrives.
// We wait in receiveOptimisedResponse and signal in handleReceivedSignal.
+ NdbMgmHandle m_local_mgm_handle;
+ char m_local_mgm_connect_string[20];
class TransporterFacade * theFacade;
int sendVersionReq( int processId, Uint32 &version, const char **address);
diff --git a/storage/ndb/src/mgmsrv/Services.cpp b/storage/ndb/src/mgmsrv/Services.cpp
index ee24cf18941..80f0aa2eda8 100644
--- a/storage/ndb/src/mgmsrv/Services.cpp
+++ b/storage/ndb/src/mgmsrv/Services.cpp
@@ -203,6 +203,8 @@ ParserRow<MgmApiSession> commands[] = {
MGM_CMD("bye", &MgmApiSession::bye, ""),
+ MGM_CMD("end session", &MgmApiSession::endSession, ""),
+
MGM_CMD("set loglevel", &MgmApiSession::setLogLevel, ""),
MGM_ARG("node", Int, Mandatory, "Node"),
MGM_ARG("category", Int, Mandatory, "Event category"),
@@ -719,11 +721,22 @@ MgmApiSession::dumpState(Parser<MgmApiSession>::Context &,
void
MgmApiSession::bye(Parser<MgmApiSession>::Context &,
- Properties const &) {
+ Properties const &) {
m_stop = true;
}
void
+MgmApiSession::endSession(Parser<MgmApiSession>::Context &,
+ Properties const &) {
+ if(m_allocated_resources)
+ delete m_allocated_resources;
+
+ m_allocated_resources= new MgmtSrvr::Allocated_resources(m_mgmsrv);
+
+ m_output->println("end session reply");
+}
+
+void
MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
Properties const &args) {
const char *reply= "set cluster loglevel reply";
diff --git a/storage/ndb/src/mgmsrv/Services.hpp b/storage/ndb/src/mgmsrv/Services.hpp
index 30f220cd060..f97223750a1 100644
--- a/storage/ndb/src/mgmsrv/Services.hpp
+++ b/storage/ndb/src/mgmsrv/Services.hpp
@@ -79,6 +79,7 @@ public:
void start(Parser_t::Context &ctx, const class Properties &args);
void startAll(Parser_t::Context &ctx, const class Properties &args);
void bye(Parser_t::Context &ctx, const class Properties &args);
+ void endSession(Parser_t::Context &ctx, const class Properties &args);
void setLogLevel(Parser_t::Context &ctx, const class Properties &args);
void setClusterLogLevel(Parser_t::Context &ctx,
const class Properties &args);
diff --git a/storage/ndb/src/mgmsrv/main.cpp b/storage/ndb/src/mgmsrv/main.cpp
index f0c2ac298a5..5960a3517b5 100644
--- a/storage/ndb/src/mgmsrv/main.cpp
+++ b/storage/ndb/src/mgmsrv/main.cpp
@@ -132,6 +132,7 @@ static MgmGlobals *glob= 0;
* Global variables
*/
bool g_StopServer;
+bool g_RestartServer;
extern EventLogger g_eventLogger;
extern int global_mgmt_server_check;
@@ -191,7 +192,22 @@ static void usage()
*/
int main(int argc, char** argv)
{
+ int mgm_connect_result;
+
NDB_INIT(argv[0]);
+
+ const char *load_default_groups[]= { "mysql_cluster","ndb_mgmd",0 };
+ load_defaults("my",load_default_groups,&argc,&argv);
+
+ int ho_error;
+#ifndef DBUG_OFF
+ opt_debug= "d:t:O,/tmp/ndb_mgmd.trace";
+#endif
+ if ((ho_error=handle_options(&argc, &argv, my_long_options,
+ ndb_std_get_one_option)))
+ exit(ho_error);
+
+start:
glob= new MgmGlobals;
/**
@@ -204,17 +220,6 @@ int main(int argc, char** argv)
#endif
global_mgmt_server_check = 1;
-
- const char *load_default_groups[]= { "mysql_cluster","ndb_mgmd",0 };
- load_defaults("my",load_default_groups,&argc,&argv);
-
- int ho_error;
-#ifndef DBUG_OFF
- opt_debug= "d:t:O,/tmp/ndb_mgmd.trace";
-#endif
- if ((ho_error=handle_options(&argc, &argv, my_long_options,
- ndb_std_get_one_option)))
- exit(ho_error);
if (opt_interactive ||
opt_non_interactive ||
@@ -293,34 +298,12 @@ int main(int argc, char** argv)
goto error_end;
}
- /* Construct a fake connectstring to connect back to ourselves */
- char connect_str[20];
- if(!opt_connect_str) {
- snprintf(connect_str,20,"localhost:%u",glob->mgmObject->getPort());
- opt_connect_str= connect_str;
- }
- glob->mgmObject->set_connect_string(opt_connect_str);
-
if(!glob->mgmObject->check_start()){
ndbout_c("Unable to check start management server.");
ndbout_c("Probably caused by illegal initial configuration file.");
goto error_end;
}
- /*
- * Connect back to ourselves so we can use mgmapi to fetch
- * config info
- */
- int mgm_connect_result;
- mgm_connect_result = glob->mgmObject->get_config_retriever()->
- do_connect(0,0,0);
-
- if(mgm_connect_result<0) {
- ndbout_c("Unable to connect to our own ndb_mgmd (Error %d)",
- mgm_connect_result);
- ndbout_c("This is probably a bug.");
- }
-
if (opt_daemon) {
// Become a daemon
char *lockfile= NdbConfig_PidFileName(glob->localNodeId);
@@ -361,6 +344,7 @@ int main(int argc, char** argv)
g_eventLogger.info(msg);
g_StopServer = false;
+ g_RestartServer= false;
glob->socketServer->startServer();
#if ! defined NDB_OSE && ! defined NDB_SOFTOSE
@@ -378,14 +362,19 @@ int main(int argc, char** argv)
while(g_StopServer != true)
NdbSleep_MilliSleep(500);
}
-
- g_eventLogger.info("Shutting down server...");
+
+ if(g_RestartServer)
+ g_eventLogger.info("Restarting server...");
+ else
+ g_eventLogger.info("Shutting down server...");
glob->socketServer->stopServer();
- glob->mgmObject->get_config_retriever()->disconnect();
+ // We disconnect from the ConfigRetreiver mgmd when we delete glob below
glob->socketServer->stopSessions(true);
g_eventLogger.info("Shutdown complete");
the_end:
delete glob;
+ if(g_RestartServer)
+ goto start;
ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
return 0;
error_end:
diff --git a/storage/ndb/tools/ndb_size.pl b/storage/ndb/tools/ndb_size.pl
index e0085c619f0..c285a7590fd 100644
--- a/storage/ndb/tools/ndb_size.pl
+++ b/storage/ndb/tools/ndb_size.pl
@@ -147,7 +147,7 @@ foreach(@{$tables})
{
my $fixed= 1+$size;
my @dynamic=$dbh->selectrow_array("select avg(length(`"
- .$name.
+ .$name
."`)) from `".$table.'`');
$dynamic[0]=0 if !$dynamic[0];
@realsize= ($fixed,$fixed,ceil($dynamic[0]));