[SERVER-11469] add a user-defined $tag attribute to queries that shows up in db.currentOp().inprog Created: 30/Oct/13 Updated: 10/Dec/14 Resolved: 27/Jun/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Admin, Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | troy molsberry | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
Interactive database applications typically require a "cancel" button for the user to stop a long running operation. Mongodb does not provide this ability, partly due to the closure of https://jira.mongodb.org/browse/SERVER-5605 Ideally, a query could be annotated with a $tag that will show up in db.currentOp().inprog output so that an application can track and potentially killOp() any queries in progress. |
| Comments |
| Comment by troy molsberry [ 27/Jun/14 ] | ||||||||||||||||||||||||||||
|
if the query exceeds 256 bytes then the comment field in the db.currentOp() output shows "query not recording too large" | ||||||||||||||||||||||||||||
| Comment by Thomas Rueckstiess [ 27/Jun/14 ] | ||||||||||||||||||||||||||||
|
Hi Troy, This feature already exists, you can use the $comment operator to annotate queries. This will show up in the profiler and db.currentOp() under the query field. I've made a quick example to demonstrate. First I insert a document and then find it again. For the query, I added a $comment with the _addSpecial() method in the shell. (To simulate a long-running query I added a $where clause that executes a sleep in the server-side javascript interpreter. You wouldn't normally need that).
In another mongo shell, we can inspect the db.currentOp()
As you can see, the $comment made it into the db.currentOp() output and shows up in the query part. I hope that helps. Regards, Thomas |