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

shardCollection no-op oplog can be written even when command ultimately fails

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.0.0-rc0
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • Fully Compatible
    • ALL
    • Sharding NYC 2022-03-21

      Currently, we write the oplog right before we send the final update that commits the migration to the config server:

      https://github.com/mongodb/mongo/blob/077b55e6330264b262d87d296a7f7006fece669e/src/mongo/db/s/create_collection_coordinator.cpp#L920

      However, if the server restarts right before the final update it sent, then it is possible for dropIndex to sneak in and drop the necessary index required by the shard collection. When the CreateCoordinator gets restored and tries to redo, it will find out that the collection doesn't have the required index for the shard key pattern and fail.

      Some context for why oplog was written before the final update: it was done to achieve the property where the oplog will have ts < any writes that come after the collection became sharded.

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            randolph@mongodb.com Randolph Tan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: