等待事件enq:HW–contention说明及解决方法

发布时间:2020-08-18 19:46:18 作者:kunlunzhiying
来源:ITPUB博客 阅读:654

一、今天在查看awr报告中,发现Top 5 Timed Foreground Events发现enq: HW - contention的等待事件;

 等待事件enq:HW–contention说明及解决方法cDNba0aAdouWi7sm73h2WV1B7XVqiQvCVVnALfM8GqZVWVarsd9SNfJvmJW+I5NU7Anrbupfdu3C2K/Nr3cC61TVvR75TAuUxmtG1zd1NWtL6fwfletmEVj3PMmqvZPEWTr2G+RjtfmYsPxZo14Yt+s9CKb3nT3EcIjKrLxI7vQMb1PTq7o98pJXN7IOsVhuAo18Xtad1yWGrFALHNRXGp3xzuVDaiSBC7hwijvMsXwUsUUo+ybpWnX5GNPxB3vVmRRMXcXRCaYp8gcy8kV/V49HpfBmhM/N9MANQceHScJDuF+md3TndTMYIuhQlXEuFxu8Zto4LhcR7L6GmGbzO65TmpmsMVQoSpiXC63+PU0ApCkD69SoSpiXC63+PU0ApCkD69SoSpiXC63+PU0ApCkD69SoSrK4vKHmAQnfjqhgXEEyQ2I4UMMFSnUuCQIgiBKMC4JgiBMkH92SYzDiZ9OaGAcQXIDYvgQQ0UK9Gb8+/1e1z9sg82Jn05oBCBJH16lQlPEuFxuMWkEIEkfXqVCU8S4XG4xaQQgSR9epUJTxLhcbjFpBCBJH16lQlMkx+UnwT3t8xfi0tmj5fhsorbO6c1J0aygAQoA1AzoceLV4+0RH8TdrJ5ucMDj7aYpLkvvqp6Ws3AP2JjTm5OimU5DLAztIUuPH68eb/t90I45iMtqT7zdbIvLy5Z02suNpkXCNCdFs5QG2Dvjk6Urrx5vHuISbJMlKx9RsXNf2uIyQ9U7xmXIuMQvQMS3I2UJefPq8eb8zbjlnfhTKrbty/JXl6XF1VkBmpOi8fzqkm/Gs+bh2WV5XZ2Y9cTbzWfejNtnBWhOioZxeVBjXPpsz/yqx7hIjOakaPirnoOa87h87W5u/SARGBM1Ky83RbPng0Tpdms1A3qcePV4c/uzy6b9jbeb/Jj6VovD0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OIKDthOR+QxzGpeWA4MwyxmX1wIpM8KNV5n2tHpeZqpQfKH3cky1omaXdboSJGL5LLQZ7WZLRnhvEYsqufcalSDW99kDycWdc+QAOiJhfrXFpPLAgDZ3GZcZMfDbIIhWz1865uI520qpMwJqLPAUWV+/btOuW5wNMY3NjXFqcceWDMS4tJacd2ywNLWFS3vGwuKxytcSl8eTjuOy4y9L2SFyWzxmPn0DLrj1O8ql2XFyWu1ktOVAAl3LSAQfvcZmFPX6lgHuyBcsx5RNLR1xa1vQQl02B3j348RPIuLSb48cH+/N62T/xzbh3I3yOprfRX/Wk/LL0yXrKbLrXKWeVjxpDATBJR4rLLmqzPkiUkceDy7s8fgJFehntx0k+1U6Jy7QIq+O1JLGUehYd2o2q52hue/Jj6huiykOb5eegXX5O4Okk6cOrVGiKGJfLLX7QriNq9wiS9OFVKjRFu+PyJc2Jn05oBCBJH16lQlPEuFxuMWkEIEkfXqVCU5TH5Q8xCU78dEID4wiSGxDDhxgqUqhxSRAEQZRgXBIEQZjwX1x+CYIgCIjPs4FNEARxChiXBEEQJjAuCYIgTPg/1yU9avBPuhwAAAAASUVORK5CYII=">

二、enq: HW - contention的官方说明:

The HW enqueue is used to serialize the allocation of space beyond the high water mark of a segment.

?V$SESSION_WAIT.P2 / V$LOCK.ID1 is the tablespace number.

?V$SESSION_WAIT.P3 / V$LOCK.ID2 is the relative data block address (dba) of segment header of the object for which space is being allocated.

If this is a point of contention for an object, then manual allocation of extents solves the problem.

 

三、等待事件解释

为防止多个进程同时修改HWM而提供的锁称为HW锁。想要移动HWM的进程必须获得HW锁。若在获取HW锁过程中发生争用,则等待enq: HW - contention事件。HW锁争用大部分是因大量执行insert所引发的,偶尔也会因大量执行update在回滚段中发生HW锁争用现象。若是update,表中段的扩展的大小虽然不多,但在创建回滚数据的过程中,需要回滚段的急速扩张。HW锁争用是在急速空间扩张时普遍出现的等待现象,有时也会引发严重的性能下降。

 

SQL> select event#,name,parameter1,parameter2,parameter3 from v$event_name where name = 'enq: HW - contention';

EVENT# NAME PARAMETER1 PARAMETER2 PARAMETER3

---------- ---------------------------------------- -------------------- -------------------- --------------------

250 enq: HW - contention name|mode table space # block

众所周知,Oracle高水位线标志着该线以下的block均被Oracle格式过,通俗一点讲就是该高水位线以下的block都被Oracle使用过。 通常在执行insert操作时,当高水位线以下block不够用时,Oracle将会推进高水位线。更进一步讲,当有多个进程在同时进行insert操作时,比较容易引起高水位线争用,主要表现为enq: HW - contention。

 

四、如何找到事件:'enq: HW - contention' 热点对象:

1、查看v$session_wait,应该会有如下等待事件:

SQL> select p1, p2, p3 from v$session_wait where event = 'enq: HW - contention';

P1 P2 P3

---------- ---------- ----------

1213661190 7 140003563

1213661190 7 140003563

1213661190 7 140003563

1213661190 7 140003563

1213661190 7 140003563

1213661190 7 140003563

1213661190 7 140003563

 

2、通过P3进行DBMS_UTILITY转换可以获知发生争用的文件和block:

SQL> select dbms_utility.data_block_address_block(140003563),dbms_utility.data_block_address_file(140003563) from dual;

DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK(140003563) DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE(140003563)

------------------------------------------------ -----------------------------------------------

1591531 33

 

3、进而通过file#和block#定位对象:

SQL> select owner, segment_type, segment_name

from dba_extents

where file_id = 33 and 1591531 between block_id and block_id + blocks - 1;

 

五、减少HW锁争用的方法如下:

If this is a point of contention for an object, then manual allocation of extents solves the problem.

脚本:alter table <TABNAME> allocate extent,提前分配空间;

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

本文作者:JOHN

ORACLE技术博客:ORACLE 猎人笔记               数据库技术群:367875324 (请备注ORACLE管理 )  

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

推荐阅读:
  1. Java使用Thread和Runnable的线程实现方法比较
  2. SpringBoot在运行时动态添加数据源的方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

hw contention enq

上一篇:Oracle自治数据仓库荣获2018年度创新产品奖

下一篇:互联网IP路由的逐跳全局最优化原则-Dijkstra算法证明

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》