From b579d31311756b86b6c5c098449e91caad1da3d2 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 30 Jul 2008 15:03:29 -0700 Subject: [PATCH] mon: election bugfix --- src/mon/ClientMonitor.cc | 12 ++++++++++++ src/mon/ClientMonitor.h | 4 ++-- src/mon/Elector.cc | 6 +++--- src/mon/MDSMonitor.cc | 1 + src/mon/Monitor.cc | 1 + src/mon/OSDMonitor.cc | 6 ++++-- src/mon/PGMonitor.cc | 6 ++++-- src/mon/PaxosService.cc | 2 +- 8 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/mon/ClientMonitor.cc b/src/mon/ClientMonitor.cc index 56dfd5fc110da..f975d0b4ba30c 100644 --- a/src/mon/ClientMonitor.cc +++ b/src/mon/ClientMonitor.cc @@ -31,6 +31,11 @@ #define derr(l) if (l<=g_conf.debug || l<=g_conf.debug_mon) *_derr << dbeginl << g_clock.now() << " mon" << mon->whoami << (mon->is_starting() ? (const char*)"(starting)":(mon->is_leader() ? (const char*)"(leader)":(mon->is_peon() ? (const char*)"(peon)":(const char*)"(?\?)"))) << ".client v" << client_map.version << " " +ostream& operator<<(ostream& out, ClientMonitor& om) +{ + return out << "v" << om.client_map.version << ": " + << om.client_map.client_addr.size() << " clients, next is client" << om.client_map.next_client; +} bool ClientMonitor::update_from_paxos() { @@ -247,4 +252,11 @@ void ClientMonitor::_unmounted(MClientUnmount *m) } } +void ClientMonitor::tick() +{ + if (!mon->is_leader()) return; + if (!paxos->is_active()) return; + update_from_paxos(); + dout(10) << *this << dendl; +} diff --git a/src/mon/ClientMonitor.h b/src/mon/ClientMonitor.h index 5419b3c0e0f69..aa3b0ca95772c 100644 --- a/src/mon/ClientMonitor.h +++ b/src/mon/ClientMonitor.h @@ -152,9 +152,9 @@ public: }; -private: Map client_map; +private: // leader Incremental pending_inc; @@ -175,7 +175,7 @@ private: public: ClientMonitor(Monitor *mn, Paxos *p) : PaxosService(mn, p) { } - //void tick(); // check state, take actions + void tick(); // check state, take actions }; diff --git a/src/mon/Elector.cc b/src/mon/Elector.cc index 5ea279acabfa5..7077385e9ea7f 100644 --- a/src/mon/Elector.cc +++ b/src/mon/Elector.cc @@ -171,7 +171,7 @@ void Elector::handle_propose(MMonElection *m) // a mon just started up, call a new election so they can rejoin! dout(5) << " got propose from old epoch, quorum is " << mon->quorum << ", " << m->get_source() << " must have just started" << dendl; - start(); + mon->call_election();//start(); } else { dout(5) << " ignoring old propose" << dendl; delete m; @@ -187,7 +187,7 @@ void Elector::handle_propose(MMonElection *m) } else { // wait, i should win! if (!electing_me) - start(); + mon->call_election();//start(); } } else { // they would win over me @@ -213,7 +213,7 @@ void Elector::handle_ack(MMonElection *m) if (m->epoch > epoch) { dout(5) << "woah, that's a newer epoch, i must have rebooted. bumping and re-starting!" << dendl; bump_epoch(m->epoch); - start(); + mon->call_election();//start(); delete m; return; } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 37683ef19ed6d..9e014b79831e8 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -630,6 +630,7 @@ void MDSMonitor::tick() if (!mon->is_leader()) return; if (!paxos->is_active()) return; + update_from_paxos(); dout(10) << *this << dendl; // expand mds cluster? diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 6ae552ff1a080..6dc5acb6d993d 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -446,6 +446,7 @@ void Monitor::tick() osdmon->tick(); mdsmon->tick(); + clientmon->tick(); pgmon->tick(); // next tick! diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 62333ac8eb5e1..dc74481a379a5 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -704,11 +704,13 @@ void OSDMonitor::bcast_full_osd() void OSDMonitor::tick() { - dout(10) << *this << dendl; - if (!mon->is_leader()) return; if (!paxos->is_active()) return; + update_from_paxos(); + dout(10) << *this << dendl; + + // mark down osds out? utime_t now = g_clock.now(); list mark_out; diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index ae2ad78545ada..867ff1656733a 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -81,12 +81,14 @@ ostream& operator<<(ostream& out, PGMonitor& pm) void PGMonitor::tick() { + if (!mon->is_leader()) return; + if (!paxos->is_active()) return; + + update_from_paxos(); dout(10) << *this << dendl; /* // magic incantation that Sage told me - if (!mon->is_leader()) return; - if (!paxos->is_active()) return; // Is it the nth second? If not, do nothing. diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index b931c0b269af7..32a9f6ccc1c3a 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -114,7 +114,7 @@ void PaxosService::propose_pending() { dout(10) << "propose_pending" << dendl; assert(have_pending); - assert(mon->is_leader()); + assert(mon->is_leader() && paxos->is_active()); if (proposal_timer) { mon->timer.cancel_event(proposal_timer); -- 2.39.5