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

_shardServerShardCollection should use afterOpTime when counting chunks on the config server

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.0
    • Sprint:
      Sharding 2018-10-08
    • Linked BF Score:
      16

      Description

      When we shard a collection, _shardServerShardCollection runs a count command on the config.chunks collection to make sure there are no chunks already in the collection. But, right now, the count query uses readConcern local, which can cause a problem in the following scenario

      1. Create a sharded collection
      2. Drop the sharded collection, which succeeds on the config server primary
      3. Try to create a sharded collection with the same name
      4. _shardServerShardCollection runs a count command to see if chunks exist from a previous sharded collection with the same name
      5. The count command targets the config server secondary, where the replication of the drop from the previous collection has not completed, and so there are still chunks in the collection
      6. The _shardServerShardCollection command fails with the error "ManualInterventionRequired: A previous attempt to shard collection <collection name> failed after writing some initial chunks to config.chunks. Please manually delete the partially written chunks for collection test.user from config.chunks", even though the previous drop completed successfully

      We should use readAfterOpTime to do this count command so that even if we read from a config server secondary, we'll wait until previous operations have replicated.

        Attachments

          Activity

            People

            Assignee:
            janna.golden Janna Golden
            Reporter:
            matthew.saltz Matthew Saltz
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: