Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-10842

Docs for SERVER-30344: prevent shards from implicitly creating a collection on createIndexes

    • Type: Icon: Task Task
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • 3.6.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Documentation Request Summary:

      This ticket makes createIndexes, reIndex, dropIndex, and collMod only actually execute on shards that currently know about the namespace. (A shard may not currently own any chunks for the namespace, but have previously owned chunks).

      For unsharded collections, these commands only target the primary shard.

      For sharded collections, these commands are broadcast to all shards, but shards that do not know about the namespace return NamespaceNotFound (reIndex, dropIndex, collMod) or CannotImplicitlyCreateCollection (createIndexes).

      Mongos treats these errors as success (the overall command will report success if shards return a mix of ok:1 and these errors), but these error codes are shown in the raw responses from shards in the 'raw' field of the response object.

      Engineering Ticket Description:

      createIndexes on mongos is currently broadcast to all shards rather than only targeting shards which own data for the collection, since listIndexes expects the primary shard to have all the indexes for the collection (and the primary shard might not own any chunks for the collection at some particular time) (SERVER-16273).

      However, this means the collection is implicitly created on shards which don't own chunks for the collection AND don't have an entry for the collection in their storage engine (e.g., any shard that has never owned chunks for the collection). The collection is implicitly created on these shards without the collection options, including the collection's UUID.

      To prevent this,

      1) mongods running as --shardsvr should fail createIndexes with NamespaceNotFound rather than implicitly create the collection with the wrong options
      2) for createIndexes on a sharded collection, mongos should ignore NamespaceNotFound errors from shards
      3) for createIndexes on an unsharded collection, mongos should check if the collection exists on the primary shard, and explicitly create it if not before sending createIndexes to the primary shard

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              6 years, 27 weeks, 4 days ago