📄 twopl.so
字号:
m4_comment([$Id: twopl.so,v 10.11 2001/05/22 19:39:32 bostic Exp $])m4_ref_title(Locking Subsystem, Locking with transactions: two-phase locking, two-phase @locking, lock/notxn, lock/cam_conv)m4_p([dnlm4_db uses a locking protocol called m4_italic(two-phase locking (2PL)). Thisis the traditional protocol used in conjunction with lock-based transactionsystems.])m4_p([dnlIn a two-phase locking system, transactions are divided into twodistinct phases. During the first phase, the transaction only acquireslocks; during the second phase, the transaction only releases locks.More formally, once a transaction releases a lock, it may not acquireany additional locks. Practically, this translates into a system inwhich locks are acquired as they are needed throughout a transactionand retained until the transaction ends, either by committing oraborting. In m4_db, locks are released during m4_ref(txn_abort) orm4_ref(txn_commit). The only exception to this protocol occurs when weuse lock-coupling to traverse a data structure. If the locks are heldonly for traversal purposes, it is safe to release locks beforetransactions commit or abort.])m4_p([dnlFor applications, the implications of 2PL are that long-runningtransactions will hold locks for a long time. When designingapplications, lock contention should be considered. In order to reducethe probability of deadlock and achieve the best level of concurrencypossible, the following guidelines are helpful.])m4_nlistbeginm4_nlist([dnlWhen accessing multiple databases, design all transactions so that theyaccess the files in the same order.])m4_nlist([dnlIf possible, access your most hotly contested resources last (so thattheir locks are held for the shortest time possible).])m4_nlist([dnlIf possible, use nested transactions to protect the parts of yourtransaction most likely to deadlock.])m4_nlistendm4_page_footer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -