How to differentiate slave's getMore from user's getMore?

Hi, all. I want to do some tweaks. What I encounter is that I haven’t figured out how to differentiate slaves’ getMore command from users’ getMore command. Is there any native way to do this such as some kind of flag or something ?

Hi @Lewis_Chan,

Here is a getmore operation that I retrieved from the COVID-19 Open Data cluster using the db.currentOp() command.

{
			"type" : "op",
			"host" : "covid-19-shard-00-02-hip2i.mongodb.net:27017",
			"desc" : "conn128308",
			"connectionId" : 128308,
			"client" : "192.168.248.179:49888",
			"clientMetadata" : {
				"driver" : {
					"name" : "NetworkInterfaceTL",
					"version" : "4.2.10"
				},
				"os" : {
					"type" : "Linux",
					"name" : "CentOS Linux release 7.8.2003 (Core)",
					"architecture" : "x86_64",
					"version" : "Kernel 3.10.0-1127.13.1.el7.x86_64"
				}
			},
			"active" : true,
			"currentOpTime" : "2020-10-12T15:12:19.339+0000",
			"effectiveUsers" : [
				{
					"user" : "__system",
					"db" : "local"
				}
			],
			"opid" : 10078976,
			"secs_running" : NumberLong(1),
			"microsecs_running" : NumberLong(1052351),
			"op" : "getmore",
			"ns" : "local.oplog.rs",
			"command" : {
				"getMore" : NumberLong("324745879443392226"),
				"collection" : "oplog.rs",
				"batchSize" : 13981010,
				"maxTimeMS" : NumberLong(2500),
				"term" : NumberLong(56),
				"lastKnownCommittedOpTime" : {
					"ts" : Timestamp(1602515538, 1),
					"t" : NumberLong(56)
				},
				"$replData" : 1,
				"$oplogQueryData" : 1,
				"$readPreference" : {
					"mode" : "secondaryPreferred"
				},
				"$clusterTime" : {
					"clusterTime" : Timestamp(1602515538, 1),
					"signature" : {
						"hash" : BinData(0,"79XMfmD01mPxPuIxfr/BS/97GAM="),
						"keyId" : NumberLong("6843755954945654786")
					}
				},
				"$db" : "local"
			},
			"planSummary" : "COLLSCAN",
			"cursor" : {
				"cursorId" : NumberLong("324745879443392226"),
				"createdDate" : ISODate("2020-10-08T15:09:57.900Z"),
				"lastAccessDate" : ISODate("2020-10-12T15:12:18.286Z"),
				"nDocsReturned" : NumberLong(259965967),
				"nBatchesReturned" : NumberLong(677767),
				"noCursorTimeout" : false,
				"tailable" : true,
				"awaitData" : true,
				"originatingCommand" : {
					"find" : "oplog.rs",
					"filter" : {
						"ts" : {
							"$gte" : Timestamp(1602169755, 78240)
						}
					},
					"tailable" : true,
					"oplogReplay" : true,
					"awaitData" : true,
					"maxTimeMS" : NumberLong(60000),
					"batchSize" : 13981010,
					"term" : NumberLong(56),
					"readConcern" : {
						"afterClusterTime" : Timestamp(0, 1)
					},
					"$replData" : 1,
					"$oplogQueryData" : 1,
					"$readPreference" : {
						"mode" : "secondaryPreferred"
					},
					"$clusterTime" : {
						"clusterTime" : Timestamp(1602169796, 1),
						"signature" : {
							"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
							"keyId" : NumberLong(0)
						}
					},
					"$db" : "local"
				},
				"operationUsingCursorId" : NumberLong(10078976)
			},
			"numYields" : 2,
			"locks" : {
				
			},
			"waitingForLock" : false,
			"lockStats" : {
				"ReplicationStateTransition" : {
					"acquireCount" : {
						"w" : NumberLong(2)
					}
				},
				"Global" : {
					"acquireCount" : {
						"r" : NumberLong(2)
					}
				},
				"Database" : {
					"acquireCount" : {
						"r" : NumberLong(2)
					}
				},
				"Mutex" : {
					"acquireCount" : {
						"r" : NumberLong(1)
					}
				},
				"oplog" : {
					"acquireCount" : {
						"r" : NumberLong(2)
					}
				}
			},
			"waitingForFlowControl" : false,
			"flowControlStats" : {
				
			}
		}

I think this part is what you are looking for:

"effectiveUsers" : [
				{
					"user" : "__system",
					"db" : "local"
				}
			]

The replication is handled by the system, so it’s using the internal special __system user. Any other getmore operation issued by a user would use a “normal” user account.

I hope it helps :smiley:.
I’m not sure what you are trying to do with this information though but good luck :+1: !

Cheers,
Maxime.

2 Likes

Many thanks for your tip. What I actually need is a kind of programmable way in 4.0.

Maybe you are looking for this then?

Hi,

If you are planning to implement your tweaks in the core database, you could use the TagMask stated by the client’s session to check if the client corresponds to an internal connection or not .