⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 read.so

📁 berkeley db 4.6.21的源码。berkeley db是一个简单的数据库管理系统
💻 SO
字号:
m4_comment([$Id: read.so,v 1.14 2006/09/13 14:30:56 mjc Exp $])m4_ref_title(m4_tam Applications,    Degrees of isolation,, transapp/inc, transapp/cursor)m4_idefz(repeatable reads)m4_p([dnlTransactions can be isolated from each other to different degrees.m4_italic(Serializable) provides the most isolation, and means that, forthe life of the transaction, every time a thread of control reads a dataitem, it will be unchanged from its previous value (assuming, of course,the thread of control does not itself modify the item).  By default,m4_db enforces serializability whenever database reads are wrapped intransactions.  This is also known as m4_italic(degree 3 isolation).])m4_p([dnlMost applications do not need to enclose all reads in transactions, andwhen possible, transactionally protected reads at serializable isolationshould be avoided as they can cause performance problems.  For example,a serializable cursor sequentially reading each key/data pair in adatabase, will acquire a read lock on most of the pages in the databaseand so will gradually block all write operations on the databases untilthe transaction commits or aborts.  Note, however, that if there areupdate transactions present in the application, the read operations muststill use locking, and must be prepared to repeat any operation(possibly closing and reopening a cursor) that fails with a return valueof m4_ref(DB_LOCK_DEADLOCK).  Applications that need repeatable readsare ones that require the ability to repeatedly access a data itemknowing that it will not have changed (for example, an operationmodifying a data item based on its existing value).])m4_p([dnlm4_italic(Snapshot isolation) also guarantees repeatable reads, butavoids read locks by using multiversion concurrency control (MVCC).This makes update operations more expensive, because they have toallocate space for new versions of pages in cache and make copies, butavoiding read locks can significantly increase throughput for manyapplications.  Snapshot isolation is discussed in detail below.])m4_idefz(cursor @stability)m4_idefz(cursor stability)m4_idefz(degree 2 @isolation)m4_idefz(degree 2 isolation)m4_p([dnlA transaction may only require m4_italic(cursor stability), that is onlybe guaranteed that cursors see committed data that does not change solong as it is addressed by the cursor, but may change before the readingtransaction completes.  This is also called m4_italic(degree 2isolation).  m4_db provides this level of isolation when a transactionis started with the m4_ref(DB_READ_COMMITTED) flag.  This flag may alsobe specified when opening a cursor within a fully isolatedtransaction.])m4_idefz(degree 1 @isolation)m4_idefz(degree 1 isolation)m4_idefz(dirty @reads)m4_idefz(dirty reads)m4_p([dnlm4_db optionally supports reading uncommitted data; that is, readoperations may request data which has been modified but not yetcommitted by another transaction.  This is also called m4_italic(degree1 isolation).  This is done by first specifying them4_ref(DB_READ_UNCOMMITTED) flag when opening the underlying database,and then specifying the m4_ref(DB_READ_UNCOMMITTED) flag when beginninga transaction, opening a cursor, or performing a read operation.  Theadvantage of using m4_ref(DB_READ_UNCOMMITTED) is that read operationswill not block when another transaction holds a write lock on therequested data; the disadvantage is that read operations may return datathat will disappear should the transaction holding the write lockabort.])m4_idefz(snapshot isolation)m4_idefz(multiversion concurrency control)m4_idefz(MVCC)m4_section([Snapshot Isolation])m4_p([dnlTo make use of snapshot isolation, databases must first be configuredfor multiversion access by calling m4_ref(dbh_open) with them4_ref(DB_MULTIVERSION) flag.  Then transactions or cursors must beconfigured with the m4_ref(DB_TXN_SNAPSHOT) flag.])m4_p([dnlWhen configuring an environment for snapshot isolation, it is importantto realize that having multiple versions of pages in cache means thatthe working set will take up more of the cache.  As a result, snapshotisolation is best suited for use with larger cache sizes.])m4_p([dnlIf the cache becomes full of page copies before the old copies can bediscarded, additional I/O will occur as pages are written to temporary"freezer" files.  This can substantially reduce throughput, and shouldbe avoided if possible by configuring a large cache and keeping snapshotisolation transactions short.  The amount of cache required to avoidfreezing buffers can be estimated by taking a checkpoint followed by acall to m4_ref(log_archive).  The amount of cache required isapproximately double the size of logs that remains.])m4_p([dnlThe environment should also be configured for sufficient transactionsusing m4_ref(dbenv_set_tx_max).  The maximum number of transactionsneeds to include all transactions executed concurrently by theapplication plus all cursors configured for snapshot isolation.Further, the transactions are retained until the last page they createdis evicted from cache, so in the extreme case, an additional transactionmay be needed for each page in the cache.])m4_p([dnlSo when m4_italic(should) applications use snapshot isolation?m4_bulletbeginm4_bullet([dnlThere is a large cache relative to size of updates performed byconcurrent transactions; and])m4_bullet([dnlRead/write contention is limiting the throughput of the application;or])m4_bullet([dnlThe application is all or mostly read-only, and contention for the lockmanager mutex is limiting throughput.])m4_bulletend])m4_p([dnlThe simplest way to take advantage of snapshot isolation is for queries:keep update transactions using full read/write locking and setm4_ref(DB_TXN_SNAPSHOT) on read-only transactions or cursors.  Thisshould minimize blocking of snapshot isolation transactions and willavoid introducing new m4_ref(DB_LOCK_DEADLOCK) errors.])m4_p([dnlIf the application has update transactions which read many items andonly update a small set (for example, scanning until a desired record isfound, then modifying it), throughput may be improved by running someupdates at snapshot isolation as well.])m4_page_footer

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -