[SERVER-17846] Non-update/non-delete user operations should fail with error if $isolated included in query predicate Created: 01/Apr/15  Updated: 06/Dec/17  Resolved: 23/Oct/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 3.6.0-rc1

Type: Improvement Priority: Major - P3
Reporter: J Rassi Assignee: Nicholas Zolnierz
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-12307 Provide a means in query framework to... Closed
Backwards Compatibility: Minor Change
Sprint: Query 2017-10-02, Query 2017-10-23, Query 2017-11-13
Participants:

 Description   

$isolated is a "query operator" that has special meaning in the context of an update/delete, and is ignored in other contexts. Operations that attempt to use $isolated in such other contexts should fail with an error (such as find({$isolated: 1})).

Eventually, the $isolated operator should be taken out of the predicate language entirely, and replaced with an option to the update/delete commands.



 Comments   
Comment by Githook User [ 23/Oct/17 ]

Author:

{'email': 'nicholas.zolnierz@mongodb.com', 'name': 'Nick Zolnierz', 'username': 'nzolnierzmdb'}

Message: SERVER-17846: Forbid $isolated outside of update/delete user operations
Branch: master
https://github.com/mongodb/mongo/commit/ec7af3523d4aa5130c56a05d76169755d9b5a611

Comment by David Storch [ 18/Sep/17 ]

In addition to the changes described by this ticket, we also need to make sure that $isolated/$atomic are illegal inside arrayFilters. For details on the new array update behavior added during development of the 3.6 stable release, see https://docs.mongodb.com/master/reference/operator/update/positional-all/#positional-update-all. Here is an example of an update that should fail due to an illegal $isolated, but instead succeeds:

> db.c.drop()
true
> db.c.insert({a: [1, 2, 3]})
WriteResult({ "nInserted" : 1 })
> db.c.update({}, {$set: {"a.$[i]": 99}}, {arrayFilters: [{i: 2, $isolated: true}]})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.c.find()
{ "_id" : ObjectId("59c017ff4c4b0d6b6dd0fd8a"), "a" : [ 1, 99, 3 ] }

blake.oler, I think we can fix this by adding kIsolated to the list of "special features" which callers of the MatchExpressionParser must explicitly enable:

https://github.com/mongodb/mongo/blob/5be92f19e87b9dc06c5ebde9ebe9f19538f1af84/src/mongo/db/matcher/expression_parser.h#L91-L102

CC tess.avitabile

Generated at Thu Feb 08 03:45:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.