createIndexes/shardCollection race condition in agg_out.js

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 4.1.8
    • Affects Version/s: 4.1.7
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • 16
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            James Wahlin
            Reporter:
            James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: