Know about RAC Clusterware Process OPROCD

OPROCD introduced in 10.2.0.4 Linux and other Unix platform.

  • Fencing
    • Cluster handling of nodes that should not have access to shared resources
    • STONITH – Power cycle the node
    • PCW – nodes fence themselves through the reboot(8) command
    • Fabric Fencing from Polyserve
      • Healthy nodes send SNMP msgs to Fabric switch to disable SAN access from unhealthy nodes [ fence them out ]
      • Server is left in up state to view logs etc.
  • Oracle’s Cluster I/O Fencing solution
  • Only started on Unix platforms when vendor Clusterware is not running
  • Does not run on Windows and Linux!
  • Takes 2 parameters
    • Timeout value [ length of time between executions ]
    • Margin [ leeway for dispatches ]
    • Oproc.debug –t 1000 –m 500
  • In fatal mode node will get reboot’ed
  • In non-fatal mode error messages will be logged

OPROCD – This process is spawned in any non-vendor clusterware environment, except
on Windows where Oracle uses a kernel driver to perform the same actions and Linux
prior to version 10.2.0.4. If oprocd detects problems, it will kill a node via C
code. It is spawned in init.cssd and runs as root. This daemon is used to detect
hardware and driver freezes on the machine. If a machine were frozen for long enough
that the other nodes evicted it from the cluster, it needs to kill itself to prevent
any IO from getting reissued to the disk after the rest of the cluster has remastered
locks.”

*** Oprocd log locations:
In /etc/oracle/oprocd or /var/opt/oracle/oprocd depending on version/platform.

Note that oprocd only runs when no vendor clusterware is running or on Linux > 10.2.0.4

COMMON CAUSES OF OPROCD REBOOTS

– A problem detected by the OPROCD process. This can be caused by 4 things:1) An OS scheduler problem.
2) The OS is getting locked up in a driver or hardware.
3) Excessive amounts of load on the machine, thus preventing the scheduler from
behaving reasonably.
4) An Oracle bug.OPROCD Bugs Known to Cause Reboots:

Bug 5015469 – OPROCD may reboot the node whenever the system date is moved
backwards.
Fixed in 10.2.0.3+

Bug 4206159 – Oprocd is prone to time regression due to current API used (AIX only)
Fixed in 10.1.0.3 + One off patch for Bug 4206159.

Diagnostic Fixes (VERY NECESSARY IN MOST CASES):

Bug 5137401 – Oprocd logfile is cleared after a reboot
Fixed in 10.2.0.4+

Bug 5037858 – Increase the warning levels if a reboot is approaching
Fixed in 10.2.0.3+

FILES TO REVIEW AND GATHER FOR OPROCD REBOOTS

If logging a service request, please provide ALL of the following files to Oracle
Support if possible:

– Oprocd logs in /etc/oracle/oprocd or /var/opt/oracle/oprocd depending on version/platform.

– All the files in the following directories from all nodes.

For 10.2 and above, all files under:

<CRS_HOME>/log

Recommended method for gathering these for each node would be to run the
diagcollection.pl script.

For 10.1:

<CRS_HOME>/crs/log
<CRS_HOME>/crs/init
<CRS_HOME>/css/log
<CRS_HOME>/css/init
<CRS_HOME>/evm/log
<CRS_HOME>/evm/init
<CRS_HOME>/srvm/log

Recommended method for gathering these for each node:

cd <CRS_HOME>
tar cf crs.tar crs/init crs/log css/init css/log evm/init evm/log srvm/log

– Messages or Syslog from all nodes from the time of the problem:

Sun: /var/adm/messages
HP-UX: /var/adm/syslog/syslog.log
Tru64: /var/adm/messages
Linux: /var/log/messages
IBM: /bin/errpt -a > messages.out

– ‘opatch lsinventory -detail’ output for the CRS home

– It would also be useful to get the following from each node leading up to the time
of the reboot:

– netstat -is (or equivelant)
– iostat -x (or equivelant)
– vmstat (or equivelant)

There is a tool called “OS Watcher” that helps gather this information. This tool
will dump netstat, vmstat, iostat, and other output at an inverval and save x number
of hours of archived data. For more information about this tool see Note 301137.1.

 

The OPROCD executable sets a signal handler for the SIGALRM handler and sets the interval timer based on the to-millisec parameter provided. The alarm handler gets the current time and checks it against the time that the alarm handler was last entered. If the difference exceeds (to-millisec + margin-millisec), it will fail; the production version will cause a node reboot.

In fatal mode, OPROCD will reboot the node if it detects excessive wait. In Non Fatal mode, it will write an error message out to the file .oprocd.log in one of the following directories.

Oracle clusterware has the following three daemons which may be responsible for panicing the node. It is possible that some other external entity may have rebooted the node. In the context of this discussion, we will assume that the reboot/panic was done by an Oracle clusterware daemon.

* Oprocd – Cluster fencing module
* Cssd – Cluster sychronization module which manages node membership
* Oclsomon – Cssd monitor which will monitor for cssd hangs

OPROCD This is a daemon that only gets activated when there is no vendor clusterware present on the OS.This daemon is also not activated to run on Windows/Linux. This daemon runs a tight loop and if it is not scheduled for 1.5 seconds, will reboot the node.
CSSD This daemon pings the other members of the cluster over the private network and Voting disk. If this does not get a response for Misscount seconds and Disktimeout seconds respectively, it will reboot the node.
Oclsomon This daemon monitors the CSSD to ensure that CSSD is scheduled by the OS, if it detects any problems it will reboot the node.

A sample log looks like
May 11 18:13:15.528 | INF | monitoring started with timeout(1000), margin(500)
May 11 18:13:15.548 | INF | normal startup, setting process to fatal mode
May 12 11:43:00.899 | INF | shutting down from client request
May 12 11:43:00.899 | INF | exiting current process in NORMAL mode
May 12 12:10:43.984 | INF | monitoring started with timeout(1000), margin(500)
May 13 11:29:37.528 | INF | shutting down from client request
May 13 11:29:37.528 | INF | exiting current process in NORMAL mode

When fatal mode is disabled, OPROCD will write the following to the log file and exit:
May 10 18:01:40.668 | INF | monitoring started with timeout(1000), margin(500)
May 10 18:23:02.490 | ERR | AlarmHandler:? timeout(1739751316) exceeds interval(1000000000)+margin(500000000)

[root@rh2 ~]# ps -ef|grep oprocd|grep -v grep
root     19763     1  0 Jun27 ?        00:00:00 oprocd start

[root@rh2 oprocd]# cd /etc/oracle/oprocd

[root@rh2 oprocd]# ls -l
total 20
drwxrwx--- 2 root oinstall 4096 Jun 27 23:52 check
drwxrwx--- 2 root oinstall 4096 Mar 29 22:37 fatal
-rwxr--r-- 1 root root      512 Jun 27 23:52 rh2.oprocd.lgl
-rw-r--r-- 1 root root      171 Jun 27 23:52 rh2.oprocd.log
drwxrwx--- 2 root oinstall 4096 Jun 27 23:52 stop

[root@rh2 oprocd]# cat rh2.oprocd.log
Jun 27 23:52:47.861 | INF | monitoring started with timeout(1000), margin(500), skewTimeout(125)
Jun 27 23:52:47.864 | INF | normal startup, setting process to fatal mode

[root@rh2 oprocd]# oprocd

usage:  oprocd [start | startInstall | stop | check | enableFatal| help | -?]

        run [ -t | -m | -g | -f  | -e]   foreground startup
              -t           timeout in ms
              -m            timout margin in ms
              -e           clock skew epsilon in ms
              -g         group name to enable fatal
              -f                    fatal startup

        start  [-t | -m  | -e]           starts the daemon
                -t         timeout in ms
                -m          timout margin in ms
                 -e         clock skew epsilon in ms

        startInstall [ -t | -m | -g  | - e] start process in install mode
                       -t    timeout in ms
                       -m     timout margin in ms
                       -e    clock skew epsilon in ms
                       -g  group name to enable fatal

        enableFatal  [ -t ]             force install mode process to fatal
                       -t    timeout for response in ms
        stop         [ -t ]             stops running daemon
                       -t    timeout for response in ms
        check        [ -t ]           checks status of daemon
                       -t    timeout for response in ms
        help                          this help information
        -?                            same as help above

[root@rh2 oprocd]# oprocd stop
Jun 28 00:17:36.604 | INF | daemon shutting down

Oracle Clusterware Process Monitor (OPROCD) From Julian Dyke

Process Monitor Daemon
Provides Cluster I/O Fencing

Implemented on Unix systems
Not required with third-party clusterware
Implemented in Linux in 10.2.0.4 and above
In 10.2.0.3 and below hangcheck timer module is used

Provides hangcheck timer functionality to maintain cluster integrity
Behaviour similar to hangcheck timer
Runs as root
Locked in memory
Failure causes reboot of system
See /etc/init.d/init.cssd for operating system reboot commands

OPROCD takes two parameters
-t  - Timeout value
Length of time between executions (milliseconds)
Normally defaults to 1000
-m - Margin
Acceptable margin before rebooting (milliseconds)
Normally defaults to 500

Parameters are specified in /etc/init.d/init.cssd
OPROCD_DEFAULT_TIMEOUT=1000
OPROCD_DEFAULT_MARGIN=500

Contact Oracle Support before changing these values

/etc/init.d/init.cssd can increase OPROCD_DEFAULT_MARGIN based on two CSS variables
reboottime (mandatory)
diagwait (optional)
Values can for these be obtained using

[root@server3]# crsctl get css reboottime
[root@server3]# crsctl get css diagwait

Both values are reported in seconds
The algorithm is

If diagwait > reboottime then
OPROCD_DEFAULT_MARGIN := (diagwait - reboottime) * 1000

Therefore increasing diagwait will reduce frequency of reboots e.g

[root@server3]# crsctl set css diagwait 13

Active Session History (ASH) performed an emergency flush

Active Session History (ASH) performed an emergency flush. This may mean that ASH is undersized. If emergency flushes are a recurring issue, you may consider increasing ASH size by setting the value of _ASH_SIZE to a sufficiently large value. Currently, ASH size is 4194304 bytes. Both ASH size and the total number of emergency flushes since instance startup can be monitored by running the following query:


SQL> select total_size,awr_flush_emergency_count from v$ash_info;

TOTAL_SIZE AWR_FLUSH_EMERGENCY_COUNT
---------- -------------------------
   4194304                         1

SQL> select * from v$ash_info;

TOTAL_SIZE FIXED_SIZE SAMPLING_INTERVAL OLDEST_SAMPLE_ID OLDEST_SAMPLE_TIME                                                          LATEST_SAMPLE_ID
---------- ---------- ----------------- ---------------- --------------------------------------------------------------------------- ----------------
LATEST_SAMPLE_TIME                                                          SAMPLE_COUNT SAMPLED_BYTES SAMPLER_ELAPSED_TIME DISK_FILTER_RATIO
--------------------------------------------------------------------------- ------------ ------------- -------------------- -----------------
AWR_FLUSH_BYTES AWR_FLUSH_ELAPSED_TIME AWR_FLUSH_COUNT AWR_FLUSH_EMERGENCY_COUNT
--------------- ---------------------- --------------- -------------------------
   4194304    4194304              1000          1168516 18-JUN-11 05.06.33.163000000 AM                                                      1490473
21-JUN-11 10.40.34.688000000 PM                                                     9257       3104088              2883663                10
        2764680                 557774               1                         1

This issue can be ignored.

RAC Deadlock For Example

Single resource deadlock: blocking enqueue which blocks itself, f 0

Single resource deadlock: blocking enqueue which blocks itself, f 0
Granted global enqueue 0xd8578490
----------enqueue 0xd8578490------------------------
lock version     : 1
Owner inst       : 2
grant_level      : KJUSERCW
req_level        : KJUSERPW
bast_level       : KJUSERNL
notify_func      : 0x4fe4b6e
resp             : 0xd9c7ad50
procp            : 0xd9971780
pid              : 0
proc version     : 0
oprocp           : (nil)
opid             : 0
group lock owner : (nil)
xid              : 0000-0000-00000000
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     :
Convert options  : KJUSERGETVALUE
History          : 0xd7d8d7da
Msg_Seq          : 0x60005
res_seq          : 2
valblk           : 0x00000000000000000000000000000000 .
DUMP LOCAL BLOCKER/HOLDER: block level 4 res [0x1451c][0x0],[TM][ext 0x0,0x0]
----------resource 0xd9c7ad50----------------------
resname       : [0x1451c][0x0],[TM][ext 0x0,0x0]
hash mask     : x3
Local inst    : 1
dir_inst      : 1
master_inst   : 1
hv idx        : 112
hv last r.inc : 56
current inc   : 56
hv status     : 0
hv master     : 0
open options  : dd cached
grant_bits    : KJUSERCW
grant mode    : KJUSERNL  KJUSERCR  KJUSERCW  KJUSERPR  KJUSERPW  KJUSEREX
count         : 0         0         2         0         0         0
val_state     : KJUSERVS_NOVALUE
valblk        : 0x00000000000000000000000000000000 .
access_inst   : 1
vbreq_state   : 0
state         : x0
resp          : 0xd9c7ad50
On Scan_q?    : N
Total accesses: 150
Imm.  accesses: 143
Granted_locks : 1
Cvting_locks  : 1
value_block:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
GRANTED_Q :
lp 0xd876ab70 gl KJUSERCW rp 0xd9c7ad50 [0x1451c][0x0],[TM][ext 0x0,0x0]
  master 1 gl owner 0xda7233c0 possible pid 1993 xid 2B000-0001-000000B5 bast 0 rseq 1 mseq 0 history 0x49a51495
  open opt KJUSERDEADLOCK
CONVERT_Q:
lp 0xd8578490 gl KJUSERCW rl KJUSERPW rp 0xd9c7ad50 [0x1451c][0x0],[TM][ext 0x0,0x0]
  master 1 owner 2  bast 1 rseq 2 mseq 0x60005 history 0xd7d8d7da
  convert opt KJUSERGETVALUE
----------enqueue 0xd876ab70------------------------
lock version     : 2071
Owner inst       : 1
grant_level      : KJUSERCW
req_level        : KJUSERPW
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9c7ad50
procp            : 0xd9979b08
pid              : 1993
proc version     : 81
oprocp           : (nil)
opid             : 1993
group lock owner : 0xda7233c0
possible pid     : 1993
xid              : 2B000-0001-000000B5
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : CONVERTING
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERGETVALUE
History          : 0x49a51495
Msg_Seq          : 0x0
res_seq          : 1
valblk           : 0x00000000000000000000000000000000 .
user session for deadlock lock 0xd876ab70
  sid: 416 ser: 217 audsid: 2301258 user: 95/SPOT
    flags: (0x10041) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40008) -/-
  pid: 43 O/S info: user: oracle, term: UNKNOWN, ospid: 1993
    image: oracle@rh2.oracle.com (J000)
  client details:
    O/S info: user: oracle, term: UNKNOWN, ospid: 1993
    machine: rh2.oracle.com program: oracle@rh2.oracle.com (J000)
    application name: DBMS_SCHEDULER, hash value=2478762354
    action name: QUEST_PPCM_JOB_PM_1, hash value=3637730750
  current SQL:
  DELETE FROM QUEST_PPCM_SNAPSHOT WHERE SNAPSHOT_TYPE = :B2 AND INSTANCE_ID > 0
  AND SNAPSHOT_TIMESTAMP < TRUNC (SYSDATE) - :B1  

----------enqueue 0xd8578490------------------------
lock version     : 1
Owner inst       : 2
grant_level      : KJUSERCW
req_level        : KJUSERPW
bast_level       : KJUSERNL
notify_func      : 0x4fe4b6e
resp             : 0xd9c7ad50
procp            : 0xd9971780
pid              : 0
proc version     : 0
oprocp           : (nil)
opid             : 0
group lock owner : (nil)
xid              : 0000-0000-00000000
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     :
Convert options  : KJUSERGETVALUE
History          : 0xd7d8d7da
Msg_Seq          : 0x60005
res_seq          : 2
valblk           : 0x03000000000000000100000000000000 . 

Requesting global enqueue 0xd876ab70 

----------enqueue 0xd876ab70------------------------
lock version     : 2071
Owner inst       : 1
grant_level      : KJUSERCW
req_level        : KJUSERPW
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9c7ad50
procp            : 0xd9979b08
pid              : 1993
proc version     : 81
oprocp           : (nil)
opid             : 1993
group lock owner : 0xda7233c0
possible pid     : 1993
xid              : 2B000-0001-000000B5
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : CONVERTING
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERGETVALUE
History          : 0x49a51495
Msg_Seq          : 0x0
res_seq          : 1
valblk           : 0x00000000000000000000000000000000 . u
ser session for deadlock lock 0xd876ab70
sid: 416 ser: 217 audsid: 2301258 user: 95/SPOT
flags: (0x10041) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
flags2: (0x40008) -/-
pid: 43 O/S info: user: oracle, term: UNKNOWN, ospid: 1993
image: oracle@rh2.oracle.com (J000)
client details:     O/S info: user: oracle, term: UNKNOWN, ospid: 1993
machine: rh2.oracle.com program: oracle@rh2.oracle.com (J000)
application name: DBMS_SCHEDULER, hash value=2478762354
action name: QUEST_PPCM_JOB_PM_1, hash value=3637730750
current SQL:
DELETE FROM QUEST_PPCM_SNAPSHOT WHERE SNAPSHOT_TYPE = :B2 AND INSTANCE_ID > 0 AND SNAPSHOT_TIMESTAMP < TRUNC (SYSDATE) - :B1
----------resource 0xd9c7ad50----------------------
resname       : [0x1451c][0x0],[TM][ext 0x0,0x0]
hash mask     : x3
Local inst    : 1
dir_inst      : 1
master_inst   : 1
hv idx        : 112
hv last r.inc : 56
current inc   : 56
hv status     : 0
hv master     : 0
open options  : dd cached
grant_bits    : KJUSERCW
grant mode    : KJUSERNL  KJUSERCR  KJUSERCW  KJUSERPR  KJUSERPW  KJUSEREX
count         : 0         0         2         0         0         0
val_state     : KJUSERVS_NOVALUE
valblk        : 0x00000000000000000000000000000000 .
access_inst   : 1
vbreq_state   : 0
state         : x0
resp          : 0xd9c7ad50
On Scan_q?    : N
Total accesses: 150
Imm.  accesses: 143
Granted_locks : 1
Cvting_locks  : 1
value_block:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
GRANTED_Q :
lp 0xd876ab70 gl KJUSERCW rp 0xd9c7ad50 [0x1451c][0x0],[TM][ext 0x0,0x0]
  master 1 gl owner 0xda7233c0 possible pid 1993 xid 2B000-0001-000000B5 bast 0 rseq 1 mseq 0 history 0x49a51495
  open opt KJUSERDEADLOCK
CONVERT_Q:
lp 0xd8578490 gl KJUSERCW rl KJUSERPW rp 0xd9c7ad50 [0x1451c][0x0],[TM][ext 0x0,0x0]
  master 1 owner 2  bast 1 rseq 2 mseq 0x60005 history 0xd7d8d7da
  convert opt KJUSERGETVALUE
-------------------------------------------------------------------------------
Trace Bucket Dump Begin: default bucket for process 43 (osid: 1993, J000)
TIME(*=approx):SEQ:COMPONENT:FILE@LINE:FUNCTION:SECT/DUMP: [EVENT#:PID:SID] DATA

TM DEADLOCK IN RAC:

* End DRM for pkey remastering request(s) (locally requested)
ENQUEUE DUMP REQUEST: from 2 spnum 12 on [0x1475a][0x0],[TM][ext 0x0,0x0] for reason 3 mtype 0

*** 2011-06-21 21:57:42.212
DUMP LOCAL BLOCKER/HOLDER: block level 5 res [0x1475a][0x0],[TM][ext 0x0,0x0]
----------resource 0xd9e62b48----------------------
resname       : [0x1475a][0x0],[TM][ext 0x0,0x0]
hash mask     : x3
Local inst    : 1
dir_inst      : 1
master_inst   : 1
hv idx        : 46
hv last r.inc : 56
current inc   : 56
hv status     : 0
hv master     : 0
open options  : dd cached
grant_bits    : KJUSERNL KJUSEREX
grant mode    : KJUSERNL  KJUSERCR  KJUSERCW  KJUSERPR  KJUSERPW  KJUSEREX
count         : 1         0         0         0         0         1
val_state     : KJUSERVS_NOVALUE
valblk        : 0x00000000000000000000000000000000 .
access_inst   : 1
vbreq_state   : 0
state         : x0
resp          : 0xd9e62b48
On Scan_q?    : N
Total accesses: 30
Imm.  accesses: 25
Granted_locks : 1
Cvting_locks  : 1
value_block:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
GRANTED_Q :
lp 0xd87530a8 gl KJUSEREX rp 0xd9e62b48 [0x1475a][0x0],[TM][ext 0x0,0x0]
  master 1 gl owner 0xda7233c0 possible pid 26255 xid 2B000-0001-00000576 bast 0 rseq 3 mseq 0 history 0x9a514495
  open opt KJUSERDEADLOCK
CONVERT_Q:
lp 0xd85b60e0 gl KJUSERNL rl KJUSEREX rp 0xd9e62b48 [0x1475a][0x0],[TM][ext 0x0,0x0]
  master 1 owner 2  bast 0 rseq 12 mseq 0x1 history 0x97ad
  convert opt KJUSERGETVALUE
----------enqueue 0xd87530a8------------------------
lock version     : 10199
Owner inst       : 1
grant_level      : KJUSEREX
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9e62b48
procp            : 0xd99750b0
pid              : 26255
proc version     : 229
oprocp           : (nil)
opid             : 26255
group lock owner : 0xda7233c0
possible pid     : 26255
xid              : 2B000-0001-00000576
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERGETVALUE
History          : 0x9a514495
Msg_Seq          : 0x0
res_seq          : 3
valblk           : 0x00000000000000000000000000000000 .
user session for deadlock lock 0xd87530a8
  sid: 416 ser: 1053 audsid: 4294967295 user: 0/SYS
    flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40008) -/-
  pid: 43 O/S info: user: oracle, term: UNKNOWN, ospid: 26255
    image: oracle@rh2.oracle.com (TNS V1-V3)
  client details:
    O/S info: user: oracle, term: pts/3, ospid: 26254
    machine: rh2.oracle.com program: sqlplus@rh2.oracle.com (TNS V1-V3)
    application name: sqlplus@rh2.oracle.com (TNS V1-V3), hash value=3660119738
  current SQL:
  lock table lock2 in exclusive mode
DUMP LOCAL BLOCKER: initiate state dump for DEADLOCK
  possible owner[43.26255] on resource TM-0001475A-00000000

*** 2011-06-21 21:57:42.215
Submitting asynchronized dump request [28]. summary=[ges process stack dump (kjdglblkrdm1)].
----------enqueue 0xd85b60e0------------------------
lock version     : 1
Owner inst       : 2
grant_level      : KJUSERNL
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9e62b48
procp            : 0xd9971780
pid              : 0
proc version     : 0
oprocp           : (nil)
opid             : 0
group lock owner : (nil)
xid              : 0000-0000-00000000
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     :  KJUSERNO_XID
Convert options  : KJUSERGETVALUE
History          : 0x97ad
Msg_Seq          : 0x1
res_seq          : 12
valblk           : 0xe0720660ff7f000020700660ff7f0000 .r` p`
Global blockers dump start:---------------------------------
DUMP LOCAL BLOCKER/HOLDER: block level 5 res [0x1485a][0x0],[TM][ext 0x0,0x0]
----------resource 0xd9c5a7c8----------------------
resname       : [0x1485a][0x0],[TM][ext 0x0,0x0]
hash mask     : x3
Local inst    : 1
dir_inst      : 1
master_inst   : 1
hv idx        : 46
hv last r.inc : 56
current inc   : 56
hv status     : 0
hv master     : 0
open options  : dd cached
grant_bits    : KJUSERNL KJUSEREX
grant mode    : KJUSERNL  KJUSERCR  KJUSERCW  KJUSERPR  KJUSERPW  KJUSEREX
count         : 1         0         0         0         0         1
val_state     : KJUSERVS_NOVALUE
valblk        : 0x000000000a0000000a00000001000000 .
access_inst   : 2
vbreq_state   : 0
state         : x0
resp          : 0xd9c5a7c8
On Scan_q?    : N
Total accesses: 29
Imm.  accesses: 20
Granted_locks : 1
Cvting_locks  : 1
value_block:  00 00 00 00 0a 00 00 00 0a 00 00 00 01 00 00 00
GRANTED_Q :
lp 0xd85b5f20 gl KJUSEREX rp 0xd9c5a7c8 [0x1485a][0x0],[TM][ext 0x0,0x0]
  master 1 owner 2  bast 0 rseq 15 mseq 0x2 history 0x977d8d
  open opt  KJUSERNO_XID
CONVERT_Q:
lp 0xd8757ff8 gl KJUSERNL rl KJUSEREX rp 0xd9c5a7c8 [0x1485a][0x0],[TM][ext 0x0,0x0]
  master 1 gl owner 0xda7233c0 possible pid 26255 xid 2B000-0001-00000576 bast 0 rseq 2 mseq 0 history 0xda51449a
  convert opt KJUSERGETVALUE
----------enqueue 0xd85b5f20------------------------
lock version     : 1
Owner inst       : 2
grant_level      : KJUSEREX
req_level        : KJUSEREX
bast_level       : KJUSEREX
notify_func      : (nil)
resp             : 0xd9c5a7c8
procp            : 0xd9971780
pid              : 0
proc version     : 0
oprocp           : (nil)
opid             : 0
group lock owner : (nil)
xid              : 0000-0000-00000000
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     :  KJUSERNO_XID
Convert options  : KJUSERGETVALUE
History          : 0x977d8d
Msg_Seq          : 0x2
res_seq          : 15
valblk           : 0x00000000000000000000000000000000 .
----------enqueue 0xd8757ff8------------------------
lock version     : 10261
Owner inst       : 1
grant_level      : KJUSERNL
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9c5a7c8
procp            : 0xd99750b0
pid              : 26255
proc version     : 229
oprocp           : (nil)
opid             : 26255
group lock owner : 0xda7233c0
possible pid     : 26255
xid              : 2B000-0001-00000576
dd_time          : 10.0 secs
dd_count         : 1
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : Y
lock_state       : OPENING CONVERTING
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERGETVALUE
History          : 0xda51449a
Msg_Seq          : 0x0
res_seq          : 2
valblk           : 0x00000000000000000000000000000000 .
user session for deadlock lock 0xd8757ff8
  sid: 416 ser: 1053 audsid: 4294967295 user: 0/SYS
    flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40008) -/-
  pid: 43 O/S info: user: oracle, term: UNKNOWN, ospid: 26255
    image: oracle@rh2.oracle.com (TNS V1-V3)
  client details:
    O/S info: user: oracle, term: pts/3, ospid: 26254
    machine: rh2.oracle.com program: sqlplus@rh2.oracle.com (TNS V1-V3)
    application name: sqlplus@rh2.oracle.com (TNS V1-V3), hash value=3660119738
  current SQL:
  lock table lock2 in exclusive mode
DUMP LOCAL BLOCKER: initiate state dump for DEADLOCK
  possible owner[43.26255] on resource TM-0001485A-00000000

*** 2011-06-21 21:57:42.219
Submitting asynchronized dump request [28]. summary=[ges process stack dump (kjdglblkrdm1)].
DUMP LOCAL BLOCKER/HOLDER: block level 5 res [0x1475a][0x0],[TM][ext 0x0,0x0]
----------resource 0xd9e62b48----------------------
resname       : [0x1475a][0x0],[TM][ext 0x0,0x0]
hash mask     : x3
Local inst    : 1
dir_inst      : 1
master_inst   : 1
hv idx        : 46
hv last r.inc : 56
current inc   : 56
hv status     : 0
hv master     : 0
open options  : dd cached
grant_bits    : KJUSERNL KJUSEREX
grant mode    : KJUSERNL  KJUSERCR  KJUSERCW  KJUSERPR  KJUSERPW  KJUSEREX
count         : 1         0         0         0         0         1
val_state     : KJUSERVS_NOVALUE
valblk        : 0x7c5b5c0900000000806a0660ff7f0000 |[\j`
access_inst   : 1
vbreq_state   : 0
state         : x0
resp          : 0xd9e62b48
On Scan_q?    : N
Total accesses: 32
Imm.  accesses: 26
Granted_locks : 1
Cvting_locks  : 1
value_block:  7c 5b 5c 09 00 00 00 00 80 6a 06 60 ff 7f 00 00
GRANTED_Q :
lp 0xd87530a8 gl KJUSEREX rp 0xd9e62b48 [0x1475a][0x0],[TM][ext 0x0,0x0]
  master 1 gl owner 0xda7233c0 possible pid 26255 xid 2B000-0001-00000576 bast 0 rseq 3 mseq 0 history 0x9a514495
  open opt KJUSERDEADLOCK
CONVERT_Q:
lp 0xd85b60e0 gl KJUSERNL rl KJUSEREX rp 0xd9e62b48 [0x1475a][0x0],[TM][ext 0x0,0x0]
  master 1 owner 2  bast 0 rseq 12 mseq 0x1 history 0x97ad
  convert opt KJUSERGETVALUE
----------enqueue 0xd87530a8------------------------
lock version     : 10199
Owner inst       : 1
grant_level      : KJUSEREX
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9e62b48
procp            : 0xd99750b0
pid              : 26255
proc version     : 229
oprocp           : (nil)
opid             : 26255
group lock owner : 0xda7233c0
possible pid     : 26255
xid              : 2B000-0001-00000576
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERGETVALUE
History          : 0x9a514495
Msg_Seq          : 0x0
res_seq          : 3
valblk           : 0x00000000ff7f000031000502ff7f0000 .1
user session for deadlock lock 0xd87530a8
  sid: 416 ser: 1053 audsid: 4294967295 user: 0/SYS
    flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40008) -/-
  pid: 43 O/S info: user: oracle, term: UNKNOWN, ospid: 26255
    image: oracle@rh2.oracle.com (TNS V1-V3)
  client details:
    O/S info: user: oracle, term: pts/3, ospid: 26254
    machine: rh2.oracle.com program: sqlplus@rh2.oracle.com (TNS V1-V3)
    application name: sqlplus@rh2.oracle.com (TNS V1-V3), hash value=3660119738
  current SQL:
  lock table lock2 in exclusive mode
DUMP LOCAL BLOCKER: initiate state dump for DEADLOCK
  possible owner[43.26255] on resource TM-0001475A-00000000

*** 2011-06-21 21:57:42.220
Submitting asynchronized dump request [28]. summary=[ges process stack dump (kjdglblkrdm1)].
----------enqueue 0xd85b60e0------------------------
lock version     : 1
Owner inst       : 2
grant_level      : KJUSERNL
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9e62b48
procp            : 0xd9971780
pid              : 0
proc version     : 0
oprocp           : (nil)
opid             : 0
group lock owner : (nil)
xid              : 0000-0000-00000000
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     :  KJUSERNO_XID
Convert options  : KJUSERGETVALUE
History          : 0x97ad
Msg_Seq          : 0x1
res_seq          : 12
valblk           : 0x406f0660ff7f0000806c0660ff7f0000 @o`l`
Global blockers dump end:-----------------------------------
Global Wait-For-Graph(WFG) at ddTS[0.1] :
BLOCKED 0xd8757ff8 5 wq 2 cvtops x1 TM 0x1485a.0x0(ext 0x0,0x0)[2B000-0001-00000576] inst 1
BLOCKER 0xd87520d0 5 wq 1 cvtops x1 TM 0x1485a.0x0(ext 0x0,0x0)[22000-0002-000010C6] inst 2
BLOCKED 0xd8766338 5 wq 2 cvtops x1 TM 0x1475a.0x0(ext 0x0,0x0)[22000-0002-000010C6] inst 2
BLOCKER 0xd87530a8 5 wq 1 cvtops x1 TM 0x1475a.0x0(ext 0x0,0x0)[2B000-0001-00000576] inst 1

TX DEADLOCK in RAC:

ENQUEUE DUMP REQUEST: from 2 spnum 12 on [0x10001][0x7b3],[TX][ext 0x2,0x0] for reason 3 mtype 0
DUMP LOCAL BLOCKER/HOLDER: block level 5 res [0x10001][0x7b3],[TX][ext 0x2,0x0]
----------resource 0xd9c5a6a0----------------------
resname       : [0x10001][0x7b3],[TX][ext 0x2,0x0]
hash mask     : x3
Local inst    : 1
dir_inst      : 1
master_inst   : 1
hv idx        : 8
hv last r.inc : 56
current inc   : 56
hv status     : 0
hv master     : 0
open options  : dd
grant_bits    : KJUSERNL KJUSEREX
grant mode    : KJUSERNL  KJUSERCR  KJUSERCW  KJUSERPR  KJUSERPW  KJUSEREX
count         : 1         0         0         0         0         1
val_state     : KJUSERVS_NOVALUE
valblk        : 0x00000000000000000000000000000000 .
access_inst   : 1
vbreq_state   : 0
state         : x0
resp          : 0xd9c5a6a0
On Scan_q?    : N
Total accesses: 54
Imm.  accesses: 44
Granted_locks : 1
Cvting_locks  : 1
value_block:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
GRANTED_Q :
lp 0xd85b62a0 gl KJUSEREX rp 0xd9c5a6a0 [0x10001][0x7b3],[TX][ext 0x2,0x0]
  master 1 gl owner 0xda7233c0 possible pid 26287 xid 2B000-0001-00000578 bast 0 rseq 8 mseq 0 history 0x95
  open opt KJUSERDEADLOCK
CONVERT_Q:
lp 0xd85b6460 gl KJUSERNL rl KJUSEREX rp 0xd9c5a6a0 [0x10001][0x7b3],[TX][ext 0x2,0x0]
  master 1 owner 2  bast 0 rseq 22 mseq 0x1 history 0x97ad
  convert opt KJUSERGETVALUE
----------enqueue 0xd85b62a0------------------------
lock version     : 1
Owner inst       : 1
grant_level      : KJUSEREX
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9c5a6a0
procp            : 0xd996b090
pid              : 22148
proc version     : 0
oprocp           : (nil)
opid             : 22148
group lock owner : 0xda7233c0
possible pid     : 26287
xid              : 2B000-0001-00000578
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERNOQUEUE KJUSERNODEADLOCKWAIT
History          : 0x95
Msg_Seq          : 0x0
res_seq          : 8
valblk           : 0x00000000000000000000000000000000 .
user session for deadlock lock 0xd85b62a0
  sid: 416 ser: 1055 audsid: 4294967295 user: 0/SYS
    flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40008) -/-
  pid: 43 O/S info: user: oracle, term: UNKNOWN, ospid: 26287
    image: oracle@rh2.oracle.com (TNS V1-V3)
  client details:
    O/S info: user: oracle, term: pts/3, ospid: 26286
    machine: rh2.oracle.com program: sqlplus@rh2.oracle.com (TNS V1-V3)
    application name: sqlplus@rh2.oracle.com (TNS V1-V3), hash value=3660119738
  current SQL:
  update lock1 set t1=t1+10 where t1=2
DUMP LOCAL BLOCKER: initiate state dump for DEADLOCK
  possible owner[43.26287] on resource TX-00010001-000007B3

*** 2011-06-21 22:08:18.048
Submitting asynchronized dump request [28]. summary=[ges process stack dump (kjdglblkrdm1)].
----------enqueue 0xd85b6460------------------------
lock version     : 1
Owner inst       : 2
grant_level      : KJUSERNL
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9c5a6a0
procp            : 0xd9971780
pid              : 0
proc version     : 0
oprocp           : (nil)
opid             : 0
group lock owner : (nil)
xid              : 0000-0000-00000000
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     :  KJUSERNO_XID
Convert options  : KJUSERGETVALUE
History          : 0x97ad
Msg_Seq          : 0x1
res_seq          : 22
valblk           : 0xe0720660ff7f000020700660ff7f0000 .r` p`
Global blockers dump start:---------------------------------
DUMP LOCAL BLOCKER/HOLDER: block level 5 res [0xb0000][0xc8],[TX][ext 0x5,0x0]
----------resource 0xd9e626a8----------------------
resname       : [0xb0000][0xc8],[TX][ext 0x5,0x0]
hash mask     : x3
Local inst    : 1
dir_inst      : 2
master_inst   : 2
hv idx        : 28
hv last r.inc : 56
current inc   : 56
hv status     : 0
hv master     : 0
open options  : dd
Held mode     : KJUSERNL
Cvt mode      : KJUSEREX
Next Cvt mode : KJUSERNL
msg_seq       : 0x1
res_seq       : 2
grant_bits    : KJUSERNL
grant mode    : KJUSERNL  KJUSERCR  KJUSERCW  KJUSERPR  KJUSERPW  KJUSEREX
count         : 1         0         0         0         0         0
val_state     : KJUSERVS_NOVALUE
valblk        : 0x000000000a0000000a00000001000000 .
access_inst   : 2
vbreq_state   : 0
state         : x8
resp          : 0xd9e626a8
On Scan_q?    : N
Total accesses: 24
Imm.  accesses: 15
Granted_locks : 0
Cvting_locks  : 1
value_block:  00 00 00 00 0a 00 00 00 0a 00 00 00 01 00 00 00
GRANTED_Q :
CONVERT_Q:
lp 0xd8757ff8 gl KJUSERNL rl KJUSEREX rp 0xd9e626a8 [0xb0000][0xc8],[TX][ext 0x5,0x0]
  master 2 gl owner 0xda7233c0 possible pid 26287 xid 2B000-0001-00000578 bast 0 rseq 2 mseq 0 history 0x495149da
  convert opt KJUSERGETVALUE
----------enqueue 0xd8757ff8------------------------
lock version     : 11019
Owner inst       : 1
grant_level      : KJUSERNL
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9e626a8
procp            : 0xd99750b0
pid              : 26287
proc version     : 230
oprocp           : (nil)
opid             : 26287
group lock owner : 0xda7233c0
possible pid     : 26287
xid              : 2B000-0001-00000578
dd_time          : 10.0 secs
dd_count         : 1
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : Y
lock_state       : OPENING CONVERTING
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERGETVALUE
History          : 0x495149da
Msg_Seq          : 0x0
res_seq          : 2
valblk           : 0x00000000000000000000000000000000 .
user session for deadlock lock 0xd8757ff8
  sid: 416 ser: 1055 audsid: 4294967295 user: 0/SYS
    flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40008) -/-
  pid: 43 O/S info: user: oracle, term: UNKNOWN, ospid: 26287
    image: oracle@rh2.oracle.com (TNS V1-V3)
  client details:
    O/S info: user: oracle, term: pts/3, ospid: 26286
    machine: rh2.oracle.com program: sqlplus@rh2.oracle.com (TNS V1-V3)
    application name: sqlplus@rh2.oracle.com (TNS V1-V3), hash value=3660119738
  current SQL:
  update lock1 set t1=t1+10 where t1=2
DUMP LOCAL BLOCKER: initiate state dump for DEADLOCK
  possible owner[43.26287] on resource TX-000B0000-000000C8

*** 2011-06-21 22:08:18.051
Submitting asynchronized dump request [28]. summary=[ges process stack dump (kjdglblkrdm1)].
DUMP LOCAL BLOCKER/HOLDER: block level 5 res [0x10001][0x7b3],[TX][ext 0x2,0x0]
----------resource 0xd9c5a6a0----------------------
resname       : [0x10001][0x7b3],[TX][ext 0x2,0x0]
hash mask     : x3
Local inst    : 1
dir_inst      : 1
master_inst   : 1
hv idx        : 8
hv last r.inc : 56
current inc   : 56
hv status     : 0
hv master     : 0
open options  : dd
grant_bits    : KJUSERNL KJUSEREX
grant mode    : KJUSERNL  KJUSERCR  KJUSERCW  KJUSERPR  KJUSERPW  KJUSEREX
count         : 1         0         0         0         0         1
val_state     : KJUSERVS_NOVALUE
valblk        : 0x7c5b5c0900000000806a0660ff7f0000 |[\j`
access_inst   : 1
vbreq_state   : 0
state         : x0
resp          : 0xd9c5a6a0
On Scan_q?    : N
Total accesses: 56
Imm.  accesses: 45
Granted_locks : 1
Cvting_locks  : 1
value_block:  7c 5b 5c 09 00 00 00 00 80 6a 06 60 ff 7f 00 00
GRANTED_Q :
lp 0xd85b62a0 gl KJUSEREX rp 0xd9c5a6a0 [0x10001][0x7b3],[TX][ext 0x2,0x0]
  master 1 gl owner 0xda7233c0 possible pid 26287 xid 2B000-0001-00000578 bast 0 rseq 8 mseq 0 history 0x95
  open opt KJUSERDEADLOCK
CONVERT_Q:
lp 0xd85b6460 gl KJUSERNL rl KJUSEREX rp 0xd9c5a6a0 [0x10001][0x7b3],[TX][ext 0x2,0x0]
  master 1 owner 2  bast 0 rseq 22 mseq 0x1 history 0x97ad
  convert opt KJUSERGETVALUE
----------enqueue 0xd85b62a0------------------------
lock version     : 1
Owner inst       : 1
grant_level      : KJUSEREX
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9c5a6a0
procp            : 0xd996b090
pid              : 22148
proc version     : 0
oprocp           : (nil)
opid             : 22148
group lock owner : 0xda7233c0
possible pid     : 26287
xid              : 2B000-0001-00000578
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERNOQUEUE KJUSERNODEADLOCKWAIT
History          : 0x95
Msg_Seq          : 0x0
res_seq          : 8
valblk           : 0x00000000ff7f000031000502ff7f0000 .1
user session for deadlock lock 0xd85b62a0
  sid: 416 ser: 1055 audsid: 4294967295 user: 0/SYS
    flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40008) -/-
  pid: 43 O/S info: user: oracle, term: UNKNOWN, ospid: 26287
    image: oracle@rh2.oracle.com (TNS V1-V3)
  client details:
    O/S info: user: oracle, term: pts/3, ospid: 26286
    machine: rh2.oracle.com program: sqlplus@rh2.oracle.com (TNS V1-V3)
    application name: sqlplus@rh2.oracle.com (TNS V1-V3), hash value=3660119738
  current SQL:
  update lock1 set t1=t1+10 where t1=2
DUMP LOCAL BLOCKER: initiate state dump for DEADLOCK
  possible owner[43.26287] on resource TX-00010001-000007B3

*** 2011-06-21 22:08:18.053
Submitting asynchronized dump request [28]. summary=[ges process stack dump (kjdglblkrdm1)].
----------enqueue 0xd85b6460------------------------
lock version     : 1
Owner inst       : 2
grant_level      : KJUSERNL
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9c5a6a0
procp            : 0xd9971780
pid              : 0
proc version     : 0
oprocp           : (nil)
opid             : 0
group lock owner : (nil)
xid              : 0000-0000-00000000
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     :  KJUSERNO_XID
Convert options  : KJUSERGETVALUE
History          : 0x97ad
Msg_Seq          : 0x1
res_seq          : 22
valblk           : 0x406f0660ff7f0000806c0660ff7f0000 @o`l`
Global blockers dump end:-----------------------------------
Global Wait-For-Graph(WFG) at ddTS[0.6] :
BLOCKED 0xd8757ff8 5 wq 2 cvtops x1 TX 0xb0000.0xc8(ext 0x5,0x0)[2B000-0001-00000578] inst 1
BLOCKER 0xd8561ee0 5 wq 1 cvtops x28 TX 0xb0000.0xc8(ext 0x5,0x0)[22000-0002-000010C6] inst 2
BLOCKED 0xd8766338 5 wq 2 cvtops x1 TX 0x10001.0x7b3(ext 0x2,0x0)[22000-0002-000010C6] inst 2
BLOCKER 0xd85b62a0 5 wq 1 cvtops x28 TX 0x10001.0x7b3(ext 0x2,0x0)[2B000-0001-00000578] inst 1 

*** 2011-06-21 22:08:19.059
* Cancel deadlock victim lockp 0xd8757ff8

TX DEADLOCK LOCAL only:

*** 2011-06-21 22:27:00.022
DUMP LOCAL BLOCKER/HOLDER: block level 5 res [0x70015][0x81e],[TX][ext 0x2,0x0]
----------resource 0xd9e62330----------------------
resname       : [0x70015][0x81e],[TX][ext 0x2,0x0]
hash mask     : x3
Local inst    : 1
dir_inst      : 1
master_inst   : 1
hv idx        : 7
hv last r.inc : 42
current inc   : 56
hv status     : 0
hv master     : 1
open options  : dd
grant_bits    : KJUSERNL KJUSEREX
grant mode    : KJUSERNL  KJUSERCR  KJUSERCW  KJUSERPR  KJUSERPW  KJUSEREX
count         : 1         0         0         0         0         1
val_state     : KJUSERVS_NOVALUE
valblk        : 0x506b0660ff7f00006d6cf50400000000 Pk`ml
access_inst   : 1
vbreq_state   : 0
state         : x0
resp          : 0xd9e62330
On Scan_q?    : N
Total accesses: 23
Imm.  accesses: 15
Granted_locks : 1
Cvting_locks  : 1
value_block:  50 6b 06 60 ff 7f 00 00 6d 6c f5 04 00 00 00 00
GRANTED_Q :
lp 0xd8767a10 gl KJUSEREX rp 0xd9e62330 [0x70015][0x81e],[TX][ext 0x2,0x0]
  master 1 gl owner 0xda2cff40 possible pid 26847 xid 2E000-0001-00000347 bast 0 rseq 1 mseq 0 history 0x14951495
  open opt KJUSERDEADLOCK
CONVERT_Q:
lp 0xd876a630 gl KJUSERNL rl KJUSEREX rp 0xd9e62330 [0x70015][0x81e],[TX][ext 0x2,0x0]
  master 1 gl owner 0xda7233c0 possible pid 26843 xid 2B000-0001-0000057A bast 0 rseq 1 mseq 0 history 0x1495149a
  convert opt KJUSERGETVALUE
----------enqueue 0xd8767a10------------------------
lock version     : 8523
Owner inst       : 1
grant_level      : KJUSEREX
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9e62330
procp            : 0xd99750b0
pid              : 26843
proc version     : 231
oprocp           : (nil)
opid             : 26843
group lock owner : 0xda2cff40
possible pid     : 26847
xid              : 2E000-0001-00000347
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERNOQUEUE KJUSERNODEADLOCKWAIT
History          : 0x14951495
Msg_Seq          : 0x0
res_seq          : 1
valblk           : 0x00000000000000000000000000000000 .
user session for deadlock lock 0xd8767a10
  sid: 16 ser: 851 audsid: 4294967295 user: 0/SYS
    flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40008) -/-
  pid: 46 O/S info: user: oracle, term: UNKNOWN, ospid: 26847
    image: oracle@rh2.oracle.com (TNS V1-V3)
  client details:
    O/S info: user: oracle, term: pts/3, ospid: 26846
    machine: rh2.oracle.com program: sqlplus@rh2.oracle.com (TNS V1-V3)
    application name: sqlplus@rh2.oracle.com (TNS V1-V3), hash value=3660119738
  current SQL:
   update lock1 set t1=t1+10 where t1=11
DUMP LOCAL BLOCKER: initiate state dump for DEADLOCK
  possible owner[46.26847] on resource TX-00070015-0000081E

*** 2011-06-21 22:27:00.024
Submitting asynchronized dump request [28]. summary=[ges process stack dump (kjdglblkrdm1)].
----------enqueue 0xd876a630------------------------
lock version     : 9399
Owner inst       : 1
grant_level      : KJUSERNL
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9e62330
procp            : 0xd99750b0
pid              : 26843
proc version     : 231
oprocp           : (nil)
opid             : 26843
group lock owner : 0xda7233c0
possible pid     : 26843
xid              : 2B000-0001-0000057A
dd_time          : 10.0 secs
dd_count         : 1
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : Y
lock_state       : OPENING CONVERTING
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERGETVALUE
History          : 0x1495149a
Msg_Seq          : 0x0
res_seq          : 1
valblk           : 0xa06e0660ff7f0000e06b0660ff7f0000 .n`k`
user session for deadlock lock 0xd876a630
  sid: 416 ser: 1057 audsid: 4294967295 user: 0/SYS
    flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40008) -/-
  pid: 43 O/S info: user: oracle, term: UNKNOWN, ospid: 26843
    image: oracle@rh2.oracle.com (TNS V1-V3)
  client details:
    O/S info: user: oracle, term: pts/4, ospid: 26842
    machine: rh2.oracle.com program: sqlplus@rh2.oracle.com (TNS V1-V3)
    application name: sqlplus@rh2.oracle.com (TNS V1-V3), hash value=3660119738
  current SQL:
  update lock1 set t1=t1+10 where t1=12
DUMP LOCAL BLOCKER: initiate state dump for DEADLOCK
  possible owner[43.26843] on resource TX-00070015-0000081E

*** 2011-06-21 22:27:00.025
Submitting asynchronized dump request [28]. summary=[ges process stack dump (kjdglblkrdm1)].
DUMP LOCAL BLOCKER/HOLDER: block level 5 res [0x40008][0x7d9],[TX][ext 0x2,0x0]
----------resource 0xd9e62208----------------------
resname       : [0x40008][0x7d9],[TX][ext 0x2,0x0]
hash mask     : x3
Local inst    : 1
dir_inst      : 1
master_inst   : 1
hv idx        : 53
hv last r.inc : 42
current inc   : 56
hv status     : 0
hv master     : 1
open options  : dd
grant_bits    : KJUSERNL KJUSEREX
grant mode    : KJUSERNL  KJUSERCR  KJUSERCW  KJUSERPR  KJUSERPW  KJUSEREX
count         : 1         0         0         0         0         1
val_state     : KJUSERVS_NOVALUE
valblk        : 0x7c5b5c0900000000e0690660ff7f0000 |[\i`
access_inst   : 1
vbreq_state   : 0
state         : x0
resp          : 0xd9e62208
On Scan_q?    : N
Total accesses: 92
Imm.  accesses: 82
Granted_locks : 1
Cvting_locks  : 1
value_block:  7c 5b 5c 09 00 00 00 00 e0 69 06 60 ff 7f 00 00
GRANTED_Q :
lp 0xd876a7f0 gl KJUSEREX rp 0xd9e62208 [0x40008][0x7d9],[TX][ext 0x2,0x0]
  master 1 gl owner 0xda7233c0 possible pid 26843 xid 2B000-0001-0000057A bast 0 rseq 6 mseq 0 history 0x14951495
  open opt KJUSERDEADLOCK
CONVERT_Q:
lp 0xd876ab70 gl KJUSERNL rl KJUSEREX rp 0xd9e62208 [0x40008][0x7d9],[TX][ext 0x2,0x0]
  master 1 gl owner 0xda2cff40 possible pid 26847 xid 2E000-0001-00000347 bast 0 rseq 6 mseq 0 history 0x1495149a
  convert opt KJUSERGETVALUE
----------enqueue 0xd876a7f0------------------------
lock version     : 6107
Owner inst       : 1
grant_level      : KJUSEREX
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9e62208
procp            : 0xd9978428
pid              : 26847
proc version     : 238
oprocp           : (nil)
opid             : 26847
group lock owner : 0xda7233c0
possible pid     : 26843
xid              : 2B000-0001-0000057A
dd_time          : 0.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : N
lock_state       : GRANTED
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERNOQUEUE KJUSERNODEADLOCKWAIT
History          : 0x14951495
Msg_Seq          : 0x0
res_seq          : 6
valblk           : 0x00000000ff7f000031000502ff7f0000 .1
user session for deadlock lock 0xd876a7f0
  sid: 416 ser: 1057 audsid: 4294967295 user: 0/SYS
    flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40008) -/-
  pid: 43 O/S info: user: oracle, term: UNKNOWN, ospid: 26843
    image: oracle@rh2.oracle.com (TNS V1-V3)
  client details:
    O/S info: user: oracle, term: pts/4, ospid: 26842
    machine: rh2.oracle.com program: sqlplus@rh2.oracle.com (TNS V1-V3)
    application name: sqlplus@rh2.oracle.com (TNS V1-V3), hash value=3660119738
  current SQL:
  update lock1 set t1=t1+10 where t1=12
DUMP LOCAL BLOCKER: initiate state dump for DEADLOCK
  possible owner[43.26843] on resource TX-00040008-000007D9

*** 2011-06-21 22:27:00.029
Submitting asynchronized dump request [28]. summary=[ges process stack dump (kjdglblkrdm1)].
----------enqueue 0xd876ab70------------------------
lock version     : 3827
Owner inst       : 1
grant_level      : KJUSERNL
req_level        : KJUSEREX
bast_level       : KJUSERNL
notify_func      : (nil)
resp             : 0xd9e62208
procp            : 0xd9978428
pid              : 26847
proc version     : 238
oprocp           : (nil)
opid             : 26847
group lock owner : 0xda2cff40
possible pid     : 26847
xid              : 2E000-0001-00000347
dd_time          : 5.0 secs
dd_count         : 0
timeout          : 0.0 secs
On_timer_q?      : N
On_dd_q?         : Y
lock_state       : OPENING CONVERTING
ast_flag         : 0x0
Open Options     : KJUSERDEADLOCK
Convert options  : KJUSERGETVALUE
History          : 0x1495149a
Msg_Seq          : 0x0
res_seq          : 6
valblk           : 0xa06e0660ff7f0000e06b0660ff7f0000 .n`k`
user session for deadlock lock 0xd876ab70
  sid: 16 ser: 851 audsid: 4294967295 user: 0/SYS
    flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40008) -/-
  pid: 46 O/S info: user: oracle, term: UNKNOWN, ospid: 26847
    image: oracle@rh2.oracle.com (TNS V1-V3)
  client details:
    O/S info: user: oracle, term: pts/3, ospid: 26846
    machine: rh2.oracle.com program: sqlplus@rh2.oracle.com (TNS V1-V3)
    application name: sqlplus@rh2.oracle.com (TNS V1-V3), hash value=3660119738
  current SQL:
   update lock1 set t1=t1+10 where t1=11
DUMP LOCAL BLOCKER: initiate state dump for DEADLOCK
  possible owner[46.26847] on resource TX-00040008-000007D9

*** 2011-06-21 22:27:00.031
Submitting asynchronized dump request [28]. summary=[ges process stack dump (kjdglblkrdm1)].
Global blockers dump end:-----------------------------------
Global Wait-For-Graph(WFG) at ddTS[0.db] :
BLOCKED 0xd876a630 5 wq 2 cvtops x1 TX 0x70015.0x81e(ext 0x2,0x0)[2B000-0001-0000057A] inst 1
BLOCKER 0xd8767a10 5 wq 1 cvtops x28 TX 0x70015.0x81e(ext 0x2,0x0)[2E000-0001-00000347] inst 1
BLOCKED 0xd876ab70 5 wq 2 cvtops x1 TX 0x40008.0x7d9(ext 0x2,0x0)[2E000-0001-00000347] inst 1
BLOCKER 0xd876a7f0 5 wq 1 cvtops x28 TX 0x40008.0x7d9(ext 0x2,0x0)[2B000-0001-0000057A] inst 1

Summary Of  Bugs Which Could Cause Deadlock In RAC Environment

Applies to:

Oracle Server - Enterprise Edition - Version: 9.2.0.4 to 11.1 Information in this document applies to any platform.

Purpose

The purpose of this Note is to explain various bugs filed specifically for the Dead lock errors in a RAC environment  against specific Oracle database versions (This Note covers bugs reported versions  above 9.2.0.4), and explain the symptoms of each bug, workarounds if any and references the patch availability at the time this article was written.

Scope

This article is a consolidated effort to summarisze top bugs reported specifically for the Dead lock  error in RAC environment  (This Note covers bugs reported versions above 9.2.0.4) which have been fixed. It is directed towards Oracle Support Analysts and Oracle Customers to have an overview of various bugs logged for the same error .

Summary Of Bugs Which Could Cause Deadlock In RAC Environment

Bugs Fixed in Version 9.2.0.5 Note 2941738.8 Bug 2941738   SMON processes may deadlock in RAC Note 2902030.8 Bug 2902030   Deadlocks in RAC not logged in alert log Bugs Fixed in Version 9.2.0.6 10.1.0.4 10.2.0.1 Note 3268802.8 Bug 3268802 Additional diagnostics for deadlock in RAC environment Note.3646162.8 Bug 3646162 False deadlock (ORA-60) in a RAC environment / TM lock mode change Note.3627263.8 Bug 3627263 DEADLOCK OPS STARTUP Deadlock / hang during RAC instance startup Bugs Fixed in Version 9.2.0.7 10.2.0.1 Note.3992847.8 Bug 3992847 Deadlocks are not detected in rac when one node rebooted more recently than the rest Note 3641819.8 Bug 3641819  Undetected deadlock possible in RAC Note 3777178.8 Bug 3777178  TA / US enqueue deadlock during transaction recovery in RAC Note 4220161.8 Bug 4220161 OPS Deadlock between SMON processes on different instances Bug Fixed in Version  9.2.0.8 10.2.0.1 Note 4371923.8 Bug 4371923 SMON may deadlock on TX enqueue waits for updates to COL_USAGE$ in RAC Bug Fixed in  Version 10.2.0.2 Note 4579381.8 Bug 4579381  Deadlock on DC_USERS in RAC (ORA-4020) Bug Fixed in Version 10.2.0.3 Note 5012368.8 Bug 5012368 Undetected deadlock in RAC  Note 4913415.8 Bug 4913415 Global deadlock not reported in RAC Bug Fixed in Version 10.2.0.4 Note 5470095.8 Bug 5470095  Self deadlock should provide more targeted diagnostics Note 5454831.8 Bug 5454831  deadlock possible on working set latches Note 5334733.8 Bug 5334733  Deadlock resolution can be slow in RAC  Note 4441119.8 Bug 4441119 Not enough information dumped when RAC detects a deadlock  Note 5883112.8 Bug 5883112 False deadlock in RAC Bug Fixed in Version 10.2.0.5 Note 6145177.8 Bug 6145177 Single resource deadlock with a zero DID For summary of bugs which could cause deadlock in single instance see Note 554616.1

SCN may jump in a distributed transaction with dblink

在分布式事务环境中数据库的SCN可能瞬间暴增,这种行为被称作SCN jump in distributed transaction,注意这种现象是正常的。在发生分布式事务的2个数据库中,SCN较低的DB会将SCN和较高的那个数据库同步,这有时候会造成我们的一些误解认为可能是Hot backup等操作引起了SCN的猛增。

我们来具体看一下这种现象:

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------------------------------------------------
www.askmac.cn

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    5072553

SQL> select current_scn from v$database@PROD;

CURRENT_SCN
-----------
    7798262

SQL> insert into testlink@PROD values(1);

1 row created.

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    7798282

由于这种SCN跳跃可能引起ORA-600 [2252]内部错误,相关的bug case.

Know more about redo log buffer and latches

1.
The Total size of the log buffer is determined by LOG_BUFFER parameter.

2.
Only Server process may pin a data block in exclusive mode.

3.
LGWR writes to the redo log files when:

  • The redo log buffer is 1/3 full.
  • 1 MB of data have been written to the redo log buffer.
  • A 3-second time-out occurs.
  • commit!
  • before dbwr write out dirty buffers
  • A thread is closed

 

4.
the correct sequence for the LGWR algorithm is :

  1. Acquire the redo writing and redo allocation latches
  2. determine the buffer to write out
  3. Release the redo allocation latch
  4. determine how many writes are required

 

5.
In Oracle8i, the redo copy latch is always acquired regardless of the redo size.

Because the parameter LOG_SMALL_ENTRY_MAX_SIZE is obsolete, a redo copy latch is always acquired.

6.
Three most relevant redo events under normal operations:

  • Log file parallel write
  • Log buffer space
  • Log file sync

 

7.
relevant redo statistics and their purpose

  • REDO writes                                                 === Number of times the log buffer is written
  • redo blocks written                                === Number of times the log buffer is written
  • redo write time                                          === Total time required to write all the redos to disk
  • redo buffer allocation retires         === Total number of retries necessary to allocate space in the redo buffer

 

8.
Log buffer contention is typically indicated by Redo buffer allocation retries .

The buffer allocation retries indicates that a process has to continually try to allocate buffers that are not available

9.
Redo buffer allocation retries can be gathered by querying the name and value columns from V$ dynamic views:
V$sesstat
V$sysstat

10.
Stripe the redo log files across physical disks will help flush the redo buffer faster.

The redo log file write batch is 128K, so striping the redo logs across 8 disks with a stripe size of 16K could improve the write time by as much as 75%.

11.
The number of redo copy latches can be defined by setting _Log_simultaneous_copies .

The parameter begins with an underscore because in 8i it is a hidden parameter.

12.
The purpose of the redo writing latch is to: Prevent multiple processes from posting
LGWR when there is no space in the buffer .

The redo writing latch frees space in log buffer and does not want
processes writing to the buffer while space is being freed

13.
_log_io_size is set to reduce contention for the redo writing latch.

But notice that it is a hidden parameter. This is the number of used redo blocks that will automatically initiate a log write.

14.
A standby database must be refreshed following a nologging operation.

When nologging occurs, the redo logs of the standby database are not written to.

15.
log_small_entry_max_size is used to determine if a redo copy latch is required based upon the redo entry size,

however, this parameter is obsolete in Oracle8i, as a copy latch is always acquired.

_log_simultaneous_copies determines the number of redo copy latches to allocate.

Note that this is a hidden parameter in Oracle8i because it is not recommended to have more than one copy latch.

log_checkpoint_interval determines the need for a checkpoint.

如何设计分区索引

通过下图定义的规则,可确定分区索引类型:
design-partition-index

Hash Global分区索引介绍
HASH-Partitioned Global索引是Oracle 10g开始提供的新特性。而在以前的版本中
,Oracle只支持Range-Partitioned Global索引。HASH-Partitioned Global索引的好处如下:
比Range-Partitioned Global索引易于实施。HASH-Partitioned Global索引是根据
索引字段值,通过Oracle内部的HASH算法自动均匀散列到定义的分区中。而
Range-Partitioned Global索引需要根据索引字段值的范围进行分区,因此实施和
维护的难度都大。
HASH-Partitioned Global索引适合于在并发量、吞吐量很大的交易系统(OLTP)
中,对某些字段的访问冲突。尤其是sequence字段值。
HASH-Partitioned Global索引适合于大批量的数据查询。HASH-Partitioned Global索引不仅可以提供分区之间的并行查询,
而且在分区内也可进行并行查询的处理。
建立分区索引必须指定表空间,并且指定的表空间要与数据表空间分开,
这样便于管理,同时尽可能分开索引和数据的IO访问,提高效率

Script to Collect Log File Sync Diagnostic Information (lfsdiag.sql)

Script

set echo off
set feedback off
column timecol new_value timestamp
column spool_extension new_value suffix
select to_char(sysdate,'Mondd_hh24mi') timecol,
'.out' spool_extension from sys.dual;
column output new_value dbname
select value || '_' output
from v$parameter where name = 'db_name';
spool lfsdiag_&&dbname&&timestamp&&suffix
set trim on
set trims on
set lines 130
set pages 100
set verify off
alter session set optimizer_features_enable = '10.2.0.4';

PROMPT LFSDIAG DATA FOR &&dbname&&timestamp
PROMPT Note: All timings are in milliseconds (1000 milliseconds = 1 second)

PROMPT
PROMPT IMPORTANT PARAMETERS RELATING TO LOG FILE SYNC WAITS:
column name format a40 wra
column value format a40 wra
select inst_id, name, value from gv$parameter
where ((value is not null and name like '%log_archive%') or
name like '%commit%' or name like '%event=%' or name like '%lgwr%')
and name not in (select name from gv$parameter where (name like '%log_archive_dest_state%'
and value = 'enable') or name = 'log_archive_format')
order by 1,2,3;

PROMPT
PROMPT HISTOGRAM DATA FOR LFS AND OTHER RELATED WAITS:
PROMPT
PROMPT APPROACH: Look at the wait distribution for log file sync waits
PROMPT by looking at "wait_time_milli". Look at the high wait times then
PROMPT see if you can correlate those with other related wait events.
column event format a40 wra
select inst_id, event, wait_time_milli, wait_count
from gv$event_histogram
where event in ('log file sync','gcs log flush sync',
'log file parallel write','wait for scn ack',
'log file switch completion','gc cr grant 2-way',
'gc buffer busy','gc current block 2-way') or
event like '%LGWR%' or event like '%LNS%'
order by 2 desc,1,3;

PROMPT
PROMPT ORDERED BY WAIT_TIME_MILLI
select inst_id, event, wait_time_milli, wait_count
from gv$event_histogram
where event in ('log file sync','gcs log flush sync',
'log file parallel write','wait for scn ack',
'log file switch completion','gc cr grant 2-way',
'gc buffer busy','gc current block 2-way')
or event like '%LGWR%' or event like '%LNS%'
order by 3,1,2 desc;

PROMPT
PROMPT REDO WRITE STATS
PROMPT
PROMPT "redo write time" in centiseconds (100 per second)
PROMPT 11.1: "redo write broadcast ack time" in centiseconds (100 per second)
PROMPT 11.2: "redo write broadcast ack time" in microseconds (1000 per millisecond)
column value format 99999999999999999999
column milliseconds format 99999999999999.999
select v.version, ss.inst_id, ss.name, ss.value,
decode(substr(version,1,4),
'11.1',decode (name,'redo write time',value*10,
'redo write broadcast ack time',value*10),
'11.2',decode (name,'redo write time',value*10,
'redo write broadcast ack time',value/1000),
decode (name,'redo write time',value*10)) milliseconds
from gv$sysstat ss, v$instance v
where name like 'redo write%' and value > 0
order by 1,2,3;

PROMPT
PROMPT ASH THRESHOLD...
PROMPT
PROMPT This will be the threshold in milliseconds for average log file sync
PROMPT times. This will be used for the next queries to look for the worst
PROMPT 'log file sync' minutes. Any minutes that have an average log file
PROMPT sync time greater than the threshold will be analyzed further.
column threshold_in_ms new_value threshold format 999999999.999
select min(threshold_in_ms) threshold_in_ms
from (select inst_id, to_char(sample_time,'Mondd_hh24mi') minute,
avg(time_waited)/1000 threshold_in_ms
from gv$active_session_history
where event = 'log file sync'
group by inst_id,to_char(sample_time,'Mondd_hh24mi')
order by 3 desc)
where rownum <= 5;

PROMPT
PROMPT ASH WORST MINUTES FOR LOG FILE SYNC WAITS:
PROMPT
PROMPT APPROACH: These are the minutes where the avg log file sync time
PROMPT was the highest (in milliseconds).
column event format a30 tru
column program format a35 tru
column total_wait_time format 999999999999.999
column avg_time_waited format 999999999999.999
select to_char(sample_time,'Mondd_hh24mi') minute, inst_id, event,
sum(time_waited)/1000 TOTAL_WAIT_TIME , count(*) WAITS,
avg(time_waited)/1000 AVG_TIME_WAITED
from gv$active_session_history
where event = 'log file sync'
group by to_char(sample_time,'Mondd_hh24mi'), inst_id, event
having avg(time_waited)/1000 > &&threshold
order by 1,2;

PROMPT
PROMPT ASH LFS BACKGROUND PROCESS WAITS DURING WORST MINUTES:
PROMPT
PROMPT APPROACH: What is LGWR doing when 'log file sync' waits
PROMPT are happening? LMS info may be relevent for broadcast
PROMPT on commit and LNS data may be relevant for dataguard.
PROMPT If more details are needed see the ASH DETAILS FOR WORST
PROMPT MINUTES section at the bottom of the report.
column inst format 999
column event format a30 tru
column program format a35 wra
select to_char(sample_time,'Mondd_hh24mi') minute, inst_id inst, program, event,
sum(time_waited)/1000 TOTAL_WAIT_TIME , count(*) WAITS,
avg(time_waited)/1000 AVG_TIME_WAITED
from gv$active_session_history
where to_char(sample_time,'Mondd_hh24mi') in (select to_char(sample_time,'Mondd_hh24mi')
from gv$active_session_history
where event = 'log file sync'
group by to_char(sample_time,'Mondd_hh24mi'), inst_id
having avg(time_waited)/1000 > &&threshold)
and (program like '%LGWR%' or program like '%LMS%' or
program like '%LNS%' or event = 'log file sync')
group by to_char(sample_time,'Mondd_hh24mi'), inst_id, program, event
order by 1,2,3,5 desc, 4;

PROMPT
PROMPT AWR WORST AVG LOG FILE SYNC SNAPS:
PROMPT
PROMPT APPROACH: These are the AWR snaps where the average 'log file sync'
PROMPT times were the highest.
column begin format a12 tru
column end format a12 tru
column name format a13 tru
select dhs.snap_id, dhs.instance_number inst, to_char(dhs.begin_interval_time,'Mondd_hh24mi') BEGIN,
to_char(dhs.end_interval_time,'Mondd_hh24mi') END,
en.name, se.time_waited_micro/1000 total_wait_time, se.total_waits,
se.time_waited_micro/1000 / se.total_waits avg_time_waited
from dba_hist_snapshot dhs, wrh$_system_event se, v$event_name en
where (dhs.snap_id = se.snap_id and dhs.instance_number = se.instance_number)
and se.event_id = en.event_id and en.name = 'log file sync' and
dhs.snap_id in (select snap_id from (
select se.snap_id, se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and en.name = 'log file sync'
order by avg_time_waited desc)
where rownum < 4)
order by 1,2;

PROMPT
PROMPT AWR REDO WRITE STATS
PROMPT
PROMPT "redo write time" in centiseconds (100 per second)
PROMPT 11.1: "redo write broadcast ack time" in centiseconds (100 per second)
PROMPT 11.2: "redo write broadcast ack time" in microseconds (1000 per millisecond)
column stat_name format a30 tru
select v.version, ss.snap_id, ss.instance_number inst, sn.stat_name, ss.value,
decode(substr(version,1,4),
'11.1',decode (stat_name,'redo write time',value*10,
'redo write broadcast ack time',value*10),
'11.2',decode (stat_name,'redo write time',value*10,
'redo write broadcast ack time',value/1000),
decode (stat_name,'redo write time',value*10)) milliseconds
from wrh$_sysstat ss, wrh$_stat_name sn, v$instance v
where ss.stat_id = sn.stat_id
and sn.stat_name like 'redo write%' and ss.value > 0
and ss.snap_id in (select snap_id from (
select se.snap_id, se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and en.name = 'log file sync'
order by avg_time_waited desc)
where rownum < 4)
order by 1,2,3;

PROMPT
PROMPT AWR LFS AND OTHER RELATED WAITS FOR WORST LFS AWRs:
PROMPT
PROMPT APPROACH: These are the AWR snaps where the average 'log file sync'
PROMPT times were the highest. Look at related waits at those times.
column name format a40 tru
select se.snap_id, se.instance_number inst, en.name,
se.total_waits, se.time_waited_micro/1000 total_wait_time,
se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and (en.name in
('log file sync','gcs log flush sync',
'log file parallel write','wait for scn ack',
'log file switch completion','gc cr grant 2-way',
'gc buffer busy','gc current block 2-way')
or en.name like '%LGWR%' or en.name like '%LNS%')
and se.snap_id in (select snap_id from (
select se.snap_id, se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and en.name = 'log file sync'
order by avg_time_waited desc)
where rownum < 4)
order by 1, 6 desc;

PROMPT
PROMPT AWR HISTOGRAM DATA FOR LFS AND OTHER RELATED WAITS FOR WORST LFS AWRs:
PROMPT Note: This query won't work on 10.2 - ORA-942
PROMPT
PROMPT APPROACH: Look at the wait distribution for log file sync waits
PROMPT by looking at "wait_time_milli". Look at the high wait times then
PROMPT see if you can correlate those with other related wait events.
select eh.snap_id, eh.instance_number inst, en.name, eh.wait_time_milli, eh.wait_count
from wrh$_event_histogram eh, v$event_name en
where eh.event_id = en.event_id and
(en.name in ('log file sync','gcs log flush sync',
'log file parallel write','wait for scn ack',
'log file switch completion','gc cr grant 2-way',
'gc buffer busy','gc current block 2-way')
or en.name like '%LGWR%' or en.name like '%LNS%')
and snap_id in (select snap_id from (
select se.snap_id, se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and en.name = 'log file sync'
order by avg_time_waited desc)
where rownum < 4)
order by 1,3 desc,2,4;

PROMPT
PROMPT ORDERED BY WAIT_TIME_MILLI
PROMPT Note: This query won't work on 10.2 - ORA-942
select eh.snap_id, eh.instance_number inst, en.name, eh.wait_time_milli, eh.wait_count
from wrh$_event_histogram eh, v$event_name en
where eh.event_id = en.event_id and
(en.name in ('log file sync','gcs log flush sync',
'log file parallel write','wait for scn ack',
'log file switch completion','gc cr grant 2-way',
'gc buffer busy','gc current block 2-way')
or en.name like '%LGWR%' or en.name like '%LNS%')
and snap_id in (select snap_id from (
select se.snap_id, se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and en.name = 'log file sync'
order by avg_time_waited desc)
where rownum < 4)
order by 1,4,2,3 desc;

PROMPT
PROMPT ASH DETAILS FOR WORST MINUTES:
PROMPT
PROMPT APPROACH: If you cannot determine the problem from the data
PROMPT above, you may need to look at the details of what each session
PROMPT is doing during each 'bad' snap. Most likely you will want to
PROMPT note the times of the high log file sync waits, look at what
PROMPT LGWR is doing at those times, and go from there...
column program format a45 wra
column sample_time format a25 tru
column event format a30 tru
column time_waited format 999999.999
column p1 format a40 tru
column p2 format a40 tru
column p3 format a40 tru
select sample_time, inst_id inst, session_id, program, event, time_waited/1000 TIME_WAITED,
p1text||': '||p1 p1,p2text||': '||p2 p2,p3text||': '||p3 p3
from gv$active_session_history
where to_char(sample_time,'Mondd_hh24mi') in (select
to_char(sample_time,'Mondd_hh24mi')
from gv$active_session_history
where event = 'log file sync'
group by to_char(sample_time,'Mondd_hh24mi'), inst_id
having avg(time_waited)/1000 > &&threshold)
order by 1,2,3,4,5;

select to_char(sysdate,'Mondd hh24:mi:ss') TIME from dual;

spool off

PROMPT
PROMPT OUTPUT FILE IS: lfsdiag_&&dbname&&timestamp&&suffix
PROMPT

Script:List Buffer Cache Details

以下脚本用于列出Oracle Buffer Cache的详细信息:

REM List Buffer Cache Details

SET LINESIZE 200 PAGESIZE 1400

SELECT /*+ ORDERED USE_HASH(o u) MERGE */
 DECODE(obj#,
        NULL,
        to_char(bh.obj),
        u.name || '.' || o.name) name,
 COUNT(*) total,
 SUM(DECODE((DECODE(lru_flag, 8, 1, 0) + DECODE(SIGN(tch - 2), 1, 1, 0)),
            2,
            1,
            1,
            1,
            0)) hot,
 SUM(DECODE(DECODE(SIGN(lru_flag - 8), 1, 0, 0, 0, 1) +
            DECODE(tch, 2, 1, 1, 1, 0, 1, 0),
            2,
            1,
            1,
            0,
            0)) cold,
 SUM(DECODE(BITAND(flag, POWER(2, 19)), 0, 0, 1)) fts,
 SUM(tch) total_tch,
 ROUND(AVG(tch), 2) avg_tch,
 MAX(tch) max_tch,
 MIN(tch) min_tch
  FROM x$bh bh, sys.obj$ o, sys.user$ u
 WHERE 
    bh.obj <> 4294967295
   AND bh.state in (1, 2, 3)
   AND bh.obj = o.dataobj#(+)
   AND bh.inst_id = USERENV('INSTANCE')
 AND o.owner# = u.user#(+)
--   AND o.owner# > 5
   AND u.name NOT like 'AURORA$%'
 GROUP BY DECODE(obj#,
                 NULL,
                 to_char(bh.obj),
                 u.name || '.' || o.name)
 ORDER BY  total desc 
 /
 
 
 COLUMN object_name FORMAT A30

SELECT t.name AS tablespace_name,
       o.object_name,
       SUM(DECODE(bh.status, 'free', 1, 0)) AS free,
       SUM(DECODE(bh.status, 'xcur', 1, 0)) AS xcur,
       SUM(DECODE(bh.status, 'scur', 1, 0)) AS scur,
       SUM(DECODE(bh.status, 'cr', 1, 0)) AS cr,
       SUM(DECODE(bh.status, 'read', 1, 0)) AS read,
       SUM(DECODE(bh.status, 'mrec', 1, 0)) AS mrec,
       SUM(DECODE(bh.status, 'irec', 1, 0)) AS irec
FROM   v$bh bh
       JOIN dba_objects o ON o.data_object_id = bh.objd
       JOIN v$tablespace t ON t.ts# = bh.ts#
GROUP BY t.name, o.object_name
order by xcur desc 
/


 
set pages 999
set lines 92
 
ttitle 'Contents of Data Buffers'
 
drop view buffer_map;
 
create view buffer_map as
select
   o.owner          owner,
   o.object_name    object_name,
   o.subobject_name subobject_name,
   o.object_type    object_type,
   count(distinct file# || block#)         num_blocks
from
   dba_objects  o,
   v$bh         bh
where
   o.data_object_id  = bh.objd
-- and  o.owner not in ('SYS','SYSTEM')
and
   bh.status != 'free'
group by
   o.owner,
   o.object_name,
   o.subobject_name,
   o.object_type
order by
   count(distinct file# || block#) desc
;
 
column c0 heading "Owner"                                    format a12
column c1 heading "Object|Name"                              format a30
column c2 heading "Object|Type"                              format a8
column c3 heading "Number of|Blocks in|Buffer|Cache"         format 99,999,999
column c4 heading "Percentage|of object|blocks in|Buffer"    format 999
column c5 heading "Buffer|Pool"                              format a7
column c6 heading "Block|Size"                               format 99,999
 
select
   buffer_map.owner                                          c0,
   object_name                                       c1,
   case when object_type = 'TABLE PARTITION' then 'TAB PART'
        when object_type = 'INDEX PARTITION' then 'IDX PART'
        else object_type end c2,
   sum(num_blocks)                                     c3,
   (sum(num_blocks)/greatest(sum(blocks), .001))*100 c4,
   buffer_pool                                       c5,
   sum(bytes)/sum(blocks)                            c6
from
   buffer_map,
   dba_segments s
where
   s.segment_name = buffer_map.object_name
and
   s.owner = buffer_map.owner
and
   s.segment_type = buffer_map.object_type
and
   nvl(s.partition_name,'-') = nvl(buffer_map.subobject_name,'-')
group by
   buffer_map.owner,
   object_name,
   object_type,
   buffer_pool
having
   sum(num_blocks) > 10
order by
   sum(num_blocks) desc
;

REM dbbuffer

select decode(pd.bp_id,1,'KEEP',2,'RECYCLE',3,'DEFAULT',
         4,'2K SUBCACHE',5,'4K SUBCACHE',6,'8K SUBCACHE',
         7,'16K SUBCACHE',8,'32KSUBCACHE','UNKNOWN') subcache,
         bh.object_name,bh.blocks
from x$kcbwds ds,x$kcbwbpd pd,(select /*+ use_hash(x) */ set_ds,
         o.name object_name,count(*) BLOCKS
         from obj$ o, x$bh x where o.dataobj# = x.obj
         and x.state !=0 and o.owner# !=0
         group by set_ds,o.name) bh 
where ds.set_id >= pd.bp_lo_sid
and ds.set_id <= pd.bp_hi_sid
and pd.bp_size != 0
and ds.addr=bh.set_ds;

column segment_name format a35
     select /*+ RULE */
       e.owner ||'.'|| e.segment_name  segment_name,
       e.extent_id  extent#,
       x.dbablk - e.block_id + 1  block#,
       x.tch,
       l.child#
     from
       sys.v$latch_children  l,
       sys.x$bh  x,
       sys.dba_extents  e
     where
       x.hladdr  = '&ADDR' and
       e.file_id = x.file# and
       x.hladdr = l.addr and
       x.dbablk between e.block_id and e.block_id + e.blocks -1
     order by x.tch desc 
/



with bh_lc as
       (select /*+ ORDERED */
          lc.addr, lc.child#, lc.gets, lc.misses, lc.immediate_gets,
          lc.immediate_misses, lc.spin_gets, lc.sleeps,
          bh.hladdr, bh.tch tch, bh.file#, bh.dbablk, bh.class,
          bh.state, bh.obj
        from
          x$kslld ld,
          v$session_wait sw,
          v$latch_children lc,
          x$bh bh
        where lc.addr =sw.p1raw
          and sw.p2= ld.indx
          and ld.kslldnam='cache buffers chains'
          and lower(sw.event) like '%latch%'
          and sw.state='WAITING'
          and bh.hladdr=lc.addr
       )
     select bh_lc.hladdr, bh_lc.tch, o.owner, o.object_name, o.object_type,
            bh_lc.child#, bh_lc.gets,
            bh_lc.misses, bh_lc.immediate_gets,
            bh_lc.immediate_misses, spin_gets, sleeps
     from
       bh_lc,
       dba_objects o
     where bh_lc.obj = o.object_id(+)
   union
     select bh_lc.hladdr, bh_lc.tch, o.owner, o.object_name, o.object_type,
            bh_lc.child#, bh_lc.gets, bh_lc.misses, bh_lc.immediate_gets,
            bh_lc.immediate_misses, spin_gets, sleeps
     from
       bh_lc,
       dba_objects o
     where bh_lc.obj = o.data_object_id(+)
  order by 1,2 desc
/

col class form A10 
select decode(greatest(class,10),10,decode(class,1,'Data',2 
            ,'Sort',4,'Header',to_char(class)),'Rollback') "Class", 
       sum(decode(bitand(flag,1),1,0,1)) "Not Dirty", 
 sum(decode(bitand(flag,1),1,1,0)) "Dirty", 
       sum(dirty_queue) "On Dirty",count(*) "Total" 
from x$bh 
group by decode(greatest(class,10),10,decode(class,1,'Data',2 
         ,'Sort',4,'Header',to_char(class)),'Rollback') 
/ 

Script:List NLS Parameters and Timezone

以下脚本用以列出Database-instance-session的NLS参数和所在时区:

REM List NLS Parameters

set linesize 90 pagesize 1400
col Parameter for a40
col Value     for a40

SELECT Parameter, Value FROM NLS_DATABASE_PARAMETERS
/

SELECT Parameter, Value FROM NLS_INSTANCE_PARAMETERS
/

SELECT Parameter, Value FROM NLS_SESSION_PARAMETERS  ORDER BY 1
/

select dbtimezone from dual
/

select sessiontimezone from dual
/

Script:List SORT ACTIVITY监控临时空间的使用

以下脚本可以用于列出数据库内的排序活跃性能信息并监控临时空间的使用:

REM SORT ACTIVITY

set linesize 150 pagesize 1400;

    SELECT d.tablespace_name "Name", 
                TO_CHAR(NVL(a.bytes / 1024 / 1024, 0),'99,999,990.900') "Size (M)", 
                TO_CHAR(NVL(t.hwm, 0)/1024/1024,'99999999.999')  "HWM (M)",
                TO_CHAR(NVL(t.hwm / a.bytes * 100, 0), '990.00') "HWM % " ,
                TO_CHAR(NVL(t.bytes/1024/1024, 0),'99999999.999') "Using (M)", 
	        TO_CHAR(NVL(t.bytes / a.bytes * 100, 0), '990.00') "Using %" 
           FROM sys.dba_tablespaces d, 
                (select tablespace_name, sum(bytes) bytes from dba_temp_files group by tablespace_name) a,
                (select tablespace_name, sum(bytes_cached) hwm, sum(bytes_used) bytes from v$temp_extent_pool group by tablespace_name) t
          WHERE d.tablespace_name = a.tablespace_name(+) 
            AND d.tablespace_name = t.tablespace_name(+) 
            AND d.extent_management like 'LOCAL' 
            AND d.contents like 'TEMPORARY'
/

alter session set nls_date_format='dd-mon-yy';
set lines 160 pages 1000 echo off feedback off
col stat_name for a25
col date_time for a40
col BEGIN_INTERVAL_TIME for a20
col END_INTERVAL_TIME for a20
prompt "Enter the date in DD-Mon-YY Format and Stats you want to trend like 'redo size','physical reads','physical writes','session logical reads' etc."

WITH sysstat AS
 (select sn.begin_interval_time begin_interval_time,
         sn.end_interval_time end_interval_time,
         ss.stat_name stat_name,
         ss.value e_value,
         lag(ss.value, 1) over(order by ss.snap_id) b_value
    from dba_hist_sysstat ss, dba_hist_snapshot sn
   where trunc(sn.begin_interval_time) >= sysdate-7
     and ss.snap_id = sn.snap_id
     and ss.dbid = sn.dbid
     and ss.instance_number = sn.instance_number
     and ss.dbid = (select dbid from v$database)
     and ss.instance_number = (select instance_number from v$instance)
     and ss.stat_name = 'sorts (disk)')
select to_char(BEGIN_INTERVAL_TIME, 'mm/dd/yy_hh24_mi') || to_char(END_INTERVAL_TIME, '_hh24_mi') date_time,
stat_name,
round((e_value - nvl(b_value,0)) / (extract(day from(end_interval_time - begin_interval_time)) * 24 * 60 * 60
+ extract(hour from(end_interval_time - begin_interval_time)) * 60 * 60
+ extract(minute from(end_interval_time - begin_interval_time)) * 60 + extract(second from(end_interval_time - begin_interval_time))),0) per_sec
from sysstat where(e_value - nvl(b_value,0)) > 0 and nvl(b_value,0) > 0
/

select temp_space/1024/1024,SQL_ID  from DBA_HIST_SQL_PLAN where temp_space>0 order by 1 asc;

--For 8.1.7 to 9.2:

SELECT a.username, a.sid, a.serial#, a.osuser, b.tablespace, b.blocks, c.sql_text
FROM v$session a, v$sort_usage b, v$sqlarea c
WHERE a.saddr = b.session_addr
AND c.address= a.sql_address
AND c.hash_value = a.sql_hash_value
ORDER BY b.tablespace, b.blocks;

--For 10.1 and above:

SELECT a.username, a.sid, a.serial#, a.osuser, b.tablespace, b.blocks, c.sql_text
FROM v$session a, v$tempseg_usage b, v$sqlarea c
WHERE a.saddr = b.session_addr
AND c.address= a.sql_address
AND c.hash_value = a.sql_hash_value
ORDER BY b.tablespace, b.blocks;

SELECT S.sid || ',' || S.serial# sid_serial, S.username, S.osuser, P.spid, S.module,
P.program, SUM (T.blocks) * TBS.block_size / 1024 / 1024 mb_used, T.tablespace,
COUNT(*) statements
FROM v$sort_usage T, v$session S, dba_tablespaces TBS, v$process P
WHERE T.session_addr = S.saddr
AND S.paddr = P.addr
AND T.tablespace = TBS.tablespace_name
GROUP BY S.sid, S.serial#, S.username, S.osuser, P.spid, S.module,
P.program, TBS.block_size, T.tablespace
ORDER BY sid_serial;

SELECT *
  FROM (SELECT matching_criteria,
               TO_CHAR(force_matching_signature) force_matching_signature,
               sql_id,
               child_number,
               sql_text,
               executions,
               elapsed_time / 1000,
               operation_type,
               policy,
               estimated_optimal_size,
               last_memory_used,
               last_execution,
               active_time / 1000,
               num_sort_operations,
               tot_active_time / 1000,
               tot_optimal_executions,
               tot_onepass_executions,
               tot_multipasses_executions,
               all_tot_active_time / 1000,
               max_tempseg_size,
               parsing_schema_name
          FROM (SELECT force_matching_signature,
                       sql_id,
                       child_number,
                       sql_text,
                       matching_criteria,
                       SUM(executions) OVER(PARTITION BY matching_criteria) executions,
                       SUM(elapsed_time) OVER(PARTITION BY matching_criteria) elapsed_time,
                       operation_type,
                       policy,
                       estimated_optimal_size,
                       last_memory_used,
                       last_execution,
                       active_time,
                       num_sort_operations,
                       SUM(tot_active_time) OVER(PARTITION BY matching_criteria) tot_active_time,
                       SUM(tot_optimal_executions) OVER(PARTITION BY matching_criteria) tot_optimal_executions,
                       SUM(tot_onepass_executions) OVER(PARTITION BY matching_criteria) tot_onepass_executions,
                       SUM(tot_multipasses_executions) OVER(PARTITION BY matching_criteria) tot_multipasses_executions,
                       MAX(max_tempseg_size) OVER(PARTITION BY matching_criteria) max_tempseg_size,
                       SUM(tot_active_time) OVER() all_tot_active_time,
                       ROW_NUMBER() OVER(PARTITION BY matching_criteria ORDER BY tot_multipasses_executions DESC, tot_onepass_executions DESC, last_memory_used DESC) rnum,
                       parsing_schema_name
                  FROM (SELECT s.sql_id,
                               s.child_number,
                               s.sql_text,
                               s.executions,
                               s.elapsed_time,
                               s.force_matching_signature,
                               CASE
                                 WHEN s.force_matching_signature > 0 THEN
                                  TO_CHAR(s.force_matching_signature)
                                 ELSE
                                  s.sql_id
                               END matching_criteria,
                               ROW_NUMBER() OVER(PARTITION BY s.sql_id, s.child_number ORDER BY sw.multipasses_executions DESC, sw.onepass_executions DESC, sw.last_memory_used DESC) rnum,
                               sw.operation_type,
                               sw.policy,
                               sw.estimated_optimal_size,
                               sw.last_memory_used,
                               sw.last_execution,
                               MAX(sw.max_tempseg_size) OVER(PARTITION BY s.sql_id, s.child_number) max_tempseg_size,
                               sw.active_time * sw.total_executions active_time,
                               SUM(sw.active_time * sw.total_executions) OVER(PARTITION BY s.sql_id, s.child_number) tot_active_time,
                               COUNT(*) OVER(PARTITION BY s.sql_id, s.child_number) num_sort_operations,
                               SUM(sw.optimal_executions) OVER(PARTITION BY s.sql_id, s.child_number) tot_optimal_executions,
                               SUM(sw.onepass_executions) OVER(PARTITION BY s.sql_id, s.child_number) tot_onepass_executions,
                               SUM(sw.multipasses_executions) OVER(PARTITION BY s.sql_id, s.child_number) tot_multipasses_executions,
                               NVL(u.username, s.parsing_schema_name) parsing_schema_name
                          FROM v$sql s, v$sql_workarea sw, all_users u
                         WHERE sw.sql_id = s.sql_id
                           AND sw.child_number = s.child_number
                           AND u.user_id(+) = s.parsing_user_id)
                 WHERE rnum = 1)
         WHERE rnum = 1
         ORDER BY tot_multipasses_executions DESC,
                  tot_onepass_executions     DESC,
                  last_memory_used           DESC)
 WHERE ROWNUM <= 200
 /

SELECT *
  FROM (SELECT s.sid,
               s.machine,
               s.program,
               s.module,
               s.osuser,
               NVL(DECODE(TYPE,
                          'BACKGROUND',
                          'SYS (' || b.ksbdpnam || ')',
                          s.username),
                   SUBSTR(p.program, INSTR(p.program, '('))) username,
               NVL(SUM(CASE
                         WHEN sn.name = 'sorts (memory)' THEN
                          ss.VALUE
                         ELSE
                          0
                       END),
                   0) sorts_memory,
               NVL(SUM(CASE
                         WHEN sn.name = 'sorts (disk)' THEN
                          ss.VALUE
                         ELSE
                          0
                       END),
                   0) sorts_disk,
               NVL(SUM(CASE
                         WHEN sn.name = 'sorts (rows)' THEN
                          ss.VALUE
                         ELSE
                          0
                       END),
                   0) sorts_rows,
               NVL(SUM(CASE
                         WHEN sn.name = 'physical reads direct temporary tablespace' THEN
                          ss.VALUE
                         ELSE
                          0
                       END),
                   0) reads_direct_temp,
               NVL(SUM(CASE
                         WHEN sn.name = 'physical writes direct temporary tablespace' THEN
                          ss.VALUE
                         ELSE
                          0
                       END),
                   0) writes_direct_temp,
               NVL(SUM(CASE
                         WHEN sn.name = 'workarea executions - optimal' THEN
                          ss.VALUE
                         ELSE
                          0
                       END),
                   0) workarea_exec_optimal,
               NVL(SUM(CASE
                         WHEN sn.name = 'workarea executions - onepass' THEN
                          ss.VALUE
                         ELSE
                          0
                       END),
                   0) workarea_exec_onepass,
               NVL(SUM(CASE
                         WHEN sn.name = 'workarea executions - multipass' THEN
                          ss.VALUE
                         ELSE
                          0
                       END),
                   0) workarea_exec_multipass
          FROM v$session  s,
               v$sesstat  ss,
               v$statname sn,
               v$process  p,
               x$ksbdp    b
         WHERE s.paddr = p.addr
           AND b.inst_id(+) = USERENV('INSTANCE')
           AND p.addr = b.ksbdppro(+)
           AND s.TYPE = 'USER'
           AND s.sid = ss.sid
           AND ss.statistic# = sn.statistic#
           AND sn.name IN ('sorts (memory)',
                           'sorts (disk)',
                           'sorts (rows)',
                           'physical reads direct temporary tablespace',
                           'physical writes direct temporary tablespace',
                           'workarea executions - optimal',
                           'workarea executions - onepass',
                           'workarea executions - multipass')
         GROUP BY s.sid,
                  s.machine,
                  s.program,
                  s.module,
                  s.osuser,
                  NVL(DECODE(TYPE,
                             'BACKGROUND',
                             'SYS (' || b.ksbdpnam || ')',
                             s.username),
                      SUBSTR(p.program, INSTR(p.program, '(')))
         ORDER BY workarea_exec_multipass DESC,
                  workarea_exec_onepass DESC,
                  reads_direct_temp + writes_direct_temp DESC,
                  sorts_rows DESC)
 WHERE ROWNUM <= 200
/

SELECT rawtohex(workarea_address) workarea_address,
       sql_id,
       sql_text,
       operation_type,
       policy,
       sid,
       active_time,
       work_area_size,
       expected_size,
       actual_mem_used,
       max_mem_used,
       number_passes,
       tempseg_size,
       tablespace,
       complete_ratio,
       elapsed,
       time_remaining,
       opname,
       machine,
       program,
       module,
       osuser,
       username
  FROM (SELECT swa.workarea_address,
               swa.sql_id,
               sa.sql_text,
               swa.operation_type,
               swa.policy,
               swa.sid,
               swa.active_time / 1000 active_time,
               swa.work_area_size,
               swa.expected_size,
               swa.actual_mem_used,
               swa.max_mem_used,
               swa.number_passes,
               swa.tempseg_size,
               swa.tablespace,
               (CASE
                 WHEN sl.totalwork <> 0 THEN
                  sl.sofar / sl.totalwork
                 ELSE
                  NULL
               END) complete_ratio,
               sl.elapsed_seconds * 1000 elapsed,
               sl.time_remaining * 1000 time_remaining,
               sl.opname,
               s.machine,
               s.program,
               s.module,
               s.osuser,
               NVL(DECODE(TYPE,
                          'BACKGROUND',
                          'SYS (' || b.ksbdpnam || ')',
                          s.username),
                   SUBSTR(p.program, INSTR(p.program, '('))) username,
               ROW_NUMBER() OVER(PARTITION BY swa.sql_id ORDER BY sl.last_update_time DESC) rnum
          FROM v$sql_workarea_active swa,
               v$sqlarea sa,
               (SELECT * FROM v$session_longops WHERE sofar <> totalwork) sl,
               v$session s,
               v$process p,
               x$ksbdp b
         WHERE sl.sid(+) = swa.sid
           AND sl.sql_id(+) = swa.sql_id
           AND swa.sid <> USERENV('sid')
           AND sa.sql_id = swa.sql_id
           AND s.sid = swa.sid
           AND s.paddr = p.addr
           AND b.inst_id(+) = USERENV('INSTANCE')
           AND p.addr = b.ksbdppro(+)
         ORDER BY swa.number_passes DESC, swa.work_area_size DESC)
 WHERE rnum = 1
/

沪ICP备14014813号-2

沪公网安备 31010802001379号