"Cross Instance call Enqueue"是一种在一个或多个instance实例间调用后台进程行为时用到的队列锁,具体调用的后台进程行为包括检查点checkpoint、日志切换logfile switch、shutdown实例、载入数据文件头等等。需要注意的是这种Enqueue Lock并不仅仅在RAC中使用,即便是单节点也会用到。CI锁的数量取决于并行执行Cross Instance Call调用的进程的总数。
SQL> col ksqsttyp for a20 SQL> col ksqstrsn for a20 SQL> col ksqstexpl for a80 SQL> set linesize 200 pagesize 2000; SQL> select ksqsttyp,ksqstrsn,ksqstexpl from x$ksqst where ksqsttyp='CI'; KSQSTTYP KSQSTRSN KSQSTEXPL -------------------- -------------------- -------------------------------------------------------------------------------- CI contention Coordinates cross-instance function invocations SQL> show parameter cluster_database NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ cluster_database boolean FALSE cluster_database_instances integer 1 SQL> select * from v$enqueue_stat where eq_type='CI'; INST_ID EQ TOTAL_REQ# TOTAL_WAIT# SUCC_REQ# FAILED_REQ# CUM_WAIT_TIME ---------- -- ---------- ----------- ---------- ----------- ------------- 1 CI 595 0 595 0 0当系统中出现有大量这种跨实例后台进程调用时,将出现CI队列锁的争用。假设在一个RAC场景中,同时有大量的回话开始对不同的数据表执行TRUNCATE截断操作,TRUNCATE的一个前提是在所有实例上(因为对象表的dirty buffer可能分布在多个实例上)发生对象级别的检查点(object level checkpoint),检查点发生时CKPT进程会通知DBWR写出指定对象表相关的脏块,DBWR需要扫描Buffer Cache以找出脏块,而如果Buffer Cache很大那么扫描将花费大量的时间,而在此过程中前台进程将一直排他地持有着本地的CI队列锁,这就将造成CI锁的严重争用。 为了减少CI队列锁地争用,我们第一步所要做的是找出实际的Cross Instance call跨实例调用的类型。这里要另外提一下的是在10g以前不管是v$session_wait或statspack中都不会将enqueue锁等待事件的具体enqueue lock类型写明,一般需要我们从p1/p2/p3列中找出enqueue的具体身份,例如"WAIT #1: nam='enqueue' ela= 910796 p1=1128857606 p2=1 p3=4",这里的p1为1128857606也就是16进制的43490006,高位的'4349'转换为ascii码也就是'CI',而这里的p2/p3对应为V$lock中的ID1/ID2,ID1=1代表了"Reuse (checkpoint and invalidate) block range",ID2=4代表了"Mounted excl, use to allocate mechanism"。 具体ID1/ID2代表的含义在不同版本中有所变化,可以参考下表:
Id1, Id2 Combination:
Oracle 10gR1
27 TO 29 *Same as 9i R2
30 process waiters after row cache requeue
31 Active Change Directory extent relocation
32 block change tracking state change
33 kgl mulitversion obsolete
34 set previous resetlogs data
35 set recovery destination pointer
36 fast object reuse request
37 test ksbcic()
38 ASM diskgroup discovery wait
39 ASM diskgroup release
40 ASM push DB updates
41 ASM add ACD chunk
42 ASM map resize message
43 ASM map lock message
44 ASM map unlock message (phase 1)
45 ASM map unlock message (phase 2)
46 ASM generate add disk redo marker
47 ASM check of PST validity
48 ASM offline disk CIC
49 Logical Standby Sync Point SCN
50 update SQL Tuning Base existence bitvector
51 PQ induced Checkpointing
52 ASM F1X0 relocation
53 Scheduler autostart
54 KZS increment grant/revoke counter
55 ASM disk operation message
56 ASM I/O error emulation
57 DB Supp log cursor invalidation
58 Cache global range invalidation
59 Cache global object invalidation
60 ASM Pre-Existing Extent Lock wait
61 Perform a ksk action through DBWR
62 ASM diskgroup refresh wait
Oracle 10gR2
30 to 62 *Same as 10gR1
63 KCBO object checkpoint
64 KCBO object pq checkpoint
65 global health check event
66 Oracle Label Security refresh
67 thread internal enable
68 cross-instance registration
69 KGL purge unused subheaps
70 clear pin instance flag
71 Rolling operations CIC
Oracle 9iR2
Id1 Meaning
~~~ ~~~~~~
25 TO 26 *Same as 9i R1
27 set Database Force Logging mode
28 invalidate cached file address translations
29 Cursor Unauthorize Mode
30 snapshot too old diagnosis
31 process waiters after row cache requeue
Oracle 9iR1
Id1 Meaning
~~~ ~~~~~~~~
18 TO 24 *Same as Oracle 8i
25 Update Dscn Tracking (ktcndt)
26 Purge dictionary Object number Cache
Oracle 8i
Id1 Meaning
~~~ ~~~~~~~
0 TO 17 *Same as Oracle 8(please see "Oracle8*" for the Meaning)
18 Object reuse request
19 Rolling release checks
20 Propagate begin backup scn for a file
21 Refresh top plan (for db scheduler)
22 Clear checkpoint progress record
23 Drop temp file
24 Quiesce database Restricted
Id2 Meaning
~~~ ~~~~~~~
0x01 Used to pass in parameters
0x02 Used to invoke the function in backgroud process
0x03 Used to indicate the foreground has not returned
0x04 Mounted excl, use to allocate mechanism
0x05 Used to queue up interested clients
Oracle 8*
Id1 Meaning
~~~ ~~~~~~~
0 Checkpoint block range
1 Reuse (checkpoint and invalidate) block range
2 LGWR Checkpointing and Hot Backup
3 DBWR syncronization of SGA with control file
4 Log file add/drop/rename notification
5 Write buffer for CR read
6 Test call
7 Invalidate KCK cache in all instances
8 Alter rollback segment optimal
9 Signal Query Servers/coordinator
10 Create Remote parallel query Server
11 Set Global Partitions
12 Stop Disk Writes
13 Drop Sort Segments
14 Release unused space from Sort Segments
15 Instance Recovery for Parallel operation Group
16 Validate parallel slave Lock Value
17 Check transaction state objects
18 Flush blocks in object
19 Rolling release checks
20 Propagate begin backup scn for a file
21 Clear checkpoint progress record
Oracle 7
Id1 Meaning
~~~ ~~~~~~~
0 Flush buffers for reuse as new class
1 LGWR checkpointing and Hot Backup
2 DBWR synchronization of SGA with control file
3 Log file add/drop/rename notification
4 Write buffer for CR read
5 Test Call
6 Invalidate KCK cache in all instances
7 Alter rollback segment optimal
8 Signal Query Servers/coordinator
9 Create Remote Parallel Query Server
10 Set Global Partitions
11 Stop Disk Writes
12 Drop Sort Segments
13 Release unused space from Sort Segments
14 Instance Recovery for Parallel operation Group
15 Validate parallel slave Lock Value
16 Check Transaction State Objects
Id2 Meaning
~~~ ~~~~~~~
1 Pass in Parameters
2 Invoke the call in background process
3 Foreground has not returned yet
4 Used to allocate the CI call
5 Used to queue up interested clients
转载于:https://blog.51cto.com/maclean/1277792