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

[v5.0] ReplicaSet started with --shardsvr but not added to a cluster doesn't consider all collections as unsharded

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.31
    • Affects Version/s: 5.0.0
    • Component/s: Sharding
    • Catalog and Routing
    • Fully Compatible
    • ALL
    • CAR team targeted by 8.0.1
    • 2

      Putting --shardsvr on the command line of a MongoD that's not part of a cluster enables the sharding subsystem and puts it in a state ready for the shard to be joined to a cluster. In this state, because the user is still directly connected to the replica set, the sharding subsystem bypasses many checks, because the requests don't come from a MongoS (i.e., don't contain a shard version).

      However, there is a problematic line introduced under SERVER-49228 that forces an otherwise unversioned request to be treated as if it came from a MongoS and this causes the checks to not be bypassed. One of these checks requires an access to the shard id of the node, which will invariant in this state because it's not present.

      One of the ways to fix this would be to take part of the changes for SERVER-84754 and make the CSR initialize collections as UNSHARDED if the sharding state is not yet enabled. This approach should be safe to do, because once initialised, the sharding state cannot be rolled-back (or rather the node fasserts if it gets rolled back). Because of the previous condition, we have the following guarantee that any collections that existed prior to the RS joining the sharded cluster will continue as UNSHARDED until either someone shards them or until the node is restarted (in which case they will become UNKNOWN because ShardingState::enabled() == true).

            Assignee:
            marcos.grillo@mongodb.com Marcos José Grillo Ramirez
            Reporter:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: