Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Suren.

Asked: September 22, 2002 - 1:23 am UTC

Last updated: April 27, 2005 - 8:14 am UTC

Version: 8.1.7.2

Viewed 1000+ times

You Asked

Greetings Tom,

I have come across the following scenario. I would appreciate if you can give a detailed explanation of what exactly is happening.

We have requests from 5 different webservers coming into a single database which uses both JDBC & ODBC.The Web connections use one common username/password to access the database. Every night we have a load process which runs against the database during which the application team doesn`t want any requests coming to the database. So what they do is lock the user by changing the password.

Sometimes a number of users try to feed in data during this loading time. Now each time a request from any of the Webserver comes to the database during the loading process, a server process is created and just sits there in an idle state.Each request might even create multiple processes.

The database is configured for a maximum processes of 100 in a dedicated server mode. Atleast once in a month they reach the max processes for the database and the load process fails because it is unable to create a new process when required.The load process runs in four parallel sessions and goes to a maximum of 15 process at any given time.

According to Oracle, a Server process is created only when a connection is established. I reconfirmed this with the following shell script.

#!/bin/ksh
cmd1="/usr/local/oracle/product/8.1.7/bin/sqlplus"
cmd2="test1/testconn@DAD1"
count=0
echo " Script Started" >/var/tmp/xyz
while test $count -lt 10
do
let count=$count+1
echo $count
$cmd1 $cmd2 >>/var/tmp/xyz 2>&1 &
echo "$cmd1 $cmd2 --->step $count "
done
echo " Script Ended" >>/var/tmp/xyz

I could`nt see any server processes created for the above script, because the connection was not established.


Here is my listener.ora file
################
# Filename......: listener.ora
# Name..........: test1.world
# Date..........: 13-AUG-02 15:14:25
################
SQLNET.AUTHENTICATION_SERVICES = (NONE)

USE_PLUG_AND_PLAY_LSNR234 = OFF
USE_CKPFILE_LSNR234 = OFF
LSNR234 =
(ADDRESS_LIST =
(ADDRESS=
(PROTOCOL=IPC)
(KEY= DAD1.world)
)
(ADDRESS=
(PROTOCOL=IPC)
(KEY= DAD1)
)
(ADDRESS=
(PROTOCOL=IPC)
(KEY= DAD2.world)
)
(ADDRESS=
(PROTOCOL=IPC)
(KEY= DAD2)
)
(ADDRESS =
(COMMUNITY = TCP.world)
(PROTOCOL = TCP)
(Host = TEST1)
(Port = 1522)
)
)
STARTUP_WAIT_TIME_LSNR234 = 0
CONNECT_TIMEOUT_LSNR234 = 10
TRACE_LEVEL_LSNR234 = OFF
SID_LIST_LSNR234 =
(SID_LIST =
(SID_DESC =

(GLOBAL_DBNAME = DAD1.world)
(SID_NAME = DAD1)
(ORACLE_HOME = /usr/local/oracle/product/8.1.7)
(PRESPAWN_MAX = 10)
)
(SID_DESC =

(GLOBAL_DBNAME = DAD2.world)
(SID_NAME = DAD2)
(ORACLE_HOME = /usr/local/oracle/product/8.1.7)
(PRESPAWN_MAX = 10)
)
)


Here is my Sqlnet.ora

################
# Filename......: sqlnet.ora
# Name..........: TCP.world
# Date..........: 05-AUG-02 14:22:30
################
AUTOMATIC_IPC = ON
TRACE_LEVEL_CLIENT = OFF
SQLNET.EXPIRE_TIME = 10
NAMES.DEFAULT_DOMAIN = world
NAME.DEFAULT_ZONE = world
SQLNET.CRYPTO_SEED = "xyz"
BEQUEATH_DETACH=yes
~

I know this problem can be fixed by the application/web team by providing time out sessions to the request.I suppose they are already working on it.

But my question is

