...
For aggregations, we compute runtime constant system variables ($$NOW, $$CLUSTER_TIME) once on mongos and set them via let variables in the command set to all shards. This ensures that all shards use the same value for the duration of the query. It appears that we are not doing this for find queries, see repro here: now-repro.js. The $$NOW variable can be referenced in a find are in filter using $expr or a computed projection.
xgen-internal-githook commented on Fri, 19 Jul 2024 19:27:46 +0000: Author: {'name': 'Peter Volk', 'email': '77723508+HCSPete@users.noreply.github.com', 'username': 'HCSPete'} Message: SERVER-86905 replace $$NOW and $$CLUSTER_TIME before sending to shards (#24660) [BACKPORT-20038](https://jira.mongodb.org/browse/BACKPORT-20038) from the original ticket. There are a few additional artifacts that had to be backported as well. Hence a non-trivial (but still simple) backport. [Original PR](https://github.com/mongodb/mongo/commit/47ca1ad4734d41c13d783507eb2e89dfdaaddc18) [Evergreen patch](https://spruce.mongodb.com/version/6690ff4d7865cb00079a8997/tasks?sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC) --------- Co-authored-by: henrinikku GitOrigin-RevId: 05f103196f431f4d115b772060453d8bc456c6f1 Branch: v7.3 https://github.com/mongodb/mongo/commit/1830eb5e8ba5a011367f8e6f0d36f52ef0c7b9cc xgen-internal-githook commented on Thu, 18 Apr 2024 11:21:36 +0000: Author: {'name': 'Peter Volk', 'email': '77723508+HCSPete@users.noreply.github.com', 'username': 'HCSPete'} Message: SERVER-86905 replace $$NOW and $$CLUSTER_TIME before sending to shards (#20920) GitOrigin-RevId: ac3e3d954e249162e97ce4b70c5d6709c7fc7615 Branch: v8.0 https://github.com/mongodb/mongo/commit/5acd0919ddace69d9236a7826724d58f59dd9c3b xgen-internal-githook commented on Wed, 17 Apr 2024 14:56:21 +0000: Author: {'name': 'Peter Volk', 'email': '77723508+HCSPete@users.noreply.github.com', 'username': 'HCSPete'} Message: SERVER-86905 replace $$NOW and $$CLUSTER_TIME before sending to shards (#20920) GitOrigin-RevId: 54b54bfd94057827fe75245b845afc41d08f3b43 Branch: master https://github.com/mongodb/mongo/commit/47ca1ad4734d41c13d783507eb2e89dfdaaddc18