gc buffer busy解释
GLOBAL BUFFER BUSY WAIT是RAC平台经常出现的一种等待事件,这种等待如果比较严重的话,会对系统的性能产生十分重大的影响。甚至导致数据库被短暂的HANG住。
今天做awr报告发现gc buffer busy等待时间
gc buffer busy
This wait event, also known as global cache buffer busy prior to Oracle 10g, specifies the time the remote instance locally spends accessing the requested data block. This wait event is very similar to the buffer busy waits wait event in asingle-instance database and are often the result of:
1. Hot Blocks - multiple sessions may be requesting a block that is either not in buffer cache or is in an incompatible mode. Deleting some of the hot rows and re-inserting them back into the table may alleviate the problem. Most of the time the rows will be placed into a different block and reduce contention on the block. The DBA may also need to adjust the pctfree and/or pctused parameters for the table to ensure the rows are placed into a different block.
2. Inefficient Queries ˆ as with the gc cr request wait event, the more blocks requested from the buffer cache the more likelihood of a session having to wait for other sessions.Tuning queries to access fewer blocks will often result in less contention for the same block.
GLOBAL BUFFER BUSY WAIT和普通的BBW类似,普通的BBW是在一个单节点上多个会话访问相同的BLOCK导致的等待事件。如果大量会话访问某个或某些BLOCK,那么这 些BLOCK被称为热块。全局的BUFFER BUSY WAIT的危害更大,因为全局的热块需要在实例间进行传递,严重的全局热块冲突会导致系统性能急剧下降。
最典型的案例就是,如果某个应用要对某张表进行大批量的数据插入,那么如果插入的进程都跑在一个节点上,那么这个系统可能会出现一些BUFFER BUSY WAIT等待事件,不过不会产生很严重的性能问题。如果这个应用负载均衡方式分布在不同的节点上,那么从STATSPACK/AWR报告中,我们可能看到 以下的情况:
Top 5 Timed Events Avg %Total
~~~~~~~~~~~~~~~~~~ wait Call
Event Waits Time (s) (ms) Time Wait Class
------------------------------ ------------ ----------- ------ ------ ----------
buffer busy waits 17,149 12,743 743 37.3 Concurrenc
gc buffer busy 21,057 12,328 585 36.1 Cluster
enq: HW - contention 19,571 7,155 366 20.9 Configurat
CPU time 1,253 3.7
gc current block 2-way 207,726 525 3 1.5 Cluster
对于这种情况,需要在应用的底层进行设计。比如有一种很常用的方法,就是在某张表中设计一个INSTANCE_ID的字段,在插入数据的时候每个实 例插入的数据中都带有INSTANCE_ID,那么如果按照INSTANCE_ID对这张表进行分区,那么两个实例之间的GC BUFFER BUSY争用就会大幅度的减少。下面的例子就是通过这种方式优化后的AWR报告:
Event Waits Time(s) Avg Wait(ms) % Total Call Time Wait Class
CPU time 1,334 92.3
log file sync 554,591 334 1 23.1 Commit
log file parallel write 536,004 106 0 7.3 System I/O
gc cr multi block request 449,571 85 0 5.9 Cluster
wait for scn ack 417,500 73 0 5.1 Other
从上面的情况可以看出,GC BUFFER BUSY消失了。
Oracle、Linux、Unix