Skip to content

Commit

Permalink
mon/PGMonitor: reset in-core PGMap if on-disk format changes
Browse files Browse the repository at this point in the history
We might have a sequence like:

- start mon, load pgmap 100
- sync
 - including a format upgrade at say v 150
- refresh
 - see format_version==1, and try read pgmap:101 as new format

This simply clears our in-memory state if we see that the format has
changed.  That will make update_from_paxos reload the latest and prevent
it from walking through the old and useless inc updates.

Note: this does not affect the auth monitor because we unconditionally
load the latest map in update_from_paxos on upgrade.  Also, the upgrade
there wasn't a format change--just a translation of cap strings from the
old to new style.

Fixes: ceph#5764
Signed-off-by: Sage Weil <[email protected]>
Reviewed-by: Greg Farnum <[email protected]>
  • Loading branch information
Sage Weil committed Jul 26, 2013
1 parent 1095940 commit 6ac8aed
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/mon/PGMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ void PGMonitor::update_from_paxos(bool *need_bootstrap)
update_logger();
}

void PGMonitor::on_upgrade()
{
dout(1) << __func__ << " discarding in-core PGMap" << dendl;
pg_map = PGMap();
}

void PGMonitor::upgrade_format()
{
unsigned current = 1;
Expand Down
1 change: 1 addition & 0 deletions src/mon/PGMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class PGMonitor : public PaxosService {
void create_initial();
void update_from_paxos(bool *need_bootstrap);
void upgrade_format();
void on_upgrade();
void post_paxos_update();
void handle_osd_timeouts();
void create_pending(); // prepare a new pending
Expand Down
8 changes: 7 additions & 1 deletion src/mon/PaxosService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ void PaxosService::refresh(bool *need_bootstrap)
// update cached versions
cached_first_committed = mon->store->get(get_service_name(), first_committed_name);
cached_last_committed = mon->store->get(get_service_name(), last_committed_name);
format_version = get_value("format_version");

version_t new_format = get_value("format_version");
if (new_format != format_version) {
dout(1) << __func__ << " upgraded, format " << format_version << " -> " << new_format << dendl;
on_upgrade();
}
format_version = new_format;

dout(10) << __func__ << dendl;

Expand Down
5 changes: 5 additions & 0 deletions src/mon/PaxosService.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ class PaxosService {
*/
virtual void upgrade_format() { }

/**
* this is called when we detect the store has just upgraded underneath us
*/
virtual void on_upgrade() {}

/**
* Called when the Paxos system enters a Leader election.
*
Expand Down

0 comments on commit 6ac8aed

Please sign in to comment.