溫馨提示×

溫馨提示×

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

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

RAC等待事件:gc buffer busy acquire

發(fā)布時間:2020-08-11 16:22:46 來源:ITPUB博客 閱讀:330 作者:q499311546 欄目:關系型數(shù)據(jù)庫
今天監(jiān)控一直報等待事件異常,查了下數(shù)據(jù)庫基本都是gc buffer busy acquire等待事件。這個等待事件之前一直沒接觸過,今天特意了解下。
參考文檔:Oracle Mos
一、簡要定義
該等待事件僅適用于RAC環(huán)境,類似于非RAC環(huán)境中的"buffer busy"等待。
當會話正在等待訪問另外一個會話正在適用和持有的塊且無法共享該塊時,會發(fā)生這種情況。多個會話可能會排隊等待同一個塊。
在11.1和更早版本中,這種類型的等待被分為"gc buffer busy"等待。
從Oracle 11.2開始"gc buffer busy"等待被分為兩個新的等待類別:
  • gc buffer busy acquire
  • gc buffer busy release
gc buffer busy acquire:是當session 1嘗試請求訪問遠程實例(remote instance)的buffer,但是session 1之前已經(jīng)有相同實例上的另外一個session 2正在請求訪問了相同的buffer,并且沒有完成,那么session 1就是在等待gc buffer busy acquire。

gc buffer busy release:是在本地實例session 1之前已經(jīng)有遠程實例session 2請求訪問了本地實例的相同buffer,并且沒有完成,那么本地實例的session 1就是在等待gc buffer busy release。

二、一般原因
  • High contention in particular HOT blocks of the objects
  •  Other waits like "gc block busy" and "enq: TX - row lock contention
  • High network latency or a problem with network
  • Busy server or active paging/swapping due to low free memory

Individual waits-(用于在GV$SESSION_WAIT中看到的等待)

P1                 File #
P2                 Block #
P3                 Mode requested/mode held/block class
SECONDS_IN_WAIT    Amount of time waited for the current event
file#              This is the file# of the file that Oracle is trying to read from.
block#             This is the starting block number in the file from where Oracle starts reading the blocks.
blocks             This parameter specifies the number of blocks that Oracle is rying to read from the file# starting at block#
Inst_id            instance number
To determine the root blocker for sessions waiting on the gc wait events use the below options
1.system state dump at cluster level
2. oratop displays waiters/blockers
3. v$wait_chains can be used to find the root blocker for sessions that are blocked,Troubleshooting Database Contention With V$Wait_Chains (Doc ID 1428210.1)
4. Using v$hang_info, v$hang_session_info, etc
5. Oracle Hang Manager (Doc ID 1534591.1)
Using the above information we can find the sessions waiting for specific gc events with their final blockers at instance level

System Wide wait-(用于在V$SYSTEM_EVNET中看到的等待)

如果等待緩沖區(qū)花費的時間較長,則需要根據(jù)以下內(nèi)容確定哪個段遭受爭用:
SELECT inst_id,
       sid,
       event,
       wait_class,
       P1,
       P2,
       P3 Mode requested / mode held / block class,
       seconds_in_wait
  FROM gv$session_wait
 WHERE event LIKE 'gc buffer%';
從前面的輸出中,使用P1和P2中的數(shù)據(jù),可以使用以下命令獲得相關的對象信息以下查詢:
SELECT segment_name
  FROM dba_extents
 WHERE file_id = &file
   AND &block BETWEEN block_id AND block_id + blocks - 1
   AND ROWNUM = 1;
三、故障排查
1)特定HOT塊的爭用較高
這是由于大量并發(fā)插入導致過多的索引塊拆分或帶有從序列生成的鍵的右增長索引。
buffer busy 會頻繁伴隨著這一點。如果問題仍然存在,可以使用 System Wide wait-(用于在V$SYSTEM_EVNET中看到的等待)說明尋找熱塊。或者從問題時期的AWR報告的 Segments by Global Cache Buffer Busy獲取問題segment。

2)gc block busy、enq: TX - row lock contention以及其他等待可能會影響阻止會話或者LMS進程。

如果還有其他等待可能會使塊的持有者放慢速度,則解決該問題是當務之急,因為gc buffer busy acquire/release可能只是該等待的副作用。
檢查AWR報告中的 Top 10 Foreground Events by Total Wait Time部分,以查看其他等待是否顯著影響數(shù)據(jù)庫的性能。

3)高網(wǎng)絡延遲或網(wǎng)絡問題

發(fā)出 "ping -s 10000 <數(shù)據(jù)庫使用的HAIP IP地址或私有IP地址>"并按照文檔執(zhí)行網(wǎng)絡檢查( How to Validate Network and Name Resolution Setup for the Clusterware and RAC (Doc ID 1054902.1))
對于過去發(fā)生的問題的RCA,請檢查OSWatcher以獲取ping延遲時間。
AWR報告將包含 Interconnect Ping Latency Stats,這對于檢查網(wǎng)絡延遲也很有用。
OSWatcher中的netstat和CHM輸出中的Nic&Protocol部分可以提供有關網(wǎng)絡運行狀況的信息。

4)繁忙的服務器或活動的頁面調(diào)度/交換(由于可用內(nèi)存不足)

檢查vmstat輸出或CHM輸出,以查看服務器是否繁忙或大量的分頁/交換。
對于過去發(fā)生的問題的RCA,請檢查CHM或OSWatcher輸出。

5)低效SQL語句

低效SQL語句會導致不必要的buffer被請求訪問,增加了buffer busy的機會。在AWR中可以找到TOP SQL。解決方法可以優(yōu)化SQL語句減少buffer訪問。這點與單機數(shù)據(jù)庫中的buffer busy waits類似。
關于select是否會導致gc buffer busy acquire:
  • 查詢一般以shared模式請求buffer,但是如果buffer不在buffer cache中,那么需要IO將buffer 讀到內(nèi)存中,這個過程需要以exclusive模式,如果同時有大量其他的session也請求查詢該buffer(以shared 模式請求),那么就會有buffer等待了,此時可能buffer cache不夠大。
  • 如果查詢請求的block已經(jīng)被修改了,查詢需要訪問CR塊,為了重構CR塊,需要讀取對應的undo block,如果undo block不在buffer中,需要IO把undo block讀到內(nèi)存,如果有大量查詢訪問這個CR塊,那么都會有buffer busy等待了。
6)數(shù)據(jù)在節(jié)點間交叉訪問
RAC數(shù)據(jù)庫,同一數(shù)據(jù)在不同數(shù)據(jù)庫實例上被請求訪問。
如果應用程序可以實現(xiàn),那么我們建議不同的應用功能/模塊數(shù)據(jù)分布在不同的數(shù)據(jù)庫實例上被訪問,避免同一數(shù)據(jù)被多個實例交叉訪問,可以減少buffer的爭用,避免gc等待。

7)Oracle  Bug

四、可能的解決方案
對于高爭用和熱塊:
Solution is to reorganize the index in a way to avoid the contention or hot spots using the below options
I. Global Hash partition the index
CREATE INDEX hgidx ON tab (c1,c2,c3) GLOBAL
     PARTITION BY HASH (c1,c2)
     (PARTITION p1  TABLESPACE tbs_1,
      PARTITION p2  TABLESPACE tbs_2,
      PARTITION p3  TABLESPACE tbs_3,
      PARTITION p4  TABLESPACE tbs_4);
II. Recreate the index as reverse key index (not suitable for large table, could require buffer cache increased accordingly)
III. If index key is generated from a sequence, increase cache size of the sequence and make the sequence 'no order' if application supports it.
Refer the doc link: http://docs.oracle.com/database/121/VLDBG/GUID-BF3F38E1-62BB-4EE3-86C1-A2EF8A258B1F.htm#VLDBG1089

對于enq: TX - row lock contention:

Mode 4-Related to ITL waits
從AWR報告或使用以下SQL查找具有較高ITL等待的段:
SELECT OWNER, OBJECT_NAME, OBJECT_TYPE
  FROM V$SEGMENT_STATISTICS
 WHERE STATISTIC_NAME = 'ITL waits'
   AND VALUE > 0
 ORDER BY VALUE;
增加這些高ITL等待的segment的inittrans值
Mode 6-Primarily due to application issue:
這是一個應用程序問題,需要應用程序開發(fā)人員來調(diào)查所涉及的SQL語句。 以下文檔可能有助于進一步深入研究:
Note:102925.1 - Tracing sessions: waiting on an enqueue
Note:179582.1 - How to Find TX Enqueue Contention in RAC or OPS
Note:1020008.6 - SCRIPT: FULLY DECODED LOCKING
Note:62354.1 - TX Transaction locks - Example wait scenarios
Note:224305.1 -Autonomous Transaction can cause locking

How to Validate Network and Name Resolution Setup for the Clusterware and RAC (Doc ID 1054902.1)

RAC等待事件:gc buffer busy acquire How to Validate Network and Name Resolution Setup for the Clusterware and RAC (Doc ID 1054902.1).pdf

向AI問一下細節(jié)

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

AI