From 640a850162bfe814444b35a8b2143f78ae40e20d Mon Sep 17 00:00:00 2001 From: Tommaso Tocci Date: Fri, 6 Nov 2020 00:25:04 +0100 Subject: SERVER-52621 Remove stale version execption handling in OpQuery exec path --- src/mongo/rpc/legacy_reply_builder.cpp | 29 ++--------------------------- src/mongo/rpc/legacy_reply_builder.h | 2 -- 2 files changed, 2 insertions(+), 29 deletions(-) (limited to 'src/mongo/rpc') diff --git a/src/mongo/rpc/legacy_reply_builder.cpp b/src/mongo/rpc/legacy_reply_builder.cpp index ca4e2d0e08a..2ceffbf0df7 100644 --- a/src/mongo/rpc/legacy_reply_builder.cpp +++ b/src/mongo/rpc/legacy_reply_builder.cpp @@ -56,24 +56,7 @@ LegacyReplyBuilder::~LegacyReplyBuilder() {} LegacyReplyBuilder& LegacyReplyBuilder::setCommandReply(Status nonOKStatus, BSONObj extraErrorInfo) { invariant(!_haveCommandReply); - if (nonOKStatus == ErrorCodes::StaleConfig) { - _staleConfigError = true; - - // 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()); - auto const scex = nonOKStatus.extraInfo(); - scex->serialize(&err); - err.appendElements(extraErrorInfo); - setRawCommandReply(err.done()); - } else { - // All other errors proceed through the normal path, which also handles state transitions. - ReplyBuilderInterface::setCommandReply(std::move(nonOKStatus), std::move(extraErrorInfo)); - } + ReplyBuilderInterface::setCommandReply(std::move(nonOKStatus), std::move(extraErrorInfo)); return *this; } @@ -117,7 +100,6 @@ void LegacyReplyBuilder::reset() { _builder.skip(sizeof(QueryResult::Value)); _message.reset(); _haveCommandReply = false; - _staleConfigError = false; _bodyOffset = 0; } @@ -126,14 +108,7 @@ Message LegacyReplyBuilder::done() { invariant(_haveCommandReply); QueryResult::View qr = _builder.buf(); - - if (_staleConfigError) { - // For compatibility with legacy mongos, we need to set this result flag on StaleConfig - qr.setResultFlags(ResultFlag_ErrSet | ResultFlag_ShardConfigStale); - } else { - qr.setResultFlagsToOk(); - } - + qr.setResultFlagsToOk(); qr.msgdata().setLen(_builder.len()); qr.msgdata().setOperation(opReply); qr.setCursorId(0); diff --git a/src/mongo/rpc/legacy_reply_builder.h b/src/mongo/rpc/legacy_reply_builder.h index 82e08f140e9..16ea869c46e 100644 --- a/src/mongo/rpc/legacy_reply_builder.h +++ b/src/mongo/rpc/legacy_reply_builder.h @@ -68,8 +68,6 @@ private: std::size_t _bodyOffset = 0; Message _message; bool _haveCommandReply = false; - // For stale config errors we need to set the correct ResultFlag. - bool _staleConfigError = false; }; } // namespace rpc -- cgit v1.2.1