Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hammer: mon: check for store writeablility before participating in election #6144

Merged
2 commits merged into from Nov 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -564,7 +566,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