-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 6.0.2
-
Component/s: None
-
Fully Compatible
-
ALL
-
v6.3, v6.0
-
-
QE 2023-02-06, QE 2023-02-20, QE 2023-03-06, QE 2023-03-20, QE 2023-04-03
I like to get detailed execution plan for this aggregation pipeline:
db.getSiblingDB('data').getCollection('tdube04mipmed0.332-0750.long').aggregate([ { "$match": { "_id": ObjectId("638468a8c6ac4d7abf8035d5") } }, { "$unwind": "$data" }, { "$replaceWith": "$data" }, { "$lookup": { "from": "sessions.20221118", "let": { "si": "$si", "sp": "$sp", "di": "$di", "dp": "$dp", "n": "$n", "t0": "$t0", "t": "$t", "ts": "$ts", "tsp": "$tsp", "tsi": "$tsi" }, "pipeline": [ { "$match": { "n": "snat", "ts": { "$exists": true }, "h": { "$in": [102, 103] } } }, { "$match": { "$expr": { "$and": [ { "$eq": ["$si", "$$si"] }, { "$eq": ["$sp", "$$sp"] }, { "$eq": ["$di", "$$di"] }, { "$eq": ["$dp", "$$dp"] }, { "$eq": ["$n", "$$n"] }, { "$gte": ["$t", "$$t"] }, { "$eq": ["$tsp", "$$tsp"] }, { "$eq": ["$tsi", "$$tsi"] }] } } }, { "$sort": { "last": -1 } }, { "$limit": 1 }], "as": "longdata" } }, { "$set": { "longdata": { "$first": "$longdata" } } }, { "$set": { "_id": { "$ifNull": ["$longdata._id", "$$REMOVE"] }, "longdata": "$$REMOVE", "ts": [ { "$min": [{ "$first": "$ts" }, { "$first": { "$ifNull": ["$longdata.ts", "$ts"] } }] }, { "$max": [{ "$last": "$ts" }, { "$last": { "$ifNull": ["$longdata.ts", "$ts"] } }] } ], "tp": { "$cond": ["$longdata._id", { "$concatArrays": [{ "$ifNull": ["$longdata.tp", []] }, [{ "$last": { "$ifNull": ["$longdata.ts", "$ts"] } }]] }, "$$REMOVE"] } } }, { "$unset": ["tt", "si_subnet", "f", "a", "p", "rb", "sb"] }, { "$merge": { "into": { "db": "data", "coll": "sessions.20221118" } } } ], { explain: 'executionStats' })
But I get this error:
MongoServerError: Use of undefined variable: si at Connection.onMessage (C:\Programs\MongoDB\Server\bin\mongosh.exe:72962:20) at MessageStream.<anonymous> (C:\Programs\MongoDB\Server\bin\mongosh.exe:72777:56) at MessageStream.emit (node:events:513:28) at MessageStream.emit (node:domain:552:15) at processIncomingData (C:\Programs\MongoDB\Server\bin\mongosh.exe:72586:14) at MessageStream._write (C:\Programs\MongoDB\Server\bin\mongosh.exe:72462:5) at writeOrBuffer (node:internal/streams/writable:391:12) at _write (node:internal/streams/writable:332:10) at MessageStream.Writable.write (node:internal/streams/writable:336:10) at Socket.ondata (node:internal/streams/readable:754:22)
Same applies for {{
{explain: 'allPlansExecution' }}}
It works fine on unsharded collections, but when lookup table is sharded then I get this error.
- related to
-
SERVER-75356 explain command for a find with $expr and let parameters fails if the collection is sharded
- Closed
-
SERVER-76037 Write commands using updateOne without shard key path fails spuriously when predicate refers to 'let' parameter
- Closed
-
SERVER-75108 Revisit implementation of explain for $unionWith
- Backlog