Below is the list of changes that have just been committed into a local
5.1 repository of stewart. When stewart 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
1.1892 05/08/26 17:50:08 stewart@stripped +4 -0
WL#2703 restart for ndb_mgmd
implementation that simply exec()s ourself. Crude form of reloading configuration
(that is *NOT* recommended if you have more than 1 mgmd). But works if you want to
just restart one node (for whatever reason).
This implementation only works for the mgm server we're connected to. Next step is to
issue the command to other mgmds if the request was to restart them.
storage/ndb/src/mgmsrv/main.cpp
1.47 05/08/26 17:49:57 stewart@stripped +28 -1
Add code to restart mgmd when g_RestartServer is set (alongside g_StopServer).
We restart by exec()ing ourselves. This would also work as a way to upgrade mgmd.
storage/ndb/src/mgmsrv/MgmtSrvr.cpp
1.80 05/08/26 17:49:57 stewart@stripped +10 -0
Set g_StopServer and g_RestartServer if we're asked to restart ourselves
storage/ndb/src/common/util/SocketServer.cpp
1.19 05/08/26 17:49:56 stewart@stripped +3 -2
Save the server socket (so it can later be closed)
storage/ndb/include/util/SocketServer.hpp
1.10 05/08/26 17:49:56 stewart@stripped +2 -0
Add closeServerSocket()
Able to close server socket. This allows us to exec() ourselves and still bind to the
socket.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: stewart
# Host: kennedy.(none)
# Root: /home/stewart/Documents/MySQL/5.1/wl2703
--- 1.9/storage/ndb/include/util/SocketServer.hpp 2005-07-20 04:40:16 +10:00
+++ 1.10/storage/ndb/include/util/SocketServer.hpp 2005-08-26 17:49:56 +10:00
@@ -96,6 +96,7 @@
*/
void startServer();
void stopServer();
+ void closeServerSocket() { NDB_CLOSE_SOCKET(m_server_socket);};
/**
* stop sessions
@@ -107,6 +108,7 @@
void foreachSession(void (*f)(Session*, void*), void *data);
private:
+ NDB_SOCKET_TYPE m_server_socket;
struct SessionInstance {
Service * m_service;
Session * m_session;
--- 1.18/storage/ndb/src/common/util/SocketServer.cpp 2005-07-20 04:40:17 +10:00
+++ 1.19/storage/ndb/src/common/util/SocketServer.cpp 2005-08-26 17:49:56 +10:00
@@ -98,8 +98,9 @@
if(Ndb_getInAddr(&servaddr.sin_addr, intface))
DBUG_RETURN(false);
}
-
- const NDB_SOCKET_TYPE sock = socket(AF_INET, SOCK_STREAM, 0);
+
+ m_server_socket= socket(AF_INET, SOCK_STREAM, 0);
+ const NDB_SOCKET_TYPE sock = m_server_socket;
if (sock == NDB_INVALID_SOCKET) {
DBUG_PRINT("error",("socket() - %d - %s",
errno, strerror(errno)));
--- 1.79/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2005-08-25 22:54:43 +10:00
+++ 1.80/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2005-08-26 17:49:57 +10:00
@@ -66,6 +66,9 @@
extern int global_flag_send_heartbeat_now;
extern int g_no_nodeid_checks;
+extern bool g_StopServer;
+extern bool g_RestartServer;
+
void *
MgmtSrvr::logLevelThread_C(void* m)
{
@@ -755,6 +758,13 @@
if(m_stopRec.inUse){
return 5029;
+ }
+
+ if(processId == (int)_ownNodeId)
+ {
+ g_RestartServer= true;
+ g_StopServer= true;
+ return 0;
}
result = okToSendTo(processId, true);
--- 1.46/storage/ndb/src/mgmsrv/main.cpp 2005-07-20 15:53:08 +10:00
+++ 1.47/storage/ndb/src/mgmsrv/main.cpp 2005-08-26 17:49:57 +10:00
@@ -131,6 +131,7 @@
* Global variables
*/
bool g_StopServer;
+bool g_RestartServer;
extern EventLogger g_eventLogger;
extern int global_mgmt_server_check;
@@ -186,6 +187,9 @@
*/
int main(int argc, char** argv)
{
+ char** mgmd_argv= argv;
+ int mgmd_argc= argc;
+ char mgmd_pwd[MAXPATHLEN];
NDB_INIT(argv[0]);
glob= new MgmGlobals;
@@ -231,6 +235,11 @@
if (glob->mgmObject->init())
goto error_end;
+ if(my_getwd(mgmd_pwd,MAXPATHLEN,0)<0)
+ {
+ fprintf(stderr,"Unable to get cwd\n");
+ exit(1);
+ }
my_setwd(NdbConfig_get_path(0), MYF(0));
glob->localNodeId= glob->mgmObject->getOwnNodeId();
@@ -343,6 +352,7 @@
g_eventLogger.info(msg);
g_StopServer = false;
+ g_RestartServer= false;
glob->socketServer->startServer();
#if ! defined NDB_OSE && ! defined NDB_SOFTOSE
@@ -364,8 +374,25 @@
g_eventLogger.info("Shutting down server...");
glob->socketServer->stopServer();
glob->mgmObject->get_config_retriever()->disconnect();
- glob->socketServer->stopSessions(true);
+ glob->socketServer->closeServerSocket();
g_eventLogger.info("Shutdown complete");
+
+ if(g_RestartServer)
+ {
+ int res;
+ g_eventLogger.info("Restarting server...");
+ if(fork()==0)
+ {
+ waitpid(getppid(),NULL,0);
+ if(my_setwd(mgmd_pwd,0)<0)
+ g_eventLogger.error("Unable to set working directory: %s",
+ mgmd_pwd);
+ if((res=execv(mgmd_argv[0],mgmd_argv))<0)
+ g_eventLogger.info("Error Restarting server: %d message: %s",
+ errno, strerror(errno));
+ }
+ }
+
the_end:
delete glob;
ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
| Thread |
|---|
| • bk commit into 5.1 tree (stewart:1.1892) | Stewart Smith | 26 Aug |