SlideShare a Scribd company logo
1 of 106
1 © 2006 Julian Dyke
Inside
RAC
Julian Dyke
Independent Consultant
Web Version
juliandyke.com
© 2006 Julian Dyke juliandyke.com2
Agenda
 Introduction to RAC
 Memory Structures
 The Buffer Cache
 Global Cache Services
 The Library Cache
 Global Enqueue Services
© 2006 Julian Dyke juliandyke.com3
Introduction
to
RAC
© 2006 Julian Dyke juliandyke.com4
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
Local
Disk
Local
Disk
© 2006 Julian Dyke juliandyke.com5
Architecture
Instance 1
Node 1
Instance 2
Node 2
Shared
Storage
Storage Network
Private Network
(Interconnect)
Public Network
© 2006 Julian Dyke juliandyke.com6
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
© 2006 Julian Dyke juliandyke.com7
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
© 2006 Julian Dyke juliandyke.com8
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
Datafiles
Controlfiles
Redo Logs
SGAUGASGA UGA
© 2006 Julian Dyke juliandyke.com9
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)
© 2006 Julian Dyke juliandyke.com10
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
© 2006 Julian Dyke juliandyke.com11
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
© 2006 Julian Dyke juliandyke.com12
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
© 2006 Julian Dyke juliandyke.com13
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
© 2006 Julian Dyke juliandyke.com14
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
© 2006 Julian Dyke juliandyke.com15
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$SGA
INST_ID NUMBER
NAME 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
© 2006 Julian Dyke juliandyke.com16
CATCLUST.SQL
 Some additional views/synonyms are created for RAC
databases using $ORACLE_HOME/rdbms/admin/catclust.sql
Synonym Name View Name
V$GES_CONVERT_LOCAL V$DLM_CONVERT_LOCAL
V$GES_CONVERT_REMOTE V$DLM_CONVERT_REMOTE
V$GES_LATCH V$DLM_LATCH
V$GES_RESOURCE V$DLM_RESS
V$GES_STATISTICS V$DLM_MISC
V$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
© 2006 Julian Dyke juliandyke.com17
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
© 2006 Julian Dyke juliandyke.com18
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
© 2006 Julian Dyke juliandyke.com19
Memory
Structures
© 2006 Julian Dyke juliandyke.com20
Memory Areas
 An Oracle process includes
the following memory areas
 Executable
 SGA
 Shared Libraries
 PGA/Session Heap
 Stack
40000000
20000000
Executable
PGA
Session Heap
Shared
Libraries
SGA
Stack
STOP
FFFFFFFF
00000000
© 2006 Julian Dyke juliandyke.com21
Shared Memory
 Shared memory areas can be dumped to trace file using
ORADEBUG SETMYPID
ORADEBUG IPC
$ sqlplus /nolog
SQL> CONNECT SYS/<password> AS SYSDBA
Connected
SQL> ORADEBUG SETMYPID
Statement processed
SQL> ORADEBUG IPC
Information written to trace file
© 2006 Julian Dyke juliandyke.com22
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
© 2006 Julian Dyke juliandyke.com23
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
© 2006 Julian Dyke juliandyke.com24
V$SGAINFO
 Summarizes SGA pools
NAME VARCHAR2(32)
BYTES NUMBER
RESIZEABLE VARCHAR2(3)
SELECT * FROM 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
© 2006 Julian Dyke juliandyke.com25
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
© 2006 Julian Dyke juliandyke.com26
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
© 2006 Julian Dyke juliandyke.com27
X$KSMGE
Introduced in Oracle 9.2
Describes individual granules
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
GRANNUM NUMBER
GRANTYPE NUMBER
GRANSTATE VARCHAR2(16)
GRANFLAGS NUMBER
LOCALITY NUMBER
KSMAREANUM NUMBER
BASEADDR RAW(4)
GRANSIZE NUMBER
GRANNEXT NUMBER
GRANPREV NUMBER
INVALID (Free)
ALLOCATED
Granule Address
Granule Size
Next granule ID
Previous granule ID
Granule ID
0 Free
1 Shared Pool
2 Large Pool
3 Java Pool
6 Buffer Pool
© 2006 Julian Dyke juliandyke.com28
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
© 2006 Julian Dyke juliandyke.com29
V$SGASTAT
 Enhanced in Oracle 10.1 and above
Shared Pool 682
Large Pool 6
Java Pool 4
Streams Pool 4
 In Oracle 10.2 describes around 700 memory areas
POOL VARCHAR2(12)
NAME VARCHAR2(26)
BYTES NUMBER
© 2006 Julian Dyke juliandyke.com30
V$SGASTAT
 RAC-specific areas include
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
ges big msg buffers
ges deadlock xid freelist
ges deadlock xid hash tab
ges enqueue cur. usage pe
ges enqueue max. usage pe
ges enqueue multiple free
ges enqueues
ges ipc instance maps
ges lmd process descripto
ges lms process descripto
ges process array
ges process hash table
ges recovery domain table
ges regular msg buffers
ges reserved msg buffers
ges res mastership bucket
ges resource
ges resource hash seq tab
ges resource hash table
ges resource pools
ges scan queue array
ges shared global area
KCL buffer header
KCL instance cache transf
KCL lock contexts
KCL lock state
KCL name table
KCL partition table
KCL region array
KJXM msg statistics table
© 2006 Julian Dyke juliandyke.com31
V$SGASTAT
 Significant RAC areas in Oracle 10.2
Name Size(bytes) Location
gcs resources 2298008 Segmented Array
gcs shadows 1632280 Segmented Array
ges resource 1257188 Heap
ges enqueues 1625344 Segmented Array
ges big msg buffers 3979396 Unknown
 In Oracle 9.2 all five structures were stored in segmented
arrays
© 2006 Julian Dyke juliandyke.com32
Permanent Areas
SELECT ksmchptr, ksmchsiz
FROM x$ksmsp
WHERE ksmchcls = 'perm';
Address Size
2D034000 3981312
2D434000 3549424
2D834000 3963236
2DC34000 3980584
2DFFFD28 728
2E034000 3919532
 Allocated at instance startup
 Contain structures such as
 processes
 sessions
 segmented arrays
STOP
2AC00000
2B800000
2BC00000
2C000000
2C400000
2C800000
2CC00000
2D000000
2D800000
2DC00000
2E000000
2E400000
2E800000
2EF00000
2F000000
2F400000
2F800000
2FC00000
30000000
2D400000
Permanent
Area
Heap
© 2006 Julian Dyke juliandyke.com33
X$KSMSP
 Externalises chunks in the shared pool
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
KSMCHIDX NUMBER
KSMCHDUR NUMBER
KSMCHCOM VARCHAR2(16)
KSMCHPTR RAW(4)
KSMCHSIZ NUMBER
KSMCHCLS VARCHAR2(8)
KSMCHTYP NUMBER
KSMCHPAR 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
© 2006 Julian Dyke juliandyke.com34
X$KSMSP
 Some RAC components are stored in the shared pool heap
SELECT ksmchcom, SUM(ksmchsiz), COUNT(*)
FROM x$ksmsp
GROUP BY ksmchcom;
gcs_mastership 4620 1
gcs_res_hash_bu 16396 1
gcs_res_latch_t 7692 1
ges_res_masters 3084 1
ges_resource 619276 164
© 2006 Julian Dyke juliandyke.com35
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
© 2006 Julian Dyke juliandyke.com36
Segmented Arrays
Segmented
Arrays
Call
Enqueues
Enqueue
Resources
Segmented
Array
Header
Segmented
Array
Segmented
Array
Header
Segmented
Array
STOP
© 2006 Julian Dyke juliandyke.com37
X$KSMDD
 Externalises segmented array headers
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
NAME VARCHAR2(30)
ELEMENTS_CHUNK NUMBER
ITEMS_PT NUMBER
INITENTRIES NUMBER
NUMENTRIES NUMBER
CURENTRIES NUMBER
NUMCHUNKS NUMBER
ELEMSIZE NUMBER
FLAGS NUMBER
HEAP RAW(4)
SECONDARY RAW(4)
Name of array
Address of parent
heap
Number of
chunks
© 2006 Julian Dyke juliandyke.com38
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
© 2006 Julian Dyke juliandyke.com39
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 2Heap
Header
Free List Chunks
STOP
© 2006 Julian Dyke juliandyke.com40
X$KSMHP
 Externalises chunks in the heap
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
KSMCHDS RAW(4)
KSMCHCOM VARCHAR2(16)
KSMCHPTR RAW(4)
KSMCHSIZ NUMBER
KSMCHCLS VARCHAR2(8)
KSMCHTYP NUMBER
KSMCHPAR RAW(4)
KSMCHOWN RAW(4)
 Can only be accessed using KSMCHDS e.g.
SELECT * FROM x$ksmhp
WHERE ksmchds = HEXTORAW ('2CA54040');
© 2006 Julian Dyke juliandyke.com41
The
Buffer
Cache
© 2006 Julian Dyke juliandyke.com42
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
© 2006 Julian Dyke juliandyke.com43
X$BH
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
HLADDR RAW(4)
BLSIZ NUMBER
NXT_HASH RAW(4)
PRV_HASH RAW(4)
NXT_REPL RAW(4)
PRV_REPL RAW(4)
FLAG NUMBER
RFLAG NUMBER
SFLAG NUMBER
LRU_FLAG NUMBER
TS# NUMBER
FILE# NUMBER
DBARFIL NUMBER
DBABLK NUMBER
CLASS NUMBER
STATE NUMBER
MODE_HELD NUMBER
CHANGES NUMBER
CSTATE NUMBER
LE_ADDR RAW(4)
DIRTY_QUEUE NUMBER
SET_DS RAW(4)
OBJ NUMBER
BA RAW(4)
CR_SCN_BAS NUMBER
CR_SCN_WRP NUMBER
CR_XID_USN NUMBER
CR_XID_SLT NUMBER
CR_XID_SQN NUMBER
CR_UBA_FIL NUMBER
CR_UBA_BLK NUMBER
CR_UBA_SEQ NUMBER
CR_UBA_REC NUMBER
CR_SFL NUMBER
CR_CLS_BAS NUMBER
CR_CLS_WRP NUMBER
LRBA_SEQ NUMBER
LRBA_BNO NUMBER
HSCN_BAS NUMBER
HSCN_WRP NUMBER
HSUB_SCN NUMBER
US_NXT RAW(4)
US_PRV RAW(4)
WA_NXT RAW(4)
WA_PRV RAW(4)
TCH NUMBER
TIM NUMBER
© 2006 Julian Dyke juliandyke.com44
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 end
Update buffer contentsInsert buffer at head of cold
end
Read Block 11
Get first available buffer
from cold end
Update 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 end
Set touch count
on block 71 to zero
Get first available buffer
from cold end
Update buffer contentsInsert buffer at head of cold
end
Read Block 34
Update touch count
for block 34
Read Block 87
Move block 42 to head
of hot end
Set touch count
on block 42 to zero
Get first available buffer
from cold end
Update buffer contentsInsert buffer at head of cold
end
STOP
Block
Number
Touch
Count
© 2006 Julian Dyke juliandyke.com45
Multi-Block Reads
Head of
Cold End
Head of
Hot End
Read Block 1
Get first four available
buffers from cold end
Read 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 end
Read next four blocks into
buffers
Insert buffers at head of
cold end
Move 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
© 2006 Julian Dyke juliandyke.com46
Global
Cache
Services
© 2006 Julian Dyke juliandyke.com47
Read with No Transfer
Instance 1
Instance 2
Instance 4
1318
Request
shared
resource
Instance 3
Resource
Master
Instance 2 requests
current read on
block
Request
granted
SN
Read
request
Block
returned
1318
1
2
3
4
STOP
© 2006 Julian Dyke juliandyke.com48
Read to Write Transfer
Instance 1
Instance 2
Instance 4
1318
Request
exclusive
resource
Instance 3
Resource
Master
Instance 1 requests
exclusive read on
block
Transfer
block to
Instance 1 for
exclusive
access
SN
Block and
resource
status
Resource
status
1318
1
2
3
4
N
N
X
1320
STOP
© 2006 Julian Dyke juliandyke.com49
Write to Write Transfer
Instance 1
Instance 2
Instance 4
1318
Request
block in
exclusive
mode
Instance 3
Resource
Master
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
4
N NX
1320
N
N
X
1320 1323
STOP
Note that Instance 1 will
create a past image (PI) of
the dirty block
© 2006 Julian Dyke juliandyke.com50
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)
© 2006 Julian Dyke juliandyke.com51
Past Images
13281329
UPDATE t1
SET c1 = 1324;
COMMIT;
UPDATE t1
SET c1 = 1329;
COMMIT;
1323
Instance 1
13231324132513261327
Buffer Cache
13241323
13251324
13261325
13271326
1328
13281327
Redo Log 1
Instance 2
Buffer Cache
13291328
UPDATE t1
SET c1 = 1325;
COMMIT;
UPDATE t1
SET c1 = 1326;
COMMIT;
UPDATE t1
SET c1 = 1327;
COMMIT;
UPDATE t1
SET 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
1324
Block 42 is read from disk
Undo/Redo written to
Redo Log 1
Block 42 is updated in buffer
cache
Instance 1 updates column to
1325
Undo/Redo written to
Redo Log 1
Block 42 is updated in buffer
cache
Instance 1 updates column to
1326
Undo/Redo written to
Redo Log 1
Block 42 is updated in buffer
cache
Instance 1 updates column to
1327
Undo/Redo written to
Redo Log 1
Block 42 is updated in buffer
cache
Instance 1 updates column to
1328
Undo/Redo written to
Redo Log 1
Block 42 is updated in buffer
cache
Instance 2 updates column to
1329
GCS transfers block from
Instance 1 to Instance 2
Instance 1 makes block 42
a Past Image block
Undo/redo written to
Redo Log 2
Block 42 is updated in buffer
cache
Instance 2 Crashes
Contents of buffer cache are lost
DBWR has not written changes
to block 42 back to disk yet
Instance 1 must perform
recovery for Instance 2
Block 42 needs recovery
Instance 1 uses Past Image
Undo/redo is applied from
Redo Log 2
Block 42 is subsequently written
back to disk by DBWR
STOP
© 2006 Julian Dyke juliandyke.com52
Write to Read Transfer
Instance 1
Instance 2
Instance 4
1318
Request block in
shared mode
Instance 3
Resource
Master
Instance 2 requests
current read on
block
SN
Block and resource status
Resource
status
1318
1
3
4
N NX
1320
N
N
X
1320 1323
Transfer
block to
Instance 1
in shared
mode
2
S
S
STOP
Note that in recent versions
_fairness_threshold is used
to avoid unnecessary lock
conversions
© 2006 Julian Dyke juliandyke.com53
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
© 2006 Julian Dyke juliandyke.com54
Fairness Threshold
Assume instance 1 holds
exclusive lock on block
Instance 2
Instance 2 requests consistent
read
Instance 1 sets counter to 1
Instance 1 sends block to
Instance 2
13231323
Instance 1
X
Instance 2 receives block with
Null lock
13231323
01234 N
Instance 2 requests consistent
read
Instance 1 sets counter to 2
Instance 1 sends block to
Instance 2
Instance 2 receives block with
Null lock
1323
Instance 2 requests consistent
read
Instance 1 sets counter to 3
Instance 1 sends block to
instance 2
Instance 2 receives block with
Null lock
Instance 2 requests consistent
read
Instance 1 sets counter to 4
Instance 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
© 2006 Julian Dyke juliandyke.com55
Lock Elements
 Contain embedded GCS Client structures (KJBL)
Lock
Element
GCS
Client
Buffer
Header
Lock
Element
GCS
Client
Buffer
Header
Buffer
Header
Lock
Element
GCS
Client
© 2006 Julian Dyke juliandyke.com56
V$LOCK_ELEMENT
 Based on X$LE
LOCK_ELEMENT_ADDR RAW(4)
INDX NUMBER
CLASS NUMBER
LOCK_ELEMENT_NAME NUMBER
MODE_HELD NUMBER
BLOCK_COUNT NUMBER
RELEASING NUMBER
ACQUIRING NUMBER
INVALID NUMBER
FLAGS NUMBER
© 2006 Julian Dyke juliandyke.com57
X$LE
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
LE_ADDR RAW(4)
NAME NUMBER
LE_CLASS NUMBER
LE_RLS NUMBER
LE_ACQ NUMBER
LE_FLAGS NUMBER
LE_MODE NUMBER
LE_WRITE NUMBER
LE_LOCAL NUMBER
LE_RECOVERY NUMBER
LE_BLKS NUMBER
LE_TIME NUMBER
LE_KJBL RAW(4)
Buffer
Header
Lock
Element
GCS
Client
STOP
© 2006 Julian Dyke juliandyke.com58
Global Cache Services
KJBRKJBR
KJBL
BH BH
LE
KJBL
LE
KJBL
GCS
Client
GCS
Shadow
© 2006 Julian Dyke juliandyke.com59
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
© 2006 Julian Dyke juliandyke.com60
X$KJBR
 Externalizes GCS Resources
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
KJBRRESP RAW(4)
KJBRGRANT VARCHAR2(9)
KJBRNCVL VARCHAR2(9)
KJBRROLE NUMBER
KJBRNAME VARCHAR2(30)
KJBRMASTER NUMBER
KJBRGRANTQ RAW(4)
KJBRCVTQ RAW(4)
KJBRWRITER RAW(4)
© 2006 Julian Dyke juliandyke.com61
X$KJBL
 Externalizes GCS Enqueues
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
KJBLLOCKP RAW(4)
KJBLGRANT VARCHAR2(9)
KJBLREQUEST VARCHAR2(9)
KJBLROLE NUMBER
KJBLRESP RAW(4)
KJBLNAME VARCHAR2(30)
KJBLNAME2 VARCHAR2(30)
KJBLQUEUE NUMBER
KJBLLOCKST VARCHAR2(64)
KJBLWRITING NUMBER
KJBLREQWRITE NUMBER
KJBLMASTER NUMBER
KJBLBLOCKED NUMBER
KJBLBLOCKER NUMBER
© 2006 Julian Dyke juliandyke.com62
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 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
© 2006 Julian Dyke juliandyke.com63
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
.....
© 2006 Julian Dyke juliandyke.com64
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
© 2006 Julian Dyke juliandyke.com65
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 0x1FF
0x280 0x2FF
0x380 0x3FF
0x480 0x4FF
0x580 0x5FF
etc etc
Start End
0x000 0x07F
0x100 0x17F
0x200 0x27F
0x300 0x37F
0x400 0x47F
0x500 0x57F
etc etc
Instance 0 Instance 1
© 2006 Julian Dyke juliandyke.com66
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....
© 2006 Julian Dyke juliandyke.com67
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
© 2006 Julian Dyke juliandyke.com68
Dynamic Remastering
 Example
