[SERVER-70134] Upsert fails if exactly one tag exists for the QE encrypted value in the query Created: 30/Sep/22 Updated: 29/Oct/23 Resolved: 01/Dec/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Queryable Encryption |
| Affects Version/s: | None |
| Fix Version/s: | 6.3.0-rc0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Erwin Pe | Assignee: | Davis Haupt (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 | |||||||||||||||||||||||||||||||||||||||||
| Backport Requested: |
v6.2, v6.1, v6.0
|
|||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: |
|
|||||||||||||||||||||||||||||||||||||||||
| Sprint: | QO 2022-12-12, Security 2022-11-28 | |||||||||||||||||||||||||||||||||||||||||
| Participants: | ||||||||||||||||||||||||||||||||||||||||||
| Description |
|
Suppose foo is a QE equality indexed field, bar is a unencrypted field, and testcoll is an encrypted collection containing a single document: {foo: "foovalue"}. Running this command with upsert:
fails with the error message: Plan executor error during findAndModify :: caused by :: The field '_safeContent_' must be an array but is of type binData in document {no id} |
| Comments |
| Comment by Githook User [ 01/Dec/22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Davis Haupt', 'email': 'davis.haupt@mongodb.com', 'username': 'davish'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 01/Dec/22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Davis Haupt', 'email': 'davis.haupt@mongodb.com', 'username': 'davish'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Davis Haupt (Inactive) [ 30/Nov/22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The solution in the PR was to wrap all {_safeContent_: {$in: [...]}} predicates in an $elemMatch. All the queries are still executed the same due to the Single Query Condition, but upsert now knows that the single element should be in an array. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Erwin Pe [ 28/Nov/22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Since this requires the query rewrite to handle the special case of upserts with 1 entry in a $in filter by rewriting it to an elemMatch, passing this ticket back to Query team. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Davis Haupt (Inactive) [ 28/Nov/22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This seems related to I don't think this is considered a bug in the query system, but just a unfortunate side effect of how arrays are queried in MQL. The solution would probably be to send a different upsert command to the query system with an $elemMatch rather than a $in if there is exactly one tag. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Erwin Pe [ 22/Nov/22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
davis.haupt@mongodb.com The $in query on _safeContent_ is being written correctly in fle_crud.cpp as the following debug log output shows:
Doing a findOne on the collection also shows the _safeContent_ as an array, so this issue is not coming from fle_crud.cpp. My hypothesis of what's happening during the command goes as follows:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Erwin Pe [ 14/Oct/22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
davis.haupt@mongodb.com here you go:
|