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

shardCollection command updates config.collections metadata for unsharded collections

    • Sharding
    • Sharding 2018-11-19, Sharding 2018-12-03

      Implementation:
      1. Add "partitioned": true to this query to correctly check if there is an existing sharded collection.

      2. Update config.chunks in _shardsvrShardCollection:
      2a. When checking for existing chunks, read in all chunks for this namespace rather than the count if this collection already exists. Assert that there exists only 1 chunk with the correct version (version(1, 0)) and chunk range (globalMin -> globalMax).
      2b. When writing the chunks to the config, we should send an update command (rather than an insert). We need to bump the major chunk version here as a part of this update.

      3. Update config.collections and set the shardKey to the new shardKey and "sharded: true" here.

      Testing:
      We need to test this for an empty unsharded collection and a non-empty sharded collection.

      Set up:
      Empty unsharded collection:
      1. Create a collection.
      2. Assert that there exists the correct entries in config.databases, config.collections ("sharded": false and dummy shard key), and config.chunks (only one entry with version(1,0) and range (globalMin : globalMax)).

      Non-empty unsharded collection:
      1. Insert some documents into a collection.
      2. Assert that there exists the correct entries in config.databases, config.collections ("sharded": false and dummy shard key), and config.chunks (only one entry with version(1,0) and range (globalMin : globalMax)).

      Assert shard collection properly updates the metadata for both empty and non-empty collections:
      Run shardCollection with each of the following scenarios:

      • Range based shard key
      • Hashed shard key
      • Hashed shard key and setting numInitialChunks (only for empty collections)
      • Zoned sharding (only for empty collections)

      For each of the above scenarios do:
      1. Shard the collection.
      2. Assert that there exists the correct entries in config.databases, config.collections ("sharded": true and updated shard key), and config.chunks (expected number of chunks for the way in which we sharded the collection this iteration, the version is bumped, and correct ranges for the way in which we sharded the collection this iteration).

      Assumptions:

      • The collection already exists and is marked in config.collections with {sharded: false}

            Assignee:
            backlog-server-sharding [DO NOT USE] Backlog - Sharding Team
            Reporter:
            misha.tyulenev@mongodb.com Misha Tyulenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: