[SERVER-37716] Do not duplicate 'planSummary' in active getMore currentOp entry Created: 23/Oct/18  Updated: 29/Oct/23  Resolved: 21/Dec/18

Status: Closed
Project: Core Server
Component/s: Aggregation Framework, Diagnostics
Affects Version/s: None
Fix Version/s: 4.1.7

Type: Improvement Priority: Major - P3
Reporter: Charlie Swanson Assignee: Vlad Rachev (Inactive)
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File avoid_duplicate_planSummary.patch    
Issue Links:
Related
related to SERVER-38687 Mongod segfaults during teardown afte... Closed
Backwards Compatibility: Fully Compatible
Sprint: Query 2018-12-17, Query 2018-12-31
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 21/Dec/18 ]

Author:

{'username': 'vrachev', 'email': 'vlad.rachev@mongodb.com', 'name': 'vrachev'}

Message: SERVER-37716 Implement internal match expression which matches a particular BinData subtype
Branch: master
https://github.com/mongodb/mongo/commit/9e3ff3f74542c8e621934e0f44b15072ee8945be

Comment by Charlie Swanson [ 23/Oct/18 ]

I've attached avoid_duplicate_planSummary.patch which I generated while investigating this issue. I think this will resolve the issue - but it may introduce an unwanted dependency on curop.cpp, and still needs testing.

Generated at Thu Feb 08 04:46:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.