Académique Documents
Professionnel Documents
Culture Documents
juliandyke.com
Agenda
Introduction to RAC
Memory Structures
The Buffer Cache
juliandyke.com
Introduction to RAC
3
juliandyke.com
What is RAC?
Multiple instances running on separate servers (nodes) Single database on shared storage accessible to all nodes Instances exchange information over an interconnect network
Interconnect
Instance 2
Node 2
Shared Storage Local Disk
juliandyke.com
Architecture
Public Network Private Network (Interconnect) Instance 1 Instance 2
Node 2
Shared Storage
juliandyke.com
Some Definitions
Resource Object to which access must be controlled at instance level Enqueue Memory structure that serializes access to a resource
juliandyke.com
Some Definitions...
Global Resource Directory (GRD) Records current state and owner of each resource Contains convert and write queues Distributed across all instances in cluster Maintained by GCS and GES Global Cache Services (GCS) Implements cache coherency for database Coordinates access to database blocks for instances Global Enqueue Services (GES) Controls access to other resources (locks) including library cache and dictionary cache Performs deadlock detection
juliandyke.com
Background Processes
DIAG LMON LCK LMD LMS LGWR CKPT ARCH Datafiles Controlfiles DBWR DBWR LGWR CKPT ARCH SGA UGA UGA SGA PMON
SMON
SMON
PMON
Instance 1
Instance 2
Redo Logs
8
Redo Logs
juliandyke.com
Background Processes
In Oracle 10.1 and above, number of GCS server processes can be configured using gcs_server_processes parameter Default value is 1 (single CPU system)
juliandyke.com
Background Processes
Manages instance resource requests cross-instance call operations Assists LMS processes Formerly known as lock process In 9.0.1 and below, number of lock processes may be configurable using _gc_lck_procs parameter
10
juliandyke.com
Background Processes
Manages requests for global enqueues Updates status of enqueues when granted to / revoked from an instance One LMD0 process per instance In 8.1.7 and below number of lock daemons may be configurable using _lm_dlmd_processes parameter
11
juliandyke.com
Background Processes
One LMON process per instance Monitors cluster to maintain global enqueues and resources
Manages instance and process expirations recovery processing for cluster enqueues
12
juliandyke.com
Background Processes
Collects diagnostic data in the event of a failure Creates subdirectories in BACKGROUND_DUMP_DEST directory In Oracle 9.0.1 and above can be disabled using _diag_daemon parameter Do not try this on a production system
13
juliandyke.com
Fixed Tables
Memory structures externalized in X$ tables Instance specific Underlying structures for dynamic performance views Can contain Structures accessed directly from executable X$KSLLD => V$LATCHNAME X$KSUSD => V$STATNAME Structures accessed directly from SGA X$KSUSE => V$SESSION X$KSUPR => V$PROCESS Executable and/or SGA structures joined in PGA X$KQLFXPL => V$SQL_PLAN X$KGLOB => V$SQL, V$SQL_AREA
14
juliandyke.com
In a RAC environment each V$ view has an equivalent GV$ view GV$ view includes INST_ID column. For example V$SGA
NAME VALUE VARCHAR2(20) NUMBER
GV$SGA
INST_ID NAME VALUE NUMBER VARCHAR2(20) NUMBER
In Oracle 9.2 and below PARALLEL_MIN_SERVERS must be >= number of hosts to use GV$ views In Oracle 10.1 and above PZnn background processes are used to return data on remote hosts e.g. PZ99
15
juliandyke.com
CATCLUST.SQL
Some additional views/synonyms are created for RAC databases using $ORACLE_HOME/rdbms/admin/catclust.sql
Synonym Name V$GES_CONVERT_LOCAL V$GES_CONVERT_REMOTE V$GES_LATCH V$GES_RESOURCE View Name V$DLM_CONVERT_LOCAL V$DLM_CONVERT_REMOTE V$DLM_LATCH V$DLM_RESS
V$GES_STATISTICS
V$GES_TRAFFIC_CONTROLLER GV$GES_CONVERT_LOCAL GV$GES_CONVERT_REMOTE GV$GES_LATCH GV$GES_RESOURCE GV$GES_STATISTICS GV$GES_TRAFFIC_CONTROLLER
V$DLM_MISC
V$DLM_TRAFFIC_CONTROLLER GV$DLM_CONVERT_LOCAL GV$DLM_CONVERT_REMOTE GV$DLM_LATCH GV$DLM_RESS GV$DLM_MISC GV$DLM_TRAFFIC_CONTROLLER
16
juliandyke.com
ORADEBUG
SQL> ORADEBUG LKDEBUG HELP Usage:lkdebug [options] -l [r|p] <enqueue pointer> -r <resource pointer> -b <gcs shadow pointer> -p <process id> -P <process pointer> -O <i1> <i2> <types> -a <res/lock/proc> -A <res/lock/proc> -a <res> [<type>] -a convlock -A convlock -a convres -A convres Enqueue Object Resource Object GCS shadow Object client pid Process Object Oracle Format resname all <res/lock/proc> pointer all <res/lock/proc> contexts all <res> pointers by an optional type all converting enqueue (pointers) all converting enqueue contexts all res ptr with converting enqueues all res contexts with converting enqueues
17
juliandyke.com
ORADEBUG
Continued...
list all resource names list all resource hash bucket counts Traffic controller info summary of all enqueue types GES SGA summary info request for remastering this object at current instance request for dissolving remastering of this object at current instance
18
juliandyke.com
Memory Structures
19
juliandyke.com
Memory Areas
00000000 Executable
20000000
SGA
40000000
FFFFFFFF
20
STOP
juliandyke.com
Shared Memory
$ sqlplus /nolog
SQL> CONNECT SYS/<password> AS SYSDBA Connected SQL> ORADEBUG SETMYPID ORADEBUG SETMYPID Statement processed ORADEBUG IPC SQL> ORADEBUG IPC Information written to trace file
21
juliandyke.com
juliandyke.com
Contains Fixed SGA Buffer Pool Shared Pool Large Pool Java Pool Streams Pool Redo buffers Buffer Pool includes Default cache Keep and Recycle cache 2K, 4K, 8K, 16K and 32K cache
Oracle 7.0 and above Oracle 8.0 and above Oracle 8.1.5 and above Oracle 10.1 and above
23
juliandyke.com
V$SGAINFO
NAME BYTES RESIZEABLE -------------------------------- ---------- ---------Fixed SGA Size 1218920 No Redo Buffers 2973696 No Buffer Cache Size 176160768 Yes Shared Pool Size 83886080 Yes Large Pool Size 4194304 Yes Java Pool Size 4194304 Yes Streams Pool Size 0 Yes Granule Size 4194304 No Maximum SGA Size 272629760 No Startup overhead in Shared Pool 46137344 No Free SGA Memory Available 0
24
juliandyke.com
Granules
Introduced in Oracle 9.0.1 SGA divided into granules In Oracle 9.2 Unix granule size dependent on SGA_MAX_SIZE 4 mb SGA_MAX_SIZE <= 128 mb 16 mb SGA_MAX_SIZE > 128 mb
If SGA_MAX_SIZE not set explicitly then defaults to sum of individual pool parameters
SGA_MAX_SIZE cannot be dynamically modified
25
juliandyke.com
Granules
Granule size dependent on SGA_MAX_SIZE 4 mb SGA_MAX_SIZE <= 256 mb?? 16 mb SGA_MAX_SIZE > 256 mb ??
Granule size can be controlled using _ksmg_granule_size unsupported parameter
26
juliandyke.com
X$KSMGE
Introduced
Granule ID 0 1 2 3 6 Free Shared Pool Large Pool Java Pool Buffer Pool
GRANTYPE
GRANSTATE GRANFLAGS
NUMBER
VARCHAR2(16) NUMBER
LOCALITY
KSMAREANUM BASEADDR
NUMBER
NUMBER RAW(4)
GRANSIZE
GRANNEXT GRANPREV
27
NUMBER
NUMBER NUMBER
juliandyke.com
Granules
4M SGA_TARGET = 260M SGA_MAX_SIZE = 260M GRANULE SIZE = 4M Fixed SGA + Redo Buffers 4M
256M Large Pool 4M Java Pool 4M This is an example of an SGA mapped using X$KSMGE
28
STOP
juliandyke.com
V$SGASTAT
BYTES
NUMBER
Java Pool
Streams Pool
4
4
29
juliandyke.com
V$SGASTAT
gcs affinity gcs close obj gcs commit sga state gcs I/O statistics struct gcs mastership buckets
gcs opaque in
gcs res hash bucket gcs res latch table gcs resource freelist arr gcs resource freelist dyn gcs resources gcs scan queue array gcs shadow locks dyn seg gcs shadow locks freelist gcs shadows
30
juliandyke.com
V$SGASTAT
Size(bytes)
Location
ges resource
ges enqueues ges big msg buffers
1257188 Heap
1625344 Segmented Array 3979396 Unknown
31
juliandyke.com
Permanent Areas
2AC00000
2B800000 2BC00000 2C000000 2C400000
Allocated at instance startup Contain structures such as processes sessions segmented arrays
SELECT ksmchptr, ksmchsiz FROM x$ksmsp WHERE ksmchcls = 'perm'; Address 2D034000 2D434000 2D834000 2DC34000 2DFFFD28 2E034000 Size 3981312 3549424 3963236 3980584 728 3919532
Heap
2C800000
2CC00000
2D000000
2D400000
2D800000
2DC00000 2E000000 2E400000 2E800000 2EF00000 2F000000
Permanent Area
32
STOP
juliandyke.com
X$KSMSP
Description of chunk type Address of chunk Size including header Class Perm Recreate Freeable Free R-Free R-Freeable Type (recreate only) 0x18 - KGL Handle 0x24 - Fixed Allocation 0x74 - KQR PO 0x80 - KQR SO 0xFFF - Extended header
KSMCHIDX
KSMCHDUR KSMCHCOM
NUMBER
NUMBER VARCHAR2(16)
KSMCHPTR
KSMCHSIZ KSMCHCLS
RAW(4)
NUMBER VARCHAR2(8)
KSMCHTYP
KSMCHPAR
NUMBER
RAW(4)
Address of parent
33
juliandyke.com
X$KSMSP
4620
16396 7692
1
1 1
ges_res_masters
ges_resource
3084
619276
1
164
34
juliandyke.com
Segmented Arrays
Used to store arrays of objects Array too large to fit in granule Array may grow dynamically Objects using segmented arrays include enqueues (locks) enqueue resources (resources) transactions transaction branches Segmented arrays managed recursively by segmented array Segmented arrays externalised in X$KSMDD
35
juliandyke.com
Segmented Arrays
Segmented Arrays Call
Enqueue Resources
36
STOP
juliandyke.com
X$KSMDD
37
juliandyke.com
Segmented Arrays
In Oracle 10.2 there are three RAC-specific segmented arrays: GCS Resources GCS Shadows GES Enqueues In previous releases there were five segmented arrays: GCS Resources GCS Shadows GES Resources GES Shadows GES Messages
38
juliandyke.com
Heaps
A heap consists of one or more extents Each heap extent occupies a single granule Each extent contains one or more chunks Each heap has a header containing list of used chunks list of free chunks
Heap Extent 0 Extent 1 Extent 2
Header
Free List
Chunks
39
STOP
juliandyke.com
X$KSMHP
40
juliandyke.com
juliandyke.com
Buffer Headers
Each buffer has a buffer header Buffer headers are stored in same granule as buffers Buffer headers include Replacement list Hash list Pointer to buffer In RAC only pointer to Lock Element
Buffer Headers
Buffers
Granule
42
STOP
juliandyke.com
X$BH
ADDR
INDX INST_ID HLADDR BLSIZ NXT_HASH PRV_HASH NXT_REPL PRV_REPL FLAG RFLAG SFLAG LRU_FLAG TS# FILE# DBARFIL DBABLK 43
RAW(4)
NUMBER NUMBER RAW(4) NUMBER RAW(4) RAW(4) RAW(4) RAW(4) NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
CLASS
STATE MODE_HELD CHANGES CSTATE LE_ADDR DIRTY_QUEUE SET_DS OBJ BA CR_SCN_BAS CR_SCN_WRP CR_XID_USN CR_XID_SLT CR_XID_SQN CR_UBA_FIL CR_UBA_BLK
NUMBER
NUMBER NUMBER NUMBER NUMBER RAW(4) NUMBER RAW(4) NUMBER RAW(4) NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
CR_UBA_SEQ
CR_UBA_REC CR_SFL CR_CLS_BAS CR_CLS_WRP LRBA_SEQ LRBA_BNO HSCN_BAS HSCN_WRP HSUB_SCN US_NXT US_PRV WA_NXT WA_PRV TCH TIM
NUMBER
NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RAW(4) RAW(4) RAW(4) RAW(4) NUMBER NUMBER
juliandyke.com
Single-Block Reads
Head of Hot End Head of Cold End
Block Number
42 71 92 0
71 92 34 0 3
92 34 72 0 3 4
34 72 45 4 2
87 72 33 45 42 52 11 4 2 1
72 33 45 42 52 71 11 4 1 2
33 45 42 52 71 66 11 1 2 0
45 42 52 71 66 49 11 1 2 0
Read Block 11 87 34 33 42 Set firsttouchat head Move buffer42 to head Insert block 71contents Update buffer count of cold Get touch counthead of cold Insert buffer at Get first available buffer available buffer on of block 34 forhotcold42 endblock 42 from cold71 to zero end from endend end
87 33 42 11
1
Touch Count
44
STOP
juliandyke.com
Multi-Block Reads
DB_FILE_MULTIBLOCK_READ_COUNT = 4 Head of Hot End Head of Cold End
7 4 3 2 1 8 6 5
6 3 2 7 1 5
5 2 1 6
1 5
1 5
1 2 5 6
2 1 5 3 7 6
4 3 2 8 7 6 5 1
Read Block3 6 5 2 8 Read Block 1 7 4 Insert next fourtohead end Move buffers atblocksof Read block 1 availableend Move next four cold end Read block 2 to cold into Get next four availableof Move buffers head Insert block3 at cold 4 7 8 6 Get first four5 toblocks into cold endfrom cold end buffers from cold end buffers cold end
5 4 1
6 3 2
2 7 3
8 1 4
45
STOP
juliandyke.com
juliandyke.com
Resource Master
Instance 3
Instance 2
2 Request granted
3 Read request
Instance 1
4 Block returned
Instance 4
1318
47
STOP
juliandyke.com
1318
Instance 2
Instance 3
N X
1320
Instance 1 Instance 1 requests exclusive read on block
Instance 4
1318
48
STOP
juliandyke.com
1318
Instance 2
Instance 3
4 Resource status
N X N
N X
1320
3 Block and resource status
1323
Instance 4
Instance 1
Instance 4 requests exclusive read on block
1318
Note that Instance 1 will create a past image (PI) of the dirty block
49
STOP
juliandyke.com
Past Images
When an instance passes a dirty block to another instance it Flushes redo buffer to redo log
Retains past image (PI) of block in buffer cache PI is retained until another instance writes block to disk Used to reduce recovery times Recorded in V$BH.STATUS as PI Based on X$BH.STATE (value 8 in Oracle 10.2)
50
juliandyke.com
Past Images
Buffer Cache UPDATE t1 SET c1 = 1324; 1328; 1327; 1326; 1325; COMMIT; Buffer Cache
1328 1329
Instance 1
Instance 2
1328
1329
1329 1323
1326 1327
1327 1328
BlockUndo/Redoapplied froma DBWR hasis 1makesperform to Instance 42updates column Block 421table t1 contains Assume2subsequentlyto 42 Instance notmustrecovery Undo/redoupdated in to GCS transferswritten from Block 1needs block Instance is2 written buffer Undo/redo Crasheswritten 42 is Instance written changes block Block 42 is read from disk ContentsPastdisk Instance 2 lost Instance 42cachePast Image toInstance usesInstance yet recovery1 to by block 2 backof 1 Imageto disk blocktobuffer cache 42 single row in block are a Redo Log 1 1327 DBWR 1324 2 1329 1328 1326 1325 for back
Redo Log 2
Redo Log 1
51
STOP
juliandyke.com
1318
Instance 2 4 Resource status
Instance 3
N X N
1320
Instance 1
Instance 2 requests current read on block
1323
Instance 4
1318
Note that in recent versions _fairness_threshold is used to avoid unnecessary lock conversions
52
STOP
juliandyke.com
Fairness Threshold
Intended to prevent unnecessary lock downgrades when other instances only require read-only copies
For write to read transfers Writing instance retains X lock Reading instance retains null lock If _fairness_threshold reached then Writing instance downgrades X lock to S lock Reading instance receives S lock _fairness_threshold default value is 4
53
juliandyke.com
Fairness Threshold
_fairness_threshold = 4
X S 1323
Instance 1
3 4 2 0 1
N S
Instance 2
Instance 1 22requests block to Instance 2 receives consistent Instance downgrades lockto Instance 2 requests blockwith Instance 1 sends consistent Instance receives 1 holds Assume instance Instance 1 sends with from Instance 1 sets counter to 2 Instance 1 sets counter to3 4 1 exclusiveread on block Shared S 2 instance 2 Instance Null lock Null lock Xread lock to lock
54
STOP
juliandyke.com
Lock Elements
Buffer Header
Buffer Header
Buffer Header
55
juliandyke.com
V$LOCK_ELEMENT
Based on X$LE
ACQUIRING
INVALID FLAGS
NUMBER
NUMBER NUMBER
56
juliandyke.com
X$LE
ADDR INDX INST_ID LE_ADDR NAME LE_CLASS LE_RLS LE_ACQ RAW(4) NUMBER NUMBER RAW(4) NUMBER NUMBER NUMBER NUMBER
Buffer Header
LE_FLAGS
LE_MODE LE_WRITE LE_LOCAL LE_RECOVERY LE_BLKS LE_TIME LE_KJBL
NUMBER
NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER RAW(4)
57
STOP
juliandyke.com
GCS Client
LE KJBL
LE KJBL KJBL
GCS Shadow
KJBR
KJBR
58
juliandyke.com
GCS Parameters
GCS Resources Number of GCS resource structures determined by _gcs_resources parameter Stored in segmented array Externalized in X$KJBR Number of free GCS resource structures in X$KJBRFX
GCS Enqueues (Shadows/Clients) Number of GCS enqueue structures determined by _gcs_shadow_locks parameter Stored in segmented array Externalized in X$KJBL Number of free GCS enqueue structures in X$KJBLFX
59
juliandyke.com
X$KJBR
60
juliandyke.com
X$KJBL
KJBLLOCKP
KJBLGRANT KJBLREQUEST KJBLROLE KJBLRESP KJBLNAME KJBLNAME2 KJBLQUEUE KJBLLOCKST KJBLWRITING
RAW(4)
VARCHAR2(9) VARCHAR2(9) NUMBER RAW(4) VARCHAR2(30) VARCHAR2(30) NUMBER VARCHAR2(64) NUMBER
KJBLREQWRITE
KJBLMASTER KJBLBLOCKED KJBLBLOCKER 61
NUMBER
NUMBER NUMBER NUMBER
juliandyke.com
GLOBAL CACHE ELEMENT DUMP (address: 0x21fecd18): id1: 0x3591 id2: 0x10000 obj: 181 block: (1/13713) lock: SL rls: 0x0000 acq: 0x0000 latch: 0 flags: 0x41 fair: 0 recovery: 0 fpin: 'kdswh05: kdsgrp' bscn: 0x0.18a9c bctx: (nil) write: 0 scan: 0x0 xflg: 0 xid: 0x0.0.0
GCS CLIENT 0x21fecd60,1 sq[(nil),(nil)] resp[(nil),0x3591.10000] pkey 181 grant 1 cvt 0 mdrole 0x21 st 0x20 GRANTQ rl LOCAL master 1 owner 0 sid 0 remote[(nil),0] hist 0x7c history 0x3c.0x1.0x0.0x0.0x0.0x0. cflag 0x0 sender 2 flags 0x0 replay# 0 disk: 0x0000.00000000 write request: 0x0000.00000000 pi scn: 0x0000.00000000 msgseq 0x1 updseq 0x0 reqids[1,0,0] infop 0x0 pkey 181 hv 107 [stat 0x0, 1->1, wm 32767, RMno 0, reminc 6, dom 0] kjga st 0x4, step 0.0.0, cinc 8, rmno 10, flags 0x0 lb 0, hb 0, myb 178, drmb 178, apifrz 0
62
juliandyke.com
Continued
GLOBAL CACHE ELEMENT DUMP (address: 0x237f4358): id1: 0x6a39 id2: 0x10000 obj: 74 block: (1/27193) lock: SL rls: 0x0000 acq: 0x0000 latch: 0 flags: 0x41 fair: 0 recovery: 0 fpin: 'kdswh05: kdsgrp' bscn: 0x0.26992 bctx: (nil) write: 0 scan: 0x0 xflg: 0 xid: 0x0.0.0 GCS SHADOW 0x237f43a0,1 sq[0x2ee64e8c,0x2eff3858] resp[0x2ee64e74,0x6a39.10000] pkey 74 grant 1 cvt 0 mdrole 0x21 st 0x40 GRANTQ rl LOCAL master 0 owner 0 sid 0 remote[(nil),0] hist 0x12a5 ..... GCS RESOURCE 0x2ee64e74 hashq [0x2ee61894,0x2ff57390] name[0x6a39.10000] pkey 74 grant 0x2eff3858 cvt (nil) send (nil),0 write (nil),0@65535 flag 0x0 mdrole 0x1 mode 1 scan 0 role LOCAL ..... GCS SHADOW 0x2eff3858,1 sq[0x237f43a0,0x2ee64e8c] resp[0x2ee64e74,0x6a39.10000] pkey 74 grant 1 cvt 0 mdrole 0x21 st 0x40 GRANTQ rl LOCAL master 0 owner 1 sid 0 remote[0x23fea160,1] hist 0x65f ..... GCS SHADOW 0x237f43a0,1 sq[0x2ee64e8c,0x2eff3858] resp[0x2ee64e74,0x6a39.10000] pkey 74 grant 1 cvt 0 mdrole 0x21 st 0x40 GRANTQ rl LOCAL master 0 owner 0 sid 0 remote[(nil),0] hist 0x12a5 .....
63
juliandyke.com
Block Mastering
Ordering
by X$KJBR.KJBRNAME is difficult because the resource names do not collate e.g. [0x900][0x70000],[BL] [0x90][0x70000],[BL]
64
juliandyke.com
Block Mastering
In Oracle 10.2 block mastering is determined by _lm_contiguous_res_count Specifies number of contiguous blocks that will hash to the same HV bucket Defaults to 128 For example Instance 1 Instance 0
Start
0x080
End
0x0FF
Start
0x000
End
0x07F
0x180
0x280 0x380
0x1FF
0x2FF 0x3FF
0x100
0x200 0x300
0x17F
0x27F 0x37F
0x480
0x580 etc
65
0x4FF
0x5FF etc
0x400
0x500 etc
0x47F
0x57F etc
juliandyke.com
Block Mastering
In Oracle 9.2 (and probably 10.1) block mastering determined by hash function Algorithm applied to groups of 1289 contiguous blocks
In two node cluster instance 0 has 645 blocks instance 1 has 644 blocks
In three node cluster instance 0 has 430 blocks instance 2 has 215 blocks instance 1 has 430 blocks instance 2 has 214 blocks
Beware of small hot tables and indexes....
66
juliandyke.com
Dynamic Remastering
In Oracle 9.2 documentation describes dynamic remastering not implemented in code In Oracle 10.1 work at data file level very high threshold so difficult to test does occur on some customer sites may cause LMON process to crash in 10.1.0.4 bug 3659289 - patch available fixed in 10.1.0.5/10.2.0.1 In Oracle 10.2 works at object level thresholds are relatively low
67
juliandyke.com
Dynamic Remastering
Example SELECT data_object_id FROM dba_objects WHERE owner = 'US01'AND object_name = 'T1';
OBJECT_ID --------52084
All blocks now mastered by the current instance To redistribute masters to all available instances use: ORADEBUG LKDEBUG -m dpkey 52084
68
juliandyke.com
V$GCSPFMASTER_INFO
69
juliandyke.com
Dynamic Remastering
Object remastering recorded in V$GCSPFMASTER_INFO Instances are internally numbered 0, 1 etc Initially contains no rows After remastering object 52084 to instance 0
SELECT object_id, current_master, previous_master FROM v$gcspfmaster_info;
Object ID 52084
Current Master 0
70
juliandyke.com
Dynamic Remastering
Information about Dynamic Remastering operations is also recorded in the following fixed views
71
juliandyke.com
juliandyke.com
KGLHD Child 2
73
STOP
juliandyke.com
KGLOB Heap 0
Child Handle
SELECT Statement
74
STOP
juliandyke.com
Library Cache
Each KGLHD structure has a set of double linked lists including; Locks Pins
75
juliandyke.com
X$KGLOB
76
STOP
juliandyke.com
Namespaces
In Oracle 10.2 there are 64 library cache namespaces Externalized by KGLHDNSP in X$KGLOB
LOB DIR QUEU OBJG PROP JVSC JVRE REIP CPOB EVNT SUMM DIMM CTS OUTL RMGR XDBS PPLN PCLS SUBS LOCS RMOB JVSD STFG TRANS RELC RULE STRM REVC RELS RELD IFSD XDBC USAG MVOBTBL JSQI MVOBINX STBO HTSO JSGA JSET TABLE CLST NSCPD JSLV MODL Unused Unused Unused Unused
PIPE
ROBJ
RULS
RSMD
STAP
CDC
INDX
Unused
77
juliandyke.com
Namespaces
ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME LIBRARY_CACHE LEVEL 1';
For example:
LIBRARY CACHE STATISTICS: namespace gets hit ratio pins hit ratio reloads invalids -------------- --------- --------- --------- --------- ---------- ---------CRSR 2403 0.086 33698 0.933 435 0 TABL 4368 0.578 10032 0.657 961 0 BODY 127 0.717 211 0.801 4 0 TRGR 4 0.000 45 0.911 0 0 INDX 81 0.272 83 0.036 21 0 CLST 101 0.921 264 0.958 3 0 KGLT 0 0.000 0 0.000 0 0 PIPE 0 0.000 0 0.000 0 0 LOB 0 0.000 0 0.000 0 0 DIR 0 0.000 0 0.000 0 0 QUEU 156 0.904 5886 0.997 0 0 .... 78
juliandyke.com
V$LIBRARYCACHE
PINHITS
PINHITRATIO RELOADS INVALIDATIONS DLM_LOCK_REQUESTS
NUMBER
NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
79
juliandyke.com
V$LIBRARYCACHE
Based on X$KGLST
SELECT inst_id, DECODE (indx, Names are generated 0,'SQL AREA', in dynamic 1,'TABLE/PROCEDURE', performance view 2,'BODY', 3,'TRIGGER', 4,'INDEX', 5,'CLUSTER', 6,'OBJECT', 7,'PIPE', 13,'JAVA SOURCE', 14,'JAVA RESOURCE', 32,'JAVA DATA',' ?' ), kglstget,kglstght, DECODE (kglstget,0,1,kglstght/kglstget), kglstpin,kglstpht, DECODE (kglstpin,0,1,kglstpht/kglstpin), kglstrld,kglstinv, kglstlrq,kglstprq,kglstprl,kglstirq,kglstmiv Only selected rows FROM x$kglst from X$KGLST WHERE indx<8 OR indx=13 OR indx=14 OR indx=32
80
juliandyke.com
X$KGLST
INST_ID
KGLSTCMS KGLSTCHT KGLSTGET KGLSTGHT KGLSTPIN KGLSTPHT KGLSTRLD KGLSTINV KGLSTLRQ
NUMBER
NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
juliandyke.com
juliandyke.com
V$LOCK_TYPE
Introduced in Oracle 10.1 Lists all lock types Wildcards for Library Cache Locks and Pins Row Cache Locks
TYPE NAME ID1_TAG ID2_TAG VARCHAR2(64) VARCHAR2(64) VARCHAR2(64) VARCHAR2(64)
IS_USER
DESCRIPTION
VARCHAR2(3)
VARCHAR2(4000)
83
juliandyke.com
ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME LIBRARY_CACHE LEVEL 4';
For example:
BUCKET 127469: LIBRARY OBJECT HANDLE: handle=2bb8dfbc mutex=0x2bb8e070(0) name=US01.T1 hash=b2f454b86387761e02fc7e686e37f1ed timestamp=01-14-2006 22:04:06 namespace=TABL flags=KGHP/TIM/MED/[40000000] kkkk-dddd-llll=0000-0701-0701 lock=0 pin=0 latch#=1 hpc=0002 hlc=0002 lwt=0x2bb8e018[0x2bb8e018,0x2bb8e018] ltm=0x2bb8e020[0x2bb8e020,0x2bb8e020] pwt=0x2bb8dffc[0x2bb8dffc,0x2bb8dffc] ptm=0x2bb8e004[0x2bb8e004,0x2bb8e004] ref=0x2bb8e038[0x2bb8e038,0x2bb8e038] lnd=0x2bb8e044[0x2bb7a7ac,0x2bb8e410] LOCK INSTANCE LOCK: id=LBb2f454b86387761e PIN INSTANCE LOCK: id=NBb2f454b86387761e mode=S release=F flags=[00 INVALIDATION INSTANCE LOCK: id=IV0000c9890e170507 mode=S LIBRARY OBJECT: object=2caede30 type=TABL flags=EXS/LOC[0005] pflags=[0000] status=VALD load=0 BUCKET 127469 total object count=1 84
juliandyke.com
Instance Locks created for Library Cache Locks Library Cache Pins Lock name based on object hash value (KGLNAHSH) For example:
BUCKET 127469: LIBRARY OBJECT HANDLE: handle=2bb8dfbc mutex=0x2bb8e070(0) name=US01.T1 hash=b2f454b86387761e02fc7e686e37f1ed timestamp=01-14-2006 22:04:06 namespace=TABL flags=KGHP/TIM/MED/[40000000] kkkk-dddd-llll=0000-0701-0701 lock=0 pin=0 latch#=1 hpc=0002 hlc=0002 lwt=0x2bb8e018[0x2bb8e018,0x2bb8e018] ltm=0x2bb8e020[0x2bb8e020,0x2bb8e020] pwt=0x2bb8dffc[0x2bb8dffc,0x2bb8dffc] ptm=0x2bb8e004[0x2bb8e004,0x2bb8e004] ref=0x2bb8e038[0x2bb8e038,0x2bb8e038] lnd=0x2bb8e044[0x2bb7a7ac,0x2bb8e410] LOCK INSTANCE LOCK: id=LBb2f454b86387761e PIN INSTANCE LOCK: id=NBb2f454b86387761e mode=S release=F flags=[00 INVALIDATION INSTANCE LOCK: id=IV0000c9890e170507 mode=S LIBRARY OBJECT: object=2caede30 type=TABL flags=EXS/LOC[0005] pflags=[0000] status=VALD load=0 BUCKET 127469 total object count=1 85
juliandyke.com
For example in library cache dump Library cache pin instance lock is id=NBb2f454b86387761e
86
juliandyke.com
Namespaces->Instance Locks
Slide 1 of 3
Namespace
CRSR TABL
Lock
LA LB
Pin
NA NB
Namespace
JVSC JVRE
Lock
LN LO
Pin
NN NO
BODY
TRGR INDX CLST KGLT PIPE LOB DIR QUEU OBJG PROP
87
LC
LD LE LF LG LH LI LJ LK LL LM
NC
ND NE NF NG NH NI NJ NK NL NM
ROBJ
REIP CPOB EVNT SUMM DIMM CTS OUTL RULS RMGR XDBS
LP
LQ LR LS LT LU LV LW LX LY LZ
NP
NQ NR NS NT NU NV NW NX NY NZ
juliandyke.com
Namespaces->Instance Locks
Slide 2 of 3
Namespace
PPLN PCLS
Lock
EA EB
Pin
GA GB
Namespace
STAP RELS
Lock
EN EO
Pin
GN GO
SUBS
LOCS RMOB RSMD JVSD STFG TRANS RELC RULE STRM REVC
88
EC
ED EE EF EG EH EI EJ EK EL EM
GC
GD GE GF GG GH GI GJ GK GL GM
RELD
IFSD XDBC USAG MVOBTBL JSQI CDC MVOBINX STBO HTSO JSGA
EP
EQ ER ES ET EU EV EW EX EY EZ
GP
GQ GR GS GT GU GV GW GX GY GZ
juliandyke.com
Namespaces->Instance Locks
Slide 3 of 3
Namespace
JSET TABLE
Lock
VA VB
Pin
YA YB
CLST
INDX NSCPD JSLV MODL Unused Unused Unused Unused Unused Unused
89
VC
VD VE VF VG VH VI VJ VK VL VM
YC
YD YE YF YG YH YI YJ YK YL YM
juliandyke.com
V$ROWCACHE
CACHE# TYPE NUMBER VARCHAR2(11)
SUBORDINATE#
PARAMETER COUNT USAGE FIXED GETS GETMISSES SCANS SCANMISSES SCANCOMPLETES
NUMBER
VARCHAR2(32) NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
MODIFICATIONS
FLUSHES
NUMBER
NUMBER NUMBER NUMBER NUMBER
juliandyke.com
V$ROWCACHE
Based on X$KQRST Contains 42 rows in Oracle 10.2 34 Parent Cache 8 Subordinate Caches
91
juliandyke.com
Slide 1 of 2
Namespace dc_tablespaces dc_free_extents dc_segments dc_rollback_segments dc_used_extents dc_tablespace_quotas dc_files dc_users dc_objects dc_qmc_cache_entries dc_usernames dc_object_ids dc_constraints Lock QA QB QC QD QE QF QG QH QI QJ QK QL QM Cache# 13 14 15 16 17 18 19 20 21 22 23 24 25 Namespace dc_sequences dc_profiles dc_database_links dc_histogram_defs dc_global_oids dc_outlines dc_table_scns rule_info rule_or_piece dc_awr_control dc_qmc_ldap_cache... outstanding_alerts dc_hintsets Lock QN QO QP QQ QR QS QT QU QV QW QX QY QZ
Cache# 0 1 2 3 4 5 6 7 8 9 10 11 12
92
juliandyke.com
Slide 2 of 2
Cache# 26 27 28 29 30 31 32 33 Namespace global_database_name qmtmrcin_cache_entries qmtmrctn_cache_entries qmtmrcip_cache_entries qmtmrctp_cache_entries qmtmrciq_cache_entries qmtmrctq_cache_entries kqlsubheap_object Lock ?? ?? ?? ?? ?? ?? ?? ??
Cache# = KQRSTCID
93
juliandyke.com
Row Caches
ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME ROW_CACHE LEVEL 1';
For example:
size ------496 388 444 452 400 396 412 520 260 108 100 gets ------8909 0 4191 4210 0 0 0 9042 0 24 0 misses -----7 0 569 31 0 0 6 23 0 17 0 hit ratio --------0.999 0.000 0.880 0.993 0.000 0.000 0.000 0.997 0.000 0.585 0.000 DLM req ------7 0 709 74 0 0 6 23 0 0 0
ROW CACHE STATISTICS: cache -------------------------dc_tablespaces dc_free_extents dc_segments dc_rollback_segments dc_used_extents dc_tablespace_quotas dc_files dc_users dc_users dc_user_grants dc_app_role .... 94
juliandyke.com
Row Caches
Row cache statistics can be dumped using: ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME ROW_CACHE LEVEL 8';
For example:
Cache ID 8 BUCKET 48205: row cache parent object: address=0x2bb8dcd8 cid=8(dc_objects) dc_objects hash=313bbc4c typ=9 transaction=(nil) flags=00000002 own=0x2bb8dd44[0x2bb8dd44,0x2bb8dd44] wat=0x2bb8dd4c[0x2bb8dd4c,0x2bb8dd4c] mode=S status=VALID/-/-/-/-/-/-/-/request=N release=FALSE flags=0 Instance Lock instance lock id=QI f611ffad e31d1de3 QI F611FFAD E31D1DE3 set=0, complete=FALSE T1 data= 00000037 31540002 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001 00000000 00000000 00000000 00000000 00000000 00000000 ...... 00000000 00000000 00000000 0000c989 00000001 0000c989 016a7802 0705170e 0e016a78 78070517 170e016a 00010705 00000000 00000000 00000000 00000000 00000000 00000006 BUCKET 48205 total object count=1
95
juliandyke.com
KJILKFT
KJILKFT
KJILKFT
KJILKFT
KJIRFT
GES Resource
96
juliandyke.com
Resource Names
Contain 1 x two byte name 2 x 32 bit integer tag fields Used with Resources Enqueues Locks Global Enqueue Services Global Cache Services Block are resources with resource name BL
97
juliandyke.com
Resource Names
Externalized inconsistently throughout Oracle in V$/GV$ dynamic performance views X$ fixed tables Dumps and trace files Stored consistently in internal C structures including KJBR KJIRFT Other structures reference the resource names in these structures including KJBL KJILFKT
98
juliandyke.com
GES Parameters
GES Resources Number of GES resource structures probably determined by _lm_ress parameter Stored in heap Externalized in X$KJIRFT
GES Enqueues Number of GES enqueue structures probably determined by _lm_locks parameter Stored in segmented array Externalized in X$KJILKFT
99
juliandyke.com
X$KJIRFT
Externals global enqueue resources Does NOT include global cache resources
ADDR INDX INST_ID KJIRFTRP KJIRFTRN RAW(4) NUMBER NUMBER RAW(4) VARCHAR2(30)
KJIRFTCQ
KJIRFTGQ KJIRFTPR KJIRFTRDN KJIRFTMN KJIRFTNCL KJIRFTVS KJIRFTVB
NUMBER
NUMBER NUMBER VARCHAR2(25) NUMBER VARCHAR2(9) VARCHAR2(32) VARCHAR2(64)
100
juliandyke.com
X$KJILKFT
ADDR INDX INST_ID KJILKFTLKP KJILKFTGL RAW(4) NUMBER NUMBER RAW(4) VARCHAR2(9) KJILKFTOONXID KJILKFTCOGV KJILKFTCOPV KJILKFTCONV KJILKFTCODV NUMBER NUMBER NUMBER NUMBER NUMBER
KJILKFTRL
KJILKFTRP KJILKFTRN1 KJILKFTRN2 KJILKFTPID KJILKFTXID0 KJILKFTXID1 KJILKFTGID KJILKFTOODD KJILKFTOOPT
VARCHAR2(9)
RAW(4) VARCHAR2(30) VARCHAR2(30) NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
KJILKFTCONQ
KJILKFTCOEP KJILKFTCONDDW KJILKFTCONDDB KJILKFTWQ KJILKFTLS KJILKFTASTE0 KJILKFTON KJILKFTBLKED KJILKFTBLKER
NUMBER
NUMBER NUMBER NUMBER NUMBER VARCHAR2(64) NUMBER NUMBER NUMBER NUMBER
KJILKFTOOPO
101
NUMBER
juliandyke.com
V$GES_RESOURCE
Contains rows from both KJIRFT and KJBR Synonym for V$DLM_RESS
RESP RESOURCE_NAME ON_CONVERT_Q ON_GRANT_Q PERSISTENT_RES MASTER_NODE NEXT_CVT_LEVEL VALUE_BLK_STATE VALUE_BLK RAW(4) VARCHAR2(30) NUMBER NUMBER NUMBER NUMBER VARCHAR2(9) VARCHAR2(32) VARCHAR2(64)
102
juliandyke.com
V$GES_RESOURCE
Contains rows from both KJIRFT and KJBR Synonym for V$DLM_RESS
SELECT inst_id, kjirftrp, kjirftrn, kjirftcq, kjirftgq, kjirftpr, kjirftmn, kjirftncl, kjirftvs, kjirftvb FROM x$kjirft UNION ALL SELECT inst_id, kjbrresp, kjbrname, DECODE (kjbrcvtq, '00', 0, 1), DECODE (kjbrgrantq, '00', 0, 1), 1, kjbrmaster, kjbrncvl, 'KJUSERVS_NOVALUE', '0x0' FROM x$kjbr
103
juliandyke.com
V$GES_ENQUEUE
HANDLE GRANT_LEVEL REQUEST_LEVEL RESOURCE_NAME1 RESOURCE_NAME2 PID TRANSACTION_ID0 TRANSACTION_ID1 GROUP_ID OPEN_OPT_DEADLOCK OPEN_OPT_PERSISTENT
NUMBER
NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER VARCHAR2(64)
OPEN_OPT_PROCESS_OWNED
OPEN_OPT_NO_XID
NUMBER
NUMBER NUMBER NUMBER
104
juliandyke.com
V$GES_ENQUEUE
105
juliandyke.com
106
juliandyke.com