# 1: "WHY" are the server processes created when requests to the
database are coming from the Webserver, eventhough that particular
user`s password is changed and there is no connection established
to the database. ( Tom i would appreciate if you can give a
detailed explanation for this question )

# 2: What would be the ideal way for a dba to restrict or clean up
such idle server processes.


Thanks in advance,
Suren

and Tom said...

1) a login to Oracle is a two step process

a) physical connection -- sets up the network path from client to server. A process is created at this point. You are not logged in but v$process has an entry for you.

b) authentication -- sets up a session (and a single process, a single physical conection can have many sessions in it). Now an entry (or more then one if you use more then one session) is made in v$session for you.


So, it sounds like you are getting connected but during the authenticate stage -- they are failing and not closing the connection. I'd be looking to the client code to see if they cleanup after a failure (and make sure you are using current jdbc drivers and such).


Now, using the 8174 jdbc THICK and THIN drivers, I was not able to reproduce this. It will be a function of the drivers you are using and how they were coded.

I used:

import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;


class test
{

public static void main(String args[])throws Exception
{
DriverManager.registerDriver
(new oracle.jdbc.driver.OracleDriver());


try
{
Connection conn=DriverManager.getConnection
("jdbc:oracle:oci8:@ora817dev","scott", "tigerx");
//("jdbc:oracle:thin:@aria-dev:1521:ora817dev" ,"scott","tiger");
}
catch (SQLException e)
{
System.out.println(e.toString());
}
System.out.println("Sleeping 30 seconds" );
java.lang.Thread.sleep( 30 * 1000 );
}

}

as a simple test program. When connected -- process (i saw it with ps). When not connected, the process went away (i saw it come and go every now and then with:

while(1)
ps -auxww | grep ora817dev | tee trace
end

(ora817dev was my sid). If you run that with your drivers and the process doesn't go away, it is a problem with that driver. If you are using connection pooling and other advanced features, make sure to use that in the test program.



Another way -- that would PRECLUDE these processes -- would be the simply shutdown the listener. Then, they have NO WAY to create a process (and you don't have to do any DDL to alter the users password).




Rating

  (4 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Idle Server Processes

Suren, September 23, 2002 - 10:51 am UTC

Tom,

1) Do you mean to say that a server(unix) process would be
created even when the authentication fails and if the
code doesn`t close the connection it would remain there
sitting in an idle state. ???

2) If yes, how would the DCD( Dead Client Detection ) work
for my scenario.

Thanks,
Suren



Tom Kyte
September 23, 2002 - 1:11 pm UTC

1) in order to authenticate -- you need a process! so yes, process created AND THEN authentication.

The code *should not* have to close the connection (in fact, the connection object doesn't even get returned to me for closing using the 8174 jdbc drivers from oracle)

I cannot replicate your issue using our jdbc drivers -- can you?

2) it would not, that cleans up a session, you don't have a session.

single process , multiple sessions ?

Ram, September 24, 2002 - 3:00 am UTC

Hello Tom,

This particular sentence is confusing - 'a process is created before authentication and a session is established after being authenticated. a process can have multiple sessions'.

how can a single process support multiple sessions ?
a client (lets say , sqlplus) gets connected to the server (for the very first time ) - a session is established.

now, if i open another sqlplus and connect , will that be a separate session but with the same process ? how ?
does this mean that the process part is client terminal driven ? that is, a client terminal to the server is a single process where as client appls getting connected to the server is multiple sessions.

i am missing something here.


Tom Kyte
September 24, 2002 - 7:41 am UTC

A single client program CAN if it wants, open more then one session.

SQLPlus does this when you set autotrace on for example. The V$ queries are executed in ANOTHER SESSION so as to not affect the V$ queries themselves.

If you fire up sqlplus two times tho -- you'll have two processes, two sessions.

If you are writing your OWN program, you can fire up multiple sessions on the same physical connection -- if you want.

Good to know

Kees Oskam, December 17, 2003 - 1:46 pm UTC

I was looking for situations where one process could have more than one session. Well, this clearly answers it. Now I want to find out how PGA memory is alloceted to processes versus sessions. That part is not yet clear to me.

Tom Kyte
December 18, 2003 - 8:48 am UTC

PGA is process memory -- meaning, allocated in a process. Session memory may be allocated in a processes PGA (dedicated server more) or in the SGA (shared server mode).

Both modes interestingly allow a single process to have more then one session ;)

I still have a question...

Kumar, April 27, 2005 - 7:07 am UTC

I am using Oracle jdbc thin driver 817. I have tested the program you have given in the explination with a small change. I have stoped the oracle using svrmgrl> shutdown immediate.
Now till the program exits the process hang. I have seen using ps -ef | grep shyam

(where shyam is my sid)

Why is it so? When DriverManager.getConnection fails with ORA-01034 and fails to get connection, should it not clean the process it has started. Only when the program exits the processes gets cleaned up.



Tom Kyte
April 27, 2005 - 8:14 am UTC

the act of connecting to a database involves a couple of steps, you can be connected without any sessions, you can have a single connection with many sessions, you can even have a session without a connection.

The act of trying to connect to a database instance creates the process, until you totally disconnect from there, it will remain.