How do you track sql queries in Oracle 12c? - oracle

We are in the process of upgrading to Oracle 12c and I need to track the queries being executed by the application. In other words if the application executes a query like select 'foobar' from dual; I would like see the text "select 'foobar' from dual" in the output file.
If I follow the instructions here: https://docs.oracle.com/database/121/TGSQL/tgsql_trace.htm#TGSQL809 I get files that contain statistics like the following but not the actual sql queries.
WAIT #0: nam='rdbms ipc message' ela= 2999770 timeout=300 p2=0 p3=0 obj#=-1 tim=1103506389
WAIT #0: nam='rdbms ipc message' ela= 9854 timeout=1 p2=0 p3=0 obj#=-1 tim=1103522400
*** 2016-04-07 15:07:20.715
WAIT #0: nam='rdbms ipc message' ela= 2999585 timeout=300 p2=0 p3=0 obj#=-1 tim=1106522506
WAIT #0: nam='rdbms ipc message' ela= 9690 timeout=1 p2=0 p3=0 obj#=-1 tim=1106532500
If I look for the query like this I get 0 results: grep -rnw "foobar" --include=*.trc ./

One option is looking up the AWR repositories for it. It will keep a few days worth of SQLs. There's plenty of additional information in the system views, so this is strictly the text, but feel free to explore.
SELECT DISTINCT u.username, to_char(substr(h.sql_text, 1, 4000)) sqltxt
FROM dba_hist_sqltext h
JOIN dba_hist_active_sess_history a ON a.sql_id = h.sql_id
JOIN dba_users u ON u.user_id = a.user_id
WHERE username = 'SYS';
I filtered the results for SYS just as an example, but you can change it as you wish.

If you would like to see all the activity the best thing you should do is have an EM (Enterprise Manager) set for you.
If you don't, gv$activity_session_history would be a good call, it's better seen when using grouping functions. Simply selecting on it would be a mess depending on the number of calls your application is pushing.
Another way, you could see it in an average manner:
`
select s.parsing_schema_name,
inst_id,
sql_id,
plan_hash_value,
child_number,
round(nullif(s.ELAPSED_TIME, 0) / nullif(s.EXECUTIONS, 0) / 1000000, 4) elap_per_exec,
round(s.USER_IO_WAIT_TIME / nullif(s.ELAPSED_TIME, 0) * 100, 2) io_wait_pct,
round(s.CLUSTER_WAIT_TIME / nullif(s.ELAPSED_TIME, 0) * 100, 2) cluster_wait_pct,
round(s.application_wait_time / nullif(s.ELAPSED_TIME, 0) * 100, 2) app_wait_pct,
round(s.CPU_TIME / nullif(s.ELAPSED_TIME, 0) * 100, 2) cpu_time_pct,
round(s.PHYSICAL_READ_BYTES / nullif(s.EXECUTIONS, 0) / 1024 / 1024, 2) pio_per_exec_mb,
round(s.PHYSICAL_READ_BYTES / nullif(s.PHYSICAL_READ_REQUESTS, 0), 2) / 1024 read_per_request_kbytes,
round(s.buffer_gets / nullif(s.executions, 0), 4) BufferGets_per_Exec
s.executions,
to_char(s.last_active_time,'dd/mm/yyyy hh24:mi:ss') last_act_time,
s.first_load_time,
s.sql_fulltext,
s.sql_profile,
s.sql_patch,
s.sql_plan_baseline
FROM gv$sql s
WHERE 1=1
and s.parsing_schema_name in ('LIST OF DATABASE USERS YOU WANT TO MONITOR')
order by s.last_active_time desc;
`
It would give a good perspective of how well your doing based in your average thresholds.

Related

ORACLE Program code to use filter and pivot table

IN EXCEL SHEET FOR THE BELOW INPUT, I HAVE TO USE FILTER TO “NET” FIRST WHERE NET=APB AND NEED TO FILTER “CODE VALUES” AS WDL, LRTF & NEED TO USE “PIVOT TABLE” TO GET OUTPUT WITH COUNT AS:
BUT I NEED CODE IN ORACLE TO RUN FOR THE FOLLOWING OUTPUT:-
INPUT:
STTID
AMOUNT
NET
CODE
SVPC12309A
5000
NFS
SOP
SVPC12309A
10000
NFS
WDL
000DHP11291
2500
APB
WDL
SVPC12309A
3000
CMV
LRTF
SVPC12309A
3000
CMV
WDL
DHP12341
4500
APB
LRTF
DHP23451
9500
APB
LRTF
DHP12341
5500
APB
LRTF
OUTPUT AS:
STTID
LRTF
WDL
TOTAL
000DHP11291
0
1
1
DHP12341
2
0
2
DHP23451
1
0
1
It appears you want something like
select sttid,
sum( case when code = 'LRTF' then 1 else 0 end ) ltrf,
sum( case when code = 'WDL' then 1 else 0 end ) wdl,
sum( case when code in ('WDL', 'LTRF') then 1 else 0 end) total
from your_table_name
group by sttid

In mrskew, can I calculate human readable timestamps from tim?

