diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-06-22 15:21:18 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-06-27 15:19:13 -0400 |
commit | 60559a00b81293184922b3418a8e56610edf8dd9 (patch) | |
tree | 4d74eaf849b70303f26aeb5ee91742e45a1a39b4 /src/mongo/s/stale_exception.cpp | |
parent | e7a75ec01e4e3683cc6b83e3bbc0f4c4b05168dc (diff) | |
download | mongo-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.cpp | 10 |
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")); } |