优秀的编程知识分享平台

网站首页 > 技术文章 正文

详解Oracle参数fast_start_parallel_rollback--并行回滚

nanyue 2024-08-19 19:04:20 技术文章 5 ℃

概述

最近因为PLSQL崩溃导致几千万的数据产生了回滚,大概有300多万块需要回滚,那么怎么去调整Oracle回滚的速度呢?


fast_start_parallel_rollback

回滚的速度快慢通过参数fast_start_parallel_rollback来实现,此参数可以动态调整

关于fast_start_parallel_rollback参数,此参数决定了回滚启动的并行次数,在繁忙的系统或者IO性能较差的系统,如果出现大量回滚操作,会显著影响系统系统,可以通过调整此参数来降低影响。官方文档的定义如下:

FAST_START_PARALLEL_ROLLBACK specifies the degree of parallelism used when recovering terminated transactions. Terminated transactions are transactions that are active before a system failure. If a system fails when there are uncommitted parallel DML or DDL transactions, then you can speed up transaction recovery during startup by using this parameter.

Values:

FALSE

Parallel rollback is disabled

LOW

Limits the maximum degree of parallelism to 2 * CPU_COUNT

HIGH

Limits the maximum degree of parallelism to 4 * CPU_COUNT

If you change the value of this parameter, then transaction recovery will be stopped and restarted with the new implied degree of parallelism.


回滚进度

回滚过程中,回滚的进度可以通过视图V$FAST_START_TRANSACTIONS来确定:

select usn,
 state,
 undoblocksdone,
 undoblockstotal,
 CPUTIME,
 pid,
 xid,
 rcvservers
 from v$fast_start_transactions;
--或者以下sql
select ktuxeusn USN, ktuxeslt Slot, ktuxesqn Seq, ktuxesta State, ktuxesiz Undo from sys.ktuxe
 where ktuxesta <> 'INACTIVE'
 and ktuxecfl like '%DEAD%'
 order by ktuxesiz asc;

说明:

  • USN:事务对应的undo段
  • STATE:事务的状态,可选的值为(BE RECOVERED, RECOVERED, or RECOVERING)
  • UNDOBLOCKSDONE:已经完成的undo块
  • UNDOBLOCKSTOTAL:总的undo数据块
  • CPUTIME:已经回滚的时间,单位是秒
  • RCVSERVERS:回滚的并行进程数

计算回滚时间

通过以下sql可以计算回滚的实际时间,不过不是很准确的,这个时间一般会慢慢变少。

select undoblockstotal "Total", undoblocksdone "Done", undoblockstotal-undoblocksdone
"ToDo",decode(cputime,0,'unknown',to_char(sysdate+(((undoblockstotal-undoblocksdone)
/ (undoblocksdone / cputime)) / 86400),'yyyy-mm-dd hh24:mi:ss'))
"Estimated time to complete",to_char(sysdate,'yyyy-mm-dd hh24:mi:ss')
from v$fast_start_transactions;

加快undo回滚

为了加快undo回滚的速度,可以通过设置fast_start_parallel_rollback,在线修改,立即生效

alter system set fast_start_parallel_rollback=HIGH scope=both;

后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下!

最近发表
标签列表