-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework, Diagnostics
-
Fully Compatible
-
Query 2018-12-17, Query 2018-12-31
When computing the $currentOp document (or currentOp command entry) for an idle cursor, we correctly strip the planSummary out of the "cursor" subobject and only include it in the top-level document:
db.aggregate([{$currentOp: {idleCursors: true}}, {$match: {type: "idleCursor"}}]).pretty() { "type" : "idleCursor", "host" : "franklinia", "ns" : "test.foo", "lsid" : { "id" : UUID("4fdd02f9-b306-4a6f-904b-6520609a845f"), "uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=") }, "planSummary" : "COLLSCAN", "cursor" : { "cursorId" : NumberLong("18723577464"), "createdDate" : ISODate("2018-10-23T16:52:12.962Z"), "lastAccessDate" : ISODate("2018-10-23T16:52:12.974Z"), "nDocsReturned" : NumberLong(22), "nBatchesReturned" : NumberLong(11), "noCursorTimeout" : false, "tailable" : false, "awaitData" : false, "originatingCommand" : { "find" : "foo", "filter" : { }, "batchSize" : 2, "lsid" : { "id" : UUID("4fdd02f9-b306-4a6f-904b-6520609a845f") }, "$db" : "test" } } }
However, when computing the document (or entry) for an active getMore operation, this information is duplicated:
> db.currentOp() { "inprog" : [ {...}, { "type" : "op", "host" : "franklinia:27017", "desc" : "conn1", "connectionId" : 1, "client" : "127.0.0.1:36968", "appName" : "MongoDB Shell", "clientMetadata" : {...}, "active" : true, "currentOpTime" : "2018-10-23T09:43:32.325-0400", "opid" : 291, "lsid" : { "id" : UUID("434c3e37-9785-4a4f-a346-6273d1c894e7"), "uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=") }, "secs_running" : NumberLong(0), "microsecs_running" : NumberLong(10197), "op" : "getmore", "ns" : "test.foo", "command" : { "getMore" : NumberLong("18557451439"), "collection" : "foo", "batchSize" : 2, "lsid" : { "id" : UUID("434c3e37-9785-4a4f-a346-6273d1c894e7") }, "$db" : "test" }, "planSummary" : "COLLSCAN", "cursor" : { "cursorId" : NumberLong("18557451439"), "createdDate" : ISODate("2018-10-23T13:43:30.701Z"), "lastAccessDate" : ISODate("2018-10-23T13:43:32.314Z"), "nDocsReturned" : NumberLong(18), "nBatchesReturned" : NumberLong(9), "noCursorTimeout" : false, "tailable" : false, "awaitData" : false, "originatingCommand" : { "find" : "foo", "filter" : { "$where" : "sleep(100); return true;" }, "batchSize" : 2, "lsid" : { "id" : UUID("434c3e37-9785-4a4f-a346-6273d1c894e7") }, "$db" : "test" }, "planSummary" : "COLLSCAN", // DUPLICATE "operationUsingCursorId" : NumberLong(291) }, "numYields" : 0, "locks" : { "Global" : "r", "Database" : "r", "Collection" : "r" }, "waitingForLock" : false, "lockStats" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } } } ], "ok" : 1 }
We should avoid duplication in both cases, and attempt to consolidate the code to include only one code path for converting the GenericCursor IDL type to a serialized state for currentOp reporting. This GenericCursor type is generated by the cursor manager for idle cursors, and attached to the CurOp object for active ones. It includes the planSummary for both active and idle cursors on mongod. It never includes a planSummary on mongos.
- related to
-
SERVER-38687 Mongod segfaults during teardown after javascript test failure
- Closed