[SERVER-58670] Modernize DBClientBase query interface to avoid OP_QUERY-derived characteristics Created: 19/Jul/21 Updated: 29/Oct/23 Resolved: 23/Aug/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Client |
| Affects Version/s: | None |
| Fix Version/s: | 5.1.0-rc0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | David Storch | Assignee: | Irina Yatsenko (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Sprint: | QE 2021-08-09, QE 2021-08-23, QE 2021-09-06 | ||||||||
| Participants: | |||||||||
| Description |
|
The Ultimate Goal: migrate DBClientBase towards the interface similar to https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#read. For example, a query() API will take namespace, BSON filter and a special type with settings, rather than the current API that takes a Query with the filter and some settings embedded into it and other settings being passes in as additional parameters. As we do that, the Query type should be replaced by QueryOptions with statically typed fields (some of which might be BSON as required by the particular settings). The Challenge: the Query type wraps around a BSON object that might contain both query filter and some query settings. For a few common settings, such as sort and hint, there are setters on Query type that integrate the settings into the internal BSON object in a well-defined way, but Query also provides implicit constructor from BSON so there is no compiler check for what it might be get wrapped around. As a result, when it comes to processing a query, the code has to inspect Query's public 'obj' member and be prepared to deal with complicated BSON. We also suspect that some of the settings passed around have become mute after OP_QUERY deprecation and could be removed but it's hard to verify when opaque BSON is used to pass them around. Due to wide usage of DBClientBase and Query types, a single change to reach the goal stated above isn't feasible and the proposed progression is as follows: https://github.com/10gen/mongo/pull/215 did some preliminary cleanups. 1. Split the query argument in query() APIS into separate 'filter' (as BSONObj) and 'querySettings' (as Query) arguments. The steps 1-4 have been implemented in https://github.com/10gen/mongo/pull/292. 5. Investigate and remove/replace the remaining four callers of fromBSONDeprecated():
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()). |
| Comments |
| Comment by Vivian Ge (Inactive) [ 06/Oct/21 ] |
|
Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you! |
| Comment by Irina Yatsenko (Inactive) [ 23/Aug/21 ] |
|
Filed https://jira.mongodb.org/browse/SERVER-59512 to track the remaining work. |
| Comment by Githook User [ 23/Aug/21 ] |
|
Author: {'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}Message: This refactor includes: |
| Comment by Githook User [ 23/Aug/21 ] |
|
Author: {'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}Message: |
| Comment by Githook User [ 14/Aug/21 ] |
|
Author: {'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}Message: |
| Comment by David Storch [ 29/Jul/21 ] |
|
We should also look into deleting DBClientBase::findN() as part of this ticket. We noticed that this method has very few callers, and those callers could easily be migrated onto the regular DBClientBase::query() API. |