[SERVER-54550] [SBE] Not all documents are matched or wrong result in jstests/core/cursor3.js Created: 13/Feb/21  Updated: 04/Mar/21  Resolved: 02/Mar/21

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

Type: Bug Priority: Major - P3
Reporter: Anton Korshunov Assignee: Mihai Andrei
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-54552 [SBE] Reverse index scan may produce ... Closed
Operating System: ALL
Steps To Reproduce:

resmoke run --suite=core_sbe jstests/core/cursor3.js

Sprint: Query Execution 2021-03-08
Participants:

 Comments   
Comment by Mihai Andrei [ 01/Mar/21 ]

This jstest fails on the following test case and on the following line with the error ‘cursor[i] is undefined’. The reason why is somewhat subtle: the assertion above it passes because the count command uses the classic engine and will pass, but when we inspect the results, we get an undefined error because SBE returned fewer results than expected. We can observe that this is the case by rewriting the ‘checkResults’ helper by storing and inspecting the result of ‘cursor.toArray()’.

Now, if we look at the explain plan of the failing query, we see the following:

"explainVersion" : "2",
 	"queryPlanner" : {
 		"namespace" : "test.cursor3",
 		"indexFilterSet" : false,
 		"parsedQuery" : {
 			"a" : {
 				"$gt" : 0
 			}
 		},
 		"queryHash" : "47F6F859",
 		"planCacheKey" : "025AEA61",
 		"maxIndexedOrSolutionsReached" : false,
 		"maxIndexedAndSolutionsReached" : false,
 		"maxScansToExplodeReached" : false,
 		"winningPlan" : {
 			"queryPlan" : {
 				"stage" : "FETCH",
 				"planNodeId" : 2,
 				"inputStage" : {
 					"stage" : "IXSCAN",
 					"planNodeId" : 1,
 					"keyPattern" : {
 						"a" : 1
 					},
 					"indexName" : "a_1",
 					"isMultiKey" : false,
 					"multiKeyPaths" : {
 						"a" : [ ]
 					},
 					"isUnique" : false,
 					"isSparse" : false,
 					"isPartial" : false,
 					"indexVersion" : 2,
 					"direction" : "backward",
 					"indexBounds" : {
 						"a" : [
 							"[inf.0, 0.0)"
 						]
 					}
 				}
 			},

And the SBE plan:

"slots" : "$$RESULT=s5 $$RID=s6 env: { timeZoneDB = s1 (TimeZoneDatabase(Asia/Anadyr...Africa/Timbuktu)) }", "stages" : "[2] nlj [] [s2]
 left
 [1] nlj [] [s3, s4]
 left
 [1] project [s3 = KS(33FFFFFFFFFFFFFFFFFE04), s4 = KS(290104)]
 [1] limit 1
 [1] coscan
 right
 [1] ixseek s3 s4 s2 [] @\"7a8fb5c7-a3c6-4e39-b25a-db50b448af92\" @\"a_1\" false
 
 
 right
 [2] limit 1
 [2] seek s2 s5 s6 [] @\"7a8fb5c7-a3c6-4e39-b25a-db50b448af92\"

We see that the winning plan is a reverse ixscan over the ‘a’ index. As such, I suspect that this jstest failure is related to Anton’s work on SERVER-54321.

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