当前位置:Gxlcms > 数据库问题 > 生产上数据库大量的latch free 导致的CPU资源耗尽的问题的解决

生产上数据库大量的latch free 导致的CPU资源耗尽的问题的解决

时间:2021-07-01 10:21:17 帮助过:18人阅读


 The content was last updated on: 01-APR-2008
 Click 

cs=UTF-8" style="text-decoration:none; color:rgb(0,130,255); outline-width:medium; padding-bottom:0px; padding-top:0px; outline-style:none; padding-left:0px; outline-color:invert; padding-right:0px">here for details of each of the sections below.

Affects:

Product (Component) Oracle Server (Rdbms)
Range of versions believed to be affected Versions < 11.2
Versions confirmed as being affected
  • cs=UTF-8" style="text-decoration:none; color:rgb(0,130,255); outline-width:medium; padding-bottom:0px; padding-top:0px; outline-style:none; padding-left:0px; outline-color:invert; padding-right:0px">10.2.0.3

Platforms affected Generic (all / most platforms affected)

Fixed:

This issue is fixed in
  • cs=UTF-8" style="text-decoration:none; color:rgb(0,130,255); outline-width:medium; padding-bottom:0px; padding-top:0px; outline-style:none; padding-left:0px; outline-color:invert; padding-right:0px">11.2 (Future Release)

  • cs=UTF-8" style="text-decoration:none; color:rgb(0,130,255); outline-width:medium; padding-bottom:0px; padding-top:0px; outline-style:none; padding-left:0px; outline-color:invert; padding-right:0px">10.2.0.4 (Server Patch Set)

  • cs=UTF-8" style="text-decoration:none; color:rgb(0,130,255); outline-width:medium; padding-bottom:0px; padding-top:0px; outline-style:none; padding-left:0px; outline-color:invert; padding-right:0px">11.1.0.7 (Server Patch Set)

Symptoms:

Related To:

  • cs=UTF-8" style="text-decoration:none; color:rgb(0,130,255); outline-width:medium; padding-bottom:0px; padding-top:0px; outline-style:none; padding-left:0px; outline-color:invert; padding-right:0px">Latch Contention

  • cs=UTF-8" style="text-decoration:none; color:rgb(0,130,255); outline-width:medium; padding-bottom:0px; padding-top:0px; outline-style:none; padding-left:0px; outline-color:invert; padding-right:0px">Waits for "latch free"

  • cs=UTF-8" style="text-decoration:none; color:rgb(0,130,255); outline-width:medium; padding-bottom:0px; padding-top:0px; outline-style:none; padding-left:0px; outline-color:invert; padding-right:0px">Performance Monitoring

  • DB_CACHE_ADVICE

Description

High simulator lru latch contention can occur when db_cache_advice is
set to ON if there is a large buffer cache.


Workaround:
  Set db_cache_advice to OFF

当然,这个仅仅是治标不治本的做法,这个是显现的表象的问题。根源的问题还是这个sql语句有问题

当一个数据块读入到sga中时,该块的块头(buffer header)会放置在一个hash bucket的链表(hash chain)中。该内存结构由一系列cache buffers chains子latch保护(又名hash latch或者cbc latch)。对Buffer cache中的块,要select或者update、insert,delete等。都得先获得cache buffers chains子latch,以保证对chain的排他訪问。

若在过程中发生争用,就会等待latch:cache buffers chains事件。

产生原因: 1. 低效率的SQL语句(主要体如今逻辑读过高) 在某些环境中,应用程序打开运行同样的低效率SQL语句的多个并发会话。这些SQL语句都设法得到同样的数据集,每次运行都带有高 BUFFER_GETS(逻辑读取)的SQL语句是基本的原因。

相反,较小的逻辑读意味着较少的latch get操作,从而降低锁存器争用并改善性能。注意v$sql中BUFFER_GETS/EXECUTIONS大的语句。 2.Hot block 当多个会话反复訪问一个或多个由同一个子cache buffers chains锁存器保护的块时。热块就会产生。

当多个会话争用cache buffers chains子锁存器时,就会出现这个等待事件。有时就算调优了SQL,但多个会话同一时候运行此SQL,那怕仅仅是扫描特定少数块,也是也会出现HOT BLOCK的。