SELECT data_object_id FROM dba_objects
WHERE 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
© 2006 Julian Dyke juliandyke.com69
V$GCSPFMASTER_INFO
 Object re mastering is recorded in V$GCSPFMASTER_INFO
FILE_ID NUMBER
OBJECT_ID NUMBER
CURRENT_MASTER NUMBER
PREVIOUS_MASTER NUMBER
REMASTER_CNT NUMBER
© 2006 Julian Dyke juliandyke.com70
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 Master
52084 0 32767
Object ID Current Master Previous Master
52084 1 0
© 2006 Julian Dyke juliandyke.com71
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
© 2006 Julian Dyke juliandyke.com72
The
Library
Cache
© 2006 Julian Dyke juliandyke.com73
Library Cache Object - Parent
16 x 1 word
pointers
KGLHD
Parent
Object
KGLNA
SELECT SUM (c2) FROM t1
WHERE c3 = 42 AND c4 < 2004
Parent
Name
Child
Handle
KGLHD
Child 1
Child 2
Heap 0
KGLOB
X$KGLOB
Parent
Handle
KGLHD
STOP
© 2006 Julian Dyke juliandyke.com74
Library Cache Object - Child
KGLHD
Child
Handle
Child
Object
SELECT
Statement
Heap 6
KGLOB
Subheap
Header
Subheap
Header
Heap 0
Subquery
Header
Statistics,
Optimizer
Environment,
BindVariables
X$KGLOB
STOP
© 2006 Julian Dyke juliandyke.com75
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
© 2006 Julian Dyke juliandyke.com76
X$KGLPN
X$KGLLK
Library Cache Object - Locks & Pins
Child
Handle
Child
Object
KGLOB
X$KGLOB
STOP
LockLock
Pin
Lock
Pin Pin
KGLHD
© 2006 Julian Dyke juliandyke.com77
Namespaces
 In Oracle 10.2 there are 64 library cache namespaces
 Externalized by KGLHDNSP in X$KGLOB
CRSR LOB REIP RMGR JVSD RELS MVOBINX NSCPD
TABL DIR CPOB XDBS STFG RELD STBO JSLV
BODY QUEU EVNT PPLN TRANS IFSD HTSO MODL
TRGR OBJG SUMM PCLS RELC XDBC JSGA Unused
INDX PROP DIMM SUBS RULE USAG JSET Unused
CLST JVSC CTS LOCS STRM MVOBTBL TABLE Unused
KGLT JVRE OUTL RMOB REVC JSQI CLST Unused
PIPE ROBJ RULS RSMD STAP CDC INDX Unused
© 2006 Julian Dyke juliandyke.com78
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 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
....
© 2006 Julian Dyke juliandyke.com79
V$LIBRARYCACHE
 Subset of rows from X$KGLST
 Contains 11 rows in Oracle 10.2
NAMESPACE VARCHAR2(15)
GETS NUMBER
GETHITS NUMBER
GETHITRATIO NUMBER
PINS NUMBER
PINHITS NUMBER
PINHITRATIO NUMBER
RELOADS NUMBER
INVALIDATIONS NUMBER
DLM_LOCK_REQUESTS NUMBER
DLM_PIN_REQUESTS NUMBER
DLM_PIN_RELEASES NUMBER
DLM_INVALIDATION_REQUESTS NUMBER
DLM_INVALIDATIONS NUMBER
RAC
Specific
Statistics
© 2006 Julian Dyke juliandyke.com80
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
© 2006 Julian Dyke juliandyke.com81
X$KGLST
 Contains one row for each namespace (59 rows in 10.2)
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
KGLSTCMS NUMBER
KGLSTCHT NUMBER
KGLSTGET NUMBER
KGLSTGHT NUMBER
KGLSTPIN NUMBER
KGLSTPHT NUMBER
KGLSTRLD NUMBER
KGLSTINV NUMBER
KGLSTLRQ NUMBER
KGLSTPRQ NUMBER
KGLSTPRL NUMBER
KGLSTIRQ NUMBER
KGLSTMIV NUMBER
RAC
Specific
Statistics
© 2006 Julian Dyke juliandyke.com82
Global
Enqueue
Services
© 2006 Julian Dyke juliandyke.com83
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)
© 2006 Julian Dyke juliandyke.com84
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.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
 For example:
© 2006 Julian Dyke juliandyke.com85
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.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
© 2006 Julian Dyke juliandyke.com86
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]
© 2006 Julian Dyke juliandyke.com87
Namespaces->Instance Locks
 Slide 1 of 3
Namespace Lock Pin
JVSC LN NN
JVRE LO NO
ROBJ LP NP
REIP LQ NQ
CPOB LR NR
EVNT LS NS
SUMM LT NT
DIMM LU NU
CTS LV NV
OUTL LW NW
RULS LX NX
RMGR LY NY
XDBS LZ NZ
Namespace Lock Pin
CRSR LA NA
TABL LB NB
BODY LC NC
TRGR LD ND
INDX LE NE
CLST LF NF
KGLT LG NG
PIPE LH NH
LOB LI NI
DIR LJ NJ
QUEU LK NK
OBJG LL NL
PROP LM NM
© 2006 Julian Dyke juliandyke.com88
Namespaces->Instance Locks
 Slide 2 of 3
Namespace Lock Pin
STAP EN GN
RELS EO GO
RELD EP GP
IFSD EQ GQ
XDBC ER GR
USAG ES GS
MVOBTBL ET GT
JSQI EU GU
CDC EV GV
MVOBINX EW GW
STBO EX GX
HTSO EY GY
JSGA EZ GZ
Namespace Lock Pin
PPLN EA GA
PCLS EB GB
SUBS EC GC
LOCS ED GD
RMOB EE GE
RSMD EF GF
JVSD EG GG
STFG EH GH
TRANS EI GI
RELC EJ GJ
RULE EK GK
STRM EL GL
REVC EM GM
© 2006 Julian Dyke juliandyke.com89
Namespaces->Instance Locks
 Slide 3 of 3
Namespace Lock Pin
JSET VA YA
TABLE VB YB
CLST VC YC
INDX VD YD
NSCPD VE YE
JSLV VF YF
MODL VG YG
Unused VH YH
Unused VI YI
Unused VJ YJ
Unused VK YK
Unused VL YL
Unused VM YM
© 2006 Julian Dyke juliandyke.com90
V$ROWCACHE
CACHE# NUMBER
TYPE VARCHAR2(11)
SUBORDINATE# NUMBER
PARAMETER VARCHAR2(32)
COUNT NUMBER
USAGE NUMBER
FIXED NUMBER
GETS NUMBER
GETMISSES NUMBER
SCANS NUMBER
SCANMISSES NUMBER
SCANCOMPLETES NUMBER
MODIFICATIONS NUMBER
FLUSHES NUMBER
DLM_REQUESTS NUMBER
DLM_CONFLICTS NUMBER
DLM_RELEASES NUMBER
RAC
Specific
Statistics
© 2006 Julian Dyke juliandyke.com91
V$ROWCACHE
 Based on X$KQRST
 Contains 42 rows in Oracle 10.2
 34 Parent Cache
 8 Subordinate Caches
© 2006 Julian Dyke juliandyke.com92
Row Caches->Instance Locks
 Slide 1 of 2
