concurrency control and transactions in the database

Source: Internet
Author: User

concurrency control and transactions in the database are often asked during an interview, but the basic knowledge of the 2 aspects of the database must also be clear to guide their daily routine. Below I summarize, this 2 days I encountered problems, basically is the carding of the points of knowledge.

concurrency control

Basic Theories and concepts:

When dealing with concurrency or writing, you can solve the problem by implementing a lock system consisting of 2 types of locks, which are commonly referred to as shared and exclusive locks, also called Read and write locks. Read locks are shared, non-blocking, and multiple clients can read the same resource at the same time without interfering with each other. Write locks are exclusive, and write locks block other read and write locks.

The size of the lock classification:

are table locks and row locks, respectively. The table lock overhead is minimal, blocking all read and write operations to the table by other users, and row locks support concurrency to the greatest extent.

Transaction

1. Features

A well-run transactional database that requires acid characteristics:

Atomicity of-atomicity

Conformance-consistency

Isolation-isolation

Persistent-durability

2. Transaction ISOLATION LEVEL

Read uncommited: Uncommitted reads

Read commited: Submission degree

REPEATABLE READ: Repeatable reading

Serializable: Serializable

Dirty Read possibility Non-REPEATABLE READ Phantom reading Locking Read
Non-committed read Yes Yes Yes NO
Submit Read NO Yes Yes No
REPEATABLE READ No No Yes No
Serializable No No No Yes

3. Deadlock

In order to solve the deadlock, the database system realizes the deadlock detection and deadlock time-out mechanism; currently INNODB handles deadlocks by rolling back transactions that hold the least row-level exclusive locks.

concurrency control and transactions in the database

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.