MongoDB local database lock Phenomenon Analysis

Source: Internet
Author: User

What is the impact of concurrency on "primary replica set?

During the copy Copy process, when a write operation is performed on the master database, MongoDB is also writing the oplog of the master database. The oplog is a special set in the local database. (In replica set mode, local. oplog. RS is a capped collection set used to store oplog ). Therefore, MongoDB must lock the database for the current write operation and the local database. Mongod must lock these two databases to maintain data consistency and ensure that write operations are "All or all" operations.

 

Under what circumstances will multiple databases be locked?

MongoDB will lock Multiple databases in the following operations:

DB. copydatabase () enable global lock

Journaling is an internal operation that locks all databases in a short time. All libraries will share a journal.

User Authentication: locks the admin database and the database logged on.

All writes to a replica set's primary locks the database that receives write operations and the local database, and locks the local database so that mongod writes oplog in the primary.

 

The original text is as follows:

How Does concurrency affect a replica Set primary?

In replication, when MongoDB writes to a collection on the primary, MongoDB also writes to the primary's oplog, which is a special collection in the local database. therefore, MongoDB must lock both the collection's database and the local database. the specified D 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.

 

Does a MongoDB operation ever lock more than one database?

The following MongoDB operations lock Multiple databases:

DB. copydatabase () must lock the entire specified D instance at once.

Journaling, which is an internal operation, locks all databases for short intervals. All databases share a single journal.

User Authentication locks the admin database as well as the database the user is accessing.

All writes to a replica set's primary lock both the database processing the writes and the local database. The lock for the local database allows the prior D to write to the primary's oplog.

 

Reference http://docs.mongodb.org/manual/faq/concurrency/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.