List:Internals« Previous MessageNext Message »
From:Stewart Smith Date:September 16 2005 5:41am
Subject:bk commit into 5.1 tree (stewart:1.1909)
View as plain text  
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.1909 05/09/16 15:41:03 stewart@stripped +4 -0
  WL#2073 config reload
  
  Recover from mgm client connection holding a lock disappearing. 

  storage/ndb/src/mgmsrv/Services.cpp
    1.52 05/09/16 15:40:59 stewart@stripped +4 -0
    On cleaning up a mgm client connection, if it is still holding the configuration
    lock, recover from this situation.

  storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp
    1.9 05/09/16 15:40:59 stewart@stripped +48 -0
    Add config_islocked() - true on this thread holding the configuration lock.
    
    Add recover_from_dropped_lock() - recovers when the connection holding the
    configuration lock is disconnected.

  storage/ndb/src/mgmsrv/MgmtSrvr.hpp
    1.38 05/09/16 15:40:59 stewart@stripped +3 -0
    Add m_config_remote - set if we should try to fetch configuration remotely.
    
    Add config_islocked() - returns true if the configuration lock is held by
    the current thread.
    
    Add recover_from_dropped_lock() - when a connection holding a lock goes away,
    we need to recover.

  storage/ndb/src/mgmsrv/MgmtSrvr.cpp
    1.83 05/09/16 15:40:59 stewart@stripped +2 -0
    Set m_config_remote if we try to fetch configuration remotely.

# 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:	willster.(none)
# Root:	/home/stewart/Documents/MySQL/5.1/wl2703

--- 1.82/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2005-09-01 18:30:45 +10:00
+++ 1.83/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2005-09-16 15:40:59 +10:00
@@ -414,6 +414,8 @@
 
   theFacade = 0;
 
+  m_config_remote= (connect_string || config_filename==NULL)?true:false;
+
   if (config_filename)
     m_configFilename.assign(config_filename);
   else

--- 1.37/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2005-09-01 18:30:45 +10:00
+++ 1.38/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2005-09-16 15:40:59 +10:00
@@ -506,6 +506,7 @@
   int set_connect_string(const char *str);
 
   int config_reload(int local);
+  void recover_from_dropped_lock();
 
   void transporter_connect(NDB_SOCKET_TYPE sockfd);
 
@@ -549,11 +550,13 @@
   Config * _config;
   Config * m_oldConfig; // used in configuration updates
   BaseString m_configFilename;
+  bool m_config_remote;
   Uint32 m_nextConfigGenerationNumber;
   Vector<NdbMgmHandle> m_mgm_handles;
 
   int lock_config();
   int unlock_config();
+  bool config_islocked();
   
   NodeBitmask m_reserved_nodes;
   struct in_addr m_connect_address[MAX_NODES];

--- 1.8/storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp	2005-09-01 18:30:45 +10:00
+++ 1.9/storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp	2005-09-16 15:40:59 +10:00
@@ -239,4 +239,52 @@
   return 1;
 }
 
+bool MgmtSrvr::config_islocked()
+{
+  return (m_oldConfig && NdbThread_EqualId(NdbThread_getId(),config_owner));
+}
+
+void MgmtSrvr::recover_from_dropped_lock()
+{
+  ndbout << "Connection dropped while holding configuration lock. "
+	 << "Reloading configuration." << endl;
+
+  delete _config;
+
+  m_config_retriever->disconnect();
+  _ownNodeId= 0;
+  if(m_config_remote && m_config_retriever->do_connect(0,0,0)==0)
+  {
+    int tmp_nodeid= 0;
+    tmp_nodeid= m_config_retriever->allocNodeId(0 /*retry*/,0 /*delay*/);
+    if (tmp_nodeid == 0)
+    {
+      ndbout_c(m_config_retriever->getErrorString());
+      exit(-1);
+    }
+    // read config from other managent server
+    _config= fetchConfig();
+    if (_config == 0)
+    {
+      ndbout << m_config_retriever->getErrorString() << endl;
+      exit(-1);
+    }
+    _ownNodeId= tmp_nodeid;
+  }
+
+  if (_ownNodeId == 0)
+  {
+    // read config locally
+    _config= readConfig();
+    if (_config == 0) {
+      ndbout << "Unable to read config file" << endl;
+      exit(-1);
+    }
+  }
+
+  delete m_oldConfig;
+  m_oldConfig= NULL;
+  NdbMutex_Unlock(m_configMutex);
+}
+
 template class Vector<NdbMgmHandle>;

--- 1.51/storage/ndb/src/mgmsrv/Services.cpp	2005-09-01 18:30:45 +10:00
+++ 1.52/storage/ndb/src/mgmsrv/Services.cpp	2005-09-16 15:40:59 +10:00
@@ -327,6 +327,10 @@
       break;
     }
   }
+  if(m_mgmsrv.config_islocked())
+  {
+    m_mgmsrv.recover_from_dropped_lock();
+  }
   if(m_socket != NDB_INVALID_SOCKET)
   {
     NDB_CLOSE_SOCKET(m_socket);
Thread
bk commit into 5.1 tree (stewart:1.1909)Stewart Smith16 Sep