|
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.
|