-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
QE 2021-11-01, QE 2021-11-15
We will add new methods to DBClientBase called find() and findOne(). These perform the same role as the pre-existing DBClientBase::query() methods, but the caller specifies the find operation that they want to perform using the IDL-generated FindCommandRequest. This will make the internal client code easier to maintain, since whenever the find command IDL specification is modified, the client code will immediately benefit without any explicit changes necessary.
Under the hood, the DBClientBase::find() methods will have slightly different logic for constructing the initial OP_MSG find request to send across the wire. In particular, DBClientBase::query() needs to upconvert the request as specified by the caller to a FindCommandRequest so that the find request can in turn be converted to an OP_MSG. This upconversion step is not necessary for the new find() API.
This ticket will not complete the work to migrate all the callers off query() and onto find(). That will be achieved as followup work. Once that migration is complete, the query() API and its supporting code can be deleted. In particular the upconversion code mentioned above can be removed!
Originally we had a slightly different plan in mind for achieving the same goal. The details of the old plan are outlined below for posterity.
Original implementation plan
Implement steps ##5-8, outlined in the description of SERVER-58670.
5. Investigate and remove/replace the remaining four callers of fromBSONDeprecated():
- (src/mongo/client/dbclient_rs.cpp) in DBClientReplicaSet::say under if (lastOp == dbQuery) check – is this code still reachable?
- (src/mongo/client/dbclient_rs.cpp) in DBClientReplicaSet::call under if (toSend.operation() == dbQuery) check – is this code still reachable?
- (src/mongo/db/repl/apply_ops.cpp) in _checkPrecondition – should/could preconditions use different format?
- (src/mongo/scripting/mozjs/mongo.cpp) in MongoBase::Functions::find::call – should we still be supporting 'query/$query' here?
6. When all Query construction from raw BSON is gone, the type will only handle a known fixed set of query properties, so it will become possible to replace the internal BSON field 'obj' with statically typed fields, and callers that inspect 'obj' will be able to switch to using specific statically typed accessors instead. There are currently 7 callers like this (search for getFullSettingsDeprecated()).
7. Rename the Query type into QueryOptions (or FindOptions) and incorporate into it the other options that are currently passed to the query() APIs as separate arguments.
8. Review and cleanup src/mongo/db/query/query_request_helper.cpp. There should be no vestiges of OP_QUERY left at this point.
- is related to
-
SERVER-58670 Modernize DBClientBase query interface to avoid OP_QUERY-derived characteristics
- Closed
- related to
-
SERVER-61385 Migrate most callers of legacy 'DBClientBase::query()' API to modern 'find()' API
- Closed
-
SERVER-62206 Remove DBClientBase::query_DEPRECATED() and migrate remaining callers
- Closed