[SERVER-10665] maxTimeMS doesn't stop active operations Created: 03/Sep/13  Updated: 10/Dec/14  Resolved: 03/Sep/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.5.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Sam Weaver Assignee: J Rassi
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Participants:

 Description   

> var start = new Date()
> var c = db.test.find({$where: function() { sleep(10000); return true; }});
> c.maxTimeMS(1000)
error: { "$err" : "JavaScript execution terminated", "code" : 16712 }
> var end = new Date() - start
> end
10021

Set the sleep to 10 seconds, set the timeout to 1 second. Run a timer, it only terminates after the 10 seconds are up and not the 1 second...

Since javascript $where doesn't allow yielding, or checking for the kill signal for that operation, it runs through to the end of the execution.

The same thing can happen with a page fault or other long running part of a query/operation.



 Comments   
Comment by J Rassi [ 04/Sep/13 ]

Since javascript $where doesn't allow yielding, or checking for the kill signal for that operation, it runs through to the end of the execution.

To clarify: the Javascript engine can be interrupted before/after each call back to native C++. So, using the $where clause "for (i=0;i<10;i++) { sleep(1000); } return true;" instead in your example would in fact cause the query to be interrupted after 1 second (since sleep() in Javascript is just mongo::native_sleep() injected into the scope).

Comment by Daniel Pasette (Inactive) [ 03/Sep/13 ]

I've marked this as "Documentation needed"

Comment by Eric Milkie [ 03/Sep/13 ]

Operations can only be interrupted at yield points. For the operation you are running, you will find you cannot even run killOp() on it until it finishes.

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