I'm using mrskew by Method-R to analyze Oracle SQL Trace files.
I want to list all database calls similar to the output of calls.rc
But instead of the value of $tim, I'd print a human readable date format.
Raw data (minimal obfuscated):
*** 2020-11-26 10:06:01.867
*** SESSION ID:(1391.49878) 2020-11-26 10:06:01.867
*** CLIENT ID:() 2020-11-26 10:06:01.867
*** SERVICE NAME:(SYS$USERS) 2020-11-26 10:06:01.867
*** MODULE NAME:(JDBC Thin Client) 2020-11-26 10:06:01.867
*** CLIENT DRIVER:(jdbcthin : 12.2.0.1.0) 2020-11-26 10:06:01.867
*** ACTION NAME:() 2020-11-26 10:06:01.867
...
WAIT #0: nam='SQL*Net message from client' ela= 491 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=12568091328841
=====================
PARSING IN CURSOR #18446744071522016088 len=71 dep=0 uid=88 oct=7 lid=88 tim=12568091329190 hv=2304270232 ad='61e4d11e0' sqlid='5kpbj024phrws'
/*Begin.Work*/
SELECT ...
END OF STMT
PARSE #18446744071522016088:c=147,e=148,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=957996380,tim=12568091329190
...
EXEC #18446744071522016088:c=683,e=11406,p=0,cr=2,cu=11,mis=0,r=1,dep=0,og=1,plh=957996380,tim=12568091341788
CLOSE #18446744071522016088:c=27,e=27,dep=0,type=1,tim=12568091343665
XCTEND rlbk=0, rd_only=0, tim=12568091343769
Current output (compacted for readability):
END-TIM LINE SQL_ID CALL-NAME STATEMENT-TEXT
-----------------------------------------------------------------------------
12568091.341788 36 5kpbj024phrws EXEC /*Begin.Work*/ SELECT ...
12568091.343769 42 XCTEND
Expected output (please don't cricicise my not correct subsecond calculation):
END-TIME LINE SQL_ID CALL-NAME STATEMENT-TEXT
-----------------------------------------------------------------------
2020-11-26 10:06:01.341788 36 5kpbj024phrws EXEC /*Begin.Work*/ SELECT ...
2020-11-26 10:06:01.343769 42 XCTEND
I assume I can use POSIX:strftime to format the timestamp properly, but I need a way to generate an epoch timestamp from the timestamp at the begin of the tracefile
*** 2020-11-26 10:06:01.867
and then an offset for each $tim relative to this begin of tracefile.
I hope methodr toolset can provide this. It should be easier for me to explain, when (in human readable form) which activity started.
Generating an epoch seconds number from a string date is simple enough. Time::Local has functions to do it.
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use Time::Local 'timelocal_posix';
my $date = '2020-11-26 10:06:01.867';
# Split the date apart
my ($yr, $mon, $day, $hr, $min, $sec, $micro) = split /[- :.]/, $date;
# Note necessary adjustments to month and year
say timelocal_posix($sec, $min, $hr, $day, $mon - 1, $yr - 1900);
With the help of comments by #DaveCross and #CaryMillsap my processing is now:
from the tracefile create an intermediate file similar to
*** 2020-11-26 10:06:01.867
END-TIM LINE SQL_ID CALL-NAME STATEMENT-TEXT
-----------------------------------------------------------------------------
XCTEND tim=12568091341788 e=2 dep=0 36 5kpbj024phrws EXEC /*Begin.Work*/ SELECT ..
XCTEND tim=12568091343769 e=1 dep=0 42 XCTEND
using in calls.rc
sprintf("XCTEND tim=%-20d e=%-5d dep=0 %10d %10d %10d %13s %-40.40s %-.46s", $tim*1000000, $line,($e+$ela)*1000000, $parse_id, $exec_id, $sqlid, "· "x$dep.$name.(scalar(#bind)?"(".join(",",#bind).")":""), "· "x$dep.$sql)
modify the result to have somewhere on top
*** 2020-11-26 10:06:01.867
process this file with mrwhen
get rid of unwantent parts by
sed -E 's/XCTEND t.{37}//'
In more detail it's documented here.

dbms_alert Polling intervals

Explain, please, here this paragraph from the documentation
WAITANY procedure. If you use the WAITANY procedure, and if a signalling session does a signal but does not commit within one second of the signal, a polling loop is required so that this uncommitted alert does not camouflage other alerts. The polling loop begins at a one second interval and exponentially backs off to 30-second intervals.
I correctly understand that here it is said that when WAITANY is called on the server, the thread queries the presence of events at certain intervals? And if I called WAITANY with a sufficiently long timeout, when an event occurs, will I be notified only after the current request interval expires? Those. on the server is about like this code
function WaitAny(ATimeout) {
const intervals = [0, 1, ....., 30);
for (i = 0; i < intervals.length; i++) {
Sleep(min(intervals[i], ATimeout))
if (IsExistsEvents())
return 0;
ATimeout -= intervals[i];
if (ATimeout <= 0)
return 1;
}
maxInterval = intervals[intervals.length - 1];
while (ATimeout > 0) {
Sleep(min(maxInterval, ATimeout))
if (IsExistsEvents())
return 0;
ATimeout -= maxInterval;
}
return 1;
}
No, it will still be "immediate".
When someones signals an alert, it will flick out a pipe message (a non-transactional blip) which the waiter will see. But of course, the waiter has not "officially" received the alert until the signaller commits.
So the waiter gets the blip, then waits on a lock (alerts are implemented with Oracle's standard locking mechanism). Because we're expecting the commit to come quickly.
If it doesn't, that's a problem because what if we get a signal from a different alert (because we are doing a WAITANY here). So when that commit does not come, we'll acquiesce and do the exponential backoff. But it is not "check for the alert at 1, 2, 4, etc seconds", it is "re-enter the wait for lock state every 1,2,4, ...seconds". So when that commit comes, we'll pretty much see it straightaway.
For example, I traced a 2 minute wait on an alert from someone who signaled but did not commit
declare
n varchar2(100);
m varchar2(100);
s int;
begin
dbms_alert.WAITANY(n,m,s);
end;
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 127.49 0 0 0 1
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 127.50 0 0 0 1
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 107
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
enq: UL - contention 9 32.01 127.47
log file sync 1 0.00 0.00
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 0.00 0.00
********************************************************************************
You can see the 2 minute wait was almost all on lock waits.

Generate random sequence in Oracle

I am trying to generate random numbers into 2 columns where the first column is from_number and second column in to_number.
My query looks as following
select to_char(5001 + (level-1)),
to_char(5005 + (level-1))
from dual
connect by level <= 100;
My output is for the above query is:
5001 5005
5002 5006
5003 5007
5004 5008
5005 5009
and so on...
But my output should be like following:
5001 5005
5006 5010
5011 5015
5016 5020
and so on...
The second-row 'from_number' should be the first-row 'to_number'+1
How can achieve this?
Thanks in advance.
Note that what you are using here is not a random sequence. It is a fixed sequence. To know how to generate random number read this
Now coming back to your question, you can do it by playing a little with level. Note I reduced the <=100 to <=20 as we are using a multiplier of 5 so the maximum value you will get is 5005 + 20*5 - 5 = 6000. Change it back to <=100 if you want total of 100 rows.
select
to_char(5001 + (level*5) - 5 ),
to_char(5005 + (level*5) - 5)
from dual
connect by level <= 20;

Deadlock in Oracle 3

I have found following errors on Oracle..
I cant understand what is happening here.
Cant understand which session is waiting for what....
Also is it about Raw level lock or something?
Can anyone please help me?
*** 2015-03-10 10:23:30.288
DEADLOCK DETECTED ( ORA-00060 )
[Transaction Deadlock]
The following deadlock is not an ORACLE error. It is a
deadlock due to user error in the design of an application
or from issuing incorrect ad-hoc SQL. The following
information may aid in determining the deadlock:
Deadlock graph:
---------Blocker(s)-------- ---------Waiter(s)---------
Resource Name process session holds waits process session holds waits
TX-001c0006-0000a440 94 2903 X 123 2284 X
TX-001d0011-0000fac7 123 2284 X 94 2903 X
session 2903: DID 0001-005E-00018DE5 session 2284: DID 0001-007B-0001863D
session 2284: DID 0001-007B-0001863D session 2903: DID 0001-005E-00018DE5
Rows waited on:
Session 2903: obj - rowid = 0001285E - AAASheAAIAABMBIAAV
(dictionary objn - 75870, file - 8, block - 311368, slot - 21)
Session 2284: obj - rowid = 0001285E - AAASheAAIAABL9/AAq
(dictionary objn - 75870, file - 8, block - 311167, slot - 42)
----- Information for the OTHER waiting sessions -----
Session 2284:
sid: 2284 ser: 207 audsid: 2893404 user: 87/ESS_ADMIN flags: 0x45
pid: 123 O/S info: user: oracle, term: UNKNOWN, ospid: 3209
image: oracle#pbifmsdb2
client details:
O/S info: user: root, term: unknown, ospid: 1234
machine: pbifmsapp2 program: JDBC Thin Client
application name: JDBC Thin Client, hash value=2546894660
current SQL:
UPDATE SEC_LOGIN_AUDIT SET LOGOUT_TIME= SYSDATE,LOGOUT_TYPE=:1 ,LST_UPDT_DT= SYSDATE WHERE UPPER(USER_NAME) IN UPPER(:2 ) AND LOGOUT_TYPE IS NULL AND TRUNC(LOGIN_DATE_TIME) BETWEEN TRUNC(SYSDATE)-1 AND TRUNC(SYSDATE)
----- End of information for the OTHER waiting sessions -----
Information for THIS session:
----- Current SQL Statement for this session (sql_id=cm6x9vt91y3v3) -----
UPDATE SEC_LOGIN_AUDIT SET LOGOUT_TIME= SYSDATE,LOGOUT_TYPE=:1 ,LST_UPDT_DT= SYSDATE WHERE UPPER(USER_NAME) IN UPPER(:2 ) AND LOGOUT_TYPE IS NULL AND TRUNC(LOGIN_DATE_TIME) BETWEEN TRUNC(SYSDATE)-1 AND TRUNC(SYSDATE)
===================================================
PROCESS STATE
-------------
Process global information:
process: 0xc000001154e37f70, call: 0xc00000113a5ee668, xact: 0xc0000011489d4808, curses: 0xc0000011598a5760, usrses: 0xc0000011598a5760
----------------------------------------
SO: 0xc000001154e37f70, type: 2, owner: 0x0000000000000000, flag: INIT/-/-/0x00 if: 0x3 c: 0x3
proc=0xc000001154e37f70, name=process, file=ksu.h LINE:11459 ID:, pg=0
(process) Oracle pid:94, ser:1, calls cur/top: 0xc00000113a5ee668/0xc00000113a5ee668
flags : (0x0) -
flags2: (0x0), flags3: (0x0)
intr error: 0, call error: 0, sess error: 0, txn error 0
intr queue: empty
ksudlp FALSE at location: 0
(post info) last post received: 134 0 2
last post received-location: ksl2.h LINE:2165 ID:kslpsr
last process to post me: c00000115cda7358 10 6
last post sent: 0 0 26
last post sent-location: ksa2.h LINE:282 ID:ksasnd
last process posted by me: c00000115cda7358 10 6
(latch info) wait_event=0 bits=0
Process Group: DEFAULT, pseudo proc: 0xc000001170f9b220
O/S info: user: oracle, term: UNKNOWN, ospid: 9438
OSD pid info: Unix process pid: 9438, image: oracle#pbifmsdb2
Dump of memory from 0xC000001154DE40C8 to 0xC000001154DE42D0
C000001154DE40C0 00000000 00000000 [........]
C000001154DE40D0 00000000 00000000 00000000 00000000 [................]
Repeat 31 times
(FOB) flags=2066 fib=c000001173a56518 incno=0 pending i/o cnt=0
fname=/iwdmsdata/PIWDMS/DATA/ess_data.dbf
fno=8 lblksz=8192 fsiz=339200
(FOB) flags=2066 fib=c000001173a55900 incno=0 pending i/o cnt=0
fname=/iwdmsdata/PIWDMS/DATA/iwas_data.dbf
fno=6 lblksz=8192 fsiz=3678848
(FOB) flags=2050 fib=c000001173a58348 incno=0 pending i/o cnt=0
fname=/iwdmsdata/PIWDMS/DATA/temp01.dbf
fno=201 lblksz=8192 fsiz=4194176
(FOB) flags=2050 fib=c000001173a56518 incno=0 pending i/o cnt=0
fname=/iwdmsdata/PIWDMS/DATA/ess_data.dbf
fno=8 lblksz=8192 fsiz=339200
(FOB) flags=2050 fib=c000001173a546d0 incno=0 pending i/o cnt=0
fname=/iwdmsdata/PIWDMS/DATA/undotbs01.dbf
fno=3 lblksz=8192 fsiz=231040
(FOB) flags=2050 fib=c000001173a55f00 incno=0 pending i/o cnt=0
fname=/iwdmsdata/PIWDMS/DATA/iwas_index.dbf
fno=7 lblksz=8192 fsiz=470400
(FOB) flags=2050 fib=c000001173a55900 incno=0 pending i/o cnt=0
fname=/iwdmsdata/PIWDMS/DATA/iwas_data.dbf
fno=6 lblksz=8192 fsiz=3678848
(FOB) flags=2050 fib=c000001173a53ab8 incno=0 pending i/o cnt=0
fname=/iwdmsdata/PIWDMS/DATA/system01.dbf
fno=1 lblksz=8192 fsiz=204800
----------------------------------------
SO: 0xc0000011598a5760, type: 4, owner: 0xc000001154e37f70, flag: INIT/-/-/0x00 if: 0x3 c: 0x3
proc=0xc000001154e37f70, name=session, file=ksu.h LINE:11467 ID:, pg=0
(session) sid: 2903 ser: 7 trans: 0xc0000011489d4808, creator: 0xc000001154e37f70
flags: (0x45) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
flags2: (0x40008) -/-
DID: , short-term DID:
txn branch: 0xc00000114052f870
oct: 6, prv: 0, sql: 0xc00000116796d070, psql: 0xc0000011675cd1f0, user: 87/ESS_ADMIN
ksuxds FALSE at location: 0
service name: SYS$USERS
client details:
O/S info: user: root, term: unknown, ospid: 1234
machine: pbifmsapp2 program: JDBC Thin Client
application name: JDBC Thin Client, hash value=2546894660
Current Wait Stack:
0: waiting for 'enq: TX - row lock contention'
name|mode=0x54580006, usn<<16 | slot=0x1d0011, sequence=0xfac7
wait_id=471131 seq_num=12392 snap_id=1
wait times: snap=3.004466 sec, exc=3.004466 sec, total=3.004466 sec
wait times: max=1 min 0 sec, heur=3.004466 sec
wait counts: calls=1 os=1
in_wait=1 iflags=0x15a0
There is at least one session blocking this session.
Dumping 1 direct blocker(s):
inst: 1, sid: 2284, ser: 207
Dumping final blocker:
inst: 1, sid: 2284, ser: 207
Wait State:
fixed_waits=0 flags=0x22 boundary=0x0000000000000000/-1
Session Wait History:
elapsed time of 1.625218 sec since current wait
0: waited for 'SQL*Net message from client'
driver id=0x74637000, #bytes=0x1, =0x0
wait_id=471130 seq_num=12391 snap_id=1
wait times: snap=0.000630 sec, exc=0.000630 sec, total=0.000630 sec
wait times: max=infinite
wait counts: calls=0 os=0
occurred after 0.000003 sec of elapsed time
1: waited for 'SQL*Net message to client'
driver id=0x74637000, #bytes=0x1, =0x0
wait_id=471129 seq_num=12390 snap_id=1
wait times: snap=0.000000 sec, exc=0.000000 sec, total=0.000000 sec
wait times: max=infinite
wait counts: calls=0 os=0
occurred after 0.000039 sec of elapsed time
2: waited for 'SQL*Net message from client'
driver id=0x74637000, #bytes=0x1, =0x0
wait_id=471128 seq_num=12389 snap_id=1
wait times: snap=0.002370 sec, exc=0.002370 sec, total=0.002370 sec
wait times: max=infinite
wait counts: calls=0 os=0
occurred after 0.000001 sec of elapsed time
3: waited for 'SQL*Net message to client'
driver id=0x74637000, #bytes=0x1, =0x0
wait_id=471127 seq_num=12388 snap_id=1
wait times: snap=0.000001 sec, exc=0.000001 sec, total=0.000001 sec
wait times: max=infinite
wait counts: calls=0 os=0
occurred after 0.000069 sec of elapsed time
4: waited for 'SQL*Net message from client'
driver id=0x74637000, #bytes=0x1, =0x0
wait_id=471126 seq_num=12387 snap_id=1
wait times: snap=0.000659 sec, exc=0.000659 sec, total=0.000659 sec
wait times: max=infinite
wait counts: calls=0 os=0
occurred after 0.000004 sec of elapsed time
5: waited for 'SQL*Net message to client'
driver id=0x74637000, #bytes=0x1, =0x0
wait_id=471125 seq_num=12386 snap_id=1
wait times: snap=0.000001 sec, exc=0.000001 sec, total=0.000001 sec
wait times: max=infinite
wait counts: calls=0 os=0
occurred after 0.001259 sec of elapsed time
6: waited for 'SQL*Net message from client'
driver id=0x74637000, #bytes=0x1, =0x0
wait_id=471124 seq_num=12385 snap_id=1
wait times: snap=0.000447 sec, exc=0.000447 sec, total=0.000447 sec
wait times: max=infinite
wait counts: calls=0 os=0
occurred after 0.000036 sec of elapsed time
7: waited for 'SQL*Net message to client'
driver id=0x74637000, #bytes=0x1, =0x0
wait_id=471123 seq_num=12384 snap_id=1
wait times: snap=0.000006 sec, exc=0.000006 sec, total=0.000006 sec
wait times: max=infinite
wait counts: calls=0 os=0
occurred after 1.741446 sec of elapsed time
8: waited for 'SQL*Net message from client'
driver id=0x74637000, #bytes=0x1, =0x0
wait_id=471122 seq_num=12383 snap_id=1
wait times: snap=0.001060 sec, exc=0.001060 sec, total=0.001060 sec
wait times: max=infinite
wait counts: calls=0 os=0
occurred after 0.000002 sec of elapsed time
9: waited for 'SQL*Net message to client'
driver id=0x74637000, #bytes=0x1, =0x0
wait_id=471121 seq_num=12382 snap_id=1
wait times: snap=0.000001 sec, exc=0.000001 sec, total=0.000001 sec
wait times: max=infinite
wait counts: calls=0 os=0
occurred after 0.000038 sec of elapsed time
Sampled Session History of session 2903 serial 7
---------------------------------------------------
The sampled session history is constructed by sampling
the target session every 1 second. The sampling process
captures at each sample if the session is in a non-idle wait,
an idle wait, or not in a wait. If the session is in a
non-idle wait then one interval is shown for all the samples
the session was in the same non-idle wait. If the
session is in an idle wait or not in a wait for
consecutive samples then one interval is shown for all
the consecutive samples. Though we display these consecutive
samples in a single interval the session may NOT be continuously
idle or not in a wait (the sampling process does not know).
The history is displayed in reverse chronological order.
sample interval: 1 sec, max history 120 sec
---------------------------------------------------
[3 samples, 10:23:27 - 10:23:29]
waited for 'enq: TX - row lock contention', seq_num: 12392
p1: 'name|mode'=0x54580006
p2: 'usn<<16 | slot'=0x1d0011
p3: 'sequence'=0xfac7
time_waited: >= 2 sec (still in wait)
[3 samples, 10:23:24 - 10:23:26]
not in wait at each sample
[13 samples, 10:23:11 - 10:23:23]
idle wait at each sample
[1 sample, 10:23:10]
not in wait at each sample
[8 samples, 10:23:02 - 10:23:09]
idle wait at each sample
[2 samples, 10:23:00 - 10:23:01]
not in wait at each sample
[5 samples, 10:22:54 - 10:22:59]
idle wait at each sample
[2 samples, 10:22:52 - 10:22:53]
not in wait at each sample
[1 sample, 10:22:51]
idle wait at each sample
[1 sample, 10:22:50]
not in wait at each sample
[2 samples, 10:22:48 - 10:22:49]
idle wait at each sample
[2 samples, 10:22:46 - 10:22:47]
not in wait at each sample
[9 samples, 10:22:37 - 10:22:45]
idle wait at each sample
[2 samples, 10:22:35 - 10:22:36]
not in wait at each sample
[1 sample, 10:22:34]
idle wait at each sample
[2 samples, 10:22:32 - 10:22:33]
not in wait at each sample
[1 sample, 10:22:31]
idle wait at each sample
[1 sample, 10:22:30]
not in wait at each sample
[1 sample, 10:22:29]
idle wait at each sample
[2 samples, 10:22:27 - 10:22:28]
not in wait at each sample
[1 sample, 10:22:26]
idle wait at each sample
[1 sample, 10:22:25]
waited for 'db file scattered read', seq_num: 9258
p1: 'file#'=0x6
p2: 'block#'=0x1fecd0
p3: 'blocks'=0x4
time_waited: 0.007933 sec (sample interval: 0 sec)
[5 samples, 10:22:20 - 10:22:24]
idle wait at each sample
[4 samples, 10:22:16 - 10:22:19]
not in wait at each sample
[3 samples, 10:22:13 - 10:22:15]
idle wait at each sample
[2 samples, 10:22:11 - 10:22:12]
not in wait at each sample
[7 samples, 10:22:04 - 10:22:10]
idle wait at each sample
[6 samples, 10:21:58 - 10:22:03]
not in wait at each sample
[30 samples, 10:21:30 - 10:21:57]
idle wait at each sample
---------------------------------------------------
Sampled Session History Summary:
longest_non_idle_wait: 'enq: TX - row lock contention'
[3 samples, 10:23:27 - 10:23:29]
time_waited: >= 2 sec (still in wait)
Can anyone please help me?
You have had two session that each waited for a resource that was held by the other session.
For example:
Session 1
update table_ .... where x = 100;
Session 1 has now locked the record x=100. No other session can modify this record until Session1 either commits or rolls back (that is: ends the transaction).
Session 2
update table_ .... where x = 200;
Session 2 has now locked the record x=200.
Then, still session 2:
update table_ .... where x=100;
Since Session 1 has locked that record, this statement will wait until it can do the modification (that is, until Session 1 end its transaction).
Session 1
update table_ .... where x=200;
Now, this is the deadlock. Since x=200 is locked by Session 2, Session 1 cannot proceed until the transaction of Session 2 ends. But Session 2 cannot proceed because it is also waiting for Session 1.
Hence the Deadlock Error ORA-00060.

Resources