[SERVER-18147] Take distributed lock on database creation Created: 20/Apr/15  Updated: 25/Jan/17  Resolved: 21/Apr/15

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 3.1.2

Type: Bug Priority: Major - P3
Reporter: Spencer Brody (Inactive) Assignee: Spencer Brody (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change
Operating System: ALL
Participants:

 Description   

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



 Comments   
Comment by Githook User [ 21/Apr/15 ]

Author:

{u'username': u'stbrody', u'name': u'Spencer T Brody', u'email': u'spencer@mongodb.com'}

Message: SERVER-18147 Take distributed lock on database creation
Branch: master
https://github.com/mongodb/mongo/commit/1b3a27a722319094d0b5683ff28bce22922bcc0a

Generated at Thu Feb 08 03:46:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.