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

createIndexes/shardCollection race condition in agg_out.js

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 4.1.8
    • 4.1.7
    • None
    • None
    • Fully Compatible
    • ALL
    • 16

    Description

      agg_out.js will occasionally attempt to create a shard key index on a shard output collection and then shard the collection. This operation can be performed by multiple threads concurrently. The index is required for collection sharding as the collection may have data.

      When 2 threads do attempt his concurrently, it is possible for the shardCollection command to fail due to missing shard key index. This can happen when:

      Thread 1: Calls createIndex() to build the shard key index. Index build is started.
      Thread 2: Calls createIndex(), which returns successfully as an index specification has been created for the in-progress index build.
      Thread 2: Attempts to shard the collection. The shardCollection command fails as it does not see the in-progress index build (as it does not call listIndexes with the {includeIndexBuilds: true} option).

      We can fix this by moving index creation for the output collection to the FSM setup function.

      Attachments

        Activity

          People

            james.wahlin@mongodb.com James Wahlin
            james.wahlin@mongodb.com James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: