dbms和sql_DBMS | 并发控制和各种并发控制方法
dbms和sql
并發控制 (Concurrency Control)
The concurrency control is the coordination of the simultaneous execution of a transaction in a multiuser database system. The concurrency control can ensure the serializability of the transaction in a multiuser database environment and that is the main objective of concurrency control. There is only One way in which the required data items can be accessed in a mutually exclusive manner. That is while one transaction is accessing a data item another transaction can modify that data item. The most common method used to implement this requirement is to allow a transaction to access a data item only if it is currently holding a lock on that item.
并發控制是在多用戶數據庫系統中同時執行事務的協調。 并發控制可以確保事務在多用戶數據庫環境中的可序列化性,這是并發控制的主要目標。 只有一種方法可以以互斥的方式訪問所需的數據項。 也就是說,當一個事務正在訪問數據項時,另一事務可以修改該數據項。 用于實現此要求的最常見方法是僅在事務當前持有該數據項的鎖時,才允許該事務訪問該數據項。
多種并發控制方法 (Various methods of concurrency control)
1)二進制鎖定 (1) Binary Locking)
A data item can be locked in various modes:
數據項可以以多種模式鎖定:
Shared mode (S): when any transaction Ti has 0 shared mode lock on any data item Q then Ti can only read but cannot write Q.
共享模式(S) :當任何事務Ti對任何數據項Q擁有0個共享模式鎖定時, Ti只能讀取而不能寫入Q。
Exclusive mode (X): Any transaction Ti can read and write Q only If a transaction Ti has obtained an exclusive mode lock (denoted by X) on any data item Q.
獨占模式(X) :只有事務Ti獲得了對任何數據項Q的獨占模式鎖(由X表示),任何事務Ti才能讀寫Q。
The transaction makes the request to the concurrency control manager. It can proceed only when the concurring control manager grants the lock to the transaction.
事務向并發控制管理器發出請求。 僅當并發控制管理器將鎖定授予事務時,它才能繼續進行。
2)基于鎖定的協議 (2) Locked based protocol)
In locked based protocol basic idea is first to acquire a lock before accessing a data item directly after use should delete that data item. Because of this, we can avoid a clash. Here transaction uses types of locks. Shared lock and exclusive lock.
在基于鎖定的協議中,基本思想是首先獲取一個鎖,然后再直接使用該數據項,然后再刪除該數據項。 因此,我們可以避免沖突。 在這里,事務使用鎖的類型。 共享鎖和排他鎖。
3)共享鎖 (3) Shared lock)
If the transaction has acquired a shared lock on a data item Q than its own perform only read operation but if a transaction has acquired exclusive lock then it can perform read as well as write operation.
如果事務已獲取了對數據項Q的共享鎖,而不是事務本身僅執行讀操作,但是如果事務已獲取了排他鎖,則它可以執行讀和寫操作。
4)兩相鎖定 (4) Two phase locking)
In two-phase locking every transaction work in 2 phase in the entire span. Growing phase and shrinking phase. In the growing phase, only a transaction may acquire locks but cannot release only lock while in shrinking phase a transaction can only release lock but cannot any acquire any lock.
在兩階段鎖定中,每個事務在整個范圍內分兩階段進行。 生長階段和收縮階段。 在增長階段,只有事務可以獲取鎖,而不能僅釋放鎖,而在收縮階段,事務只能釋放鎖,而不能獲取任何鎖。
Growing and shrinking phase terminology is applicable to the transaction not suitable.
增長和收縮階段術語適用于不適合的交易。
5)嚴格的2相鎖定 (5) Rigorous 2 phase locking)
In rigorous 2 phase locking, we remove shrinking phases from the system i.e. a transaction can acquire locks but cannot release any lock because of which dirty read is not possible. This protocol ensures conflict and view serializability recoverability and cascadeless but may suffer from deadlock.
在嚴格的兩階段鎖定中,我們從系統中刪除了縮小的階段,即,事務可以獲取鎖定,但不能釋放任何鎖定,因為這樣不可能進行臟讀。 該協議可確保沖突并查看可序列化的可恢復性,并且無級聯,但可能會出現死鎖。
6)嚴格2相鎖相 (6) Strict 2 phase locking)
In strict 2 phase locking is an improvement over rigorous 2 phase locking ensure rigorous two-phase locking where unlocking of a shared lock is allowed in the shrinking phase.
在嚴格的2相鎖定中,是對嚴格2相鎖定的一種改進,可確保嚴格2相鎖定,其中在收縮階段允許對共享鎖進行解鎖。
7)保守2相鎖相 (7) Conservative 2 phase locking)
In conservation 2 phase locking we remove growing phase from the system and every transaction is first required to acquire all the lock first before performing any read or write. It ensures conflict serializability view serializability and deadlock independence but suffers from recoverability and cascades.
在保護2階段鎖定中,我們從系統中刪除了增長階段,在執行任何讀取或寫入操作之前,首先需要每個事務先獲取所有鎖定。 它確保了沖突的可序列化性,視圖可序列化性和死鎖獨立性,但是會遭受可恢復性和級聯的困擾。
8)時間戳記協議 (8) Time stamping protocol)
In this method, we decide to order before transaction enters into the system here every transaction is given time stamp Ts(Ti) which is actually the value of the system clock when the transaction enters into the system. This time stamp will remain constant until the transaction is in the system.
在這種方法中,我們決定在事務進入系統之前進行排序,此處為每個事務都賦予時間戳Ts(Ti),該時間戳實際上是事務進入系統時系統時鐘的值。 該時間戳將保持不變,直到事務在系統中。
Write every data item Q use associate two time stamp read time stamp of Q and write time stamp of Q.
寫入每個數據項Q使用關聯Q的兩個時間戳讀取時間戳和Q的寫入時間戳。
Note: If a read operation is allowed than reading timestamp must be updated and if a write operation is allowed than write timestamp must be updated. If an operation is not allowed than transaction must enter into a system with a new timestamp.
注意:如果允許讀取操作,則必須更新讀取時間戳;如果允許寫入操作,則必須更新寫入時間戳。 如果不允許某項操作,則事務必須以新的時間戳進入系統。
翻譯自: https://www.includehelp.com/dbms/concurrency-control-and-various-methods-of-concurrency-control.aspx
dbms和sql
總結
以上是生活随笔為你收集整理的dbms和sql_DBMS | 并发控制和各种并发控制方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 原神流放者套装怎么刷取
- 下一篇: ai人工智能在手机的应用_强化学习在人工