static int update_paxos(MonitorDBStore& st)
{
+ const string prefix("paxos");
+ // a large enough version greater than the maximum possible `last_committed`
+ // that could be replied by the peons when the leader is collecting paxos
+ // transactions during recovery
+ constexpr version_t first_committed = 0x42;
+ constexpr version_t last_committed = first_committed;
+ for (version_t v = first_committed; v < last_committed + 1; v++) {
+ auto t = make_shared<MonitorDBStore::Transaction>();
+ if (v == first_committed) {
+ t->put(prefix, "first_committed", v);
+ }
+ bufferlist proposal;
+ MonitorDBStore::Transaction empty_txn;
+ empty_txn.encode(proposal);
+ t->put(prefix, v, proposal);
+ t->put(prefix, "last_committed", v);
+ st.apply_transaction(t);
+ }
// build a pending paxos proposal from all non-permanent k/v pairs. once the
// proposal is committed, it will gets applied. on the sync provider side, it
// will be a no-op, but on its peers, the paxos commit will help to build up
}
t.encode(pending_proposal);
}
- const string prefix("paxos");
+ auto pending_v = last_committed + 1;
auto t = make_shared<MonitorDBStore::Transaction>();
- t->put(prefix, "first_committed", 0);
- t->put(prefix, "last_committed", 0);
- auto pending_v = 1;
t->put(prefix, pending_v, pending_proposal);
t->put(prefix, "pending_v", pending_v);
t->put(prefix, "pending_pn", 400);