|
Part of my job as an Oracle Database administrator is to help resolve problems that people are experiencing. Periodically, I'll receive calls from someone whose Oracle session has gone to never-never land, and they are just hanging around, waiting for it to come back. Well, maybe not actually hanging around, but impatiently waiting for their PC to respond.
The cause of this condition is often varied, ranging anywhere from problems with the PC, with Windows, the network, the file-server, the database-server, and of course, the database itself. (This is by no means a complete list of causes, rather it is an illustration to show the diversity of reasons.)
As an Oracle DBA, it is my job to determine if the problem is related to the Oracle database. Just by attempting to connect to the database with SQL*Plus for Windows, much can be discovered about the problem. For example, if a connection is made, then we know that part of the network and the database server are working okay. We also know that the database and the SQL*Net listener are up and running. If the connection failed, we would begin researching those items just mentioned (the network, the database server, the listener, and the database) to see if one had problems.
Assuming a connection to the database can be made, the next step would be to run a script called sessions.sql. This script, which I created initially for Oracle 7.1, provides quite a bit of information about the different sessions connected to the Oracle database, including: the username, status, type of session (shared or dedicated), number of open cursors, and time connected. Most important to the situation being researched are three columns: Status, Lck, and Lat. These columns tell us what, if anything, is holding the session up in the database.
If there is an X in the Lck column, you can begin researching application locking issues. If there is an X in the Lat column, you can begin researching contention for system resources. If the column Status is ACTIVE (while Lck and Lat are blank), then the session is busy doing work, and you can look into performance issues. Finally, if the column Status is INACTIVE, then session is not doing any work, and the problem is probably outside of the database.
Figure 1. Sessions.sql script:
-- This script describes the current sessions connected
-- to the instance.
--
-- J. Lopatosky March 1996
-- J. Lopatosky April 1997, Modified for connect time, cursors
--
clear columns
clear breaks
clear computes
| column |
sid |
format |
99999 |
heading |
"SID" |
| column |
serial# |
format |
99999 |
heading |
"Srl #" |
| column |
cursors |
format |
99999 |
heading |
"OpCsr" |
| column |
username |
format |
a12 |
heading |
"Username" |
| column |
Status |
format |
a08 |
heading |
"status" |
| column |
server |
format |
a10 |
heading |
"ServerType" |
| column |
locked |
format |
a03 |
heading |
"Lck |
| column |
latched |
format |
a03 |
heading |
"Lat" |
| column |
machine |
format |
a10 |
heading |
"Machine" |
| column |
terminal |
format |
a10 |
heading |
"Terminal" |
| column |
cprogram |
format |
a27 |
heading |
"Client Program" |
| column |
sprogram |
format |
a27 |
heading |
"RDBMS Process" |
| column |
connect_date |
format |
a17 |
heading |
"Connect Time" |
select a.sid,
a.serial#,
a.username,
count(c.user_name) cursors,
a.status,
a.server,
to_char(a.logon_time,'yyyy-mm-dd hh24:mi') connect_date,
decode(a.lockwait,null,' ','x') locked,
decode(b.latchwait,null,' ','x') latched,
b.program sprogram,
a.program cprogram,
a.machine,
a.terminal
from v$session a,
v$process b,
v$open_cursor c
where a.paddr = b.addr
and a.saddr = c.saddr (+)
group by a.sid, a.serial#, a.username, a.status, a.server,
a.logon_time, a.lockwait, b.latchwait, b.program, a.program,
a.machine, a.terminal
;
Figure 2. Sample output of sessions.sql script:
| SID |
SRL # |
Username |
OpCsr Status |
ServerType |
Connect Time |
Lck Lat RDBMS Process |
Client Program |
Machine |
Terminal |
| 1 |
1 |
|
O Active |
Dedicated |
1997-11-10 03:38 |
oracle@bisprod(PMON) |
oracle@bisproc(PMON) |
bisprod |
? |
| 2 |
1 |
|
0 Active |
Dedicated |
1997-11-10 03:48 |
oracle@bisprod (DBWR) |
oracle@bisprod (DBWR) |
bisprod |
? |
| 3 |
1 |
|
0 Active |
Dedicated |
1997-11-10 03:48 |
oracle@bisprod (LGWR) |
oracle@bisprod (LGWR) |
bisprod |
? |
| 4 |
1 |
|
0 Active |
Dedicated |
1997-11-10 03:48 |
oracle@bisprod (CKPT) |
oracle@bisprod (CKPT) |
bisprod |
? |
| 5 |
1 |
|
0 Active |
Dedicated |
1997-11-10 03:48 |
oracle@bisprod (SMON)> |
oracle@bisprod (SMON) |
bisprod |
? |
| 6 |
1 |
|
0 Active |
Dedicated |
1997-11-10 03:48 |
oracle@bisprod (RECO) |
oracle@bisprod (RECO) |
bisprod |
? |
| 11 |
47 |
TESTDBA |
2 Active |
Shared |
1997-11-10 21:46 |
oracle@bisprod (S000) |
PLUS33W.EXE |
CCJLOPA |
Windows 95 |
| 13 |
28 |
USER01 |
2 Inactive |
None |
1997-11-10 08:48 |
oracle@bisprod (D004) |
Q:\GQL\GQLEN333.DLL |
|
Windows PC |
8 rows selected.
|