Vladas Diržys
Vladas Diržys

Reputation: 1388

MongoDb update atomicity

I had a discussion with a friend about MongoDb and it's atomicity, and I'd like know if he's right.. I was told, that MongoDb during an update does two atomic operations:

Which means that for a fraction of the time, the document is empty.

Even though this doesn't sound plausible to me, does anyone know for sure if this is true or not true?

Thanks a lot for you responses and would appreciate if someone could point to some online documents to read about it.

Edit: spelling

Upvotes: 3

Views: 3150

Answers (1)

Theo
Theo

Reputation: 132862

MongoDB uses a global write lock (per server before 2.2 and per database in 2.2) for all mutating operations. This means that regardless of the implementation details of updates they are atomic from the perspective of clients. The global write lock guarantees that no other client can see a partial update to a single document.

There is documentation on MongoDB's global write lock here: http://www.mongodb.org/display/DOCS/How+does+concurrency+work

Upvotes: 1

Related Questions