溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

參數(shù)fast_start_parallel_rollback調(diào)整oracle回滾的速度

發(fā)布時(shí)間:2020-08-16 00:52:50 來源:ITPUB博客 閱讀:275 作者:不一樣的天空w 欄目:關(guān)系型數(shù)據(jù)庫
https://blog.csdn.net/hijk139/article/details/21543127

回滾的速度快慢通過參數(shù)fast_start_parallel_rollback來實(shí)現(xiàn),此參數(shù)可以動態(tài)調(diào)整

參數(shù)fast_start_parallel_rollback決定了回滾啟動的并行次數(shù),在繁忙的系統(tǒng)或者IO性能較差的系統(tǒng),如果出現(xiàn)大量回滾操作,會顯著影響系統(tǒng)系統(tǒng),可以通過調(diào)整此參數(shù)來降低影響。官方文檔的定義如下:

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.  


回滾過程中,回滾的進(jìn)度可以通過視圖V$FAST_START_TRANSACTIONS來確定

SQL> select usn, state, undoblocksdone, undoblockstotal, CPUTIME, pid,xid, rcvservers from v$fast_start_transactions;

       USN STATE            UNDOBLOCKSDONE UNDOBLOCKSTOTAL    CPUTIME        PID XID              RCVSERVERS
---------- ---------------- -------------- --------------- ---------- ---------- ---------------- ----------
       454 RECOVERED                110143          110143        210            01C600210027E0D9          1
       468 RECOVERED                   430             430         17            01D40000001F3A36        128
       
USN:事務(wù)對應(yīng)的undo段
STATE:事務(wù)的狀態(tài),可選的值為(BE RECOVERED, RECOVERED, or RECOVERING)       
UNDOBLOCKSDONE:事物中已經(jīng)完成的undo塊
UNDOBLOCKSTOTAL:總的需要recovery的undo數(shù)據(jù)塊
CPUTIME:已經(jīng)回滾的時(shí)間,單位是秒
RCVSERVERS:回滾的并行進(jìn)程數(shù)


--補(bǔ)充,查詢回滾時(shí)間更好的腳本  
SQL> select undoblockstotal "Total",
       undoblocksdone "Done",
       undoblockstotal - undoblocksdone "ToDo",
       decode(cputime,
              0,
              'unknown',
              to_char(sysdate + (((undoblockstotal - undoblocksdone) /
                      (undoblocksdone / cputime)) / 86400),
                      'yyyy-mm-dd hh34:mi:ss')) "Estimated time to complete",to_char(sysdate, 'yyyy-mm-dd hh34:mi:ss')
  from v$fast_start_transactions;
      
     Total  MB       Done       ToDo Estimated time to complete             TO_CHAR(SYSDATE,'YYYY-MM-DDHH24:MI:SS'  
    ---------- ---------- ---------- -------------------------------------- --------------------------------------  
        36,767      36767          0 2014-03-19 16:59:19                    2014-03-19 16:59:19  
         7,209       7209          0 2014-03-19 16:59:19                    2014-03-19 16:59:19  
         3,428       3428          0 2014-03-19 16:59:19                    2014-03-19 16:59:19  
        34,346       1604      32742 2014-03-19 17:25:31                    2014-03-19 16:59:19  


下面是一次大量wait for a undo record等待事件的處理過程

1,某用戶使用plsql執(zhí)行某 insert操作異常,導(dǎo)致表空間不斷增長,于是手工kill該回滾停掉,kill后大量wait for a undo record,大約100多個(gè)


2,查詢v$fast_start_transactions視圖,由于fast_start_parallel_rollback參數(shù)設(shè)置為HIGH,且cpu為32個(gè),因此并行進(jìn)程為32×4=128個(gè)

SQL> select usn, state, undoblocksdone, undoblockstotal, CPUTIME, pid,xid, rcvservers from v$fast_start_transactions;  
 
       USN STATE            UNDOBLOCKSDONE UNDOBLOCKSTOTAL    CPUTIME        PID XID              RCVSERVERS  
---------- ---------------- -------------- --------------- ---------- ---------- ---------------- ----------  
       454 RECOVERING                26922          464160        103       3744 01C600210027E0D9        128  
       468 RECOVERED                   430             430         17            01D40000001F3A36        128         
         
SQL> SHOW parameter ROLLBACK  
 
NAME                                 TYPE                             VALUE  
------------------------------------ -------------------------------- ------------------------------  
fast_start_parallel_rollback         string                           HIGH  
 
SQL> show parameter cpu  
 
NAME                                 TYPE                             VALUE  
------------------------------------ -------------------------------- ------------------------------  
cpu_count                            integer                          32  


3,由于估計(jì)還有103/(26922/464160)=30分鐘才能執(zhí)行完,為了降低對系統(tǒng)性能的影響,對相關(guān)表進(jìn)行了truncate(業(yè)務(wù)表中的數(shù)據(jù)不再需要)

SQL> truncate table user1.JT_t1_20140318;

4,truncate時(shí),短時(shí)間內(nèi)出現(xiàn)了row cache lock異常等待,大約幾十秒之后,恢復(fù)正常,truncat操作能結(jié)束undo回滾操作嗎?

5,其實(shí)為了減少undo的影響,可以通過設(shè)置fast_start_parallel_rollback,可以在線修改,立即生效

alter system set fast_start_parallel_rollback= FALSE;

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI