[DOCS-2021] Locking of user DB and Local DB is not at same time Created: 01/Oct/13 Updated: 11/Jan/17 Resolved: 01/Oct/13 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual |
| Affects Version/s: | None |
| Fix Version/s: | 01112017-cleanup |
| Type: | Bug | Priority: | Trivial - P5 |
| Reporter: | Thomas Boyd | Assignee: | Sam Kleinman (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: | |
| Days since reply: | 10 years, 20 weeks, 1 day ago |
| Description |
|
The description of how locking works with oplog doesn't seem correct to me. This is on the concurrency FAQ page: http://docs.mongodb.org/manual/faq/concurrency/ In particular: The mongod must lock both databases at the same time keep both data consistent and ensure that write operations, even with replication, are “all-or-nothing” operations. My understanding is that the write is first done to the user DB, holding the lock for that DB, and then it is done to the oplog, holding the lock for the local DB. The locks happen as part of the same operation, but they are done serially. If the locks were in fact held at the same time, DB level locking would be of no real use in replica sets. The fact that they are done in serial and that writes to the oplog are extremely fast (capped collection, no index, almost always in memory) means that DB level locking does increase concurrency even in replica sets. It is journaling and the fact that the user datafile writes and corresponding oplog writes are guaranteed My above explanation should be checked with engineering and obviously includes a lot of detail that would not need to be part of a doc change. |
| Comments |
| Comment by auto [ 01/Oct/13 ] |
|
Author: {u'username': u'tychoish', u'name': u'Sam Kleinman', u'email': u'samk@10gen.com'}Message: |
| Comment by Sam Kleinman (Inactive) [ 01/Oct/13 ] |
|
Just confirmed with scotthernandez... The write operations on primaries take a database lock, perform that write, and then without releasing the first database lock, take a second lock on the local database, write the oplog entry and then release both locks. The idea being that the lock on the local database will be a small fraction of the total time that the initial database lock is held. I'm going to add a word or two to clarify this. |