[SERVER-21285] currentOp ignores $near and $text predicates Created: 04/Nov/15  Updated: 06/Dec/22  Resolved: 26/Jul/19

Status: Closed
Project: Core Server
Component/s: Diagnostics, Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: J Rassi Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 0
Labels: query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-13020 db.currentOp() with $text in predicat... Closed
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

The currentOp command (and the equivalent pseudocommand "inprog") incorrectly ignores any $near or $text predicates passed in as a filter. Instead, an error should be returned at parse time if these predicates are used.

See, for example:

> db.adminCommand("currentOp", {$text: {$search: "hello"}}).inprog.length
1  // Unexpected: no operations should match.
> db.adminCommand("currentOp", {a: {$near: [0, 0]}}).inprog.length
1  // Unexpected: no operations should match.

I believe that this behavior has existed since the introduction of the $text and $near predicates.



 Comments   
Comment by David Storch [ 26/Jul/19 ]

This is fixed as of 4.2:

MongoDB Enterprise > db.adminCommand("currentOp", \{$text: {$search: "hello"}})
 {
 "ok" : 0,
 "errmsg" : "$match with $text is only allowed as the first pipeline stage",
 "code" : 17313,
 "codeName" : "Location17313"
 }
 MongoDB Enterprise > db.adminCommand("currentOp", {a: {$near: [0, 0]}})
{
	"ok" : 0,
	"errmsg" : "$geoNear, $near, and $nearSphere are not allowed in this context",
	"code" : 2,
	"codeName" : "BadValue"
}

I suspect the fix is also present in older versions, but I did not confirm. Closing as Gone Away.

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