Skip to content

Commit

Permalink
SERVER-22498 fix migration session id multiversion failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Dianna Hohensee committed Feb 8, 2016
1 parent 183a1d8 commit a6903e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/mongo/db/s/migration_session_id.cpp
Expand Up @@ -92,4 +92,8 @@ std::string MigrationSessionId::toString() const {
return (_sessionId ? *_sessionId : "");
}

bool MigrationSessionId::isEmpty() const {
return !_sessionId;
}

} // namespace mongo
2 changes: 2 additions & 0 deletions src/mongo/db/s/migration_session_id.h
Expand Up @@ -73,6 +73,8 @@ class MigrationSessionId {

std::string toString() const;

bool isEmpty() const;

private:
MigrationSessionId();
explicit MigrationSessionId(std::string sessionId);
Expand Down
11 changes: 8 additions & 3 deletions src/mongo/db/s/migration_source_manager.cpp
Expand Up @@ -326,7 +326,10 @@ bool MigrationSourceManager::transferMods(OperationContext* txn,
return false;
}

if (!_sessionId->matches(sessionId)) {
// TODO after 3.4 release, !sessionId.isEmpty() can be removed: versions >= 3.2 will
// all have sessionId implemented. (two more instances below).
// A mongod version < v3.2 will not have sessionId, in which case it is empty and ignored.
if (!sessionId.isEmpty() && !_sessionId->matches(sessionId)) {
errmsg = str::stream() << "requested migration session id " << sessionId.toString()
<< " does not match active session id "
<< _sessionId->toString();
Expand Down Expand Up @@ -482,7 +485,8 @@ bool MigrationSourceManager::clone(OperationContext* txn,
return false;
}

if (!_sessionId->matches(sessionId)) {
// A mongod version < v3.2 will not have sessionId, in which case it is empty and ignored.
if (!sessionId.isEmpty() && !_sessionId->matches(sessionId)) {
errmsg = str::stream() << "requested migration session id " << sessionId.toString()
<< " does not match active session id "
<< _sessionId->toString();
Expand Down Expand Up @@ -512,7 +516,8 @@ bool MigrationSourceManager::clone(OperationContext* txn,
return false;
}

if (!_sessionId->matches(sessionId)) {
// A mongod version < v3.2 will not have sessionId, in which case it is empty and ignored.
if (!sessionId.isEmpty() && !_sessionId->matches(sessionId)) {
errmsg = str::stream() << "migration session id changed from " << sessionId.toString()
<< " to " << _sessionId->toString()
<< " while initial clone was active";
Expand Down

0 comments on commit a6903e2

Please sign in to comment.