常见的 Lock mode write(modify): X(exuclusive) read(select): S(Shared) insert: X(Exclusive) 一.概述 1.RAC bffer 结构 buffer eqenue1 ------ |Rac1| | | | | | |------->-------- ------ ------ | | GES | | | GC | ----------> |DB | |Cache| ----------> | | ------ | | GCS | | | |-------->------- ------ |Rac2| | | | | ------ buffer equenue2 2.基本规则 *.不管是insert,update,delete,select都会先从local buffer去搜索(需要得到global cache null模式) *.当local buffer搜索不到的时候就会尝试从Global bufffer去找,如果找不到,则 *.当想从新获取权限的时候必须将gc buffer 设置为null 3.等待事件 1).cr requeset *.When a session is looking for a consistent read (CR) copy of the buffer cached by the remote instance, it waits on the global cache cr request event till the buffer is available in the local instance. Normally the holder constructs the CR version of the buffer and ships it to the requesting instance through the high speed interconnect. The wait ends when the CR buffer arrives at the local buffer cache. *.From Oracle Database 10g Release 1, global cache cr request waits are known as gc cr request waits. *.Depending on the mode of the buffer held in the remote instance and the number of times the remote instance ships the CR copy to the local instance, one of the following will happen: .The CR copy of the buffer is sent to the requesting instance and the “fairness counter” is incremented for that buffer. Subsequently the global cache cr blocks received statistic is incremented. .If the buffer is not cached by the remote instance (but mastered by the remote instance), it grants it to the requesting instance. The session can read the block from the disk and the global cache gets statistic is incremented. .If the number of CR copies for that particular buffer reaches the _fairness_threshold limit, the remote instance downgrades the lock to null mode and flushes the redo to the disk. The session can do the disk I/O to get the block from the disk. --当需要请求的数量超过远程instance的限制的时候,远处的instance将该Global buffer锁降级为null,同时flush redo(将该buffer flush,可能由于算法优先,remote get的代价大于从diks读取).这样local instance能够从Disk i/o读取该buffer 2).global cache null to x 将gc cache传输到最终到本地(local)buffer块的(update,modify)修改需要从null到x模式加锁,没有任何模式(null)则GCS自动加锁 3).global cache null to s 将gc cache传输到最终到本地(local)buffer块的read(select)从null到s模式锁 4).global cache s to x global cache从shared到exclusive模式加锁进行修改,global cache自动upgrade升级(GCS) 5).global cache open x 当前会话需要修改当前块,但是该块没有在本地(local)任何模式的cache (insert or bulk load data) --null模式才能获取到本地修改,查询 6).global cache open s 某个会话等待global cache对该buffer以s的模式打开.发生在数据库启动或者第一次将block cache到Local buffer. The block can either be read from the disk or shipped from the other instance cache.
