diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2016-02-05 16:31:21 -0500 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2016-02-08 09:31:23 -0500 |
commit | 44643e26669b9bdba0e9f20c7d1edb230d7fbfb2 (patch) | |
tree | 84a48e37f717d22bfb09166b060487c6c4bf9037 | |
parent | 94fc167ce1196957f2fcbd17cae27bc78244a30b (diff) | |
download | mongo-44643e26669b9bdba0e9f20c7d1edb230d7fbfb2.tar.gz |
SERVER-22498 fix migration session id multiversion failure
(cherry picked from commit a6903e29adf6a674711a4cbcd8f4cf3b9bd66432)
-rw-r--r-- | src/mongo/db/s/migration_session_id.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/s/migration_session_id.h | 2 | ||||
-rw-r--r-- | src/mongo/db/s/migration_source_manager.cpp | 11 |
3 files changed, 14 insertions, 3 deletions
diff --git a/src/mongo/db/s/migration_session_id.cpp b/src/mongo/db/s/migration_session_id.cpp index 25a0bea7aeb..0e2234efdd4 100644 --- a/src/mongo/db/s/migration_session_id.cpp +++ b/src/mongo/db/s/migration_session_id.cpp @@ -92,4 +92,8 @@ std::string MigrationSessionId::toString() const { return (_sessionId ? *_sessionId : ""); } +bool MigrationSessionId::isEmpty() const { + return !_sessionId; +} + } // namespace mongo diff --git a/src/mongo/db/s/migration_session_id.h b/src/mongo/db/s/migration_session_id.h index dbfde922c88..a16733e1dbe 100644 --- a/src/mongo/db/s/migration_session_id.h +++ b/src/mongo/db/s/migration_session_id.h @@ -73,6 +73,8 @@ public: std::string toString() const; + bool isEmpty() const; + private: MigrationSessionId(); explicit MigrationSessionId(std::string sessionId); diff --git a/src/mongo/db/s/migration_source_manager.cpp b/src/mongo/db/s/migration_source_manager.cpp index e65edff5711..e6f9bf8000f 100644 --- a/src/mongo/db/s/migration_source_manager.cpp +++ b/src/mongo/db/s/migration_source_manager.cpp @@ -313,7 +313,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(); @@ -470,7 +473,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(); @@ -500,7 +504,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"; |