[SERVER-46686] Explain does not respect maxTimeMS Created: 06/Mar/20  Updated: 29/Oct/23  Resolved: 11/May/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.7.0, 3.6.23, 4.0.23, 4.2.13, 4.4.5

Type: Bug Priority: Major - P3
Reporter: Chris Harris Assignee: Drew Paroski
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
related to SERVER-28039 Add full maxTimeMS support to the exp... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.4, v4.2, v4.0, v3.6
Sprint: Query 2020-05-04, Query 2020-05-18
Participants:
Case:

 Description   

Per this comment in SERVER-41343, explain is expected to respect a maxTimeMS applied to it.  Testing appears to indicate that this is not the case:

> db.range.find({z:123}).maxTimeMS(1).explain(1).executionStats
{
	"executionSuccess" : true,
	"nReturned" : 0,
	"executionTimeMillis" : 433,
	"totalKeysExamined" : 0,
	"totalDocsExamined" : 1000000,
	"executionStages" : {
		"stage" : "COLLSCAN",
		"filter" : {
			"z" : {
				"$eq" : 123
			}
		},
		"nReturned" : 0,
		"executionTimeMillisEstimate" : 309,
		"works" : 1000002,
		"advanced" : 0,
		"needTime" : 1000001,
		"needYield" : 0,
		"saveState" : 7822,
		"restoreState" : 7822,
		"isEOF" : 1,
		"invalidates" : 0,
		"direction" : "forward",
		"docsExamined" : 1000000
	},
	"allPlansExecution" : [ ]
} 

The operation certainly appears to have yielded thousands of times, which is supposed to allow the interruption to happen based on my understanding.  

The log file suggests that the parameter itself is getting successfully passed to the server:

command: explain { explain: { find: "range", filter: { z: 123.0 }, maxTimeMS: 1.0 } 

 



 Comments   
Comment by Githook User [ 23/Feb/21 ]

Author:

{'name': 'Drew Paroski', 'email': 'drew.paroski@mongodb.com', 'username': 'paroski'}

Message: SERVER-46686 Explain does not respect maxTimeMS

(cherry picked from commit ff441d6e3f30a5c6a779d416409a46d35d9c26b7)
Branch: v4.4
https://github.com/mongodb/mongo/commit/0ff534cd8b7d07e70e73dfcf6fa0d60fe73ca843

Comment by Githook User [ 06/Feb/21 ]

Author:

{'name': 'Drew Paroski', 'email': 'drew.paroski@mongodb.com', 'username': 'paroski'}

Message: SERVER-46686 Explain does not respect maxTimeMS

(cherry picked from commit 8147d05d7038c6bf08a0b523fd69a44c13553cf1)
(cherry picked from commit a221c9d0afcbb52d01bd00d80ca1120efa470a58)
Branch: v3.6
https://github.com/mongodb/mongo/commit/86cb951909097936b313b860bf11e59e14704d49

Comment by Githook User [ 05/Feb/21 ]

Author:

{'name': 'Drew Paroski', 'email': 'drew.paroski@mongodb.com', 'username': 'paroski'}

Message: SERVER-46686 Explain does not respect maxTimeMS

(cherry picked from commit 4ba1495c898b5644d7be9efe21cfb2eecb3f1863)
Branch: v4.0
https://github.com/mongodb/mongo/commit/a221c9d0afcbb52d01bd00d80ca1120efa470a58

Comment by Githook User [ 05/Feb/21 ]

Author:

{'name': 'Drew Paroski', 'email': 'drew.paroski@mongodb.com', 'username': 'paroski'}

Message: SERVER-46686 Explain does not respect maxTimeMS
Branch: v4.2
https://github.com/mongodb/mongo/commit/8147d05d7038c6bf08a0b523fd69a44c13553cf1

Comment by Githook User [ 11/May/20 ]

Author:

{'name': 'Drew Paroski', 'email': 'drew.paroski@mongodb.com', 'username': 'paroski'}

Message: SERVER-46686 Update explain() shell command to propagate "maxTimeMS" arg to top-level, take 2
Branch: master
https://github.com/mongodb/mongo/commit/ff441d6e3f30a5c6a779d416409a46d35d9c26b7

Comment by Githook User [ 11/May/20 ]

Author:

{'name': 'Drew Paroski', 'email': 'drew.paroski@mongodb.com', 'username': 'paroski'}

Message: Revert "SERVER-46686 Update explain() shell command to propagate "maxTimeMS" arg to top-level"

This reverts commit d7d3a0d782ced557c26b9eb81ea97cc242762c8f.
Branch: master
https://github.com/mongodb/mongo/commit/af62a3eeaf0b1101cb2f6e8e7595b70f2fe2f10f

Comment by Githook User [ 09/May/20 ]

Author:

{'name': 'Drew Paroski', 'email': 'drew.paroski@mongodb.com', 'username': 'paroski'}

Message: SERVER-46686 Update explain() shell command to propagate "maxTimeMS" arg to top-level
Branch: master
https://github.com/mongodb/mongo/commit/d7d3a0d782ced557c26b9eb81ea97cc242762c8f

Comment by Drew Paroski [ 05/May/20 ]

Disregard the question in my previous comment - I talked with David Storch offline and he answered my questions about what the desired behavior should be here.

Comment by Drew Paroski [ 01/May/20 ]

christopher.harris: Thanks for the welcome!

I wanted to make sure I'm looking at the right thing here. In the example command you gave in this task's description, the "maxTimeMS" limit binds to the "find" operation, not the "explain" itself. In other words, the example command you posted is equivalent to:

db.runCommand({"explain" : {"find":"range", "filter":{"z":123.0}, "maxTimeMS":1.0}})

So the expectation here is that "maxTimeMS" should limit how long trial execution is allowed to happen, but outside of trial execution it shouldn't limit how long the explain operation itself is allowed to run? (This is my understanding from reading this task from reading everything so far, just wanted to double check.)

Generated at Thu Feb 08 05:12:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.