ITPub博客

首页 > 数字化转型 > ERP > Serializable Isolation (320)

Serializable Isolation (320)

原创 ERP 作者:tsinglee 时间:2007-12-06 12:14:40 0 删除 编辑

Serializable isolation is suitable for environments:
■ With large databases and short transactions that update only a few rows
■ Where the chance that two concurrent transactions will modify the same rows is
relatively low
■ Where relatively long-running transactions are primarily read only
Serializable isolation permits concurrent transactions to make only those database
changes they could have made if the transactions had been scheduled to run one after
another. Specifically, Oracle permits a serializable transaction to modify a data row
only if it can determine that prior changes to the row were made by transactions that
had committed when the serializable transaction began.

To make this determination efficiently, Oracle uses control information stored in the
data block that indicates which rows in the block contain committed and uncommitted
changes. In a sense, the block contains a recent history of transactions that affected
each row in the block. The amount of history that is retained is controlled by the
INITRANS parameter of CREATE TABLE and ALTER TABLE.

Under some circumstances, Oracle can have insufficient history information to
determine whether a row has been updated by a too recent transaction. This can occur
when many transactions concurrently modify the same data block, or do so in a very
short period. You can avoid this situation by setting higher values of INITRANS for
tables that will experience many transactions updating the same blocks. Doing so
enables Oracle to allocate sufficient storage in each block to record the history of
recent
transactions that accessed the block.

Oracle generates an error when a serializable transaction tries to update or delete data
modified by a transaction that commits after the serializable transaction began:
ORA-08177: Cannot serialize access for this transaction .

When a serializable transaction fails with the Cannot serialize access error, the
application can take any of several actions:
■ Commit the work executed to that point
■ Execute additional (but different) statements (perhaps after rolling back to a
savepoint established earlier in the transaction)
■ Undo the entire transaction

串行化隔离
1. 符合以下特性的系统适合采用串行化隔离:
* 数据量大,但事务短小,只更新少量数据行的数据库
* 两个并发事务修改相同数据的概率相对较少
* 运行时间相对较长的事务只执行只读操作
2. Oracle 在数据块内存储了相关的控制信息,用于记录此块内数据行中所包含的变化。
即数据块内记录了近段时间内对本数据块内数据行进行了修改的事务信息 , 能记录多少条这样的记录
有建表时的参数INITRANS决定
3.
当一个串行化事务试图更新或删除数据,而这些数据在此事务开始后被其他事务修改并进行了提交,
Oracle 将报错:事务不能串行化访问 .
解决方法 :
* 将错误发生点之前的操作提交
* 执行其他操作
* 撤销整个事务

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10599713/viewspace-989000/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    740
  • 访问量
    1892402