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

Include databaseVersion when targeting by primary shard in paths that use buildVersionedRequestsForTargetedShards()

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.7.3
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Fully Compatible
    • Sharding 2018-02-12, Sharding 2018-02-26, Sharding 2018-03-12

      If mongos doesn’t see a namespace in its cache, it will discover whether the namespace is a view or collection from the primary shard.
      It will discover if the primary shard has changed through database versioning.

      Routing logic for a namespace not in mongos’s cache:

      1. Mongos forwards the request to the node it believes to be the primary shard for “test”, with both
        1. shardVersion “UNSHARDED”
        2. databaseVersion <mongos’s cached databaseVersion>
      2. Since the request contains a databaseVersion, the shard verifies it
        1. If the databaseVersion doesn't match, the shard returns StaleDbVersion
        2. If it does match, the shard tries to resolve the namespace
          1. If it’s a view, returns the viewDefinition
          2. Else processes the request normally
            1. This can return StaleShardVersion or actual data
      3. Mongos receives the response. If the response is
        1. StaleDbVersion, refreshes its cache entry for db “test” and retries
        2. StaleShardVersion, refreshes cache entry for “test.foo” and retries
        3. viewDefinition, rewrites the request as an aggregation and retries
        4. actual data, returns the data

            Assignee:
            esha.maharishi@mongodb.com Esha Maharishi (Inactive)
            Reporter:
            randolph@mongodb.com Randolph Tan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: