Skip to content

Commit

Permalink
Merge pull request #6144 from dachary/wip-13339-hammer
Browse files Browse the repository at this point in the history
mon: check for store writeablility before participating in election

Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
Loic Dachary committed Nov 17, 2015
1 parent 699275a commit 236f9ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/mon/Elector.cc
Expand Up @@ -78,8 +78,15 @@ void Elector::start()
init();

// start by trying to elect me
if (epoch % 2 == 0)
if (epoch % 2 == 0) {
bump_epoch(epoch+1); // odd == election cycle
} else {
// do a trivial db write just to ensure it is writeable.
MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction);
t->put(Monitor::MONITOR_NAME, "election_writeable_test", rand());
int r = mon->store->apply_transaction(t);
assert(r >= 0);
}
start_stamp = ceph_clock_now(g_ceph_context);
electing_me = true;
acked_me[mon->rank] = CEPH_FEATURES_ALL;
Expand Down
5 changes: 4 additions & 1 deletion src/mon/MonitorDBStore.h
Expand Up @@ -291,6 +291,8 @@ class MonitorDBStore
db->compact_range_async(compact.front().first, compact.front().second.first, compact.front().second.second);
compact.pop_front();
}
} else {
assert(0 == "failed to write to db");
}
return r;
}
Expand Down Expand Up @@ -568,7 +570,8 @@ class MonitorDBStore
for (iter = prefixes.begin(); iter != prefixes.end(); ++iter) {
dbt->rmkeys_by_prefix((*iter));
}
db->submit_transaction_sync(dbt);
int r = db->submit_transaction_sync(dbt);
assert(r >= 0);
}

int open(ostream &out) {
Expand Down

0 comments on commit 236f9ec

Please sign in to comment.