summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2021-10-25 17:43:20 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-25 18:34:49 +0000
commit6e9942b464bcf90cf96f7dd2e2ce6d4f28f1a7d0 (patch)
tree35c8cb489d12b972ace39d0a49fba7047ab946b7
parentbb31ac84744de48a5013ee747c08ee942e317eb3 (diff)
downloadmongo-6e9942b464bcf90cf96f7dd2e2ce6d4f28f1a7d0.tar.gz
SERVER-60749 Change internal client to stop issuing 'availableQueryOptions' command
-rw-r--r--src/mongo/client/dbclient_base.cpp17
-rw-r--r--src/mongo/client/dbclient_base.h16
-rw-r--r--src/mongo/client/dbclient_connection.cpp2
-rw-r--r--src/mongo/db/dbdirectclient.cpp5
-rw-r--r--src/mongo/db/dbdirectclient.h2
-rw-r--r--src/mongo/db/dbdirectclient_test.cpp20
-rw-r--r--src/mongo/db/dbmessage.h3
-rw-r--r--src/mongo/s/commands/cluster_available_query_options_cmd.cpp6
8 files changed, 26 insertions, 45 deletions
diff --git a/src/mongo/client/dbclient_base.cpp b/src/mongo/client/dbclient_base.cpp
index c283e338d5f..e646d5c7461 100644
--- a/src/mongo/client/dbclient_base.cpp
+++ b/src/mongo/client/dbclient_base.cpp
@@ -100,23 +100,6 @@ bool DBClientBase::isNotPrimaryErrorString(const BSONElement& e) {
(str::contains(e.valuestr(), "not primary") || str::contains(e.valuestr(), "not master"));
}
-
-enum QueryOptions DBClientBase::availableOptions() {
- if (!_haveCachedAvailableOptions) {
- _cachedAvailableOptions = _lookupAvailableOptions();
- _haveCachedAvailableOptions = true;
- }
- return _cachedAvailableOptions;
-}
-
-enum QueryOptions DBClientBase::_lookupAvailableOptions() {
- BSONObj ret;
- if (runCommand("admin", BSON("availablequeryoptions" << 1), ret)) {
- return QueryOptions(ret.getIntField("options"));
- }
- return QueryOptions(0);
-}
-
void DBClientBase::setRequestMetadataWriter(rpc::RequestMetadataWriter writer) {
_metadataWriter = std::move(writer);
}
diff --git a/src/mongo/client/dbclient_base.h b/src/mongo/client/dbclient_base.h
index ad86f30a6b9..e0dd05ff0c2 100644
--- a/src/mongo/client/dbclient_base.h
+++ b/src/mongo/client/dbclient_base.h
@@ -83,10 +83,7 @@ public:
static const uint64_t INVALID_SOCK_CREATION_TIME;
DBClientBase(const ClientAPIVersionParameters* apiParameters = nullptr)
- : _logLevel(logv2::LogSeverity::Log()),
- _connectionId(ConnectionIdSequence.fetchAndAdd(1)),
- _cachedAvailableOptions((enum QueryOptions)0),
- _haveCachedAvailableOptions(false) {
+ : _logLevel(logv2::LogSeverity::Log()), _connectionId(ConnectionIdSequence.fetchAndAdd(1)) {
if (apiParameters) {
_apiParameters = *apiParameters;
}
@@ -742,14 +739,6 @@ protected:
int skip,
boost::optional<BSONObj> readConcernObj);
- /**
- * Looks up the options available on this client. Caches the answer from
- * _lookupAvailableOptions(), below.
- */
- QueryOptions availableOptions();
-
- virtual QueryOptions _lookupAvailableOptions();
-
virtual void _auth(const BSONObj& params);
/**
@@ -775,9 +764,6 @@ private:
rpc::RequestMetadataWriter _metadataWriter;
rpc::ReplyMetadataReader _metadataReader;
- enum QueryOptions _cachedAvailableOptions;
- bool _haveCachedAvailableOptions;
-
// The operationTime associated with the last command handled by the client.
Timestamp _lastOperationTime;
diff --git a/src/mongo/client/dbclient_connection.cpp b/src/mongo/client/dbclient_connection.cpp
index f896b49ca8f..760b060aa57 100644
--- a/src/mongo/client/dbclient_connection.cpp
+++ b/src/mongo/client/dbclient_connection.cpp
@@ -625,7 +625,7 @@ unsigned long long DBClientConnection::query(std::function<void(DBClientCursorBa
int queryOptions,
int batchSize,
boost::optional<BSONObj> readConcernObj) {
- if (!(queryOptions & QueryOption_Exhaust) || !(availableOptions() & QueryOption_Exhaust)) {
+ if (!(queryOptions & QueryOption_Exhaust)) {
return DBClientBase::query(f,
nsOrUuid,
filter,
diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp
index 91b0c3738a5..580104f1c48 100644
--- a/src/mongo/db/dbdirectclient.cpp
+++ b/src/mongo/db/dbdirectclient.cpp
@@ -119,11 +119,6 @@ double DBDirectClient::getSoTimeout() const {
return 0;
}
-QueryOptions DBDirectClient::_lookupAvailableOptions() {
- // Exhaust mode is not available in DBDirectClient.
- return QueryOptions(DBClientBase::_lookupAvailableOptions() & ~QueryOption_Exhaust);
-}
-
namespace {
DbResponse loopbackBuildResponse(OperationContext* const opCtx, Message& toSend) {
DirectClientScope directClientScope(opCtx);
diff --git a/src/mongo/db/dbdirectclient.h b/src/mongo/db/dbdirectclient.h
index 24d0e3dc4e8..b0f8a74f09f 100644
--- a/src/mongo/db/dbdirectclient.h
+++ b/src/mongo/db/dbdirectclient.h
@@ -107,8 +107,6 @@ public:
double getSoTimeout() const override;
- QueryOptions _lookupAvailableOptions() override;
-
int getMinWireVersion() final;
int getMaxWireVersion() final;
diff --git a/src/mongo/db/dbdirectclient_test.cpp b/src/mongo/db/dbdirectclient_test.cpp
index f500603eb80..9b94c094aa2 100644
--- a/src/mongo/db/dbdirectclient_test.cpp
+++ b/src/mongo/db/dbdirectclient_test.cpp
@@ -157,5 +157,25 @@ TEST_F(DBDirectClientTest, DeleteDocumentIncorrectHintDoesNotThrow) {
ASSERT_EQ(writeErrors[0].getIntField("code"), ErrorCodes::BadValue);
}
+TEST_F(DBDirectClientTest, ExhaustQuery) {
+ DBDirectClient client(_opCtx);
+ write_ops::InsertCommandRequest insertOp(kNs);
+ const int numDocs = 10;
+ std::vector<BSONObj> docsToInsert{numDocs};
+ for (int i = 0; i < numDocs; ++i) {
+ docsToInsert[i] = BSON("_id" << i);
+ }
+ insertOp.setDocuments(std::move(docsToInsert));
+ auto insertReply = client.insert(insertOp);
+ ASSERT_EQ(insertReply.getN(), numDocs);
+ ASSERT_FALSE(insertReply.getWriteErrors());
+
+ // The query should work even though exhaust mode is requested.
+ int batchSize = 2;
+ auto cursor = client.query(
+ kNs, BSONObj{}, Query{}, 0 /*limit*/, 0 /*skip*/, nullptr, QueryOption_Exhaust, batchSize);
+ ASSERT_EQ(cursor->itcount(), numDocs);
+}
+
} // namespace
} // namespace mongo
diff --git a/src/mongo/db/dbmessage.h b/src/mongo/db/dbmessage.h
index ced00eef47e..99e174f246a 100644
--- a/src/mongo/db/dbmessage.h
+++ b/src/mongo/db/dbmessage.h
@@ -361,9 +361,6 @@ enum QueryOptions {
QueryOption_AllSupported = QueryOption_CursorTailable | QueryOption_SecondaryOk |
QueryOption_NoCursorTimeout | QueryOption_AwaitData | QueryOption_Exhaust |
QueryOption_PartialResults,
-
- QueryOption_AllSupportedForSharding = QueryOption_CursorTailable | QueryOption_SecondaryOk |
- QueryOption_NoCursorTimeout | QueryOption_AwaitData | QueryOption_PartialResults,
};
/**
diff --git a/src/mongo/s/commands/cluster_available_query_options_cmd.cpp b/src/mongo/s/commands/cluster_available_query_options_cmd.cpp
index c4ebd9f39ec..0786017bc7d 100644
--- a/src/mongo/s/commands/cluster_available_query_options_cmd.cpp
+++ b/src/mongo/s/commands/cluster_available_query_options_cmd.cpp
@@ -57,8 +57,10 @@ public:
const std::string& dbname,
const BSONObj& cmdObj,
BSONObjBuilder& result) override {
- result << "options" << QueryOption_AllSupportedForSharding;
- return true;
+ // TODO SERVER-60892: Remove this command entirely along with the corresponding mongod
+ // implementation.
+ uasserted(ErrorCodes::CommandNotSupported,
+ "'availableQueryOptions' command is not supported on mongos");
}
} clusterAvailableQueryOptionsCmd;