Oracle一致读的一些细节  

[参考]一致读的步骤
1. Read the Data Block.



2. Read the Row Header.



3. Check the Lock Byte todetermine whether theres an ITL entry.



4. Read the ITL entry to determinethe Transaction ID (Xid).



5. Read the Transaction Tableusing the Transaction ID. If the transaction has been committed and has aSystem Commit Number less than the querys System Change Number, update thestatus of the block (block cleanout) and start over at step 1.



第5步细分
---IF 在TransactionTable 中根据Transaction ID 找到transaction
-----------IF transaction 已经commit
----------------------IF queryscn>commit scn
------------------------------------则接受该块,进行clean out,返回1
------------------------ELSEIFquery scn
-------------------------------------则进行一致性读,从第6步向后执行
------------ELSEIF transaction 没有commit
------------------------也进行一致性读,从第6步向后执行
---ELSEIF 在Transaction Table 中没有找到transaction(undoheader中的transaction slot被覆盖了,也说明事务已经提交,因为只有提交后所在的transaction slot才能被覆盖。这样query scn则去比较control scn。在该回滚段上control scn以前的transaction都已经被提交,也就是事务表中所能找到的最小的commit scn了)
------------IF query scn
-----------------------则无法知道query scn和commit scn得大小关系,出现ORA-01555错误
------------IF queryscn>control scn
-----------------------则query scn肯定>commit scn
------------------------------------则接受该块,进行clean out,并将block 中ITL标记上“U”,表示“upper bound commit” ,并返回1



6. Read the last undo block (Uba).



7. Compare the block transactionID with the transaction table transaction ID. If the Transaction ID in the undoblock doesnt equal the Transaction ID from the Transaction Table, then issueORA-1555, Snapshot Too Old. 表示回滚段中回滚信息被覆盖,无法为一致读提供必需的beforeimage。


8. If the Transaction IDs areidentical, make a copy of the data block in memory. Starting with the head undoentry, apply the changes to the copied data block.



9. If the tail undo entry (theactual first undo entry in the chain, or the last in the chain goingbackwards!) indicates another data block address, read the indicated undo blockinto memory and repeat steps 7 and 8 until the undo entries dont contain a valuefor the data block address.



10. When theres no previous datablock address, the transaction has been completely undone.



11. If the undo entry contains:

a. a pointer to a previoustransaction undo block address, read the Transaction ID in the previoustransaction undo block header and read the appropriate Transaction Table entry.Return to step 5.
b. an ITL record, restore the ITLrecord to the data block. Return to step 4.



出现1555的时候,首先判断是哪个原因导致,可以设置event;如果因为transaction slot被覆盖导致,则增加回滚段数目;如果因为回滚信息被覆盖,则增加回滚大大小。1555错误比较复杂,通常需要考虑很多问题。


event = 1555 trace nameprocessstate forever, level 10



That will give you a process statedump for any process that gets an ORA-1555 error. The dump will show you whichblock the process was trying to rollback to its snapshot SCN. If its a rollbacksegment header block, then you have your proof. see more from
标签: 暂无标签
oraunix

写了 199 篇文章,拥有财富 1026,被 339 人关注

转播转播 分享分享 分享淘帖
回复

使用道具

P4 | 发表于 2011-3-2 00:28:08
Oracle一致读的一些细节
回复

使用道具

P4 | 发表于 2011-3-2 00:29:29
又明白了一点 嘿嘿~~~   又深刻了一些  感谢老师~~
回复

使用道具

P4 | 发表于 2011-3-2 01:26:12
学习学习~~
回复

使用道具

P3 | 发表于 2011-3-14 23:05:11
我只看明白了一部分。。。。继续学习ing
回复

使用道具

P4 | 发表于 2011-3-20 13:11:04
学习:)
回复

使用道具

游客 | 发表于 2011-4-13 10:07:11
第七步,没理解:
每一个回滚段块中都有一个事务id,记录哪个事务正在使用这个块。那么事务表中的事务ID就会等于undo 数据块中记录的事务ID。即使是回滚信息被覆盖了,这个undo 数据块中记录的事务ID,不还是和事务表中新的事务ID一致吗?
回复

使用道具

游客 | 发表于 2011-4-13 13:59:17
明白了,回滚信息被覆盖了,里面就记录了新的事物ID,此时去和旧的slot(还没有被覆盖)中事物ID比较,不一致就说明回滚信息被覆盖掉了。
回复

使用道具

P4 | 发表于 2012-6-11 15:15:25
以前一直不解,看了老师的解释,终于明白了一些
回复

使用道具

P4 | 发表于 2012-6-14 10:17:21
学习学习
回复

使用道具

您需要登录后才可以回帖 登录 | 加入社区

本版积分规则

意见
反馈