Cache# Namespace Lock
0 dc_tablespaces QA
1 dc_free_extents QB
2 dc_segments QC
3 dc_rollback_segments QD
4 dc_used_extents QE
5 dc_tablespace_quotas QF
6 dc_files QG
7 dc_users QH
8 dc_objects QI
9 dc_qmc_cache_entries QJ
10 dc_usernames QK
11 dc_object_ids QL
12 dc_constraints QM
Cache# Namespace Lock
13 dc_sequences QN
14 dc_profiles QO
15 dc_database_links QP
16 dc_histogram_defs QQ
17 dc_global_oids QR
18 dc_outlines QS
19 dc_table_scns QT
20 rule_info QU
21 rule_or_piece QV
22 dc_awr_control QW
23 dc_qmc_ldap_cache... QX
24 outstanding_alerts QY
25 dc_hintsets QZ
© 2006 Julian Dyke juliandyke.com93
Row Caches->Instance Locks
 Slide 2 of 2
Cache# Namespace Lock
26 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
© 2006 Julian Dyke juliandyke.com94
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 7
dc_free_extents 388 0 0 0.000 0
dc_segments 444 4191 569 0.880 709
dc_rollback_segments 452 4210 31 0.993 74
dc_used_extents 400 0 0 0.000 0
dc_tablespace_quotas 396 0 0 0.000 0
dc_files 412 0 6 0.000 6
dc_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
....
© 2006 Julian Dyke juliandyke.com95
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 Lock
QI F611FFAD E31D1DE3
Cache ID 8
dc_objects
© 2006 Julian Dyke juliandyke.com96
GES
Resource
Global Enqueue Services
KJIRFT
KJILKFT
GES
EnqueueKJILKFT KJILKFT
KJILKFTKJILKFT
KJILKFT
Holders Converters Waiters
© 2006 Julian Dyke juliandyke.com97
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
© 2006 Julian Dyke juliandyke.com98
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
© 2006 Julian Dyke juliandyke.com99
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
© 2006 Julian Dyke juliandyke.com100
X$KJIRFT
 Externals global enqueue resources
 Does NOT include global cache resources
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
KJIRFTRP RAW(4)
KJIRFTRN VARCHAR2(30)
KJIRFTCQ NUMBER
KJIRFTGQ NUMBER
KJIRFTPR NUMBER
KJIRFTRDN VARCHAR2(25)
KJIRFTMN NUMBER
KJIRFTNCL VARCHAR2(9)
KJIRFTVS VARCHAR2(32)
KJIRFTVB VARCHAR2(64)
© 2006 Julian Dyke juliandyke.com101
X$KJILKFT
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
KJILKFTLKP RAW(4)
KJILKFTGL VARCHAR2(9)
KJILKFTRL VARCHAR2(9)
KJILKFTRP RAW(4)
KJILKFTRN1 VARCHAR2(30)
KJILKFTRN2 VARCHAR2(30)
KJILKFTPID NUMBER
KJILKFTXID0 NUMBER
KJILKFTXID1 NUMBER
KJILKFTGID NUMBER
KJILKFTOODD NUMBER
KJILKFTOOPT NUMBER
KJILKFTOOPO NUMBER
KJILKFTOONXID NUMBER
KJILKFTCOGV NUMBER
KJILKFTCOPV NUMBER
KJILKFTCONV NUMBER
KJILKFTCODV NUMBER
KJILKFTCONQ NUMBER
KJILKFTCOEP NUMBER
KJILKFTCONDDW NUMBER
KJILKFTCONDDB NUMBER
KJILKFTWQ NUMBER
KJILKFTLS VARCHAR2(64)
KJILKFTASTE0 NUMBER
KJILKFTON NUMBER
KJILKFTBLKED NUMBER
KJILKFTBLKER NUMBER
© 2006 Julian Dyke juliandyke.com102
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 NUMBER
ON_GRANT_Q NUMBER
PERSISTENT_RES NUMBER
MASTER_NODE NUMBER
NEXT_CVT_LEVEL VARCHAR2(9)
VALUE_BLK_STATE VARCHAR2(32)
VALUE_BLK VARCHAR2(64)
© 2006 Julian Dyke juliandyke.com103
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
© 2006 Julian Dyke juliandyke.com104
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 NUMBER
TRANSACTION_ID0 NUMBER
TRANSACTION_ID1 NUMBER
GROUP_ID NUMBER
OPEN_OPT_DEADLOCK NUMBER
OPEN_OPT_PERSISTENT NUMBER
OPEN_OPT_PROCESS_OWNED NUMBER
OPEN_OPT_NO_XID NUMBER
CONVERT_OPT_GETVALUE NUMBER
CONVERT_OPT_PUTVALUE NUMBER
CONVERT_OPT_NOVALUE NUMBER
CONVERT_OPT_DUBVALUE NUMBER
CONVERT_OPT_NOQUEUE NUMBER
CONVERT_OPT_EXPRESS NUMBER
CONVERT_OPT_NODEADLOCKWAIT NUMBER
CONVERT_OPT_NODEADLOCKBLOCK NUMBER
WHICH_QUEUE NUMBER
STATE VARCHAR2(64)
AST_EVENT0 NUMBER
OWNER_NODE NUMBER
BLOCKED NUMBER
BLOCKER NUMBER
© 2006 Julian Dyke juliandyke.com105
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
© 2006 Julian Dyke juliandyke.com106
Thank you for your interest
For more information and to provide feedback
please contact me
My e-mail address is:
info@juliandyke.com
My website address is:
www.juliandyke.com

More Related Content

What's hot

Manual Tecnico OGG Oracle to MySQL
Manual Tecnico OGG Oracle to MySQLManual Tecnico OGG Oracle to MySQL
Manual Tecnico OGG Oracle to MySQLErick Vidbaz
 
RAC - The Savior of DBA
RAC - The Savior of DBARAC - The Savior of DBA
RAC - The Savior of DBANikhil Kumar
 
Go Programming Patterns
Go Programming PatternsGo Programming Patterns
Go Programming PatternsHao Chen
 
Cloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And TricksCloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And TricksScott Jenner
 
Oracle Clusterware and Private Network Considerations - Practical Performance...
Oracle Clusterware and Private Network Considerations - Practical Performance...Oracle Clusterware and Private Network Considerations - Practical Performance...
Oracle Clusterware and Private Network Considerations - Practical Performance...Guenadi JILEVSKI
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11gfcamachob
 
Cassandra summit 2013 - DataStax Java Driver Unleashed!
Cassandra summit 2013 - DataStax Java Driver Unleashed!Cassandra summit 2013 - DataStax Java Driver Unleashed!
Cassandra summit 2013 - DataStax Java Driver Unleashed!Michaël Figuière
 
MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016Dave Stokes
 
MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016Dave Stokes
 
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019GOG.com dev team
 
Replication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTIDReplication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTIDMydbops
 
RAC-Installing your First Cluster and Database
RAC-Installing your First Cluster and DatabaseRAC-Installing your First Cluster and Database
RAC-Installing your First Cluster and DatabaseNikhil Kumar
 
Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Antonios Giannopoulos
 
MySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELKMySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELKI Goo Lee
 
Introduction to apache zoo keeper
Introduction to apache zoo keeper Introduction to apache zoo keeper
Introduction to apache zoo keeper Omid Vahdaty
 
How Prometheus Store the Data
How Prometheus Store the DataHow Prometheus Store the Data
How Prometheus Store the DataHao Chen
 

What's hot (19)

Manual Tecnico OGG Oracle to MySQL
Manual Tecnico OGG Oracle to MySQLManual Tecnico OGG Oracle to MySQL
Manual Tecnico OGG Oracle to MySQL
 
RAC - The Savior of DBA
RAC - The Savior of DBARAC - The Savior of DBA
RAC - The Savior of DBA
 
Go Programming Patterns
Go Programming PatternsGo Programming Patterns
Go Programming Patterns
 
Dnsdist
DnsdistDnsdist
Dnsdist
 
Cloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And TricksCloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
 
Oracle Clusterware and Private Network Considerations - Practical Performance...
Oracle Clusterware and Private Network Considerations - Practical Performance...Oracle Clusterware and Private Network Considerations - Practical Performance...
Oracle Clusterware and Private Network Considerations - Practical Performance...
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11g
 
Cassandra summit 2013 - DataStax Java Driver Unleashed!
Cassandra summit 2013 - DataStax Java Driver Unleashed!Cassandra summit 2013 - DataStax Java Driver Unleashed!
Cassandra summit 2013 - DataStax Java Driver Unleashed!
 
MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016
 
MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016
 
Zookeeper
ZookeeperZookeeper
Zookeeper
 
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
 
Replication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTIDReplication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTID
 
RAC-Installing your First Cluster and Database
RAC-Installing your First Cluster and DatabaseRAC-Installing your First Cluster and Database
RAC-Installing your First Cluster and Database
 
Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018
 
MySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELKMySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELK
 
Query logging with proxysql
Query logging with proxysqlQuery logging with proxysql
Query logging with proxysql
 
Introduction to apache zoo keeper
Introduction to apache zoo keeper Introduction to apache zoo keeper
Introduction to apache zoo keeper
 
How Prometheus Store the Data
How Prometheus Store the DataHow Prometheus Store the Data
How Prometheus Store the Data
 

Viewers also liked

Course 102: Lecture 16: Process Management (Part 2)
Course 102: Lecture 16: Process Management (Part 2) Course 102: Lecture 16: Process Management (Part 2)
Course 102: Lecture 16: Process Management (Part 2) Ahmed El-Arabawy
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldabaux singapore
 

Viewers also liked (7)

Unix ch03-03(2)
Unix ch03-03(2)Unix ch03-03(2)
Unix ch03-03(2)
 
UNIX - Class1 - Basic Shell
UNIX - Class1 - Basic ShellUNIX - Class1 - Basic Shell
UNIX - Class1 - Basic Shell
 
IO Management
IO ManagementIO Management
IO Management
 
Course 102: Lecture 16: Process Management (Part 2)
Course 102: Lecture 16: Process Management (Part 2) Course 102: Lecture 16: Process Management (Part 2)
Course 102: Lecture 16: Process Management (Part 2)
 
Basic Unix
Basic UnixBasic Unix
Basic Unix
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Similar to RAC MEMORY STRUCTURES

VMworld 2013: vSphere Data Protection (VDP) Technical Deep Dive and Troublesh...
VMworld 2013: vSphere Data Protection (VDP) Technical Deep Dive and Troublesh...VMworld 2013: vSphere Data Protection (VDP) Technical Deep Dive and Troublesh...
VMworld 2013: vSphere Data Protection (VDP) Technical Deep Dive and Troublesh...VMworld
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and ArchitectureSidney Chen
 
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...Zahid Anwar (OCM)
 
Oracle Fleet Patching and Provisioning Deep Dive Webcast Slides
Oracle Fleet Patching and Provisioning Deep Dive Webcast SlidesOracle Fleet Patching and Provisioning Deep Dive Webcast Slides
Oracle Fleet Patching and Provisioning Deep Dive Webcast SlidesLudovico Caldara
 
Sga internals
Sga internalsSga internals
Sga internalssergkosko
 
What we unlearned_and_learned_by_moving_from_m9000_to_ssc_ukoug2014
What we unlearned_and_learned_by_moving_from_m9000_to_ssc_ukoug2014What we unlearned_and_learned_by_moving_from_m9000_to_ssc_ukoug2014
What we unlearned_and_learned_by_moving_from_m9000_to_ssc_ukoug2014Philippe Fierens
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsYour tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsJohn Kanagaraj
 
gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”Ruggero Citton
 
GemFire In Memory Data Grid
GemFire In Memory Data GridGemFire In Memory Data Grid
GemFire In Memory Data GridDmitry Buzdin
 
6.3 DatacenterService Laporan Juni .pptx
6.3 DatacenterService Laporan Juni .pptx6.3 DatacenterService Laporan Juni .pptx
6.3 DatacenterService Laporan Juni .pptxAndreWirawan14
 
Oow2007 performance
Oow2007 performanceOow2007 performance
Oow2007 performanceRicky Zhu
 
Presentation of OrientDB v2.2 - Webinar
Presentation of OrientDB v2.2 - WebinarPresentation of OrientDB v2.2 - Webinar
Presentation of OrientDB v2.2 - WebinarOrient Technologies
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...Frederic Descamps
 
F5 OpenShift Workshop
F5 OpenShift WorkshopF5 OpenShift Workshop
F5 OpenShift WorkshopTyler Hatton
 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionFrederic Descamps
 

Similar to RAC MEMORY STRUCTURES (20)

VMworld 2013: vSphere Data Protection (VDP) Technical Deep Dive and Troublesh...
VMworld 2013: vSphere Data Protection (VDP) Technical Deep Dive and Troublesh...VMworld 2013: vSphere Data Protection (VDP) Technical Deep Dive and Troublesh...
VMworld 2013: vSphere Data Protection (VDP) Technical Deep Dive and Troublesh...
 
Convert single instance to RAC
Convert single instance to RACConvert single instance to RAC
Convert single instance to RAC
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and Architecture
 
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...
 
Oracle Fleet Patching and Provisioning Deep Dive Webcast Slides
Oracle Fleet Patching and Provisioning Deep Dive Webcast SlidesOracle Fleet Patching and Provisioning Deep Dive Webcast Slides
Oracle Fleet Patching and Provisioning Deep Dive Webcast Slides
 
Sga internals
Sga internalsSga internals
Sga internals
 
What we unlearned_and_learned_by_moving_from_m9000_to_ssc_ukoug2014
What we unlearned_and_learned_by_moving_from_m9000_to_ssc_ukoug2014What we unlearned_and_learned_by_moving_from_m9000_to_ssc_ukoug2014
What we unlearned_and_learned_by_moving_from_m9000_to_ssc_ukoug2014
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsYour tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
 
GemFire In-Memory Data Grid
GemFire In-Memory Data GridGemFire In-Memory Data Grid
GemFire In-Memory Data Grid
 
gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”
 
GemFire In Memory Data Grid
GemFire In Memory Data GridGemFire In Memory Data Grid
GemFire In Memory Data Grid
 
6.3 DatacenterService Laporan Juni .pptx
6.3 DatacenterService Laporan Juni .pptx6.3 DatacenterService Laporan Juni .pptx
6.3 DatacenterService Laporan Juni .pptx
 
Oow2007 performance
Oow2007 performanceOow2007 performance
Oow2007 performance
 
21 Pdfsam
21 Pdfsam21 Pdfsam
21 Pdfsam
 
21 Rac
21 Rac21 Rac
21 Rac
 
Presentation of OrientDB v2.2 - Webinar
Presentation of OrientDB v2.2 - WebinarPresentation of OrientDB v2.2 - Webinar
Presentation of OrientDB v2.2 - Webinar
 
WLS
WLSWLS
WLS
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
 
F5 OpenShift Workshop
F5 OpenShift WorkshopF5 OpenShift Workshop
F5 OpenShift Workshop
 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
 

RAC MEMORY STRUCTURES

  • 1. 1 © 2006 Julian Dyke Inside RAC Julian Dyke Independent Consultant Web Version juliandyke.com
  • 2. © 2006 Julian Dyke juliandyke.com2 Agenda  Introduction to RAC  Memory Structures  The Buffer Cache  Global Cache Services  The Library Cache  Global Enqueue Services
  • 3. © 2006 Julian Dyke juliandyke.com3 Introduction to RAC
  • 4. © 2006 Julian Dyke juliandyke.com4 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 Local Disk Local Disk
  • 5. © 2006 Julian Dyke juliandyke.com5 Architecture Instance 1 Node 1 Instance 2 Node 2 Shared Storage Storage Network Private Network (Interconnect) Public Network
  • 6. © 2006 Julian Dyke juliandyke.com6 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 Dyke juliandyke.com7 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 Dyke juliandyke.com8 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 Datafiles Controlfiles Redo Logs SGAUGASGA UGA
  • 9. © 2006 Julian Dyke juliandyke.com9 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.com10 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 Dyke juliandyke.com11 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.com12 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.com13 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.com14 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.com15 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$SGA INST_ID NUMBER NAME 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.com16 CATCLUST.SQL  Some additional views/synonyms are created for RAC databases using $ORACLE_HOME/rdbms/admin/catclust.sql Synonym Name View Name V$GES_CONVERT_LOCAL V$DLM_CONVERT_LOCAL V$GES_CONVERT_REMOTE V$DLM_CONVERT_REMOTE V$GES_LATCH V$DLM_LATCH V$GES_RESOURCE V$DLM_RESS V$GES_STATISTICS V$DLM_MISC V$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.com17 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.com18 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.com19 Memory Structures
  • 20. © 2006 Julian Dyke juliandyke.com20 Memory Areas  An Oracle process includes the following memory areas  Executable  SGA  Shared Libraries  PGA/Session Heap  Stack 40000000 20000000 Executable PGA Session Heap Shared Libraries SGA Stack STOP FFFFFFFF 00000000
  • 21. © 2006 Julian Dyke juliandyke.com21 Shared Memory  Shared memory areas can be dumped to trace file using ORADEBUG SETMYPID ORADEBUG IPC $ sqlplus /nolog SQL> CONNECT SYS/<password> AS SYSDBA Connected SQL> ORADEBUG SETMYPID Statement processed SQL> ORADEBUG IPC Information written to trace file
  • 22. © 2006 Julian Dyke juliandyke.com22 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.com23 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.com24 V$SGAINFO  Summarizes SGA pools NAME VARCHAR2(32) BYTES NUMBER RESIZEABLE VARCHAR2(3) SELECT * FROM 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
  • 25. © 2006 Julian Dyke juliandyke.com25 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.com26 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.com27 X$KSMGE Introduced in Oracle 9.2 Describes individual granules ADDR RAW(4) INDX NUMBER INST_ID NUMBER GRANNUM NUMBER GRANTYPE NUMBER GRANSTATE VARCHAR2(16) GRANFLAGS NUMBER LOCALITY NUMBER KSMAREANUM NUMBER BASEADDR RAW(4) GRANSIZE NUMBER GRANNEXT NUMBER GRANPREV NUMBER INVALID (Free) ALLOCATED Granule Address Granule Size Next granule ID Previous granule ID Granule ID 0 Free 1 Shared Pool 2 Large Pool 3 Java Pool 6 Buffer Pool
  • 28. © 2006 Julian Dyke juliandyke.com28 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.com29 V$SGASTAT  Enhanced in Oracle 10.1 and above Shared Pool 682 Large Pool 6 Java Pool 4 Streams Pool 4  In Oracle 10.2 describes around 700 memory areas POOL VARCHAR2(12) NAME VARCHAR2(26) BYTES NUMBER
  • 30. © 2006 Julian Dyke juliandyke.com30 V$SGASTAT  RAC-specific areas include 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 ges big msg buffers ges deadlock xid freelist ges deadlock xid hash tab ges enqueue cur. usage pe ges enqueue max. usage pe ges enqueue multiple free ges enqueues ges ipc instance maps ges lmd process descripto ges lms process descripto ges process array ges process hash table ges recovery domain table ges regular msg buffers ges reserved msg buffers ges res mastership bucket ges resource ges resource hash seq tab ges resource hash table ges resource pools ges scan queue array ges shared global area KCL buffer header KCL instance cache transf KCL lock contexts KCL lock state KCL name table KCL partition table KCL region array KJXM msg statistics table
  • 31. © 2006 Julian Dyke juliandyke.com31 V$SGASTAT  Significant RAC areas in Oracle 10.2 Name Size(bytes) Location gcs resources 2298008 Segmented Array gcs shadows 1632280 Segmented Array ges resource 1257188 Heap ges enqueues 1625344 Segmented Array ges big msg buffers 3979396 Unknown  In Oracle 9.2 all five structures were stored in segmented arrays
  • 32. © 2006 Julian Dyke juliandyke.com32 Permanent Areas SELECT ksmchptr, ksmchsiz FROM x$ksmsp WHERE ksmchcls = 'perm'; Address Size 2D034000 3981312 2D434000 3549424 2D834000 3963236 2DC34000 3980584 2DFFFD28 728 2E034000 3919532  Allocated at instance startup  Contain structures such as  processes  sessions  segmented arrays STOP 2AC00000 2B800000 2BC00000 2C000000 2C400000 2C800000 2CC00000 2D000000 2D800000 2DC00000 2E000000 2E400000 2E800000 2EF00000 2F000000 2F400000 2F800000 2FC00000 30000000 2D400000 Permanent Area Heap
  • 33. © 2006 Julian Dyke juliandyke.com33 X$KSMSP  Externalises chunks in the shared pool ADDR RAW(4) INDX NUMBER INST_ID NUMBER KSMCHIDX NUMBER KSMCHDUR NUMBER KSMCHCOM VARCHAR2(16) KSMCHPTR RAW(4) KSMCHSIZ NUMBER KSMCHCLS VARCHAR2(8) KSMCHTYP NUMBER KSMCHPAR 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.com34 X$KSMSP  Some RAC components are stored in the shared pool heap SELECT ksmchcom, SUM(ksmchsiz), COUNT(*) FROM x$ksmsp GROUP BY ksmchcom; gcs_mastership 4620 1 gcs_res_hash_bu 16396 1 gcs_res_latch_t 7692 1 ges_res_masters 3084 1 ges_resource 619276 164
  • 35. © 2006 Julian Dyke juliandyke.com35 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.com36 Segmented Arrays Segmented Arrays Call Enqueues Enqueue Resources Segmented Array Header Segmented Array Segmented Array Header Segmented Array STOP
  • 37. © 2006 Julian Dyke juliandyke.com37 X$KSMDD  Externalises segmented array headers ADDR RAW(4) INDX NUMBER INST_ID NUMBER NAME VARCHAR2(30) ELEMENTS_CHUNK NUMBER ITEMS_PT NUMBER INITENTRIES NUMBER NUMENTRIES NUMBER CURENTRIES NUMBER NUMCHUNKS NUMBER ELEMSIZE NUMBER FLAGS NUMBER HEAP RAW(4) SECONDARY RAW(4) Name of array Address of parent heap Number of chunks
  • 38. © 2006 Julian Dyke juliandyke.com38 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.com39 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 2Heap Header Free List Chunks STOP
  • 40. © 2006 Julian Dyke juliandyke.com40 X$KSMHP  Externalises chunks in the heap ADDR RAW(4) INDX NUMBER INST_ID NUMBER KSMCHDS RAW(4) KSMCHCOM VARCHAR2(16) KSMCHPTR RAW(4) KSMCHSIZ NUMBER KSMCHCLS VARCHAR2(8) KSMCHTYP NUMBER KSMCHPAR RAW(4) KSMCHOWN RAW(4)  Can only be accessed using KSMCHDS e.g. SELECT * FROM x$ksmhp WHERE ksmchds = HEXTORAW ('2CA54040');
  • 41. © 2006 Julian Dyke juliandyke.com41 The Buffer Cache
  • 42. © 2006 Julian Dyke juliandyke.com42 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.com43 X$BH ADDR RAW(4) INDX NUMBER INST_ID NUMBER HLADDR RAW(4) BLSIZ NUMBER NXT_HASH RAW(4) PRV_HASH RAW(4) NXT_REPL RAW(4) PRV_REPL RAW(4) FLAG NUMBER RFLAG NUMBER SFLAG NUMBER LRU_FLAG NUMBER TS# NUMBER FILE# NUMBER DBARFIL NUMBER DBABLK NUMBER CLASS NUMBER STATE NUMBER MODE_HELD NUMBER CHANGES NUMBER CSTATE NUMBER LE_ADDR RAW(4) DIRTY_QUEUE NUMBER SET_DS RAW(4) OBJ NUMBER BA RAW(4) CR_SCN_BAS NUMBER CR_SCN_WRP NUMBER CR_XID_USN NUMBER CR_XID_SLT NUMBER CR_XID_SQN NUMBER CR_UBA_FIL NUMBER CR_UBA_BLK NUMBER CR_UBA_SEQ NUMBER CR_UBA_REC NUMBER CR_SFL NUMBER CR_CLS_BAS NUMBER CR_CLS_WRP NUMBER LRBA_SEQ NUMBER LRBA_BNO NUMBER HSCN_BAS NUMBER HSCN_WRP NUMBER HSUB_SCN NUMBER US_NXT RAW(4) US_PRV RAW(4) WA_NXT RAW(4) WA_PRV RAW(4) TCH NUMBER TIM NUMBER
  • 44. © 2006 Julian Dyke juliandyke.com44 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 end Update buffer contentsInsert buffer at head of cold end Read Block 11 Get first available buffer from cold end Update 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 end Set touch count on block 71 to zero Get first available buffer from cold end Update buffer contentsInsert buffer at head of cold end Read Block 34 Update touch count for block 34 Read Block 87 Move block 42 to head of hot end Set touch count on block 42 to zero Get first available buffer from cold end Update buffer contentsInsert buffer at head of cold end STOP Block Number Touch Count
  • 45. © 2006 Julian Dyke juliandyke.com45 Multi-Block Reads Head of Cold End Head of Hot End Read Block 1 Get first four available buffers from cold end Read 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 end Read next four blocks into buffers Insert buffers at head of cold end Move 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.com46 Global Cache Services
  • 47. © 2006 Julian Dyke juliandyke.com47 Read with No Transfer Instance 1 Instance 2 Instance 4 1318 Request shared resource Instance 3 Resource Master 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.com48 Read to Write Transfer Instance 1 Instance 2 Instance 4 1318 Request exclusive resource Instance 3 Resource Master Instance 1 requests exclusive read on block Transfer block to Instance 1 for exclusive access SN Block and resource status Resource status 1318 1 2 3 4 N N X 1320 STOP
  • 49. © 2006 Julian Dyke juliandyke.com49 Write to Write Transfer Instance 1 Instance 2 Instance 4 1318 Request block in exclusive mode Instance 3 Resource Master 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 4 N NX 1320 N N X 1320 1323 STOP Note that Instance 1 will create a past image (PI) of the dirty block
  • 50. © 2006 Julian Dyke juliandyke.com50 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.com51 Past Images 13281329 UPDATE t1 SET c1 = 1324; COMMIT; UPDATE t1 SET c1 = 1329; COMMIT; 1323 Instance 1 13231324132513261327 Buffer Cache 13241323 13251324 13261325 13271326 1328 13281327 Redo Log 1 Instance 2 Buffer Cache 13291328 UPDATE t1 SET c1 = 1325; COMMIT; UPDATE t1 SET c1 = 1326; COMMIT; UPDATE t1 SET c1 = 1327; COMMIT; UPDATE t1 SET 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 1324 Block 42 is read from disk Undo/Redo written to Redo Log 1 Block 42 is updated in buffer cache Instance 1 updates column to 1325 Undo/Redo written to Redo Log 1 Block 42 is updated in buffer cache Instance 1 updates column to 1326 Undo/Redo written to Redo Log 1 Block 42 is updated in buffer cache Instance 1 updates column to 1327 Undo/Redo written to Redo Log 1 Block 42 is updated in buffer cache Instance 1 updates column to 1328 Undo/Redo written to Redo Log 1 Block 42 is updated in buffer cache Instance 2 updates column to 1329 GCS transfers block from Instance 1 to Instance 2 Instance 1 makes block 42 a Past Image block Undo/redo written to Redo Log 2 Block 42 is updated in buffer cache Instance 2 Crashes Contents of buffer cache are lost DBWR has not written changes to block 42 back to disk yet Instance 1 must perform recovery for Instance 2 Block 42 needs recovery Instance 1 uses Past Image Undo/redo is applied from Redo Log 2 Block 42 is subsequently written back to disk by DBWR STOP
  • 52. © 2006 Julian Dyke juliandyke.com52 Write to Read Transfer Instance 1 Instance 2 Instance 4 1318 Request block in shared mode Instance 3 Resource Master Instance 2 requests current read on block SN Block and resource status Resource status 1318 1 3 4 N NX 1320 N N X 1320 1323 Transfer block to Instance 1 in shared mode 2 S S STOP Note that in recent versions _fairness_threshold is used to avoid unnecessary lock conversions
  • 53. © 2006 Julian Dyke juliandyke.com53 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.com54 Fairness Threshold Assume instance 1 holds exclusive lock on block Instance 2 Instance 2 requests consistent read Instance 1 sets counter to 1 Instance 1 sends block to Instance 2 13231323 Instance 1 X Instance 2 receives block with Null lock 13231323 01234 N Instance 2 requests consistent read Instance 1 sets counter to 2 Instance 1 sends block to Instance 2 Instance 2 receives block with Null lock 1323 Instance 2 requests consistent read Instance 1 sets counter to 3 Instance 1 sends block to instance 2 Instance 2 receives block with Null lock Instance 2 requests consistent read Instance 1 sets counter to 4 Instance 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.com55 Lock Elements  Contain embedded GCS Client structures (KJBL) Lock Element GCS Client Buffer Header Lock Element GCS Client Buffer Header Buffer Header Lock Element GCS Client
  • 56. © 2006 Julian Dyke juliandyke.com56 V$LOCK_ELEMENT  Based on X$LE LOCK_ELEMENT_ADDR RAW(4) INDX NUMBER CLASS NUMBER LOCK_ELEMENT_NAME NUMBER MODE_HELD NUMBER BLOCK_COUNT NUMBER RELEASING NUMBER ACQUIRING NUMBER INVALID NUMBER FLAGS NUMBER
  • 57. © 2006 Julian Dyke juliandyke.com57 X$LE ADDR RAW(4) INDX NUMBER INST_ID NUMBER LE_ADDR RAW(4) NAME NUMBER LE_CLASS NUMBER LE_RLS NUMBER LE_ACQ NUMBER LE_FLAGS NUMBER LE_MODE NUMBER LE_WRITE NUMBER LE_LOCAL NUMBER LE_RECOVERY NUMBER LE_BLKS NUMBER LE_TIME NUMBER LE_KJBL RAW(4) Buffer Header Lock Element GCS Client STOP
  • 58. © 2006 Julian Dyke juliandyke.com58 Global Cache Services KJBRKJBR KJBL BH BH LE KJBL LE KJBL GCS Client GCS Shadow
  • 59. © 2006 Julian Dyke juliandyke.com59 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.com60 X$KJBR  Externalizes GCS Resources ADDR RAW(4) INDX NUMBER INST_ID NUMBER KJBRRESP RAW(4) KJBRGRANT VARCHAR2(9) KJBRNCVL VARCHAR2(9) KJBRROLE NUMBER KJBRNAME VARCHAR2(30) KJBRMASTER NUMBER KJBRGRANTQ RAW(4) KJBRCVTQ RAW(4) KJBRWRITER RAW(4)
  • 61. © 2006 Julian Dyke juliandyke.com61 X$KJBL  Externalizes GCS Enqueues ADDR RAW(4) INDX NUMBER INST_ID NUMBER KJBLLOCKP RAW(4) KJBLGRANT VARCHAR2(9) KJBLREQUEST VARCHAR2(9) KJBLROLE NUMBER KJBLRESP RAW(4) KJBLNAME VARCHAR2(30) KJBLNAME2 VARCHAR2(30) KJBLQUEUE NUMBER KJBLLOCKST VARCHAR2(64) KJBLWRITING NUMBER KJBLREQWRITE NUMBER KJBLMASTER NUMBER KJBLBLOCKED NUMBER KJBLBLOCKER NUMBER
  • 62. © 2006 Julian Dyke juliandyke.com62 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 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
  • 63. © 2006 Julian Dyke juliandyke.com63 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.com64 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.com65 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 0x1FF 0x280 0x2FF 0x380 0x3FF 0x480 0x4FF 0x580 0x5FF etc etc Start End 0x000 0x07F 0x100 0x17F 0x200 0x27F 0x300 0x37F 0x400 0x47F 0x500 0x57F etc etc Instance 0 Instance 1
  • 66. © 2006 Julian Dyke juliandyke.com66 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.com67 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.com68 Dynamic Remastering  Example SELECT data_object_id FROM dba_objects WHERE 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.com69 V$GCSPFMASTER_INFO  Object re mastering is recorded in V$GCSPFMASTER_INFO FILE_ID NUMBER OBJECT_ID NUMBER CURRENT_MASTER NUMBER PREVIOUS_MASTER NUMBER REMASTER_CNT NUMBER
  • 70. © 2006 Julian Dyke juliandyke.com70 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 Master 52084 0 32767 Object ID Current Master Previous Master 52084 1 0
  • 71. © 2006 Julian Dyke juliandyke.com71 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.com72 The Library Cache
  • 73. © 2006 Julian Dyke juliandyke.com73 Library Cache Object - Parent 16 x 1 word pointers KGLHD Parent Object KGLNA SELECT SUM (c2) FROM t1 WHERE c3 = 42 AND c4 < 2004 Parent Name Child Handle KGLHD Child 1 Child 2 Heap 0 KGLOB X$KGLOB Parent Handle KGLHD STOP
  • 74. © 2006 Julian Dyke juliandyke.com74 Library Cache Object - Child KGLHD Child Handle Child Object SELECT Statement Heap 6 KGLOB Subheap Header Subheap Header Heap 0 Subquery Header Statistics, Optimizer Environment, BindVariables X$KGLOB STOP
  • 75. © 2006 Julian Dyke juliandyke.com75 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.com76 X$KGLPN X$KGLLK Library Cache Object - Locks & Pins Child Handle Child Object KGLOB X$KGLOB STOP LockLock Pin Lock Pin Pin KGLHD
  • 77. © 2006 Julian Dyke juliandyke.com77 Namespaces  In Oracle 10.2 there are 64 library cache namespaces  Externalized by KGLHDNSP in X$KGLOB CRSR LOB REIP RMGR JVSD RELS MVOBINX NSCPD TABL DIR CPOB XDBS STFG RELD STBO JSLV BODY QUEU EVNT PPLN TRANS IFSD HTSO MODL TRGR OBJG SUMM PCLS RELC XDBC JSGA Unused INDX PROP DIMM SUBS RULE USAG JSET Unused CLST JVSC CTS LOCS STRM MVOBTBL TABLE Unused KGLT JVRE OUTL RMOB REVC JSQI CLST Unused PIPE ROBJ RULS RSMD STAP CDC INDX Unused
  • 78. © 2006 Julian Dyke juliandyke.com78 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 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 ....
  • 79. © 2006 Julian Dyke juliandyke.com79 V$LIBRARYCACHE  Subset of rows from X$KGLST  Contains 11 rows in Oracle 10.2 NAMESPACE VARCHAR2(15) GETS NUMBER GETHITS NUMBER GETHITRATIO NUMBER PINS NUMBER PINHITS NUMBER PINHITRATIO NUMBER RELOADS NUMBER INVALIDATIONS NUMBER DLM_LOCK_REQUESTS NUMBER DLM_PIN_REQUESTS NUMBER DLM_PIN_RELEASES NUMBER DLM_INVALIDATION_REQUESTS NUMBER DLM_INVALIDATIONS NUMBER RAC Specific Statistics
  • 80. © 2006 Julian Dyke juliandyke.com80 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.com81 X$KGLST  Contains one row for each namespace (59 rows in 10.2) ADDR RAW(4) INDX NUMBER INST_ID NUMBER KGLSTCMS NUMBER KGLSTCHT NUMBER KGLSTGET NUMBER KGLSTGHT NUMBER KGLSTPIN NUMBER KGLSTPHT NUMBER KGLSTRLD NUMBER KGLSTINV NUMBER KGLSTLRQ NUMBER KGLSTPRQ NUMBER KGLSTPRL NUMBER KGLSTIRQ NUMBER KGLSTMIV NUMBER RAC Specific Statistics
  • 82. © 2006 Julian Dyke juliandyke.com82 Global Enqueue Services
  • 83. © 2006 Julian Dyke juliandyke.com83 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.com84 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.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  For example:
  • 85. © 2006 Julian Dyke juliandyke.com85 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.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
  • 86. © 2006 Julian Dyke juliandyke.com86 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.com87 Namespaces->Instance Locks  Slide 1 of 3 Namespace Lock Pin JVSC LN NN JVRE LO NO ROBJ LP NP REIP LQ NQ CPOB LR NR EVNT LS NS SUMM LT NT DIMM LU NU CTS LV NV OUTL LW NW RULS LX NX RMGR LY NY XDBS LZ NZ Namespace Lock Pin CRSR LA NA TABL LB NB BODY LC NC TRGR LD ND INDX LE NE CLST LF NF KGLT LG NG PIPE LH NH LOB LI NI DIR LJ NJ QUEU LK NK OBJG LL NL PROP LM NM
  • 88. © 2006 Julian Dyke juliandyke.com88 Namespaces->Instance Locks  Slide 2 of 3 Namespace Lock Pin STAP EN GN RELS EO GO RELD EP GP IFSD EQ GQ XDBC ER GR USAG ES GS MVOBTBL ET GT JSQI EU GU CDC EV GV MVOBINX EW GW STBO EX GX HTSO EY GY JSGA EZ GZ Namespace Lock Pin PPLN EA GA PCLS EB GB SUBS EC GC LOCS ED GD RMOB EE GE RSMD EF GF JVSD EG GG STFG EH GH TRANS EI GI RELC EJ GJ RULE EK GK STRM EL GL REVC EM GM
  • 89. © 2006 Julian Dyke juliandyke.com89 Namespaces->Instance Locks  Slide 3 of 3 Namespace Lock Pin JSET VA YA TABLE VB YB CLST VC YC INDX VD YD NSCPD VE YE JSLV VF YF MODL VG YG Unused VH YH Unused VI YI Unused VJ YJ Unused VK YK Unused VL YL Unused VM YM
  • 90. © 2006 Julian Dyke juliandyke.com90 V$ROWCACHE CACHE# NUMBER TYPE VARCHAR2(11) SUBORDINATE# NUMBER PARAMETER VARCHAR2(32) COUNT NUMBER USAGE NUMBER FIXED NUMBER GETS NUMBER GETMISSES NUMBER SCANS NUMBER SCANMISSES NUMBER SCANCOMPLETES NUMBER MODIFICATIONS NUMBER FLUSHES NUMBER DLM_REQUESTS NUMBER DLM_CONFLICTS NUMBER DLM_RELEASES NUMBER RAC Specific Statistics
  • 91. © 2006 Julian Dyke juliandyke.com91 V$ROWCACHE  Based on X$KQRST  Contains 42 rows in Oracle 10.2  34 Parent Cache  8 Subordinate Caches
  • 92. © 2006 Julian Dyke juliandyke.com92 Row Caches->Instance Locks  Slide 1 of 2 Cache# Namespace Lock 0 dc_tablespaces QA 1 dc_free_extents QB 2 dc_segments QC 3 dc_rollback_segments QD 4 dc_used_extents QE 5 dc_tablespace_quotas QF 6 dc_files QG 7 dc_users QH 8 dc_objects QI 9 dc_qmc_cache_entries QJ 10 dc_usernames QK 11 dc_object_ids QL 12 dc_constraints QM Cache# Namespace Lock 13 dc_sequences QN 14 dc_profiles QO 15 dc_database_links QP 16 dc_histogram_defs QQ 17 dc_global_oids QR 18 dc_outlines QS 19 dc_table_scns QT 20 rule_info QU 21 rule_or_piece QV 22 dc_awr_control QW 23 dc_qmc_ldap_cache... QX 24 outstanding_alerts QY 25 dc_hintsets QZ
  • 93. © 2006 Julian Dyke juliandyke.com93 Row Caches->Instance Locks  Slide 2 of 2 Cache# Namespace Lock 26 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.com94 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 7 dc_free_extents 388 0 0 0.000 0 dc_segments 444 4191 569 0.880 709 dc_rollback_segments 452 4210 31 0.993 74 dc_used_extents 400 0 0 0.000 0 dc_tablespace_quotas 396 0 0 0.000 0 dc_files 412 0 6 0.000 6 dc_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.com95 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 Lock QI F611FFAD E31D1DE3 Cache ID 8 dc_objects
  • 96. © 2006 Julian Dyke juliandyke.com96 GES Resource Global Enqueue Services KJIRFT KJILKFT GES EnqueueKJILKFT KJILKFT KJILKFTKJILKFT KJILKFT Holders Converters Waiters
  • 97. © 2006 Julian Dyke juliandyke.com97 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.com98 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.com99 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.com100 X$KJIRFT  Externals global enqueue resources  Does NOT include global cache resources ADDR RAW(4) INDX NUMBER INST_ID NUMBER KJIRFTRP RAW(4) KJIRFTRN VARCHAR2(30) KJIRFTCQ NUMBER KJIRFTGQ NUMBER KJIRFTPR NUMBER KJIRFTRDN VARCHAR2(25) KJIRFTMN NUMBER KJIRFTNCL VARCHAR2(9) KJIRFTVS VARCHAR2(32) KJIRFTVB VARCHAR2(64)
  • 101. © 2006 Julian Dyke juliandyke.com101 X$KJILKFT ADDR RAW(4) INDX NUMBER INST_ID NUMBER KJILKFTLKP RAW(4) KJILKFTGL VARCHAR2(9) KJILKFTRL VARCHAR2(9) KJILKFTRP RAW(4) KJILKFTRN1 VARCHAR2(30) KJILKFTRN2 VARCHAR2(30) KJILKFTPID NUMBER KJILKFTXID0 NUMBER KJILKFTXID1 NUMBER KJILKFTGID NUMBER KJILKFTOODD NUMBER KJILKFTOOPT NUMBER KJILKFTOOPO NUMBER KJILKFTOONXID NUMBER KJILKFTCOGV NUMBER KJILKFTCOPV NUMBER KJILKFTCONV NUMBER KJILKFTCODV NUMBER KJILKFTCONQ NUMBER KJILKFTCOEP NUMBER KJILKFTCONDDW NUMBER KJILKFTCONDDB NUMBER KJILKFTWQ NUMBER KJILKFTLS VARCHAR2(64) KJILKFTASTE0 NUMBER KJILKFTON NUMBER KJILKFTBLKED NUMBER KJILKFTBLKER NUMBER
  • 102. © 2006 Julian Dyke juliandyke.com102 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 NUMBER ON_GRANT_Q NUMBER PERSISTENT_RES NUMBER MASTER_NODE NUMBER NEXT_CVT_LEVEL VARCHAR2(9) VALUE_BLK_STATE VARCHAR2(32) VALUE_BLK VARCHAR2(64)
  • 103. © 2006 Julian Dyke juliandyke.com103 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.com104 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 NUMBER TRANSACTION_ID0 NUMBER TRANSACTION_ID1 NUMBER GROUP_ID NUMBER OPEN_OPT_DEADLOCK NUMBER OPEN_OPT_PERSISTENT NUMBER OPEN_OPT_PROCESS_OWNED NUMBER OPEN_OPT_NO_XID NUMBER CONVERT_OPT_GETVALUE NUMBER CONVERT_OPT_PUTVALUE NUMBER CONVERT_OPT_NOVALUE NUMBER CONVERT_OPT_DUBVALUE NUMBER CONVERT_OPT_NOQUEUE NUMBER CONVERT_OPT_EXPRESS NUMBER CONVERT_OPT_NODEADLOCKWAIT NUMBER CONVERT_OPT_NODEADLOCKBLOCK NUMBER WHICH_QUEUE NUMBER STATE VARCHAR2(64) AST_EVENT0 NUMBER OWNER_NODE NUMBER BLOCKED NUMBER BLOCKER NUMBER
  • 105. © 2006 Julian Dyke juliandyke.com105 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.com106 Thank you for your interest For more information and to provide feedback please contact me My e-mail address is: info@juliandyke.com My website address is: www.juliandyke.com

Editor's Notes

  1. hot buffers moved to head of LRU statistic measures the number of hot buffers moved from the cold end to the hot end of the LRU free buffers requested measures the number of times a current get or consistent get is performed against a buffer that is not already in cache.