summaryrefslogtreecommitdiff
path: root/src/mongo/rpc
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-06-15 16:49:43 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-06-22 15:59:53 -0400
commitc2a1af025f133c366569448323f1acad3db6f8f7 (patch)
treeaa2b94e8b3d50f2afabe00f959fee96ccbba61e2 /src/mongo/rpc
parent323cee61a4ef26ef127b917cf1ae386c816979c7 (diff)
downloadmongo-c2a1af025f133c366569448323f1acad3db6f8f7.tar.gz
SERVER-35691 Make all code paths returning StaleConfig error go through the StaleConfigInfo serializer
Diffstat (limited to 'src/mongo/rpc')
-rw-r--r--src/mongo/rpc/SConscript3
-rw-r--r--src/mongo/rpc/legacy_reply_builder.cpp7
2 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/rpc/SConscript b/src/mongo/rpc/SConscript
index 35651a9edd6..fff0a749384 100644
--- a/src/mongo/rpc/SConscript
+++ b/src/mongo/rpc/SConscript
@@ -125,10 +125,11 @@ env.Library(
'legacy_reply_builder.cpp'
],
LIBDEPS=[
+ '$BUILD_DIR/mongo/s/common_s',
+ '$BUILD_DIR/mongo/util/net/network',
'command_reply',
'metadata',
'object_check',
- '$BUILD_DIR/mongo/util/net/network',
],
)
diff --git a/src/mongo/rpc/legacy_reply_builder.cpp b/src/mongo/rpc/legacy_reply_builder.cpp
index 1696ea42902..c2edc42b1cb 100644
--- a/src/mongo/rpc/legacy_reply_builder.cpp
+++ b/src/mongo/rpc/legacy_reply_builder.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/rpc/metadata.h"
#include "mongo/rpc/metadata/sharding_metadata.h"
+#include "mongo/s/stale_exception.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/mongoutils/str.h"
@@ -56,12 +57,18 @@ LegacyReplyBuilder& LegacyReplyBuilder::setCommandReply(Status nonOKStatus,
invariant(_state == State::kCommandReply);
if (nonOKStatus == ErrorCodes::StaleConfig) {
_staleConfigError = true;
+ auto scex = nonOKStatus.extraInfo<StaleConfigInfo>();
+
// Need to use the special $err format for StaleConfig errors to be backwards
// compatible.
BSONObjBuilder err;
+
// $err must be the first field in object.
err.append("$err", nonOKStatus.reason());
err.append("code", nonOKStatus.code());
+ if (scex) {
+ scex->serialize(&err);
+ }
err.appendElements(extraErrorInfo);
setRawCommandReply(err.done());
} else {