回滚段中保存的回滚数据有个作用一致读和回滚回滚段是由连续block组成的区间extent组成回滚段有顺序的循环的使用这些区间当当前区间写满的时候oracle移向下一个区间 如一个回滚段有个区间ABCD;当区间C被写满的时候oracle将写区间D而当D写满的时候oracle将尝试重新写区间A这样循环的有顺序的使用区间
事务必须将回滚信息写到回滚段中事务的当前新产生的回滚信息写在该回滚段的位置叫做回滚段的head 而在该回滚段上最早发生的尚未提交的事务最早产生的回滚信息所在位置叫做回滚段的tail 当前区间写满的时候oracle移动head到下一个区间
i时每个事务只能使用一个回滚段Oracle会根据回滚段workload平均将事务分配给各个回滚段在回滚段使用上的一些规则
一个事务只能使用一个回滚段
多个事务可以共用一个区间但Active的事务不能共用一个block
回滚段的current extent写满的时候回滚段的Head不能够移动到回滚段tail所在的区间
区间总是被有顺序的循环的时候当head移动的时候不会跳跃区间只能移动到下一个区间
如果head不能够使用下一个区间(如tail在下一个区间)将会分配一个新的区间extent并将新区间extent插入到这个循环使用的extent圈中这叫做回滚段的扩展
ORA snapshot too old主要是在一致读和延迟块清除delay block cleanout的时候产生
[参考]一致读的步骤
Read the Data Block
Read the Row Header
Check the Lock Byte to determine whether theres an ITL entry
Read the ITL entry to determine the Transaction ID (Xid)
Read the Transaction Table using the Transaction ID If the transaction has been committed and has a System Commit Number less than the querys System Change Number update the status of the block (block cleanout) and start over at step
第步细分
IF 在Transaction Table 中根据Transaction ID 找到transaction
IF transaction 已经commit
IF query scn>commit scn
则接受该块进行clean out返回
ELSEIF query scn
则进行一致性读从第步向后执行
ELSEIF transaction 没有commit
也进行一致性读从第步向后执行
ELSEIF 在Transaction Table 中没有找到transaction(undo header中的transaction slot被覆盖了也说明事务已经提交因为只有提交后所在的transaction slot才能被覆盖这样query scn则去比较control scn在该回滚段上control scn以前的transaction都已经被提交也就是事务表中所能找到的最小的commit scn了)
IF query scn
则无法知道query scn和commit scn得大小关系出现ORA错误
IF query scn>control scn
则query scn肯定>commit scn
则接受该块进行clean out并将block 中ITL标记上U表示upper bound commit 并返回
Read the last undo block (Uba)
Compare the block transaction ID with the transaction table transaction ID If the Transaction ID in the undo block doesnt equal the Transaction ID from the Transaction Table then issue ORA Snapshot Too Old 表示回滚段中回滚信息被覆盖无法为一致读提供必需的before image
If the Transaction IDs are identical make a copy of the data block in memory Starting with the head undo entry apply the changes to the copied data block
If the tail undo entry (the actual first undo entry in the chain or the last in the chain going backwards!) indicates another data block address read the indicated undo block into memory and repeat steps and until the undo entries dont contain a value for the data block address
When theres no previous data block address the transaction has been completely undone
If the undo entry contains:
a a pointer to a previous transaction undo block address read the Transaction ID in the previous transaction undo block header and read the appropriate Transaction Table entry Return to step
b an ITL record restore the ITL record to the data block Return to step
出现的时候首先判断是哪个原因导致可以设置event如果因为transaction slot被覆盖导致则增加回滚段数目如果因为回滚信息被覆盖则增加回滚大大小错误比较复杂通常需要考虑很多问题
event = trace name processstate forever level
That will give you a process state dump for any process that gets an ORA error The dump will show you which block the process was trying to rollback to its snapshot SCN If its a rollback segment header block then you have your proof see more from