clusterTime and operationTime are not visble

Hi, i do have clusters that are configured in the same way but in one of them there is not showing info about
$clusterTime" : { "clusterTime"

I search the internet for 2 days and I didn’t find any clue if this part is enabled by settings?

Welcome to the MongoDB Community @wojtas!

The $clusterTime document is an internal reference which will only appear in command responses for replica sets and sharded clusters running MongoDB 3.6+. The absence of this field should not impact your use case unless you are trying to use read operations associated with casually consistent sessions.

Per the documentation on Command Responses, the $clusterTime is:

A document that returns the signed cluster time. Cluster time is a logical time used for ordering of operations. Only for replica sets and sharded clusters. For internal use only.

If this information doesn’t help explain the difference you are observing, please provide some further details on each of your environments:

  • What type of deployment is used (standalone, replica set, or sharded cluster)?

  • What specific version of MongoDB is being used (eg as reported by db.version() in the mongo shell)?

  • What command are you running, and what tool or driver version are you using to run this?

  • Is this a self-managed deployment or using a hosted service (for example, MongoDB Atlas)?

  • If using a hosted service, what cluster tier is being used?

Regards,
Stennie

Hi, Thank you for a quick answer
Here are answers:

  • What type of deployment is used (standalone, replica set, or sharded cluster)?
    3 nodes replica SET

  • What specific version of MongoDB is being used (eg as reported by db.version() in the mongo shell)?
    MongoDB shell version v4.2.8
    MongoDB server version: 4.2.8

  • What command are you running, and what tool or driver version are you using to run this?
    just mongo shell and admin user that has root role

  • Is this a self-managed deployment or using a hosted service (for example, MongoDB Atlas)?
    Self-hosted on my VMs

  • If using a hosted service, what cluster tier is being used?
    DEV Tier.

additional notes:
NO back compatibility -
{ “featureCompatibilityVersion” : { “version” : “4.2” }, “ok” : 1 }

SOME RS info
rs_test:SECONDARY> rs.status() { "set" : "rs_test", "date" : ISODate("2021-06-16T12:47:01.702Z"), "myState" : 2, "term" : NumberLong(54), "syncingTo" : "xxxxx:27017", "syncSourceHost" : "xxxxxx27017", "syncSourceId" : 2, "heartbeatIntervalMillis" : NumberLong(2000), "majorityVoteCount" : 2, "writeMajorityCount" : 2,
so writeMajorityCount is set to 2

No replication lag

Hi @wojtas,

I can’t reproduce this issue with a fresh install of MongoDB 4.2.8 and it sounds like your environments should be fine. Absence of the $clusterTime value shouldn’t affect normal usage of your cluster outside of the causal session option I mentioned, so I wouldn’t be particularly concerned although it is a mysterious outcome.

I didn’t find any SERVER issues related to this, but you may want to try upgrading to the latest version of MongoDB 4.2 (currently 4.2.14) as minor releases only include bug fixes & stability improvements.

Replication lag and writeMajorityCount should not affect the presence of $clusterTime in command responses.

On the replica set that doesn’t display the $clusterTime, can you share the output of running the following in the mongo shell:

rs.status().ok
rs.status()['$clusterTime']
db.version()
version()
db.isMaster().ismaster
db.isMaster().secondary
db.serverBuildInfo().gitVersion
db.serverStatus().uptime

Thanks,
Stennie

Hi, Thank You for the follow-up.
I did that (upgrade to 4.2.14) on one slave node and noting wasn’t better - still no
clusterTime in output - can I try to upgrade all cluster nodes.

We are, dev need them to check something on query. EDIT: i asked and the operationTime is needed for them to monitor query time.

Here are command output that You asked:

~]# mongo
MongoDB shell version v4.2.8
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“bla bla bla”) }
MongoDB server version: 4.2.8
rs_test:SECONDARY> rs.status().ok
1
rs_test:SECONDARY> rs.status()[‘$clusterTime’]
rs_test:SECONDARY> db.version()
4.2.8
rs_test:SECONDARY> version()
4.2.8
rs_test:SECONDARY> db.isMaster().ismaster
false
rs_test:SECONDARY> db.isMaster().secondary
true
rs_test:SECONDARY> db.serverBuildInfo().gitVersion
43d25964249164d76d5e04dd6cf38f6111e21f5f
rs_test:SECONDARY> db.serverStatus().uptime
156415
rs_test:SECONDARY>

I’m just wondering it that a enabled option? I tried to read some test that You have on GIT repo, and i know to have that visible user if he have some AdvencedTime role. But is it possible that admin user that have root role do not have permissions?

EDIT2:
I dig out the all internet :smiley:
https://jira.mongodb.org/browse/SERVER-43086?attachmentViewMode=list
I got something similar where my response to a query is simply ending on the OK.
No additional info about operationTime and clusterTime and we need that.

EDIT3:
More info:
the funny part is that this output does not work even when --norc is added and the mongo shell was not authorized

server1 ~]# mongo --norc
MongoDB shell version v4.2.8
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“bla bla bla”) }
MongoDB server version: 4.2.8
rs_test:SECONDARY> rs.status()
{
“ok” : 0,
“errmsg” : “command replSetGetStatus requires authentication”,
“code” : 13,
“codeName” : “Unauthorized”
}
rs_test:SECONDARY>

where on the second server

sever2 ~]# mongo --norc
MongoDB shell version v4.2.8
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { “id” : UUID("bla ble bla ") }
MongoDB server version: 4.2.8
rsamdb:SECONDARY> rs.status()
{
“operationTime” : Timestamp(1623927100, 1),
“ok” : 0,
“errmsg” : “command replSetGetStatus requires authentication”,
“code” : 13,
“codeName” : “Unauthorized”,
“$clusterTime” : {
“clusterTime” : Timestamp(1623927100, 1),
“signature” : {
“hash” : BinData(0,“0RRWUPgvVn+s+EWkXO1dyDd9e5k=”),
“keyId” : NumberLong(“6923043821483720705”)
}
}
}
rsamdb:SECONDARY> db.serverBuildInfo().gitVersion
43d25964249164d76d5e04dd6cf38f6111e21f5f
rsamdb:SECONDARY>