Database Theory: Timeout, Lock, Block và Deadlock trong hệ thống cơ sở dữ liệu là gì?

2022-03-20 16:05:48

Hết giờ:

When the client application is waiting for a require resource, Hết giờ occurs.

There are multiple reasons for Hết giờ like transaction blocking, the distance network, high CPU utilization and multiple request user request at one time.

The Database Hết giờ cannot affect to other running connection, and it treated independently, but for solving the Hết giờ issue we need to check other causes like OS response, Network response, Database Hết giờ threshold value, number of Database Connections and other.

Khoa:

Khi một quá trình đang truy cập một đối tượng, nó có thể yêu cầu khóa cho đối tượng cụ thể đó để các quá trình khác không thể thực hiện đọc hoặc cập nhật trên đối tượng đó.

There are different types of lock like Exclusive Khoa, Non-exclusive Khoa.

An Exclusive Khoa prevents object or data from the reading and writing both the actions.
A Non-Exclusive Khoa allows read-only access for an object or data, but it prevents the write action for an object or data.

Khối:

Nếu hai tiến trình đang truy cập cùng một tài nguyên thì tại thời điểm đó một tiến trình phải đợi cho đến khi tiến trình kia giải phóng tài nguyên bị chiếm.

Điều này được gọi là chặn vì một giao dịch bị chặn bởi một giao dịch khác và tất cả các quy trình bị chặn được giữ trong hàng đợi.

If the blocked transaction is waiting for a long time, it may generate a Database Hết giờ.
Nếu giao dịch bị chặn trong thời gian dài yêu cầu khóa, nó có thể tạo ra một Khóa cơ sở dữ liệu.

Bế tắc:

Một quy trình X đang đợi để hoàn tất giao dịch của quy trình Y và đồng thời, quy trình Y bị chặn vì nó cũng đang chờ hoàn tất giao dịch của quy trình X..
This is called as Bế tắc situation.

In the Bế tắc situation, both the processes trying to access a particular resource and also has a lock on that resource by each other, so both are waiting for each other to release a lock and complete the transaction.

Bế tắc is a next stage of the blocking situation so if you want to avoid Bế tắc situation, you should first find the blocked transaction and tried to remove internal dependency for those transactions.

Xem thêm:


Chia sẻ: