summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTommaso Tocci <tommaso.tocci@mongodb.com>2020-11-06 00:25:04 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-06 19:43:11 +0000
commit640a850162bfe814444b35a8b2143f78ae40e20d (patch)
tree9edc3d8ccf719d488870ee9a4e2724d63d577f51 /src
parentd6c15c62c4335266dfd30336ae1cf582b84e09ac (diff)
downloadmongo-640a850162bfe814444b35a8b2143f78ae40e20d.tar.gz
SERVER-52621 Remove stale version execption handling in OpQuery exec path
Diffstat (limited to 'src')
-rw-r--r--src/mongo/client/constants.h4
-rw-r--r--src/mongo/client/dbclient_base.cpp8
-rw-r--r--src/mongo/client/dbclient_cursor.cpp12
-rw-r--r--src/mongo/db/service_entry_point_common.cpp16
-rw-r--r--src/mongo/rpc/legacy_reply_builder.cpp29
-rw-r--r--src/mongo/rpc/legacy_reply_builder.h2
6 files changed, 14 insertions, 57 deletions
diff --git a/src/mongo/client/constants.h b/src/mongo/client/constants.h
index 5f282e0da7f..8e6b6228909 100644
--- a/src/mongo/client/constants.h
+++ b/src/mongo/client/constants.h
@@ -40,8 +40,8 @@ enum ResultFlagType {
/* { $err : ... } is being returned */
ResultFlag_ErrSet = 2,
- /* Have to update config from the server, usually $err is also set */
- ResultFlag_ShardConfigStale = 4,
+ /* Formerly used to comminicate stale version errors */
+ ResultFlag_ShardConfigStaleDeprecated = 4,
/* for backward compatibility: this let's us know the server supports
the QueryOption_AwaitData option. if it doesn't, a repl slave client should sleep
diff --git a/src/mongo/client/dbclient_base.cpp b/src/mongo/client/dbclient_base.cpp
index 9f75d9c2352..5de427f1a83 100644
--- a/src/mongo/client/dbclient_base.cpp
+++ b/src/mongo/client/dbclient_base.cpp
@@ -739,11 +739,9 @@ void DBClientBase::findN(vector<BSONObj>& out,
<< " ns: " << ns << " query: " << query.toString(),
c.get());
- if (c->hasResultFlag(ResultFlag_ShardConfigStale)) {
- BSONObj error;
- c->peekError(&error);
- uasserted(StaleConfigInfo::parseFromCommandError(error), "findN stale config");
- }
+ tassert(5262100,
+ "Deprecated ShardConfigStale flag encountered in query result",
+ !c->hasResultFlag(ResultFlag_ShardConfigStaleDeprecated));
for (int i = 0; i < nToReturn; i++) {
if (!c->more())
diff --git a/src/mongo/client/dbclient_cursor.cpp b/src/mongo/client/dbclient_cursor.cpp
index 8031febcffa..10e7ad1adf9 100644
--- a/src/mongo/client/dbclient_cursor.cpp
+++ b/src/mongo/client/dbclient_cursor.cpp
@@ -363,11 +363,11 @@ void DBClientCursor::dataReceived(const Message& reply, bool& retry, string& hos
QueryResult::View qr = reply.singleData().view2ptr();
resultFlags = qr.getResultFlags();
- if (qr.getResultFlags() & ResultFlag_ErrSet) {
+ if (resultFlags & ResultFlag_ErrSet) {
wasError = true;
}
- if (qr.getResultFlags() & ResultFlag_CursorNotFound) {
+ if (resultFlags & ResultFlag_CursorNotFound) {
// cursor id no longer valid at the server.
invariant(qr.getCursorId() == 0);
@@ -408,11 +408,9 @@ void DBClientCursor::dataReceived(const Message& reply, bool& retry, string& hos
_client->checkResponse(batch.objs, false, &retry, &host); // watches for "not primary"
- if (qr.getResultFlags() & ResultFlag_ShardConfigStale) {
- BSONObj error;
- verify(peekError(&error));
- uasserted(StaleConfigInfo::parseFromCommandError(error), "stale config on lazy receive");
- }
+ tassert(5262101,
+ "Deprecated ShardConfigStale flag encountered in query result",
+ !(resultFlags & ResultFlag_ShardConfigStaleDeprecated));
/* this assert would fire the way we currently work:
verify( nReturned || cursorId == 0 );
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index b70b330acb9..332afff5ce7 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -244,15 +244,8 @@ void generateLegacyQueryErrorResponse(const AssertionException& exception,
}
BSONObj errObj = err.done();
- const bool isStaleConfig = exception.code() == ErrorCodes::StaleConfig;
- if (isStaleConfig) {
- LOGV2_OPTIONS(21953,
- {logv2::LogComponent::kQuery},
- "Stale version detected during query over {namespace}: {error}",
- "Detected stale version while querying namespace",
- "namespace"_attr = queryMessage.ns,
- "error"_attr = errObj);
- }
+ invariant(!exception.isA<ErrorCategory::StaleShardVersionError>() &&
+ exception.code() != ErrorCodes::StaleDbVersion);
BufBuilder bb;
bb.skip(sizeof(QueryResult::Value));
@@ -262,9 +255,6 @@ void generateLegacyQueryErrorResponse(const AssertionException& exception,
QueryResult::View msgdata = bb.buf();
QueryResult::View qr = msgdata;
qr.setResultFlags(ResultFlag_ErrSet);
- if (isStaleConfig) {
- qr.setResultFlags(qr.getResultFlags() | ResultFlag_ShardConfigStale);
- }
qr.msgdata().setLen(bb.len());
qr.msgdata().setOperation(opReply);
qr.setCursorId(0);
@@ -1836,8 +1826,6 @@ DbResponse receivedQuery(OperationContext* opCtx,
dbResponse.shouldRunAgainForExhaust = runQuery(opCtx, q, nss, dbResponse.response);
} catch (const AssertionException& e) {
- behaviors.handleException(e.toStatus(), opCtx);
-
dbResponse.response.reset();
generateLegacyQueryErrorResponse(e, q, &op, &dbResponse.response);
}
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<StaleConfigInfo>();
- 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