SELECT P935.SEQUENCEID,
       null FA_SEQUENCEID,
       P935.ORDERID,
       P935.ORGORDERID,
       P935.PRODUCTNAME,
       P935.PRODUCTNUM,
       P935.ORDERTIME,
       P935.LASTUPDATETIME,
       P935.ORDERSTATUS,
       P935.MEMO,
       935 orderCode,
       P935.PAYERACCTCODE,
       P935.PAYERACCTTYPE,
       P935.PAYEEACCTCODE PLATACCTCODE,
       P935.PAYEEACCTTYPE PLATACCTTYPE,
       P936.PAYEEACCTCODE,
       P936.PAYEEACCTTYPE,
       EXT935.PAYER_DISPLAYNAME,
       EXT935.PAYER_NAME,
       EXT935.PAYER_IDC,
       EXT935.PAYER_MEMBERTYPE,
       EXT936.PAYER_DISPLAYNAME PLAT_DISPLAYNAME,
       EXT936.SUBMITNAME PLAT_NAME,
       EXT936.PAYER_IDC PLAT_IDC,
       EXT936.PAYER_MEMBERTYPE PLAT_MEMBERTYPE,
       EXT936.PAYEE_DISPLAYNAME,
       EXT936.PAYEE_NAME,
       EXT936.PAYEE_IDC,
       EXT936.PAYEE_MEMBERTYPE,
       P935.PAYEEDISPLAYNAME WEBSITENAME,
       CASE
         WHEN (SELECT count(*)
                 FROM PAYMENTORDER P936
                WHERE P936.Ordercode = 936
                  and P936.Orderstatus = 0
                  AND <span style="color:#ff0000;">P936.Relatedsequenceid = P935.SEQUENCEID</span>) > 0 THEN
          0
         ELSE
          1
       END AS SHARINGRESULT,
       CASE D935.Dealcode
         WHEN 210 then
          14
         else
          D935.DEALTYPE
       end PAYMETHOD,
       D935.DEALAMOUNT,
       G935.EXT1,
       G935.Ext2,
       G935.PAYERCONTACTTYPE,
       G935.PAYERCONTACT,
       NVL(D935.PAYEEFEE, 0) PAYEEFEE,
       NVL(D935.PAYERFEE, 0) PAYERFEE,
       nvl(MS936.PAYEEFEE, 0) PLATFORMFEE,
       P935.VERSION
  FROM PAYMENTORDER          P935,
       PAYMENTORDER          P936,
       DEAL                  D935,
       GATEWAYORDER          G935,
       MSGATEWAYSHARINGORDER MS936,
       PAYMENTORDEREXT       EXT935,
       PAYMENTORDEREXT       EXT936
 WHERE P936.ORDERCODE = 936
   AND P935.ORDERCODE = 935
   AND P936.RELATEDSEQUENCEID = to_char(P935.SEQUENCEID)
   AND P935.SEQUENCEID = G935.SEQUENCEID(+)
   AND P935.SEQUENCEID = D935.ORDERSEQID(+)
   AND P935.SEQUENCEID = EXT935.ORDERSEQID(+)
   AND P936.SEQUENCEID = EXT936.ORDERSEQID(+)
   AND P936.SEQUENCEID = MS936.SEQUENCEID(+)
   AND MS936.SHARINGTYPE = 1
   AND P935.SEQUENCEID = :1
UNION
SELECT P938.SEQUENCEID,
       P935.SEQUENCEID FA_SEQUENCEID,
       P938.ORDERID,
       P938.ORGORDERID,
       P935.PRODUCTNAME,
       P935.PRODUCTNUM,
       P938.ORDERTIME,
       P938.LASTUPDATETIME,
       P938.ORDERSTATUS,
       P938.MEMO,
       938 orderCode,
       P938.PAYERACCTCODE,
       P938.PAYERACCTTYPE,
       P938.PAYEEACCTCODE PLATACCTCODE,
       P938.PAYEEACCTTYPE PLATACCTTYPE,
       P938.PAYEEACCTCODE,
       P938.PAYEEACCTTYPE,
       EXT938.PAYER_DISPLAYNAME,
       EXT938.PAYER_NAME,
       EXT938.PAYER_IDC,
       EXT938.PAYER_MEMBERTYPE,
       EXT938.PAYEE_DISPLAYNAME PLAT_DISPLAYNAME,
       EXT938.SUBMITNAME PLAT_NAME,
       EXT938.PAYEE_IDC PLAT_IDC,
       EXT938.PAYEE_MEMBERTYPE PLAT_MEMBERTYPE,
       EXT938.PAYEE_DISPLAYNAME,
       EXT938.PAYEE_NAME,
       EXT938.PAYEE_IDC,
       EXT938.PAYEE_MEMBERTYPE,
       P935.PAYEEDISPLAYNAME WEBSITENAME,
       null SHARINGRESULT,
       D938.DEALTYPE PAYMETHOD,
       D938.DEALAMOUNT,
       G935.EXT1,
       G935.Ext2,
       G935.PAYERCONTACTTYPE,
       G935.PAYERCONTACT,
       NVL(D938.PAYEEFEE, 0) PAYEEFEE,
       NVL(D938.PAYERFEE, 0) PAYERFEE,
       0 PLATFORMFEE,
       P935.VERSION
  FROM PAYMENTORDER    P935,
       PAYMENTORDER    P938,
       DEAL            D938,
       GATEWAYORDER    G935,
       PAYMENTORDEREXT EXT938
 WHERE P935.ORDERCODE = 935
   AND P938.ORDERCODE = 938
   AND P938.RELATEDSEQUENCEID = to_char(P935.SEQUENCEID)
   AND P935.SEQUENCEID = G935.SEQUENCEID(+)
   AND P938.SEQUENCEID = D938.ORDERSEQID(+)
   AND P938.SEQUENCEID = EXT938.ORDERSEQID(+)
   AND P935.SEQUENCEID = :2

分析上面的sql,上面标红的地方。等号左边是varchar2的数据类型,括号右边是number的数据类型。会导致数据类型的隐式转换,造成极大的性能影响

联系研发。改动了sql语句,问题解决

生产上数据库大量的latch free 导致的CPU资源耗尽的问题的解决

标签:查看   mod   exec   like   buffers   解决   sans   sga   confirm   

人气教程排行