summaryrefslogtreecommitdiff
path: root/src/mongo/s/stale_exception.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-06-22 15:21:18 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-06-27 15:19:13 -0400
commit60559a00b81293184922b3418a8e56610edf8dd9 (patch)
tree4d74eaf849b70303f26aeb5ee91742e45a1a39b4 /src/mongo/s/stale_exception.cpp
parente7a75ec01e4e3683cc6b83e3bbc0f4c4b05168dc (diff)
downloadmongo-60559a00b81293184922b3418a8e56610edf8dd9.tar.gz
SERVER-32198 Add support for an optional `vWanted` to StaleConfigInfo
Diffstat (limited to 'src/mongo/s/stale_exception.cpp')
-rw-r--r--src/mongo/s/stale_exception.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mongo/s/stale_exception.cpp b/src/mongo/s/stale_exception.cpp
index 8ebe97e75f0..3919bf86f3e 100644
--- a/src/mongo/s/stale_exception.cpp
+++ b/src/mongo/s/stale_exception.cpp
@@ -39,7 +39,7 @@ namespace {
MONGO_INIT_REGISTER_ERROR_EXTRA_INFO(StaleConfigInfo);
MONGO_INIT_REGISTER_ERROR_EXTRA_INFO(StaleDbRoutingVersion);
-ChunkVersion extractOptionalVersion(const BSONObj& obj, StringData field) {
+boost::optional<ChunkVersion> extractOptionalVersion(const BSONObj& obj, StringData field) {
auto swChunkVersion = ChunkVersion::parseLegacyWithField(obj, field);
if (swChunkVersion == ErrorCodes::NoSuchKey)
return ChunkVersion::UNSHARDED();
@@ -51,7 +51,9 @@ ChunkVersion extractOptionalVersion(const BSONObj& obj, StringData field) {
void StaleConfigInfo::serialize(BSONObjBuilder* bob) const {
bob->append("ns", _nss.ns());
_received.appendLegacyWithField(bob, "vReceived");
- _wanted.appendLegacyWithField(bob, "vWanted");
+ if (_wanted) {
+ _wanted->appendLegacyWithField(bob, "vWanted");
+ }
}
std::shared_ptr<const ErrorExtraInfo> StaleConfigInfo::parse(const BSONObj& obj) {
@@ -59,8 +61,8 @@ std::shared_ptr<const ErrorExtraInfo> StaleConfigInfo::parse(const BSONObj& obj)
}
StaleConfigInfo StaleConfigInfo::parseFromCommandError(const BSONObj& obj) {
- return StaleConfigInfo(NamespaceString(obj["ns"].str()),
- extractOptionalVersion(obj, "vReceived"),
+ return StaleConfigInfo(NamespaceString(obj["ns"].String()),
+ uassertStatusOK(ChunkVersion::parseLegacyWithField(obj, "vReceived")),
extractOptionalVersion(obj, "vWanted"));
}