📄 atomicity.so
字号:
m4_comment([$Id: atomicity.so,v 10.3 2002/05/17 15:48:41 bostic Exp $])m4_ref_title(m4_tam Applications, Atomicity,, transapp/put, transapp/inc)m4_p([dnlThe second reason listed for using transactions was m4_italic(atomicity).Atomicity means that multiple operations can be grouped into a singlelogical entity, that is, other threads of control accessing the databasewill either see all of the changes or none of the changes. Atomicityis important for applications wanting to update two related databases(for example, a primary database and secondary index) in a singlelogical action. Or, for an application wanting to update multiplerecords in one database in a single logical action.])m4_p([dnlAny number of operations on any number of databases can be included ina single transaction to ensure the atomicity of the operations. Thereis, however, a trade-off between the number of operations included ina single transaction and both throughput and the possibility ofdeadlock. The reason for this is because transactions acquire locksthroughout their lifetime and do not release the locks until commit orabort time. So, the more operations included in a transaction, the morelikely it is that a transaction will block other operations and thatdeadlock will occur. However, each transaction commit requires asynchronous disk I/O, so grouping multiple operations into a transactioncan increase overall throughput. (There is one exception to this: them4_ref(DB_TXN_WRITE_NOSYNC) and m4_ref(DB_TXN_NOSYNC) flags causetransactions to exhibit the ACI (atomicity, consistency and isolation)properties, but not D (durability); avoiding the write and/orsynchronous disk I/O on transaction commit greatly increases transactionthroughput for some applications.)])m4_p([dnlWhen applications do create complex transactions, they often avoidhaving more than one complex transaction at a time because simpleoperations like a single m4_ref(dbh_put) are unlikely to deadlock witheach other or the complex transaction; while multiple complextransactions are likely to deadlock with each other because they willboth acquire many locks over their lifetime. Alternatively, complextransactions can be broken up into smaller sets of operations, and eachof those sets may be encapsulated in a nested transaction. Becausenested transactions may be individually aborted and retried withoutcausing the entire transaction to be aborted, this allows complextransactions to proceed even in the face of heavy contention, repeatedlytrying the suboperations until they succeed.])m4_p([dnlIt is also helpful to order operations within a transaction; that is,access the databases and items within the databases in the same order,to the extent possible, in all transactions. Accessing databases anditems in different orders greatly increases the likelihood of operationsbeing blocked and failing due to deadlocks.])m4_page_footer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -