Inside RAC - Julian Dyke
Download
Report
Transcript Inside RAC - Julian Dyke
Inside
RAC
Julian Dyke
Independent Consultant
Web Version
1
© 2006 Julian Dyke
juliandyke.com
Agenda
2
Introduction to RAC
Memory Structures
The Buffer Cache
Global Cache Services
The Library Cache
Global Enqueue Services
© 2006 Julian Dyke
juliandyke.com
Introduction
to
RAC
3
© 2006 Julian Dyke
juliandyke.com
What is RAC?
Multiple instances running on separate servers (nodes)
Single database on shared storage accessible to all nodes
Instances exchange information over an interconnect network
Instance 1
Interconnect
Node 1
Local
Disk
4
© 2006 Julian Dyke
Instance 2
Node 2
Shared
Storage
Local
Disk
juliandyke.com
Architecture
Public Network
Private Network
(Interconnect)
Instance 1
Instance 2
Node 1
Node 2
Storage Network
Shared
Storage
5
© 2006 Julian Dyke
juliandyke.com
Some Definitions
6
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.com
Some Definitions...
7
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.com
Background Processes
DIAG
LMON
PMON
SMON
SMON
Instance 1
PMON
Instance 2
LCK
LMD
LMON
LCK
SGA
UGA
UGA
SGA
LMS
LMD
LMS
LGWR
DBWR
DBWR
LGWR
CKPT
CKPT
ARCH
ARCH
Datafiles
Controlfiles
Redo Logs
8
DIAG
© 2006 Julian Dyke
Redo Logs
juliandyke.com
Background Processes
9
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.com
Background Processes
10
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.com
Background Processes
11
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.com
Background Processes
12
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.com
Background Processes
13
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.com
Fixed Tables
14
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.com
Dynamic Performance Views
15
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.com
CATCLUST.SQL
16
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.com
ORADEBUG
ORADEBUG includes LKDEBUG
Must be run by user with SYSDBA privilege
SQL> ORADEBUG LKDEBUG HELP
Usage:lkdebug [options]
-l [r|p] <enqueue pointer>
-r <resource pointer>
-b <gcs shadow pointer>
-p <process id>
-P <process pointer>
-O <i1> <i2> <types>
-a <res/lock/proc>
-A <res/lock/proc>
-a <res> [<type>]
-a convlock
-A convlock
-a convres
-A convres
17
© 2006 Julian Dyke
Enqueue Object
Resource Object
GCS shadow Object
client pid
Process Object
Oracle Format resname
all <res/lock/proc> pointer
all <res/lock/proc> contexts
all <res> pointers by an optional type
all converting enqueue (pointers)
all converting enqueue contexts
all res ptr with converting enqueues
all res contexts with converting enqueues
juliandyke.com
ORADEBUG
Continued...
-a name
-a hashcount
-t
-s
-k
-m pkey <objectno>
-m dpkey <objectno>
18
© 2006 Julian Dyke
list all resource names
list all resource hash bucket counts
Traffic controller info
summary of all enqueue types
GES SGA summary info
request for remastering this object at current instance
request for dissolving remastering of this object at
current instance
juliandyke.com
Memory
Structures
19
© 2006 Julian Dyke
juliandyke.com
Memory Areas
00000000
An Oracle process includes
the following memory areas
Executable
SGA
Shared Libraries
PGA/Session Heap
Stack
Executable
20000000
SGA
40000000
Shared
Libraries
PGA
Session Heap
Stack
FFFFFFFF
20
STOP
© 2006 Julian Dyke
juliandyke.com
Shared Memory
Shared memory areas can be dumped to trace file using
$ sqlplus /nolog
SQL> CONNECT SYS/<password> AS SYSDBA
Connected
SQL> ORADEBUG SETMYPID
ORADEBUG SETMYPID
Statement processed
ORADEBUG IPC
SQL> ORADEBUG IPC
Information written to trace file
21
© 2006 Julian Dyke
juliandyke.com
ORADEBUG IPC - Example
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
Fixed Area
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
Variable Area
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
Redo Buffers
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
OS Specific
0000000000001000 0000000010800000
22
STOP
© 2006 Julian Dyke
juliandyke.com
Shared Global Area
23
Contains
Fixed SGA
Buffer Pool
Shared Pool
Large Pool
Java Pool
Streams Pool
Redo buffers
Buffer Pool includes
Default cache
Keep and Recycle cache
2K, 4K, 8K, 16K and 32K cache
© 2006 Julian Dyke
Oracle 7.0 and above
Oracle 8.0 and above
Oracle 8.1.5 and above
Oracle 10.1 and above
Oracle 8.0 and above
Oracle 9.0.1 and above
juliandyke.com
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
24
© 2006 Julian Dyke
juliandyke.com
Granules
25
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.com
Granules
26
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.com
X$KSMGE
Introduced
in Oracle 9.2
Describes individual granules
27
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
© 2006 Julian Dyke
Granule ID
0
1
2
3
6
Free
Shared Pool
Large Pool
Java Pool
Buffer Pool
INVALID (Free)
ALLOCATED
Granule Address
Granule Size
Next granule ID
Previous granule ID
juliandyke.com
Granules
4M
SGA_TARGET = 260M
SGA_MAX_SIZE = 260M
Fixed SGA + Redo
Buffers 4M
Buffer Pool 172M
GRANULE SIZE = 4M
256M
Large Pool 4M
Java Pool 4M
This is an example of an
SGA mapped using
X$KSMGE
28
STOP
© 2006 Julian Dyke
Shared Pool 76M
juliandyke.com
V$SGASTAT
Enhanced in Oracle 10.1 and above
POOL
VARCHAR2(12)
NAME
VARCHAR2(26)
BYTES
NUMBER
In Oracle 10.2 describes around 700 memory areas
Shared Pool
29
© 2006 Julian Dyke
682
Large Pool
6
Java Pool
4
Streams Pool
4
juliandyke.com
V$SGASTAT
RAC-specific areas include
gcs affinity
ges big msg buffers
gcs close obj
ges deadlock xid freelist
gcs commit sga state
ges deadlock xid hash tab
gcs I/O statistics struct
ges enqueue cur. usage pe
gcs mastership buckets
ges enqueue max. usage pe
gcs opaque in
ges enqueue multiple free
gcs res hash bucket
ges enqueues
gcs res latch table
ges ipc instance maps
gcs resource freelist arr
ges lmd process descripto
gcs resource freelist dyn
ges lms process descripto
gcs resources
ges process array
gcs scan queue array
gcs shadow locks dyn seg
gcs shadow locks freelist
gcs shadows
30
© 2006 Julian Dyke
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
juliandyke.com
V$SGASTAT
Significant RAC areas in Oracle 10.2
Name
31
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.com
Permanent Areas
2AC00000
Allocated at instance startup
Contain structures such as
processes
sessions
segmented arrays
2B800000
SELECT ksmchptr, ksmchsiz
FROM x$ksmsp
WHERE ksmchcls = 'perm';
2D400000
2BC00000
Heap
2C000000
2C400000
2C800000
2CC00000
2D000000
2D800000
2DC00000
2E000000
Address
2D034000
3981312
2E400000
2E800000
2D434000
3549424
2EF00000
2D834000
3963236
2DC34000
3980584
2DFFFD28
728
2E034000
32
STOP
Size
© 2006 Julian Dyke
3919532
Permanent
Area
2F000000
2F400000
2F800000
2FC00000
30000000
juliandyke.com
X$KSMSP
Externalises chunks in the shared pool
Description of chunk type
Address of chunk
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)
Size including header
Class
●Perm
●Recreate
●Freeable
●Free
●R-Free
●R-Freeable
Type (recreate only)
●0x18 - KGL Handle
●0x24 - Fixed Allocation
●0x74 - KQR PO
●0x80 - KQR SO
●0xFFF - Extended header
Address of parent
33
© 2006 Julian Dyke
juliandyke.com
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
16396
1
gcs_res_latch_t
7692
1
ges_res_masters
3084
1
619276
164
gcs_res_hash_bu
ges_resource
34
© 2006 Julian Dyke
juliandyke.com
Segmented Arrays
35
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.com
Segmented Arrays
Segmented
Arrays
Call
Segmented
Array
Segmented
Array
Segmented
Header
Array
Segmented
Array
Header
36
STOP
© 2006 Julian Dyke
Enqueues
Enqueue
Resources
juliandyke.com
X$KSMDD
Externalises segmented array headers
Name of array
37
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)
© 2006 Julian Dyke
Number of
chunks
Address of parent
heap
juliandyke.com
Segmented Arrays
38
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.com
Heaps
A heap consists of one or more extents
Each heap extent occupies a single granule
Each extent contains one or more chunks
Each heap has a header containing
list of used chunks
list of free chunks
Heap
Extent 0
Extent 1
Extent 2
Header
Free List
39
STOP
© 2006 Julian Dyke
Chunks
juliandyke.com
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');
40
© 2006 Julian Dyke
juliandyke.com
The
Buffer
Cache
41
© 2006 Julian Dyke
juliandyke.com
Buffer Headers
Each buffer has a buffer header
Buffer headers are stored in same granule as buffers
Buffer headers include
Replacement list
Hash list
Pointer to buffer
In RAC only pointer to Lock Element
Buffer
Headers
Buffers
Granule
42
STOP
© 2006 Julian Dyke
juliandyke.com
X$BH
43
ADDR
RAW(4)
CLASS
NUMBER
CR_UBA_SEQ
NUMBER
INDX
NUMBER
STATE
NUMBER
CR_UBA_REC
NUMBER
INST_ID
NUMBER
MODE_HELD
NUMBER
CR_SFL
NUMBER
HLADDR
RAW(4)
CHANGES
NUMBER
CR_CLS_BAS
NUMBER
BLSIZ
NUMBER
CSTATE
NUMBER
CR_CLS_WRP
NUMBER
NXT_HASH
RAW(4)
LE_ADDR
RAW(4)
LRBA_SEQ
NUMBER
PRV_HASH
RAW(4)
DIRTY_QUEUE
NUMBER
LRBA_BNO
NUMBER
NXT_REPL
RAW(4)
SET_DS
RAW(4)
HSCN_BAS
NUMBER
PRV_REPL
RAW(4)
OBJ
NUMBER
HSCN_WRP
NUMBER
FLAG
NUMBER
BA
RAW(4)
HSUB_SCN
NUMBER
RFLAG
NUMBER
CR_SCN_BAS
NUMBER
US_NXT
RAW(4)
SFLAG
NUMBER
CR_SCN_WRP
NUMBER
US_PRV
RAW(4)
LRU_FLAG
NUMBER
CR_XID_USN
NUMBER
WA_NXT
RAW(4)
TS#
NUMBER
CR_XID_SLT
NUMBER
WA_PRV
RAW(4)
FILE#
NUMBER
CR_XID_SQN
NUMBER
TCH
NUMBER
DBARFIL
NUMBER
CR_UBA_FIL
NUMBER
TIM
NUMBER
DBABLK
NUMBER
CR_UBA_BLK
NUMBER
© 2006 Julian Dyke
juliandyke.com
Single-Block Reads
Head of
Hot End
92
71
42
34
92
71
72
34
92
45
72
34
52
42
45
33
72
87
11
71
52
42
45
33
72
11
66
71
52
42
45
33
11
49
66
71
52
42
45
11
0
3
0
3
4
0
2
4
2
4
1
2
1
4
0
2
1
0
1
2
Read Block 87
11
42
33
34
Get
Insert
Update
Move
Set
Gettouch
Insert
first
first
block
buffer
buffer
touch
buffer
available
available
count
71
42
at
atcount
contents
to
head
head
head
buffer
buffer
of
of cold
cold
from
end
for
of
on
from
end
hot
block
block
cold
cold
end42
71
42
34
end
end
to zero
44
STOP
Block
Number
Head of
Cold End
© 2006 Julian Dyke
42
33
87
11
Touch
Count
1
juliandyke.com
Multi-Block Reads
DB_FILE_MULTIBLOCK_READ_COUNT = 4
Head of
Hot End
ReadBlock
Block7
28
5
6
Read
1
3
4
Head of
Cold End
7
2
1
3
4
8
5
6
6
2
3
7
1
5
5
2
1
6
1
5
41
5
2
3
6
2
3
7
4
1
8
1
5
1
2
5
6
2
1
5
3
6
7
2
3
4
6
7
8
1
5
Insert
Read
Move
Move
Get
Read
Insert
Move
next
next
block
buffers
next
block
block
buffers
four
four
four
17
2
3
4
5
86available
at
to
available
to
to
at
blocks
blocks
head
cold
cold
cold
headend
end
of
end
into
of
into
Get
first
four
cold
buffers
buffers
coldend
end
from cold
cold end
end
from
45
STOP
© 2006 Julian Dyke
juliandyke.com
Global
Cache
Services
46
© 2006 Julian Dyke
juliandyke.com
Read with No Transfer
N S
Instance 2
1 Request
shared
resource
2 Request
granted
Resource
Master
Instance 3
3 Read
request
Instance 1
4 Block
returned
Instance 2 requests
current read on
block
47
STOP
© 2006 Julian Dyke
Instance 4
1318
juliandyke.com
Read to Write Transfer
N S N
3 Block and
resource
status
1318
2 Transfer
block to
Instance 1 for
exclusive
access
Instance 2
N X
1320
Instance 3
1 Request
exclusive
resource
4 Resource
status
Instance 1
Instance 1 requests
exclusive read on
block
48
STOP
© 2006 Julian Dyke
Resource
Master
Instance 4
1318
juliandyke.com
Write to Write Transfer
N S N
1318
2 Transfer
block to
Instance 4
in exclusive
mode
Instance 2
Resource
Master
Instance 3
4 Resource
status
N X N
1320
3 Block and resource status
Instance 1
Instance 4 requests
exclusive read on
block
49
STOP
© 2006 Julian Dyke
1 Request
block in
exclusive
mode
N X
1323
Instance 4
1318
Note that Instance 1 will
create a past image (PI) of
the dirty block
juliandyke.com
Past Images
50
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.com
Past Images
Buffer Cache
UPDATE t1
SET c1 = 1328;
1324;
1325;
1326;
1327;
COMMIT;
Buffer Cache
1323
1324
1325
1326
1327
1328
1329
1328
1329
Instance 1
1323
1324
1324
1325
1325
1326
1326
1327
1327
1328
STOP
Instance 2
1328
1329
1323
1329
Block
DBWR
Instance
Block
Assume
Instance
Undo/redo
GCS
Block
Instance
Undo/Redo
Undo/redo
42
Instance
has
42
transfers
is42
1
2is
table
subsequently
not
1updates
1
needs
updated
makes
is
must
2
written
applied
t1
written
written
Crashes
block
contains
recovery
perform
column
block
inchanges
from
to
from
buffer
to
written
42ato
Block 42 is read from disk
Contents
Instance
toInstance
recovery
back
block
single
a Past
of
to
Redo
42
1row
buffer
disk
cache
uses
1Image
1324
1327
1325
1326
1328
1329
for
back
toin
Log
Instance
by
Instance
cache
block
Past
toblock
1
2
DBWR
disk
Image
42
are
2yet
2 lost
Redo Log 1
51
UPDATE t1
SET c1 = 1329;
COMMIT;
© 2006 Julian Dyke
Redo Log 2
juliandyke.com
Write to Read Transfer
N S N S
1 Request block
in shared mode
1318
Instance 2
4 Resource
status
Resource
Master
Instance 3
N X N
1320
N X S
3 Block and resource status
Instance 1
Instance 2 requests
current read on
block
52
STOP
© 2006 Julian Dyke
2 Transfer
block to
Instance 1
in shared
mode
1323
Instance 4
1318
Note that in recent versions
_fairness_threshold is used
to avoid unnecessary lock
conversions
juliandyke.com
Fairness Threshold
53
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.com
Fairness Threshold
_fairness_threshold = 4
2
4
03
1
X S
N S
1323
Instance 1
Instance 2
Instance
Instance
Instance
Instance
Instance
Instance
Assume
Instance
1 22downgrades
22requests
receives
requests
1
receives
instance
1sends
sendsblock
consistent
block
consistent
1 lock
holds
to
with
to
with
from
Instance
Instance11sets
setscounter
counterto
to4
21
3
exclusive
Shared
instance
Instance
Null
Null
Xread
read
lock
tolock
lock
S
lock
on
22 block
54
STOP
© 2006 Julian Dyke
juliandyke.com
Lock Elements
55
Contain embedded GCS Client structures (KJBL)
Buffer
Header
Buffer
Header
Buffer
Header
Lock
Element
Lock
Element
Lock
Element
GCS
Client
GCS
Client
GCS
Client
© 2006 Julian Dyke
juliandyke.com
V$LOCK_ELEMENT
56
Based on X$LE
© 2006 Julian Dyke
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
juliandyke.com
X$LE
57
STOP
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)
© 2006 Julian Dyke
Buffer
Header
Lock
Element
GCS
Client
juliandyke.com
Global Cache Services
GCS
Client
BH
BH
LE
LE
KJBL
KJBL
KJBR
58
© 2006 Julian Dyke
GCS
Shadow
KJBL
KJBR
juliandyke.com
GCS Parameters
59
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.com
X$KJBR
60
Externalizes GCS Resources
© 2006 Julian Dyke
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)
juliandyke.com
X$KJBL
61
Externalizes GCS Enqueues
© 2006 Julian Dyke
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
juliandyke.com
Global Cache Dumps
To dump the contents of the global cache use:
ALTER SESSION SET EVENTS
'IMMEDIATE TRACE NAME GC_ELEMENTS LEVEL 1';
GLOBAL CACHE ELEMENT DUMP (address: 0x21fecd18):
id1: 0x3591 id2: 0x10000 obj: 181 block: (1/13713)
lock: SL rls: 0x0000 acq: 0x0000 latch: 0
flags: 0x41 fair: 0 recovery: 0 fpin: 'kdswh05: kdsgrp'
bscn: 0x0.18a9c bctx: (nil) write: 0 scan: 0x0 xflg: 0 xid: 0x0.0.0
GCS CLIENT 0x21fecd60,1 sq[(nil),(nil)] resp[(nil),0x3591.10000] pkey 181
grant 1 cvt 0 mdrole 0x21 st 0x20 GRANTQ rl LOCAL
master 1 owner 0 sid 0 remote[(nil),0] hist 0x7c
history 0x3c.0x1.0x0.0x0.0x0.0x0. cflag 0x0 sender 2 flags 0x0 replay# 0
disk: 0x0000.00000000 write request: 0x0000.00000000
pi scn: 0x0000.00000000
msgseq 0x1 updseq 0x0 reqids[1,0,0] infop 0x0
pkey 181
hv 107 [stat 0x0, 1->1, wm 32767, RMno 0, reminc 6, dom 0]
kjga st 0x4, step 0.0.0, cinc 8, rmno 10, flags 0x0
lb 0, hb 0, myb 178, drmb 178, apifrz 0
62
© 2006 Julian Dyke
juliandyke.com
Global Cache Dumps
Continued
GLOBAL CACHE ELEMENT DUMP (address: 0x237f4358):
id1: 0x6a39 id2: 0x10000 obj: 74 block: (1/27193)
lock: SL rls: 0x0000 acq: 0x0000 latch: 0
flags: 0x41 fair: 0 recovery: 0 fpin: 'kdswh05: kdsgrp'
bscn: 0x0.26992 bctx: (nil) write: 0 scan: 0x0 xflg: 0 xid: 0x0.0.0
GCS SHADOW 0x237f43a0,1 sq[0x2ee64e8c,0x2eff3858] resp[0x2ee64e74,0x6a39.10000] pkey 74
grant 1 cvt 0 mdrole 0x21 st 0x40 GRANTQ rl LOCAL
master 0 owner 0 sid 0 remote[(nil),0] hist 0x12a5
.....
GCS RESOURCE 0x2ee64e74 hashq [0x2ee61894,0x2ff57390] name[0x6a39.10000] pkey 74
grant 0x2eff3858 cvt (nil) send (nil),0 write (nil),0@65535
flag 0x0 mdrole 0x1 mode 1 scan 0 role LOCAL
.....
GCS SHADOW 0x2eff3858,1 sq[0x237f43a0,0x2ee64e8c] resp[0x2ee64e74,0x6a39.10000] pkey 74
grant 1 cvt 0 mdrole 0x21 st 0x40 GRANTQ rl LOCAL
master 0 owner 1 sid 0 remote[0x23fea160,1] hist 0x65f
.....
GCS SHADOW 0x237f43a0,1 sq[0x2ee64e8c,0x2eff3858] resp[0x2ee64e74,0x6a39.10000] pkey 74
grant 1 cvt 0 mdrole 0x21 st 0x40 GRANTQ rl LOCAL
master 0 owner 0 sid 0 remote[(nil),0] hist 0x12a5
.....
63
© 2006 Julian Dyke
juliandyke.com
Block Mastering
Each block is mastered on one instance
Block DBA is reported by X$KJBR.KJBRNAME
Names
for have the format:
[<block_number>][<file_number>],[BL]
Ordering
by X$KJBR.KJBRNAME is difficult because
the resource names do not collate e.g.
[0x900][0x70000],[BL]
[0x90][0x70000],[BL]
64
Current master reported by X$KJBR.KJBRMASTER
© 2006 Julian Dyke
juliandyke.com
Block Mastering
65
In Oracle 10.2 block mastering is determined by
_lm_contiguous_res_count
Specifies number of contiguous blocks that will hash to the
same HV bucket
Defaults to 128
For example
Instance 1
Instance 0
Start
End
Start
End
0x080
0x0FF
0x000
0x07F
0x180
0x1FF
0x100
0x17F
0x280
0x2FF
0x200
0x27F
0x380
0x3FF
0x300
0x37F
0x480
0x4FF
0x400
0x47F
0x580
0x5FF
0x500
0x57F
etc
etc
etc
etc
© 2006 Julian Dyke
juliandyke.com
Block Mastering
66
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.com
Dynamic Remastering
67
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.com
Dynamic Remastering
Example
SELECT data_object_id FROM dba_objects
WHERE owner = 'US01'AND object_name = 'T1';
OBJECT_ID
--------52084
To remaster object at current instance use:
ORADEBUG LKDEBUG -m pkey 52084
All blocks now mastered by the current instance
To redistribute masters to all available instances use:
ORADEBUG LKDEBUG -m dpkey 52084
68
Blocks mastered by both (all) instances again
© 2006 Julian Dyke
juliandyke.com
V$GCSPFMASTER_INFO
69
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.com
Dynamic Remastering
Object remastering recorded in V$GCSPFMASTER_INFO
Instances are internally numbered 0, 1 etc
Initially contains no rows
After remastering object 52084 to instance 0
SELECT object_id, current_master, previous_master
FROM v$gcspfmaster_info;
70
Object ID
Current Master
Previous Master
52084
0
32767
After remastering object 52084 to instance 1
Object ID
Current Master
Previous Master
52084
1
0
© 2006 Julian Dyke
juliandyke.com
Dynamic Remastering
71
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.com
The
Library
Cache
72
© 2006 Julian Dyke
juliandyke.com
Library Cache Object - Parent
KGLNA
KGLHD
SELECT SUM (c2) FROM t1
WHERE c3 = 42 AND c4 < 2004
KGLOB
Parent
Handle
Parent
Name
Parent
Object
Heap 0
X$KGLOB
Child
Handle
KGLHD
Child 1
16 x 1 word
pointers
73
STOP
© 2006 Julian Dyke
KGLHD
Child 2
juliandyke.com
Library Cache Object - Child
KGLHD
Child
Object
Subheap
Header
Statistics,
Optimizer
Environment,
BindVariables
KGLOB
Heap 0
Heap 6
Child
Handle
Subquery
Header
X$KGLOB
74
STOP
© 2006 Julian Dyke
Subheap
Header
SELECT
Statement
juliandyke.com
Library Cache
In general
Locks are required for parsing
Externalized in X$KGLLK
75
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.com
Library Cache Object - Locks & Pins
X$KGLLK
Lock
Lock
Lock
KGLHD
Child
Object
KGLOB
Pin
Pin
Pin
X$KGLPN
Child
Handle
X$KGLOB
76
STOP
© 2006 Julian Dyke
juliandyke.com
Namespaces
77
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.com
Namespaces
Library cache statistics can be dumped using:
ALTER SESSION SET EVENTS
'IMMEDIATE TRACE NAME LIBRARY_CACHE LEVEL 1';
For example:
LIBRARY CACHE STATISTICS:
namespace
gets hit ratio
pins hit ratio
reloads
invalids
-------------- --------- --------- --------- --------- ---------- ---------CRSR
2403
0.086
33698
0.933
435
0
TABL
4368
0.578
10032
0.657
961
0
BODY
127
0.717
211
0.801
4
0
TRGR
4
0.000
45
0.911
0
0
INDX
81
0.272
83
0.036
21
0
CLST
101
0.921
264
0.958
3
0
KGLT
0
0.000
0
0.000
0
0
PIPE
0
0.000
0
0.000
0
0
LOB
0
0.000
0
0.000
0
0
DIR
0
0.000
0
0.000
0
0
QUEU
156
0.904
5886
0.997
0
0
....
78
© 2006 Julian Dyke
juliandyke.com
V$LIBRARYCACHE
Subset of rows from X$KGLST
Contains 11 rows in Oracle 10.2
RAC
Specific
Statistics
79
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
© 2006 Julian Dyke
juliandyke.com
V$LIBRARYCACHE
Based on X$KGLST
SELECT inst_id,
DECODE (indx,
Names are generated
0,'SQL AREA',
in dynamic
1,'TABLE/PROCEDURE',
performance view
2,'BODY',
3,'TRIGGER',
4,'INDEX',
5,'CLUSTER',
6,'OBJECT',
7,'PIPE',
13,'JAVA SOURCE',
14,'JAVA RESOURCE',
32,'JAVA DATA','
?'
),
kglstget,kglstght, DECODE (kglstget,0,1,kglstght/kglstget),
kglstpin,kglstpht, DECODE (kglstpin,0,1,kglstpht/kglstpin),
kglstrld,kglstinv, kglstlrq,kglstprq,kglstprl,kglstirq,kglstmiv
Only selected rows
FROM x$kglst
from X$KGLST
WHERE indx<8 OR indx=13 OR indx=14 OR indx=32
80
© 2006 Julian Dyke
juliandyke.com
X$KGLST
Contains one row for each namespace (59 rows in 10.2)
RAC
Specific
Statistics
81
© 2006 Julian Dyke
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
juliandyke.com
Global
Enqueue
Services
82
© 2006 Julian Dyke
juliandyke.com
V$LOCK_TYPE
83
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.com
Library Cache Objects
Library Cache Objects can be dumped using:
ALTER SESSION SET EVENTS
'IMMEDIATE TRACE NAME LIBRARY_CACHE LEVEL 4';
For example:
BUCKET 127469:
LIBRARY OBJECT HANDLE: handle=2bb8dfbc mutex=0x2bb8e070(0)
name=US01.T1
hash=b2f454b86387761e02fc7e686e37f1ed timestamp=01-14-2006 22:04:06
namespace=TABL flags=KGHP/TIM/MED/[40000000]
kkkk-dddd-llll=0000-0701-0701 lock=0 pin=0 latch#=1 hpc=0002 hlc=0002
lwt=0x2bb8e018[0x2bb8e018,0x2bb8e018] ltm=0x2bb8e020[0x2bb8e020,0x2bb8e020]
pwt=0x2bb8dffc[0x2bb8dffc,0x2bb8dffc] ptm=0x2bb8e004[0x2bb8e004,0x2bb8e004]
ref=0x2bb8e038[0x2bb8e038,0x2bb8e038] lnd=0x2bb8e044[0x2bb7a7ac,0x2bb8e410]
LOCK INSTANCE LOCK: id=LBb2f454b86387761e
PIN INSTANCE LOCK: id=NBb2f454b86387761e mode=S release=F flags=[00
INVALIDATION INSTANCE LOCK: id=IV0000c9890e170507 mode=S
LIBRARY OBJECT: object=2caede30
type=TABL flags=EXS/LOC[0005] pflags=[0000] status=VALD load=0
BUCKET 127469 total object count=1
84
© 2006 Julian Dyke
juliandyke.com
Library Cache Instance Locks
Instance Locks created for
Library Cache Locks
Library Cache Pins
Lock name based on object hash value (KGLNAHSH)
For example:
BUCKET 127469:
LIBRARY OBJECT HANDLE: handle=2bb8dfbc mutex=0x2bb8e070(0)
name=US01.T1
hash=b2f454b86387761e02fc7e686e37f1ed timestamp=01-14-2006 22:04:06
namespace=TABL flags=KGHP/TIM/MED/[40000000]
kkkk-dddd-llll=0000-0701-0701 lock=0 pin=0 latch#=1 hpc=0002 hlc=0002
lwt=0x2bb8e018[0x2bb8e018,0x2bb8e018] ltm=0x2bb8e020[0x2bb8e020,0x2bb8e020]
pwt=0x2bb8dffc[0x2bb8dffc,0x2bb8dffc] ptm=0x2bb8e004[0x2bb8e004,0x2bb8e004]
ref=0x2bb8e038[0x2bb8e038,0x2bb8e038] lnd=0x2bb8e044[0x2bb7a7ac,0x2bb8e410]
LOCK INSTANCE LOCK: id=LBb2f454b86387761e
PIN INSTANCE LOCK: id=NBb2f454b86387761e mode=S release=F flags=[00
INVALIDATION INSTANCE LOCK: id=IV0000c9890e170507 mode=S
LIBRARY OBJECT: object=2caede30
type=TABL flags=EXS/LOC[0005] pflags=[0000] status=VALD load=0
BUCKET 127469 total object count=1
85
© 2006 Julian Dyke
juliandyke.com
Library Cache Instance Locks
For example in library cache dump
Library cache pin instance lock is
id=NBb2f454b86387761e
86
In X$KJIRFT this KJIRFTRN column
[0xb2f454b8][0x6387761e],[NB]
© 2006 Julian Dyke
juliandyke.com
Namespaces->Instance Locks
87
Slide 1 of 3
Namespace
Lock
Pin
Namespace
Lock
Pin
CRSR
LA
NA
JVSC
LN
NN
TABL
LB
NB
JVRE
LO
NO
BODY
LC
NC
ROBJ
LP
NP
TRGR
LD
ND
REIP
LQ
NQ
INDX
LE
NE
CPOB
LR
NR
CLST
LF
NF
EVNT
LS
NS
KGLT
LG
NG
SUMM
LT
NT
PIPE
LH
NH
DIMM
LU
NU
LOB
LI
NI
CTS
LV
NV
DIR
LJ
NJ
OUTL
LW
NW
QUEU
LK
NK
RULS
LX
NX
OBJG
LL
NL
RMGR
LY
NY
PROP
LM
NM
XDBS
LZ
NZ
© 2006 Julian Dyke
juliandyke.com
Namespaces->Instance Locks
88
Slide 2 of 3
Namespace
Lock
Pin
Namespace
Lock
Pin
PPLN
EA
GA
STAP
EN
GN
PCLS
EB
GB
RELS
EO
GO
SUBS
EC
GC
RELD
EP
GP
LOCS
ED
GD
IFSD
EQ
GQ
RMOB
EE
GE
XDBC
ER
GR
RSMD
EF
GF
USAG
ES
GS
JVSD
EG
GG
MVOBTBL
ET
GT
STFG
EH
GH
JSQI
EU
GU
TRANS
EI
GI
CDC
EV
GV
RELC
EJ
GJ
MVOBINX
EW
GW
RULE
EK
GK
STBO
EX
GX
STRM
EL
GL
HTSO
EY
GY
REVC
EM
GM
JSGA
EZ
GZ
© 2006 Julian Dyke
juliandyke.com
Namespaces->Instance Locks
89
Slide 3 of 3
© 2006 Julian Dyke
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
juliandyke.com
V$ROWCACHE
RAC
Specific
Statistics
90
© 2006 Julian Dyke
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
juliandyke.com
V$ROWCACHE
91
Based on X$KQRST
Contains 42 rows in Oracle 10.2
34 Parent Cache
8 Subordinate Caches
© 2006 Julian Dyke
juliandyke.com
Row Caches->Instance Locks
Cache#
92
Slide 1 of 2
Namespace
Lock
Cache#
Namespace
Lock
0
dc_tablespaces
QA
13
dc_sequences
QN
1
dc_free_extents
QB
14
dc_profiles
QO
2
dc_segments
QC
15
dc_database_links
QP
3
dc_rollback_segments
QD
16
dc_histogram_defs
QQ
4
dc_used_extents
QE
17
dc_global_oids
QR
5
dc_tablespace_quotas
QF
18
dc_outlines
QS
6
dc_files
QG
19
dc_table_scns
QT
7
dc_users
QH
20
rule_info
QU
8
dc_objects
QI
21
rule_or_piece
QV
9
dc_qmc_cache_entries
QJ
22
dc_awr_control
QW
10
dc_usernames
QK
23
dc_qmc_ldap_cache...
QX
11
dc_object_ids
QL
24
outstanding_alerts
QY
12
dc_constraints
QM
25
dc_hintsets
QZ
© 2006 Julian Dyke
juliandyke.com
Row Caches->Instance Locks
Slide 2 of 2
Cache#
93
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.com
Row Caches
Row cache statistics can be dumped using:
ALTER SESSION SET EVENTS
'IMMEDIATE TRACE NAME ROW_CACHE LEVEL 1';
For example:
ROW CACHE STATISTICS:
cache
-------------------------dc_tablespaces
dc_free_extents
dc_segments
dc_rollback_segments
dc_used_extents
dc_tablespace_quotas
dc_files
dc_users
dc_users
dc_user_grants
dc_app_role
....
94
© 2006 Julian Dyke
size
------496
388
444
452
400
396
412
520
260
108
100
gets
------8909
0
4191
4210
0
0
0
9042
0
24
0
misses
-----7
0
569
31
0
0
6
23
0
17
0
hit ratio
--------0.999
0.000
0.880
0.993
0.000
0.000
0.000
0.997
0.000
0.585
0.000
DLM req
------7
0
709
74
0
0
6
23
0
0
0
juliandyke.com
Row Caches
Row cache statistics can be dumped using:
ALTER SESSION SET EVENTS
'IMMEDIATE TRACE NAME ROW_CACHE LEVEL 8';
For example:
Cache ID 8
BUCKET 48205:
row cache parent object: address=0x2bb8dcd8 cid=8(dc_objects) dc_objects
hash=313bbc4c typ=9 transaction=(nil) flags=00000002
own=0x2bb8dd44[0x2bb8dd44,0x2bb8dd44]
wat=0x2bb8dd4c[0x2bb8dd4c,0x2bb8dd4c] mode=S
status=VALID/-/-/-/-/-/-/-/request=N release=FALSE flags=0
Instance Lock
instance lock id=QI f611ffad e31d1de3
QI F611FFAD E31D1DE3
set=0, complete=FALSE
T1
data=
00000037 31540002 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000001 00000000 00000000 00000000 00000000 00000000 00000000
......
00000000 00000000 00000000 0000c989 00000001 0000c989 016a7802 0705170e
0e016a78 78070517 170e016a 00010705 00000000 00000000 00000000 00000000
00000000 00000006
BUCKET 48205 total object count=1
95
© 2006 Julian Dyke
juliandyke.com
Global Enqueue Services
Holders
Converters
Waiters
KJILKFT
KJILKFT
KJILKFT
KJILKFT
KJILKFT
KJIRFT
96
© 2006 Julian Dyke
KJILKFT
GES
Enqueue
GES
Resource
juliandyke.com
Resource Names
97
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.com
Resource Names
98
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.com
GES Parameters
99
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.com
X$KJIRFT
100
Externals global enqueue resources
Does NOT include global cache resources
© 2006 Julian Dyke
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)
juliandyke.com
X$KJILKFT
101
ADDR
RAW(4)
KJILKFTOONXID
NUMBER
INDX
NUMBER
KJILKFTCOGV
NUMBER
INST_ID
NUMBER
KJILKFTCOPV
NUMBER
KJILKFTLKP
RAW(4)
KJILKFTCONV
NUMBER
KJILKFTGL
VARCHAR2(9)
KJILKFTCODV
NUMBER
KJILKFTRL
VARCHAR2(9)
KJILKFTCONQ
NUMBER
KJILKFTRP
RAW(4)
KJILKFTCOEP
NUMBER
KJILKFTRN1
VARCHAR2(30)
KJILKFTCONDDW
NUMBER
KJILKFTRN2
VARCHAR2(30)
KJILKFTCONDDB
NUMBER
KJILKFTPID
NUMBER
KJILKFTWQ
NUMBER
KJILKFTXID0
NUMBER
KJILKFTLS
VARCHAR2(64)
KJILKFTXID1
NUMBER
KJILKFTASTE0
NUMBER
KJILKFTGID
NUMBER
KJILKFTON
NUMBER
KJILKFTOODD
NUMBER
KJILKFTBLKED
NUMBER
KJILKFTOOPT
NUMBER
KJILKFTBLKER
NUMBER
KJILKFTOOPO
NUMBER
© 2006 Julian Dyke
juliandyke.com
V$GES_RESOURCE
102
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.com
V$GES_RESOURCE
Contains rows from both KJIRFT and KJBR
Synonym for V$DLM_RESS
SELECT
inst_id, kjirftrp, kjirftrn, kjirftcq, kjirftgq, kjirftpr, kjirftmn, kjirftncl,
kjirftvs, kjirftvb
FROM x$kjirft
UNION ALL
SELECT
inst_id, kjbrresp, kjbrname, DECODE (kjbrcvtq, '00', 0, 1),
DECODE (kjbrgrantq, '00', 0, 1), 1, kjbrmaster, kjbrncvl,
'KJUSERVS_NOVALUE', '0x0'
FROM x$kjbr
103
© 2006 Julian Dyke
juliandyke.com
V$GES_ENQUEUE
Contains rows from both KJILKFT and KJBL
HANDLE
RAW(4)
GRANT_LEVEL
VARCHAR2(9)
CONVERT_OPT_GETVALUE
VARCHAR2(9)
CONVERT_OPT_PUTVALUE
VARCHAR2(30)
CONVERT_OPT_NOVALUE
VARCHAR2(30)
CONVERT_OPT_DUBVALUE
NUMBER
CONVERT_OPT_NOQUEUE
NUMBER
CONVERT_OPT_EXPRESS
NUMBER
CONVERT_OPT_NODEADLOCKWAIT
NUMBER
CONVERT_OPT_NODEADLOCKBLOCK
NUMBER
WHICH_QUEUE
NUMBER
STATE
NUMBER
AST_EVENT0
NUMBER
OWNER_NODE
REQUEST_LEVEL
RESOURCE_NAME1
RESOURCE_NAME2
PID
TRANSACTION_ID0
TRANSACTION_ID1
GROUP_ID
OPEN_OPT_DEADLOCK
OPEN_OPT_PERSISTENT
OPEN_OPT_PROCESS_OWNED
OPEN_OPT_NO_XID
104
© 2006 Julian Dyke
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
VARCHAR2(64)
NUMBER
NUMBER
BLOCKED
NUMBER
BLOCKER
NUMBER
juliandyke.com
V$GES_ENQUEUE
Contains rows from both KJILKFT and KJBL
SELECT
inst_id, kjilkftlkp, kjilkftgl, kjilkftrl, kjilkftrn1, kjilkftrn2, kjilkftpid,
kjilkftxid0, kjilkftxid1, kjilkftgid, kjilkftoodd, kjilkftoopt, kjilkftoopo,
kjilkftoonxid, kjilkftcogv, kjilkftcopv, kjilkftconv, kjilkftcodv, kjilkftconq,
kjilkftcoep, kjilkftconddw, kjilkftconddb, kjilkftwq, kjilkftls, kjilkftaste0,
kjilkfton, kjilkftblked, kjilkftblker
FROM x$kjilkft
UNION ALL
SELECT inst_id,
kjbllockp, kjblgrant, kjblrequest, kjblname, kjblname2, 0, 0, 0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, kjblqueue, kjbllockst, 0, kjblowner, kjblblocked,
kjblblocker
FROM x$kjbl
105
© 2006 Julian Dyke
juliandyke.com
Thank you for your interest
For more information and to provide feedback
please contact me
My e-mail address is:
[email protected]
My website address is:
www.juliandyke.com
106
© 2006 Julian Dyke
juliandyke.com