Inside RAC
description
Transcript of Inside RAC
1 © 2006 Julian Dyke
InsideRAC
Julian DykeIndependent Consultant
Web Version
juliandyke.com
2
© 2006 Julian Dykejuliandyke.com
Agenda
Introduction to RAC
Memory Structures
The Buffer Cache
Global Cache Services
The Library Cache
Global Enqueue Services
3
© 2006 Julian Dykejuliandyke.com
Introductionto
RAC
4
© 2006 Julian Dykejuliandyke.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
Node 1
Instance 1
Node 2
Instance 2Interconnect
Shared Storage
LocalDisk
LocalDisk
5
© 2006 Julian Dykejuliandyke.com
Architecture
Instance 1
Node 1
Instance 2
Node 2
SharedStorage
Storage Network
Private Network(Interconnect)
Public Network
6
© 2006 Julian Dykejuliandyke.com
Some Definitions Resource
Object to which access must be controlled at instance level
Enqueue Memory structure that serializes access to a resource
Global Resources Object to which access must be controlled at cluster level
Global Enqueue Locks and enqueues which need to be consistent between
all instances
7
© 2006 Julian Dykejuliandyke.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
8
© 2006 Julian Dykejuliandyke.com
Instance 2Instance 1
Background Processes
DIAG
LMON
LCK
LMD
LMS
LGWR
SMONPMON
CKPT
ARCH
DIAG
LMON
LCK
LMD
LMS
CKPT
ARCH
LGWR
PMON
DBWR
SMON
DBWR
Redo Logs
DatafilesControlfiles
Redo Logs
SGAUGASGA UGA
9
© 2006 Julian Dykejuliandyke.com
Background Processes LMSn
Global Cache Service Process
Manage requests for data access across cluster
Up to 20 in Oracle 10.1 LMS0-LMS9 LMSa-LMSj
Up to 36 in Oracle 10.2 LMS0-LMS9 LMSa-LMSz
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)
10
© 2006 Julian Dyke
juliandyke.com
Background Processes LCK0
Instance Enqueue Process
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
11
© 2006 Julian Dykejuliandyke.com
Background Processes LMD0
Global Enqueue Service Daemon
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
12
© 2006 Julian Dyke
juliandyke.com
Background Processes LMON
Global Enqueue Service Monitor
One LMON process per instance
Monitors cluster to maintain global enqueues and resources
Manages instance and process expirations recovery processing for cluster enqueues
13
© 2006 Julian Dyke
juliandyke.com
Background Processes DIAG - Diagnosibility Process
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
14
© 2006 Julian Dyke
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
15
© 2006 Julian Dyke
juliandyke.com
Dynamic Performance Views In a RAC environment each V$ view has an equivalent GV$
view GV$ view includes INST_ID column. For example V$SGA
NAME VARCHAR2(20)
VALUE NUMBER
GV$SGAINST_ID NUMBERNAME VARCHAR2(20)VALUE 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
16
© 2006 Julian Dyke
juliandyke.com
CATCLUST.SQL Some additional views/synonyms are created for RAC
databases using $ORACLE_HOME/rdbms/admin/catclust.sql
Synonym Name View NameV$GES_CONVERT_LOCAL V$DLM_CONVERT_LOCALV$GES_CONVERT_REMOTE V$DLM_CONVERT_REMOTEV$GES_LATCH V$DLM_LATCHV$GES_RESOURCE V$DLM_RESSV$GES_STATISTICS V$DLM_MISCV$GES_TRAFFIC_CONTROLLER V$DLM_TRAFFIC_CONTROLLER
GV$GES_CONVERT_LOCAL GV$DLM_CONVERT_LOCAL
GV$GES_CONVERT_REMOTE GV$DLM_CONVERT_REMOTE
GV$GES_LATCH GV$DLM_LATCH
GV$GES_RESOURCE GV$DLM_RESS
GV$GES_STATISTICS GV$DLM_MISC
GV$GES_TRAFFIC_CONTROLLER GV$DLM_TRAFFIC_CONTROLLER
17
© 2006 Julian Dyke
juliandyke.com
ORADEBUG ORADEBUG includes LKDEBUG
Must be run by user with SYSDBA privilege
SQL> ORADEBUG LKDEBUG HELP
Usage:lkdebug [options] -l [r|p] <enqueue pointer> Enqueue Object -r <resource pointer> Resource Object -b <gcs shadow pointer> GCS shadow Object -p <process id> client pid -P <process pointer> Process Object -O <i1> <i2> <types> Oracle Format resname -a <res/lock/proc> all <res/lock/proc> pointer -A <res/lock/proc> all <res/lock/proc> contexts -a <res> [<type>] all <res> pointers by an optional type -a convlock all converting enqueue (pointers) -A convlock all converting enqueue contexts -a convres all res ptr with converting enqueues -A convres all res contexts with converting enqueues
18
© 2006 Julian Dyke
juliandyke.com
ORADEBUG Continued...
-a name list all resource names -a hashcount list all resource hash bucket counts -t Traffic controller info -s summary of all enqueue types -k GES SGA summary info -m pkey <objectno> request for remastering this object at current instance -m dpkey <objectno> request for dissolving remastering of this object at current instance
19
© 2006 Julian Dyke
juliandyke.com
MemoryStructures
20
© 2006 Julian Dyke
juliandyke.com
Memory Areas An Oracle process includes
the following memory areas
Executable SGA Shared Libraries PGA/Session Heap Stack
40000000
20000000
Executable
PGASession Heap
SharedLibraries
SGA
Stack
STOPFFFFFFFF
00000000
21
© 2006 Julian Dyke
juliandyke.com
Shared Memory Shared memory areas can be dumped to trace file using
ORADEBUG SETMYPIDORADEBUG IPC
$ sqlplus /nologSQL> CONNECT SYS/<password> AS SYSDBAConnectedSQL> ORADEBUG SETMYPIDStatement processedSQL> ORADEBUG IPCInformation written to trace file
22
© 2006 Julian Dyke
juliandyke.com
Area #0 `Fixed Size' containing Subareas 0-0 Total size 0000000000129968 Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Addr 0 0 65537 0x00000020000000 0x00000020000000 Subarea size Segment size 000000000012a000 0000000010800000 Area #1 `Variable Size' containing Subareas 2-2 Total size 0000000010000000 Minimum Subarea size 00400000 Area Subarea Shmid Stable Addr Actual Addr 1 2 65537 0x00000020400000 0x00000020400000 Subarea size Segment size 0000000010000000 0000000010800000 Area #2 `Redo Buffers' containing Subareas 1-1 Total size 00000000002d6000 Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Add 2 1 65537 0x0000002012a000 0x0000002012a000 Subarea size Segment size 00000000002d6000 0000000010800000 Area #3 `skgm overhead' containing Subareas 3-3 Total size 0000000000001000 Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Addr 3 3 65537 0x00000030400000 0x00000030400000 Subarea size Segment size 0000000000001000 0000000010800000
ORADEBUG IPC - Example
STOP
Area #0 `Fixed Size' containing Subareas 0-0 Total size 0000000000129968 Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Addr 0 0 65537 0x00000020000000 0x00000020000000 Subarea size Segment size 000000000012a000 0000000010800000 Area #1 `Variable Size' containing Subareas 2-2 Total size 0000000010000000 Minimum Subarea size 00400000 Area Subarea Shmid Stable Addr Actual Addr 1 2 65537 0x00000020400000 0x00000020400000 Subarea size Segment size 0000000010000000 0000000010800000 Area #2 `Redo Buffers' containing Subareas 1-1 Total size 00000000002d6000 Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Add 2 1 65537 0x0000002012a000 0x0000002012a000 Subarea size Segment size 00000000002d6000 0000000010800000 Area #3 `skgm overhead' containing Subareas 3-3 Total size 0000000000001000 Minimum Subarea size 00000000 Area Subarea Shmid Stable Addr Actual Addr 3 3 65537 0x00000030400000 0x00000030400000 Subarea size Segment size 0000000000001000 0000000010800000
Fixed Area
Variable Area
Redo Buffers
OS Specific
23
© 2006 Julian Dyke
juliandyke.com
Shared Global Area Contains
Fixed SGA Buffer Pool Shared Pool Oracle 7.0 and above Large Pool Oracle 8.0 and above Java Pool Oracle 8.1.5 and above Streams Pool Oracle 10.1 and above Redo buffers
Buffer Pool includes Default cache Keep and Recycle cache Oracle 8.0 and above 2K, 4K, 8K, 16K and 32K cache Oracle 9.0.1 and above
24
© 2006 Julian Dyke
juliandyke.com
V$SGAINFO Summarizes SGA pools
NAME VARCHAR2(32)BYTES NUMBERRESIZEABLE VARCHAR2(3)
SELECT * FROM v$sgainfo;
NAME BYTES RESIZEABLE-------------------------------- ---------- ----------Fixed SGA Size 1218920 NoRedo Buffers 2973696 NoBuffer Cache Size 176160768 YesShared Pool Size 83886080 YesLarge Pool Size 4194304 YesJava Pool Size 4194304 YesStreams Pool Size 0 YesGranule Size 4194304 NoMaximum SGA Size 272629760 NoStartup overhead in Shared Pool 46137344 NoFree SGA Memory Available 0
25
© 2006 Julian Dyke
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
26
© 2006 Julian Dyke
juliandyke.com
Granules In Oracle 10.1 and above
SGA_MAX_SIZE dependent on SGA_TARGET
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
27
© 2006 Julian Dyke
juliandyke.com
X$KSMGEIntroduced in Oracle 9.2Describes individual granules
ADDR RAW(4)INDX NUMBERINST_ID NUMBERGRANNUM NUMBERGRANTYPE NUMBERGRANSTATE VARCHAR2(16)GRANFLAGS NUMBERLOCALITY NUMBERKSMAREANUM NUMBERBASEADDR RAW(4)GRANSIZE NUMBERGRANNEXT NUMBERGRANPREV NUMBER
INVALID (Free)ALLOCATED
Granule Address
Granule Size
Next granule ID
Previous granule ID
Granule ID
0 Free1 Shared Pool2 Large Pool3 Java Pool6 Buffer Pool
28
© 2006 Julian Dyke
juliandyke.com
Granules
SGA_TARGET = 260M SGA_MAX_SIZE = 260M
GRANULE SIZE = 4M
256M
4M
Buffer Pool 172M
Fixed SGA + Redo Buffers 4M
Large Pool 4M
Shared Pool 76M
Java Pool 4M
STOP
This is an example of an SGA mapped using X$KSMGE
29
© 2006 Julian Dyke
juliandyke.com
V$SGASTAT Enhanced in Oracle 10.1 and above
Shared Pool 682Large Pool 6Java Pool 4Streams Pool 4
In Oracle 10.2 describes around 700 memory areas
POOL VARCHAR2(12)NAME VARCHAR2(26)BYTES NUMBER
30
© 2006 Julian Dyke
juliandyke.com
V$SGASTAT RAC-specific areas includegcs affinitygcs close objgcs commit sga stategcs I/O statistics structgcs mastership bucketsgcs opaque ingcs res hash bucketgcs res latch tablegcs resource freelist arrgcs resource freelist dyngcs resourcesgcs scan queue arraygcs shadow locks dyn seggcs shadow locks freelistgcs shadows
ges big msg buffersges deadlock xid freelistges deadlock xid hash tabges enqueue cur. usage peges enqueue max. usage peges enqueue multiple freeges enqueuesges ipc instance mapsges lmd process descriptoges lms process descriptoges process arrayges process hash tableges recovery domain tableges regular msg buffersges reserved msg buffers
ges res mastership bucketges resourceges resource hash seq tabges resource hash tableges resource poolsges scan queue arrayges shared global areaKCL buffer headerKCL instance cache transfKCL lock contextsKCL lock stateKCL name tableKCL partition tableKCL region arrayKJXM msg statistics table
31
© 2006 Julian Dyke
juliandyke.com
V$SGASTAT Significant RAC areas in Oracle 10.2
Name Size(bytes) Locationgcs resources 2298008 Segmented Arraygcs shadows 1632280 Segmented Arrayges resource 1257188 Heapges enqueues 1625344 Segmented Arrayges big msg buffers 3979396 Unknown
In Oracle 9.2 all five structures were stored in segmented arrays
32
© 2006 Julian Dyke
juliandyke.com
Permanent Areas
SELECT ksmchptr, ksmchsizFROM x$ksmspWHERE ksmchcls = 'perm';
Address Size
2D034000 3981312
2D434000 3549424
2D834000 39632362DC34000 39805842DFFFD28 7282E034000 3919532
Allocated at instance startup Contain structures such as
processes sessions segmented arrays
STOP
2AC000002B8000002BC000002C0000002C4000002C8000002CC000002D000000
2D8000002DC000002E0000002E4000002E8000002EF000002F0000002F4000002F8000002FC0000030000000
2D400000
PermanentArea
Heap
33
© 2006 Julian Dyke
juliandyke.com
X$KSMSP Externalises chunks in the shared pool
ADDR RAW(4)INDX NUMBERINST_ID NUMBERKSMCHIDX NUMBERKSMCHDUR NUMBERKSMCHCOM VARCHAR2(16)KSMCHPTR RAW(4)KSMCHSIZ NUMBERKSMCHCLS VARCHAR2(8)KSMCHTYP NUMBERKSMCHPAR RAW(4)
Description of chunk type
Address of chunk
Size including header
Class●Perm●Recreate●Freeable●Free●R-Free●R-Freeable
Address of parent
Type (recreate only)●0x18 - KGL Handle●0x24 - Fixed Allocation●0x74 - KQR PO●0x80 - KQR SO●0xFFF - Extended header
34
© 2006 Julian Dyke
juliandyke.com
X$KSMSP Some RAC components are stored in the shared pool heap
SELECT ksmchcom, SUM(ksmchsiz), COUNT(*)FROM x$ksmspGROUP BY ksmchcom;
gcs_mastership 4620 1gcs_res_hash_bu 16396 1gcs_res_latch_t 7692 1ges_res_masters 3084 1ges_resource 619276 164
35
© 2006 Julian Dyke
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
36
© 2006 Julian Dyke
juliandyke.com
Segmented Arrays
SegmentedArrays
Call
Enqueues
EnqueueResources
SegmentedArray
HeaderSegmented
Array
SegmentedArray
Header
SegmentedArray
STOP
37
© 2006 Julian Dyke
juliandyke.com
X$KSMDD Externalises segmented array headers
ADDR RAW(4)INDX NUMBERINST_ID NUMBERNAME VARCHAR2(30)ELEMENTS_CHUNK NUMBERITEMS_PT NUMBERINITENTRIES NUMBERNUMENTRIES NUMBERCURENTRIES NUMBERNUMCHUNKS NUMBERELEMSIZE NUMBERFLAGS NUMBERHEAP RAW(4)SECONDARY RAW(4)
Name of array
Address of parent heap
Number of chunks
38
© 2006 Julian Dyke
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
39
© 2006 Julian Dyke
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
Extent 0 Extent 1 Extent 2HeapHeader
Free List Chunks
STOP
40
© 2006 Julian Dyke
juliandyke.com
X$KSMHP Externalises chunks in the heap
ADDR RAW(4)INDX NUMBERINST_ID NUMBERKSMCHDS RAW(4)KSMCHCOM VARCHAR2(16)KSMCHPTR RAW(4)KSMCHSIZ NUMBERKSMCHCLS VARCHAR2(8)KSMCHTYP NUMBERKSMCHPAR RAW(4)KSMCHOWN RAW(4)
Can only be accessed using KSMCHDS e.g.SELECT * FROM x$ksmhpWHERE ksmchds = HEXTORAW ('2CA54040');
41
© 2006 Julian Dyke
juliandyke.com
The BufferCache
42
© 2006 Julian Dyke
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
Granule
Buffers
STOP
43
© 2006 Julian Dyke
juliandyke.com
X$BHADDR RAW(4)INDX NUMBERINST_ID NUMBERHLADDR RAW(4)BLSIZ NUMBERNXT_HASH RAW(4)PRV_HASH RAW(4)NXT_REPL RAW(4)PRV_REPL RAW(4)FLAG NUMBERRFLAG NUMBERSFLAG NUMBERLRU_FLAG NUMBERTS# NUMBERFILE# NUMBERDBARFIL NUMBERDBABLK NUMBER
CLASS NUMBERSTATE NUMBERMODE_HELD NUMBERCHANGES NUMBERCSTATE NUMBERLE_ADDR RAW(4)DIRTY_QUEUE NUMBERSET_DS RAW(4)OBJ NUMBERBA RAW(4)CR_SCN_BAS NUMBERCR_SCN_WRP NUMBERCR_XID_USN NUMBERCR_XID_SLT NUMBERCR_XID_SQN NUMBERCR_UBA_FIL NUMBERCR_UBA_BLK NUMBER
CR_UBA_SEQ NUMBERCR_UBA_REC NUMBERCR_SFL NUMBERCR_CLS_BAS NUMBERCR_CLS_WRP NUMBERLRBA_SEQ NUMBERLRBA_BNO NUMBERHSCN_BAS NUMBERHSCN_WRP NUMBERHSUB_SCN NUMBERUS_NXT RAW(4)US_PRV RAW(4)WA_NXT RAW(4)WA_PRV RAW(4)TCH NUMBERTIM NUMBER
44
© 2006 Julian Dyke
juliandyke.com
Head of Cold End
Head of Hot End
Single-Block Reads
92
0
34
3
72
4
52
1
71
2
66
0
49
0
42
1
45
2
52
1
71
2
66
0
42
1
11
1
52
1
71
2
11
1
42
1
42
2
71
0
92
0
34
3
72
4
45
2
11
1
52
1
42
2
33
1
45
2
11
1
42
2
33
1
34
4
92
0
34
4
72
4
45
2
11
1
42
0
33
1
71
0
87
1
87
1
72
4
33
1
45
2
Read Block 42
Get first available buffer from cold endUpdate buffer contentsInsert buffer at head of cold end
Read Block 11
Get first available buffer from cold endUpdate buffer contentsInsert buffer at head of cold end
Read Block 42
Update touch count for block 42
Read Block 33
Move block 71 to head of hot endSet touch count on block 71 to zeroGet first available bufferfrom cold endUpdate buffer contentsInsert buffer at head of coldend
Read Block 34
Update touch countfor block 34
Read Block 87
Move block 42 to headof hot endSet touch counton block 42 to zeroGet first available bufferfrom cold endUpdate buffer contentsInsert buffer at head of coldend
STOP
Block Number
Touch Count
45
© 2006 Julian Dyke
juliandyke.com
Multi-Block Reads
Head of Cold End
Head of Hot End
Read Block 1
Get first four available buffers from cold endRead next four blocks into buffers
1 2 3 4
Insert buffers at head of cold end
12 13 2 14 3 2 1
Move block 1 to cold end
121
Read Block 2
Move block 2 to cold end
21 321 3 4
Read Block 3
Move block 3 to cold end
Read Block 4
Move block 4 to cold end
Read Block 5
Get next four available buffers from cold endRead next four blocks into buffersInsert buffers at head of cold endMove block 5 to cold end
4 3 2 15
5 56
76
7 6 5
8
78 5 56 5 65 6 75 6 7 8
Read Block 6
Move block 6 to cold end
Read Block 7
Move block 7 to cold end
Read Block 8
Move block 8 to cold end
STOP
DB_FILE_MULTIBLOCK_READ_COUNT = 4
46
© 2006 Julian Dyke
juliandyke.com
GlobalCache
Services
47
© 2006 Julian Dyke
juliandyke.com
Read with No Transfer
Instance 1
Instance 2
Instance 4
1318
Request shared resource
Instance 3
ResourceMaster
Instance 2 requests current read on block
Request granted
SN
Read request
Block returned
1318
1
2
3
4
STOP
48
© 2006 Julian Dyke
juliandyke.com
Read to Write Transfer
Instance 1
Instance 2
Instance 4
1318
Request exclusiveresource
Instance 3
ResourceMaster
Instance 1 requests exclusive read on block
Transfer block to Instance 1 for
exclusiveaccess
SNBlock and resource status
Resource status
1318
1
2
3
4
N
N
X
1320
STOP
49
© 2006 Julian Dyke
juliandyke.com
Write to Write Transfer
Instance 1
Instance 2
Instance 4
1318
Request block in exclusive mode
Instance 3
ResourceMaster
Instance 4 requests exclusive read on block
Transfer block to Instance 4 in exclusive
mode
SN
Block and resource status
Resource status
1318
12
3
4N NX
1320N
N
X1320 1323
STOP
Note that Instance 1 will create a past image (PI) of the dirty block
50
© 2006 Julian Dyke
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)
51
© 2006 Julian Dyke
juliandyke.com
Past Images
13281329UPDATE t1SET c1 = 1324;COMMIT;
UPDATE t1SET c1 = 1329;COMMIT;
1323
Instance 1
13231324132513261327
Buffer Cache
13241323
13251324
13261325
13271326
1328
13281327
Redo Log 1
Instance 2
Buffer Cache
13291328
UPDATE t1SET c1 = 1325;COMMIT;
UPDATE t1SET c1 = 1326;COMMIT;
UPDATE t1SET c1 = 1327;COMMIT;
UPDATE t1SET c1 = 1328;COMMIT; 1328
1323
Redo Log 2
1323
132813291329
1329
1329
Assume table t1 contains a single row in block 42
Instance 1 updates column to 1324Block 42 is read from diskUndo/Redo written to
Redo Log 1Block 42 is updated in buffer
cacheInstance 1 updates column to
1325Undo/Redo written to
Redo Log 1Block 42 is updated in buffer
cacheInstance 1 updates column to
1326Undo/Redo written to
Redo Log 1Block 42 is updated in buffer
cacheInstance 1 updates column to
1327Undo/Redo written to
Redo Log 1Block 42 is updated in buffer
cacheInstance 1 updates column to
1328Undo/Redo written to
Redo Log 1Block 42 is updated in buffer
cacheInstance 2 updates column to
1329GCS transfers block from Instance 1 to Instance 2
Instance 1 makes block 42 a Past Image blockUndo/redo written to
Redo Log 2Block 42 is updated in buffer
cacheInstance 2 Crashes
Contents of buffer cache are lostDBWR has not written changes
to block 42 back to disk yetInstance 1 must perform recovery for Instance 2
Block 42 needs recoveryInstance 1 uses Past Image Undo/redo is applied from
Redo Log 2Block 42 is subsequently written
back to disk by DBWR
STOP
52
© 2006 Julian Dyke
juliandyke.com
Write to Read Transfer
Instance 1
Instance 2
Instance 4
1318
Request block in shared mode
Instance 3
ResourceMaster
Instance 2 requests current read on block
SN
Block and resource status
Resource status
1318
1
3
4
N NX1320
N
N
X1320 1323
Transferblock to Instance 1in sharedmode
2
S
S
STOP
Note that in recent versions _fairness_threshold is used to avoid unnecessary lock conversions
53
© 2006 Julian Dyke
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
54
© 2006 Julian Dyke
juliandyke.com
Fairness Threshold
Assume instance 1 holds exclusive lock on block
Instance 2
Instance 2 requests consistent readInstance 1 sets counter to 1Instance 1 sends block to
Instance 2
13231323
Instance 1
X
Instance 2 receives block with Null lock
13231323
01234 N
Instance 2 requests consistent readInstance 1 sets counter to 2Instance 1 sends block to
Instance 2Instance 2 receives block with
Null lock
1323
Instance 2 requests consistent readInstance 1 sets counter to 3Instance 1 sends block to
instance 2Instance 2 receives block with
Null lockInstance 2 requests consistent
readInstance 1 sets counter to 4Instance 1 downgrades lock from X to S
S
Instance 1 sends block to Instance 2
Instance 2 receives block with Shared lock
S
_fairness_threshold = 4
STOP
55
© 2006 Julian Dyke
juliandyke.com
Lock Elements Contain embedded GCS Client structures (KJBL)
LockElement
GCSClient
BufferHeader
LockElement
GCSClient
BufferHeader
BufferHeader
LockElement
GCSClient
56
© 2006 Julian Dyke
juliandyke.com
V$LOCK_ELEMENT Based on X$LE
LOCK_ELEMENT_ADDR RAW(4)INDX NUMBERCLASS NUMBERLOCK_ELEMENT_NAME NUMBERMODE_HELD NUMBERBLOCK_COUNT NUMBERRELEASING NUMBERACQUIRING NUMBERINVALID NUMBERFLAGS NUMBER
57
© 2006 Julian Dyke
juliandyke.com
X$LEADDR RAW(4)INDX NUMBERINST_ID NUMBERLE_ADDR RAW(4)NAME NUMBERLE_CLASS NUMBERLE_RLS NUMBERLE_ACQ NUMBERLE_FLAGS NUMBERLE_MODE NUMBERLE_WRITE NUMBERLE_LOCAL NUMBERLE_RECOVERY NUMBERLE_BLKS NUMBERLE_TIME NUMBERLE_KJBL RAW(4)
BufferHeader
LockElement
GCSClient
STOP
58
© 2006 Julian Dyke
juliandyke.com
Global Cache Services
KJBRKJBR
KJBL
BH BH
LE
KJBL
LE
KJBL
GCSClient
GCSShadow
59
© 2006 Julian Dyke
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
60
© 2006 Julian Dyke
juliandyke.com
X$KJBR Externalizes GCS Resources
ADDR RAW(4)INDX NUMBERINST_ID NUMBERKJBRRESP RAW(4)KJBRGRANT VARCHAR2(9)KJBRNCVL VARCHAR2(9)KJBRROLE NUMBERKJBRNAME VARCHAR2(30)KJBRMASTER NUMBERKJBRGRANTQ RAW(4)KJBRCVTQ RAW(4)KJBRWRITER RAW(4)
61
© 2006 Julian Dyke
juliandyke.com
X$KJBL Externalizes GCS Enqueues
ADDR RAW(4)INDX NUMBERINST_ID NUMBERKJBLLOCKP RAW(4)KJBLGRANT VARCHAR2(9)KJBLREQUEST VARCHAR2(9)KJBLROLE NUMBERKJBLRESP RAW(4)KJBLNAME VARCHAR2(30)KJBLNAME2 VARCHAR2(30)KJBLQUEUE NUMBERKJBLLOCKST VARCHAR2(64)KJBLWRITING NUMBERKJBLREQWRITE NUMBERKJBLMASTER NUMBERKJBLBLOCKED NUMBERKJBLBLOCKER NUMBER
62
© 2006 Julian Dyke
juliandyke.com
Global Cache Dumps To dump the contents of the global cache use:
ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME GC_ELEMENTS LEVEL 1';
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 181grant 1 cvt 0 mdrole 0x21 st 0x20 GRANTQ rl LOCALmaster 1 owner 0 sid 0 remote[(nil),0] hist 0x7chistory 0x3c.0x1.0x0.0x0.0x0.0x0. cflag 0x0 sender 2 flags 0x0 replay# 0disk: 0x0000.00000000 write request: 0x0000.00000000pi scn: 0x0000.00000000msgseq 0x1 updseq 0x0 reqids[1,0,0] infop 0x0pkey 181hv 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 0x0lb 0, hb 0, myb 178, drmb 178, apifrz 0
63
© 2006 Julian Dyke
juliandyke.com
Global Cache Dumps 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 .....
64
© 2006 Julian Dyke
juliandyke.com
Block Mastering Each block is mastered on one instance
Block DBA is reported by X$KJBR.KJBRNAME
Names for have the format: [<block_number>][<file_number>],[BL]
Ordering by X$KJBR.KJBRNAME is difficult because the resource names do not collate e.g.
[0x900][0x70000],[BL] [0x90][0x70000],[BL]
Current master reported by X$KJBR.KJBRMASTER
65
© 2006 Julian Dyke
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
Start End
0x080 0x0FF
0x180 0x1FF0x280 0x2FF0x380 0x3FF0x480 0x4FF0x580 0x5FF
etc etc
Start End
0x000 0x07F
0x100 0x17F0x200 0x27F0x300 0x37F0x400 0x47F0x500 0x57F
etc etc
Instance 0 Instance 1
66
© 2006 Julian Dyke
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....
67
© 2006 Julian Dyke
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
68
© 2006 Julian Dyke
juliandyke.com
Dynamic Remastering Example
SELECT data_object_id FROM dba_objectsWHERE owner = 'US01'AND object_name = 'T1';
OBJECT_ID---------52084
ORADEBUG LKDEBUG -m pkey 52084
To remaster object at current instance use:
All blocks now mastered by the current instance
To redistribute masters to all available instances use:
ORADEBUG LKDEBUG -m dpkey 52084
Blocks mastered by both (all) instances again
69
© 2006 Julian Dyke
juliandyke.com
V$GCSPFMASTER_INFO Object re mastering is recorded in V$GCSPFMASTER_INFO
FILE_ID NUMBEROBJECT_ID NUMBERCURRENT_MASTER NUMBERPREVIOUS_MASTER NUMBERREMASTER_CNT NUMBER
70
© 2006 Julian Dyke
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;
After remastering object 52084 to instance 1
Object ID Current Master Previous Master52084 0 32767
Object ID Current Master Previous Master52084 1 0
71
© 2006 Julian Dyke
juliandyke.com
Dynamic Remastering Information about Dynamic Remastering operations is also
recorded in the following fixed views
X$KJDRMREQ Dynamic Remastering Requests
X$KJDRMAFNSTATS File Remastering Statistics
X$KJDRMHVSTATS Hash Value Statistics
72
© 2006 Julian Dyke
juliandyke.com
The LibraryCache
73
© 2006 Julian Dyke
juliandyke.com
Library Cache Object - Parent
16 x 1 wordpointers
KGLHD
ParentObject
KGLNA
SELECT SUM (c2) FROM t1WHERE c3 = 42 AND c4 < 2004
ParentName
ChildHandle
KGLHD
Child 1
Child 2
Heap 0
KGLOB
X$KGLOBParentHandle
KGLHD
STOP
74
© 2006 Julian Dyke
juliandyke.com
Library Cache Object - Child
KGLHD
ChildHandle
ChildObject
SELECTStatement
Heap 6
KGLOB
SubheapHeader
SubheapHeader
Heap 0
SubqueryHeader
Statistics,Optimizer
Environment,BindVariables
X$KGLOB
STOP
75
© 2006 Julian Dyke
juliandyke.com
Library Cache In general
Locks are required for parsing Externalized in X$KGLLK
Pins are required for execution Externalized in X$KGLPN
Each KGLHD structure has a set of double linked lists including; Locks Pins
76
© 2006 Julian Dyke
juliandyke.com
X$KGLPN
X$KGLLK
Library Cache Object - Locks & Pins
ChildHandle
ChildObject
KGLOB
X$KGLOB
STOP
LockLock
Pin
Lock
Pin Pin
KGLHD
77
© 2006 Julian Dyke
juliandyke.com
Namespaces In Oracle 10.2 there are 64 library cache namespaces Externalized by KGLHDNSP in X$KGLOB
CRSR LOB REIP RMGR JVSD RELS MVOBINX NSCPDTABL DIR CPOB XDBS STFG RELD STBO JSLVBODY QUEU EVNT PPLN TRANS IFSD HTSO MODLTRGR OBJG SUMM PCLS RELC XDBC JSGA UnusedINDX PROP DIMM SUBS RULE USAG JSET UnusedCLST JVSC CTS LOCS STRM MVOBTBL TABLE UnusedKGLT JVRE OUTL RMOB REVC JSQI CLST UnusedPIPE ROBJ RULS RSMD STAP CDC INDX Unused
78
© 2006 Julian Dyke
juliandyke.com
Namespaces Library cache statistics can be dumped using:
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 0TABL 4368 0.578 10032 0.657 961 0BODY 127 0.717 211 0.801 4 0TRGR 4 0.000 45 0.911 0 0INDX 81 0.272 83 0.036 21 0CLST 101 0.921 264 0.958 3 0KGLT 0 0.000 0 0.000 0 0PIPE 0 0.000 0 0.000 0 0LOB 0 0.000 0 0.000 0 0DIR 0 0.000 0 0.000 0 0QUEU 156 0.904 5886 0.997 0 0....
79
© 2006 Julian Dyke
juliandyke.com
V$LIBRARYCACHE Subset of rows from X$KGLST Contains 11 rows in Oracle 10.2
NAMESPACE VARCHAR2(15)GETS NUMBERGETHITS NUMBERGETHITRATIO NUMBERPINS NUMBERPINHITS NUMBERPINHITRATIO NUMBERRELOADS NUMBERINVALIDATIONS NUMBERDLM_LOCK_REQUESTS NUMBERDLM_PIN_REQUESTS NUMBERDLM_PIN_RELEASES NUMBERDLM_INVALIDATION_REQUESTS NUMBERDLM_INVALIDATIONS NUMBER
RAC Specific
Statistics
80
© 2006 Julian Dyke
juliandyke.com
SELECT inst_id, DECODE (indx,
0,'SQL AREA',1,'TABLE/PROCEDURE',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 FROM x$kglst WHERE indx<8 OR indx=13 OR indx=14 OR indx=32
V$LIBRARYCACHE Based on X$KGLST
Names are generated in dynamic performance view
Only selected rows from X$KGLST
81
© 2006 Julian Dyke
juliandyke.com
X$KGLST Contains one row for each namespace (59 rows in 10.2)
ADDR RAW(4)INDX NUMBERINST_ID NUMBERKGLSTCMS NUMBERKGLSTCHT NUMBERKGLSTGET NUMBERKGLSTGHT NUMBERKGLSTPIN NUMBERKGLSTPHT NUMBERKGLSTRLD NUMBERKGLSTINV NUMBERKGLSTLRQ NUMBERKGLSTPRQ NUMBERKGLSTPRL NUMBERKGLSTIRQ NUMBERKGLSTMIV NUMBER
RAC Specific
Statistics
82
© 2006 Julian Dyke
juliandyke.com
GlobalEnqueueServices
83
© 2006 Julian Dyke
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 VARCHAR2(64)NAME VARCHAR2(64)ID1_TAG VARCHAR2(64)ID2_TAG VARCHAR2(64)IS_USER VARCHAR2(3)DESCRIPTION VARCHAR2(4000)
84
© 2006 Julian Dyke
juliandyke.com
Library Cache Objects Library Cache Objects can be dumped using:
ALTER SESSION SET EVENTS'IMMEDIATE TRACE NAME LIBRARY_CACHE LEVEL 4';
BUCKET 127469:LIBRARY OBJECT HANDLE: handle=2bb8dfbc mutex=0x2bb8e070(0)name=US01.T1hash=b2f454b86387761e02fc7e686e37f1ed timestamp=01-14-2006 22:04:06namespace=TABL flags=KGHP/TIM/MED/[40000000]kkkk-dddd-llll=0000-0701-0701 lock=0 pin=0 latch#=1 hpc=0002 hlc=0002lwt=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=LBb2f454b86387761ePIN INSTANCE LOCK: id=NBb2f454b86387761e mode=S release=F flags=[00INVALIDATION INSTANCE LOCK: id=IV0000c9890e170507 mode=SLIBRARY OBJECT: object=2caede30type=TABL flags=EXS/LOC[0005] pflags=[0000] status=VALD load=0
BUCKET 127469 total object count=1
For example:
85
© 2006 Julian Dyke
juliandyke.com
Library Cache Instance Locks 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.T1hash=b2f454b86387761e02fc7e686e37f1ed timestamp=01-14-2006 22:04:06namespace=TABL flags=KGHP/TIM/MED/[40000000]kkkk-dddd-llll=0000-0701-0701 lock=0 pin=0 latch#=1 hpc=0002 hlc=0002lwt=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=LBb2f454b86387761ePIN INSTANCE LOCK: id=NBb2f454b86387761e mode=S release=F flags=[00INVALIDATION INSTANCE LOCK: id=IV0000c9890e170507 mode=SLIBRARY OBJECT: object=2caede30type=TABL flags=EXS/LOC[0005] pflags=[0000] status=VALD load=0
BUCKET 127469 total object count=1
86
© 2006 Julian Dyke
juliandyke.com
Library Cache Instance Locks For example in library cache dump
Library cache pin instance lock is id=NBb2f454b86387761e
In X$KJIRFT this KJIRFTRN column [0xb2f454b8][0x6387761e],[NB]
87
© 2006 Julian Dyke
juliandyke.com
Namespaces->Instance Locks Slide 1 of 3
Namespace Lock PinJVSC LN NNJVRE LO NOROBJ LP NPREIP LQ NQCPOB LR NREVNT LS NSSUMM LT NTDIMM LU NUCTS LV NV
OUTL LW NWRULS LX NXRMGR LY NYXDBS LZ NZ
Namespace Lock PinCRSR LA NATABL LB NBBODY LC NCTRGR LD NDINDX LE NECLST LF NFKGLT LG NGPIPE LH NHLOB LI NIDIR LJ NJ
QUEU LK NKOBJG LL NLPROP LM NM
88
© 2006 Julian Dyke
juliandyke.com
Namespaces->Instance Locks Slide 2 of 3
Namespace Lock PinSTAP EN GNRELS EO GORELD EP GPIFSD EQ GQXDBC ER GRUSAG ES GS
MVOBTBL ET GTJSQI EU GUCDC EV GV
MVOBINX EW GWSTBO EX GXHTSO EY GYJSGA EZ GZ
Namespace Lock PinPPLN EA GAPCLS EB GBSUBS EC GCLOCS ED GDRMOB EE GERSMD EF GFJVSD EG GGSTFG EH GH
TRANS EI GIRELC EJ GJRULE EK GKSTRM EL GLREVC EM GM
89
© 2006 Julian Dyke
juliandyke.com
Namespaces->Instance Locks Slide 3 of 3
Namespace Lock PinJSET VA YA
TABLE VB YBCLST VC YCINDX VD YD
NSCPD VE YEJSLV VF YFMODL VG YG
Unused VH YHUnused VI YIUnused VJ YJUnused VK YKUnused VL YLUnused VM YM
90
© 2006 Julian Dyke
juliandyke.com
V$ROWCACHECACHE# NUMBERTYPE VARCHAR2(11)SUBORDINATE# NUMBERPARAMETER VARCHAR2(32)COUNT NUMBERUSAGE NUMBERFIXED NUMBERGETS NUMBERGETMISSES NUMBERSCANS NUMBERSCANMISSES NUMBERSCANCOMPLETES NUMBERMODIFICATIONS NUMBERFLUSHES NUMBERDLM_REQUESTS NUMBERDLM_CONFLICTS NUMBERDLM_RELEASES NUMBER
RAC Specific
Statistics
91
© 2006 Julian Dyke
juliandyke.com
V$ROWCACHE Based on X$KQRST Contains 42 rows in Oracle 10.2
34 Parent Cache 8 Subordinate Caches
92
© 2006 Julian Dyke
juliandyke.com
Row Caches->Instance Locks Slide 1 of 2
Cache# Namespace Lock0 dc_tablespaces QA1 dc_free_extents QB2 dc_segments QC3 dc_rollback_segments QD4 dc_used_extents QE5 dc_tablespace_quotas QF6 dc_files QG7 dc_users QH8 dc_objects QI9 dc_qmc_cache_entries QJ
10 dc_usernames QK11 dc_object_ids QL12 dc_constraints QM
Cache# Namespace Lock13 dc_sequences QN14 dc_profiles QO15 dc_database_links QP16 dc_histogram_defs QQ17 dc_global_oids QR18 dc_outlines QS19 dc_table_scns QT20 rule_info QU21 rule_or_piece QV22 dc_awr_control QW23 dc_qmc_ldap_cache... QX24 outstanding_alerts QY25 dc_hintsets QZ
93
© 2006 Julian Dyke
juliandyke.com
Row Caches->Instance Locks Slide 2 of 2
Cache# Namespace Lock26 global_database_name ??27 qmtmrcin_cache_entries ??28 qmtmrctn_cache_entries ??29 qmtmrcip_cache_entries ??30 qmtmrctp_cache_entries ??31 qmtmrciq_cache_entries ??32 qmtmrctq_cache_entries ??33 kqlsubheap_object ??
Cache# = KQRSTCID
94
© 2006 Julian Dyke
juliandyke.com
Row Caches Row cache statistics can be dumped using:
ALTER SESSION SET EVENTS'IMMEDIATE TRACE NAME ROW_CACHE LEVEL 1';
For example:
ROW CACHE STATISTICS:cache size gets misses hit ratio DLM req-------------------------- ------- ------- ------ --------- -------dc_tablespaces 496 8909 7 0.999 7dc_free_extents 388 0 0 0.000 0dc_segments 444 4191 569 0.880 709dc_rollback_segments 452 4210 31 0.993 74dc_used_extents 400 0 0 0.000 0dc_tablespace_quotas 396 0 0 0.000 0dc_files 412 0 6 0.000 6dc_users 520 9042 23 0.997 23 dc_users 260 0 0 0.000 0 dc_user_grants 108 24 17 0.585 0 dc_app_role 100 0 0 0.000 0....
95
© 2006 Julian Dyke
juliandyke.com
BUCKET 48205: row cache parent object: address=0x2bb8dcd8 cid=8(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 id=QI f611ffad e31d1de3 set=0, complete=FALSE 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
Row Caches Row cache statistics can be dumped using:
ALTER SESSION SET EVENTS'IMMEDIATE TRACE NAME ROW_CACHE LEVEL 8';
For example:
T1
Instance LockQI F611FFAD E31D1DE3
Cache ID 8dc_objects
96
© 2006 Julian Dyke
juliandyke.com
GESResource
Global Enqueue Services
KJIRFT
KJILKFTGES
EnqueueKJILKFT KJILKFT
KJILKFTKJILKFT
KJILKFT
Holders Converters Waiters
97
© 2006 Julian Dyke
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
98
© 2006 Julian Dyke
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
99
© 2006 Julian Dyke
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
100
© 2006 Julian Dyke
juliandyke.com
X$KJIRFT Externals global enqueue resources Does NOT include global cache resources
ADDR RAW(4)INDX NUMBERINST_ID NUMBERKJIRFTRP RAW(4)KJIRFTRN VARCHAR2(30)KJIRFTCQ NUMBERKJIRFTGQ NUMBERKJIRFTPR NUMBERKJIRFTRDN VARCHAR2(25)KJIRFTMN NUMBERKJIRFTNCL VARCHAR2(9)KJIRFTVS VARCHAR2(32)KJIRFTVB VARCHAR2(64)
101
© 2006 Julian Dyke
juliandyke.com
X$KJILKFT
ADDR RAW(4)INDX NUMBERINST_ID NUMBERKJILKFTLKP RAW(4)KJILKFTGL VARCHAR2(9)KJILKFTRL VARCHAR2(9)KJILKFTRP RAW(4)KJILKFTRN1 VARCHAR2(30)KJILKFTRN2 VARCHAR2(30)KJILKFTPID NUMBERKJILKFTXID0 NUMBERKJILKFTXID1 NUMBERKJILKFTGID NUMBERKJILKFTOODD NUMBERKJILKFTOOPT NUMBERKJILKFTOOPO NUMBER
KJILKFTOONXID NUMBERKJILKFTCOGV NUMBERKJILKFTCOPV NUMBERKJILKFTCONV NUMBERKJILKFTCODV NUMBERKJILKFTCONQ NUMBERKJILKFTCOEP NUMBERKJILKFTCONDDW NUMBERKJILKFTCONDDB NUMBERKJILKFTWQ NUMBERKJILKFTLS VARCHAR2(64)KJILKFTASTE0 NUMBERKJILKFTON NUMBERKJILKFTBLKED NUMBERKJILKFTBLKER NUMBER
102
© 2006 Julian Dyke
juliandyke.com
V$GES_RESOURCE Contains rows from both KJIRFT and KJBR Synonym for V$DLM_RESS
RESP RAW(4)RESOURCE_NAME VARCHAR2(30)ON_CONVERT_Q NUMBERON_GRANT_Q NUMBERPERSISTENT_RES NUMBERMASTER_NODE NUMBERNEXT_CVT_LEVEL VARCHAR2(9)VALUE_BLK_STATE VARCHAR2(32)VALUE_BLK VARCHAR2(64)
103
© 2006 Julian Dyke
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
104
© 2006 Julian Dyke
juliandyke.com
V$GES_ENQUEUE Contains rows from both KJILKFT and KJBL
HANDLE RAW(4)GRANT_LEVEL VARCHAR2(9)REQUEST_LEVEL VARCHAR2(9)RESOURCE_NAME1 VARCHAR2(30)RESOURCE_NAME2 VARCHAR2(30)PID NUMBERTRANSACTION_ID0 NUMBERTRANSACTION_ID1 NUMBERGROUP_ID NUMBEROPEN_OPT_DEADLOCK NUMBEROPEN_OPT_PERSISTENT NUMBEROPEN_OPT_PROCESS_OWNED NUMBEROPEN_OPT_NO_XID NUMBER
CONVERT_OPT_GETVALUE NUMBERCONVERT_OPT_PUTVALUE NUMBERCONVERT_OPT_NOVALUE NUMBERCONVERT_OPT_DUBVALUE NUMBERCONVERT_OPT_NOQUEUE NUMBERCONVERT_OPT_EXPRESS NUMBERCONVERT_OPT_NODEADLOCKWAIT NUMBERCONVERT_OPT_NODEADLOCKBLOCK NUMBERWHICH_QUEUE NUMBERSTATE VARCHAR2(64)AST_EVENT0 NUMBEROWNER_NODE NUMBERBLOCKED NUMBERBLOCKER NUMBER
105
© 2006 Julian Dyke
juliandyke.com
V$GES_ENQUEUE Contains rows from both KJILKFT and KJBL
SELECT inst_id, kjilkftlkp, kjilkftgl, kjilkftrl, kjilkftrn1, kjilkftrn2, kjilkftpid,kjilkftxid0, kjilkftxid1, kjilkftgid, kjilkftoodd, kjilkftoopt, kjilkftoopo,kjilkftoonxid, kjilkftcogv, kjilkftcopv, kjilkftconv, kjilkftcodv, kjilkftconq,kjilkftcoep, kjilkftconddw, kjilkftconddb, kjilkftwq, kjilkftls, kjilkftaste0,kjilkfton, kjilkftblked, kjilkftblker
FROM x$kjilkft UNION ALL SELECT inst_id,
kjbllockp, kjblgrant, kjblrequest, kjblname, kjblname2, 0, 0, 0, 0, 0, 1, 0, 1,0, 0, 0, 0, 0, 0, 0, 0, kjblqueue, kjbllockst, 0, kjblowner, kjblblocked,
kjblblocker FROM x$kjbl
106
© 2006 Julian Dyke
juliandyke.com
Thank you for your interest
For more information and to provide feedback
please contact me
My e-mail address is:[email protected]
My website address is:
www.juliandyke.com