]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: only standby-replay when explicitly requested on startup.
authorSage Weil <sage@newdream.net>
Wed, 17 Dec 2008 21:32:11 +0000 (13:32 -0800)
committerSage Weil <sage@newdream.net>
Wed, 17 Dec 2008 21:32:11 +0000 (13:32 -0800)
Until it does something more than just replay the log and quit.

src/cmds.cc
src/mds/MDS.cc
src/mds/MDS.h
src/mds/MDSMap.cc
src/mon/MDSMonitor.cc

index b8d324696de53f6f277444d68a2c119e7066447e..4749d85c59ed2eaaa9e54bf948f18a51935f111f 100644 (file)
@@ -43,11 +43,14 @@ int main(int argc, const char **argv)
   const char *monhost = 0;
   int whoami = -1;
   bool standby = false;  // by default, i'll start active.
+  int standby_replay_for;
   for (unsigned i=0; i<args.size(); i++) {
     if (strcmp(args[i], "--standby") == 0) 
       standby = true;
     else if (strcmp(args[i], "--mds") == 0) 
       whoami = atoi(args[++i]);
+    else if (strcmp(args[i], "--standby_replay_for") == 0)
+      whoami = standby_replay_for = atoi(args[++i]);
     else if (monhost == 0) 
       monhost = args[i];
     else {
@@ -79,6 +82,7 @@ int main(int argc, const char **argv)
   
   // start mds
   MDS *mds = new MDS(whoami, m, &monmap);
+  mds->standby_replay_for = standby_replay_for;
   mds->init(standby);
   
   rank.wait();
index 4f380fd50fd772bf2806f640d2a8ad0ab948574f..303241958999cd64d7ada2f6542164e61c31506b 100644 (file)
@@ -75,6 +75,7 @@ MDS::MDS(int whoami_, Messenger *m, MonMap *mm) :
   mds_lock("MDS::mds_lock"),
   timer(mds_lock),
   whoami(whoami_), incarnation(0),
+  standby_replay_for(-1),
   messenger(m),
   monmap(mm),
   logclient(messenger, monmap),
@@ -568,8 +569,13 @@ void MDS::handle_mds_map(MMDSMap *m)
   if (state == MDSMap::STATE_STANDBY) {
     want_state = state = MDSMap::STATE_STANDBY;
     dout(1) << "handle_mds_map standby" << dendl;
+
+    if (standby_replay_for >= 0)
+      request_state(MDSMap::STATE_STANDBY_REPLAY);
+
     goto out;
   }
+
   // ??
   assert(whoami >= 0);
   incarnation = mdsmap->get_inc(whoami);
index 0ac678d681f673a7e4f3f18c6b60d9586700ff7c..929a376ee649412f265a40b587cbe9349952742d 100644 (file)
@@ -75,6 +75,8 @@ class MDS : public Dispatcher {
 
   int whoami;
   int incarnation;
+  
+  int standby_replay_for;
 
   Messenger    *messenger;
   MonMap       *monmap;
index 29c74297d68dc461136e23aa776daec432b62659..b1417e2d9b82dbfa92e8cbc8f5f661e1eda75bc8 100644 (file)
@@ -74,7 +74,7 @@ void MDSMap::print_summary(ostream& out)
 
   out << "e" << get_epoch() << ": " << up.size() << "/" << in.size() << " up";
 
-  for (map<int,int>::iterator p = by_state.begin(); p != by_state.end(); p++)
+  for (map<int,int>::reverse_iterator p = by_state.rbegin(); p != by_state.rend(); p++)
     out << ", " << p->second << " " << get_state_name(p->first);
   
   if (failed.size())
index a727a8fef02ee365fce06bc9c8d0de33c2f7dd98..57a50f56c4c4afd934974a77ac14e38fb823f44c 100644 (file)
@@ -215,6 +215,14 @@ bool MDSMonitor::preprocess_beacon(MMDSBeacon *m)
                 << " -> " << MDSMap::get_state_name(state) << ")" << dendl;
        goto ignore;
       }
+
+      if (info.state == MDSMap::STATE_STANDBY &&
+         state == MDSMap::STATE_STANDBY_REPLAY &&
+         (pending_mdsmap.is_degraded() ||
+          pending_mdsmap.get_state(info.mds) < MDSMap::STATE_ACTIVE)) {
+       dout(10) << "mds_beacon can't standby-replay mds" << info.mds << " at this time (cluster degraded, or mds not active)" << dendl;
+       goto ignore;
+      }
       
       return false;  // need to update map
     }
@@ -549,7 +557,7 @@ void MDSMonitor::tick()
       // and is there a non-laggy standby that can take over for us?
       entity_addr_t sa;
       if (info.mds >= 0 &&
-         (info.state > 0 || info.state == MDSMap::STATE_STANDBY_REPLAY) &&
+         info.state > 0 && //|| info.state == MDSMap::STATE_STANDBY_REPLAY) &&
          pending_mdsmap.find_standby_for(info.mds, sa)) {
        dout(10) << " replacing " << addr << " mds" << info.mds << "." << info.inc
                 << " " << MDSMap::get_state_name(info.state)
@@ -588,6 +596,12 @@ void MDSMonitor::tick()
          mon->osdmon()->propose_pending();
        }
        
+       do_propose = true;
+      } else if (info.state == MDSMap::STATE_STANDBY_REPLAY) {
+       dout(10) << " failing " << addr << " mds" << info.mds << "." << info.inc
+                << " " << MDSMap::get_state_name(info.state)
+                << dendl;
+       pending_mdsmap.mds_info.erase(addr);
        do_propose = true;
       } else if (!info.laggy()) {
        // just mark laggy
@@ -625,7 +639,8 @@ void MDSMonitor::tick()
   }
 
   // have a standby replay/shadow an active mds?
-  if (!pending_mdsmap.is_degraded() &&
+  if (false &&
+      !pending_mdsmap.is_degraded() &&
       pending_mdsmap.get_num_mds(MDSMap::STATE_STANDBY) >= pending_mdsmap.get_num_mds()) {
     // see which nodes are shadowed
     set<int> shadowed;
@@ -703,7 +718,7 @@ void MDSMonitor::do_stop()
     case MDSMap::STATE_RESOLVE:
     case MDSMap::STATE_RECONNECT:
     case MDSMap::STATE_REJOIN:
-      // BUG: hrm, if this is the case, the STOPPING gusy won't be able to stop, will they?
+      // BUG: hrm, if this is the case, the STOPPING guys won't be able to stop, will they?
       pending_mdsmap.failed.insert(info.mds);
       pending_mdsmap.up.erase(info.mds);
       pending_mdsmap.mds_info.erase(info.addr);