Understanding Lock and Lockout duration

Source: Internet
Author: User

Locks are generated when multiple concurrent exclusive accesses, so the isolation in the lock and transaction characteristics is closely related. The isolation level is roughly divided into four kinds.

    1. Read not submitted

    2. Read Committed

    3. REPEATABLE READ

    4. Serializable

Exclusive locks are persisted to the end of the transaction in order to ensure the integrity and consistency of the transaction.

So let's talk about how shared locks are locked under these four isolation levels.

    1. READ UNCOMMITTED: As the name implies, others did not submit I can read, which I read without sharing the lock Bai, read dirty (dirty data and dirty data page is completely different two concepts, swelling data is neither committed nor rollback data, intermediate state, bulging data page is in memory has not redo to disk data, When checkpoint is triggered, it is written to disk in bulk and then marked as clean on the page header.

    2. Read Committed: As the name implies, others submitted I can read, then I read the time is to add a shared lock, but the shared lock is to read a release, the lock will not last until the end of time.

    3. REPEATABLE READ: As the name implies, can be repeated reading, since in a transaction I can read repeatedly, in fact, the consciousness is in a food multiple read data is the same, then this shared lock is continued until the end of the transaction. From Start--commit This period of time shared locks have been held, so other people can not change, will be read more than once.

    4. Serializable: Like a table primary key ID 3 data I want to insert a 2.5 between 2-3 if someone now queries select COUNT (1) from Tbname where Id>=1 and id<=3 is not allowed because this isolation level On the range lock this time not only the data can not be modified, this section of the scope can not insert new data. So the number of times in a transaction count is 3 data, if the table does not have a primary key, there is no aggregation built on the scope of the heap table is not a logical concept, storage is the physical location fileid:pageid:slotnumber, if the heap table this isolation level when reading will be added to the table lock.

This article is from the "Xinle" blog, please be sure to keep this source http://xinle.blog.51cto.com/1935834/1736981

Understanding Lock and Lockout duration

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.