summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2015-10-15 16:00:31 -0400
committerSpencer T Brody <spencer@mongodb.com>2015-10-16 16:27:53 -0400
commit7cf6b9bf5a47f1446be71105a4186be924e20a85 (patch)
tree2468ba86eb63b1cfb29656504a05c3bf2b87e94e /src/mongo/db
parentaf021f6e674f003f1d8227d46f43fe69cdef7606 (diff)
downloadmongo-7cf6b9bf5a47f1446be71105a4186be924e20a85.tar.gz
SERVER-20748 Handle epoch mismatch explicitly in cluster find command
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/commands.cpp5
-rw-r--r--src/mongo/db/query/cursor_response.cpp8
2 files changed, 11 insertions, 2 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp
index ec130328bef..bd3d95e7295 100644
--- a/src/mongo/db/commands.cpp
+++ b/src/mongo/db/commands.cpp
@@ -424,8 +424,9 @@ void _generateErrorResponse(OperationContext* txn,
static_cast<const SendStaleConfigException&>(exception);
replyBuilder->setCommandReply(scex.toStatus(),
BSON("ns" << scex.getns() << "vReceived"
- << scex.getVersionReceived().toBSON() << "vWanted"
- << scex.getVersionWanted().toBSON()));
+ << BSONArray(scex.getVersionReceived().toBSON())
+ << "vWanted"
+ << BSONArray(scex.getVersionWanted().toBSON())));
} else {
replyBuilder->setCommandReply(exception.toStatus());
}
diff --git a/src/mongo/db/query/cursor_response.cpp b/src/mongo/db/query/cursor_response.cpp
index 3c86439f622..2954da683c9 100644
--- a/src/mongo/db/query/cursor_response.cpp
+++ b/src/mongo/db/query/cursor_response.cpp
@@ -34,6 +34,7 @@
#include "mongo/bson/bsontypes.h"
#include "mongo/rpc/get_status_from_command_result.h"
+#include "mongo/s/chunk_version.h"
namespace mongo {
@@ -97,6 +98,13 @@ CursorResponse& CursorResponse::operator=(CursorResponse&& other) {
StatusWith<CursorResponse> CursorResponse::parseFromBSON(const BSONObj& cmdResponse) {
Status cmdStatus = getStatusFromCommandResult(cmdResponse);
if (!cmdStatus.isOK()) {
+ if (ErrorCodes::isStaleShardingError(cmdStatus.code())) {
+ auto vWanted = ChunkVersion::fromBSON(cmdResponse, "vWanted");
+ auto vReceived = ChunkVersion::fromBSON(cmdResponse, "vReceived");
+ if (!vWanted.hasEqualEpoch(vReceived)) {
+ return Status(ErrorCodes::StaleEpoch, cmdStatus.reason());
+ }
+ }
return cmdStatus;
}