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

Take distributed lock on database creation

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.2
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • Minor Change
    • ALL

      There is a race condition if two different mongoses (or even two connections to the same mongos) try to create a database at the same time. Poor timing can make the mongos receive a "config write inconsistent" error when writing the config.databases entry where the insert is successful on 1 or more config servers but fails with a duplicate key error on 1 or more other config servers because the simultaneous db creation got there first.

      We didn't do this previously because of the way mongos was written wrt implicit database creation made it difficult to avoid taking the dist lock on every write event. With the new catalog refactor we've separated out implicit database creation so now it should be possible to take the distlock only when actually needed

            Assignee:
            spencer@mongodb.com Spencer Brody (Inactive)
            Reporter:
            spencer@mongodb.com Spencer Brody (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: