Skip to content

Commit a6903e2

Browse files
author
Dianna Hohensee
committed
SERVER-22498 fix migration session id multiversion failure
1 parent 183a1d8 commit a6903e2

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/mongo/db/s/migration_session_id.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,8 @@ std::string MigrationSessionId::toString() const {
9292
return (_sessionId ? *_sessionId : "");
9393
}
9494

95+
bool MigrationSessionId::isEmpty() const {
96+
return !_sessionId;
97+
}
98+
9599
} // namespace mongo

src/mongo/db/s/migration_session_id.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class MigrationSessionId {
7373

7474
std::string toString() const;
7575

76+
bool isEmpty() const;
77+
7678
private:
7779
MigrationSessionId();
7880
explicit MigrationSessionId(std::string sessionId);

src/mongo/db/s/migration_source_manager.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ bool MigrationSourceManager::transferMods(OperationContext* txn,
326326
return false;
327327
}
328328

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

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

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

0 commit comments

Comments
 (0)