Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-86905

Inconsistent values for $$NOW across shards in find queries

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0, 8.0.0-rc3, 7.3.4
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • ALL
    • v8.0, v7.3, v7.0, v6.0, v5.0
    • QO 2024-03-04, QO 2024-03-18, QO 2024-04-01, QO 2024-04-15, QO 2024-04-29

      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.

        1. now-repro.js
          0.4 kB
          Ben Shteinfeld

            Assignee:
            peter.volk@mongodb.com Peter Volk
            Reporter:
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: