extend_lease();
if (do_refresh()) {
- finish_proposal();
+ finish_round();
finish_contexts(g_ceph_context, waiting_for_active);
finish_contexts(g_ceph_context, waiting_for_readable);
// we're alone, take it easy
commit();
if (do_refresh()) {
- finish_proposal();
+ assert(is_updating()); // we can't be updating-previous with quorum of 1
+ commit_proposal();
+ finish_round();
finish_contexts(g_ceph_context, waiting_for_active);
finish_contexts(g_ceph_context, waiting_for_commit);
finish_contexts(g_ceph_context, waiting_for_readable);
commit();
if (!do_refresh())
goto out;
+ if (is_updating())
+ commit_proposal();
+ finish_contexts(g_ceph_context, waiting_for_commit);
}
// done?
// yay!
extend_lease();
- finish_proposal();
+ finish_round();
// wake people up
finish_contexts(g_ceph_context, waiting_for_active);
- finish_contexts(g_ceph_context, waiting_for_commit);
finish_contexts(g_ceph_context, waiting_for_readable);
finish_contexts(g_ceph_context, waiting_for_writeable);
}
return true;
}
-void Paxos::finish_proposal()
+void Paxos::commit_proposal()
{
+ dout(10) << __func__ << dendl;
assert(mon->is_leader());
+ assert(!proposals.empty());
+ assert(is_updating());
- // ok, now go active!
- state = STATE_ACTIVE;
+ C_Proposal *proposal = static_cast<C_Proposal*>(proposals.front());
+ assert(proposal->proposed);
+ dout(10) << __func__ << " proposal " << proposal << " took "
+ << (ceph_clock_now(NULL) - proposal->proposal_time)
+ << " to finish" << dendl;
+ proposals.pop_front();
+ proposal->complete(0);
+}
- // finish off the last proposal
- if (!proposals.empty()) {
- assert(mon->is_leader());
+void Paxos::finish_round()
+{
+ assert(mon->is_leader());
- C_Proposal *proposal = static_cast<C_Proposal*>(proposals.front());
- if (!proposal->proposed) {
- dout(10) << __func__ << " proposal " << proposal << ": we must have received a stay message and we're "
- << "trying to finish before time. "
- << "Instead, propose it (if we are active)!" << dendl;
- } else {
- dout(10) << __func__ << " proposal " << proposal << " took "
- << (ceph_clock_now(NULL) - proposal->proposal_time)
- << " to finish" << dendl;
- proposals.pop_front();
- proposal->complete(0);
- }
- }
+ // ok, now go active!
+ state = STATE_ACTIVE;
dout(10) << __func__ << " state " << state
<< " proposals left " << proposals.size() << dendl;