Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, lynxx.

Asked: May 27, 2008 - 5:03 pm UTC

Last updated: November 29, 2011 - 11:39 am UTC

Version: 10.2.0

Viewed 10K+ times! This question is

You Asked

Hi Tom,

I have seen people using scripts to clean the sessions which are idle from last x hours.
My expression is to use idle limit in profile and oracle would terminate
that session.

I have had discussion with DBA and he said - this option would release the resource/locks but will not decrese the no. of session as sometime we do this
just prevent to reach the max limit of processes.

Is this true that the session disconnected/cleand by profile would not decrease the no. of sessions/processes and we have to have some os job to kill the sessions explicitly?

Regards,
Lyxx

and Tom said...

If your session gets sniped by an idle timeout we

a) release the locks and other resources
b) keep the session
c) until the client application touches the database - then the client immediately gets ora-28, you have been killed and then the session goes away.

that is by design, else the client would get an ora-3113, which would lead to an infinite number of calls to support asking "why am I getting a 3113"...

If you have so many sessions that you are hitting max processes, it might just be time to look at shared server.... There you won't have a process per user.

Rating

  (8 ratings)

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

Comments

Benefit of this

Lyxx, May 28, 2008 - 11:09 pm UTC

Thanks Tom for replying.

Then, what is the benefit of using this?

No one normally leaves system idle for hours after a uncommited transactions, I see less/no benefit from releasing the resources.

People leave terminal and do not log off properly and we reached maximum sessions limit.

Regards,
Lyxx
Tom Kyte
May 29, 2008 - 7:41 am UTC

...
No one normally leaves system idle for hours after a uncommited transactions, I
see less/no benefit from releasing the resources
....

keyword = normally. That is the benefit here, it releases resources of an idle session that would normally have released them for did not - due to a bug, due to an end user doing something unanticipated.


This does what it does....

scripts to clean the sessions which are idle from last x hours.

Tibor, September 25, 2009 - 9:07 am UTC

Dear Tom,

Could you tell me which dictionry view or package supply the information of how long a session is being idle.

Thank you,
Tibor
Tom Kyte
September 29, 2009 - 9:29 am UTC

use a profile, you create a profile (read about create profile) and set a max idle time on it.

after that time, we'll 'snipe' those sessions - releasing their resources.


but - in general - this isn't something you want to do, really.


( select last_call_et from v$session where status = 'INACTIVE' or status is null;
will give you in seonds how long idle sessions have been that way)

Still the IDLE_TIME is of no use

Reena, May 28, 2011 - 5:31 am UTC

It means IDLE_TIME will release locks and the sessions would become 'SNIPED' and will remain in v$session. Will the OS script would be the last thing to kill such sessions ?
Tom Kyte
May 31, 2011 - 9:44 am UTC

question for you - why do you have these idle sessions - what is the client doing that causes them????? This is the underlying problem we need to solve here. Those sessions will stay 'sniped' until the client tries to use those connections - so we can return to the client a meaningful error message and then disconnect. If the client is NEVER reaching out to the server again either:

a) the client has died, blued screened or something. dead client detection is what we need to enable to fix that.

b) the client is a connection pool and your developers have a rather SERIOUS bug in their code that needs to be tracked down.


no server needed to return a meaningful error message

Sokrates, June 01, 2011 - 1:59 am UTC



Those sessions will stay 'sniped' until the client tries to use those connections - so we can return to the client a meaningful error message and then disconnect.

I don't understand that.
"we" is "the Oracle Software", I suppose ?
It usually consists of a server and a client, right ?
The session is not needed to return a meaningful error message in my opinion, this part could also be handled be the Oracle client software - like
ORA-03114: not connected to ORACLE
for example - I think this one is *not* "thrown over the wire", but only raised by client software ?


why do you have these idle sessions - what is the client doing that causes them????? This is the underlying problem we need to solve here.

ok, take this example:
a classical client/server user interface with a human operator working on it.
He/She goes to lunch, forgot to press the "commit" button, and doesn't return in the afternoon because of whatever.

Good luck we have configured idle timeout for her/him ! so transaction is rolled back (after an hour or so).

why the session is hold ?
the client could be informed about the sniping (so that he could raise an appropriate exception when operator touches the application once again) and the session could be killed

would be an improvement in my eyes
should not a be big thing in times of client result cache for example ...

Tom Kyte
June 01, 2011 - 8:49 am UTC

we would be "oracle" yes.

ora-3114 causes calls to support. why? because people (clients) are disconnected and they have no idea or clue why.


Why is an idle session in this case a big deal to you - do you have thousands of people doing this? They are going to come back eventually.

I think a more likely scenario that you are actually experiencing is the one I've described. You have a connect pool leaking like a sieve. And you are trying to patch it - just like this guy describes: http://marc.info/?l=openbsd-misc&m=130683944229077&w=2 - instead of having the developers actually fix it.

I say this because - in order for your scenario to play out and be an issue - you would have to have thousands of connected users (so you would have the possibility of having hundreds of idle sessions) - but I doubt you have thousands of connected sessions...

impact of IDLE_TIME over connection pool

Abhishek Kumar, November 29, 2011 - 3:40 am UTC

Hi Tom,
If we have an application with connection pooling enabled. Let suppose when the application starts, it automatically creates around 100 connection in the DB pool which has been configured on the basis of normal day load. Now suppose, during early morning or night, those much of users are not connected.
Will the connections present in pool, which are not being used, become inactive and then sniped if IDLE_TIME is enabled?

If yes, how these connections from the pool can be removed?

Thanks,
Abhishek
Tom Kyte
November 29, 2011 - 11:39 am UTC

if you have connection pooling, you don't want an idle timeout set for those connections. Do not use that particular database feature, it wouldn't make sense for these connections.

Regarding Session disconnection

Ahmed Hamdy, June 03, 2013 - 11:41 am UTC

Hi tom ,
I've followed this post from the beginning but after i set idle time and connect time in profile option to 10 minutes plus adding the parameter SQLNET.EXPIRE_TIME=10 minutes in sqlnet.ora , the problem is the session still marked sniped .
how to tell oracle to disconnect these sniped sessions automatically ?

Apache tomcat web app connection pooling issue

kls, July 19, 2014 - 1:30 pm UTC

we have a web based application "A" running on apache tomcat server. The database is Oracle 11.2.3.0. Let's call this database that uses as "P". The web application "A" also views data from a remote database (let's call this database "C") via database links. Database "C" is seeing inactive sessions in v$session for the "user" that database "P" uses via the database link. Database "C" has had to be bounced or their web app had to be restarted in the past because they have had ORA-00020 maximum processes error. People who use/manager database "C" think it is caused because database "P" is leaking connections via the database link it uses to connect to database "C". Hence the DBA for database "P" set the following "max_sessions" and "sessions_per_user" to 50 and "idle_time" to 30min. Setting "idle_time" has caused errors "ORA-02396, ORA-02050" on the web app "A" that uses database "P" because of broken connections being returned to the connection pool after session inactive period. My recommendation was to remove the "idle_time".

I checked with the DBA who administers database "P" and "C" he looked at the Process usage and indicated database "P" on an average used 30% since Januuary until now and he did not see any connection leak issues in database "P". However database "C" seems to be close to 100% dropped down to 60%, 40% and it has been more erratic.

I have set the min and max connection pool parameter to 1 on web application "A". From the tests I have done so far web app "A" created 1 session in v$session for the connection pool and when I ran a functionality on web app "A" that uses objects in database "B" it created a session for it in database "B". I have not seen the sessions increase from the tests I have done in both database "A" and "B". I see v$session entries for these to be inactive and I understand from this trail that having inactive sessions from the connection pool is okay as long as the application is going to be using it and it can use it. Until I shutdown apache/tomcat services for the web app "A" the v$session entries generated from the web app "A" persisted to exist. Now I have the following questions.

1. Is it okay to have v$sessions entries generated via the connection pool in database "P" and "C" which are in inactive state remain until the web app "A" is shutdown ?
My thought is it is okay to leave the v$session entries as such as long as the v$session entries does not keep on increasing on database "P" and "C" and hit the max processes error.

2. I have not seen connection leaks in database "P" but it could also be because of databae bounce done for patches/web application restart when new releases are done. But looking at the "process" usage sent by the DBA for database "P" it does not appear that the processes keeps on increasing. It is steady at 30% approimatelly.
My question is how do I determine on database "C" that connection leaks are happening via the database link tfrom database "P"?
After the DBA set the sessions_per_user and max_session to 50 web app "A" has encountered maximum sessions reached error.

The maximum processes "PROCESSES" has been set to 350 on both database "P" and "C".

3. When running DML using database link do you need to always have to commit to release connections? I read this somewhere. Can you please elaborate on this?

4. Eventhough I dont plan to use it in the application if idle_time is set on the remote database "C" for the database user that database "P" connects to will the transaction via a dblink be rolled back? if there were other transactions made before the database link was used what happens to those? will it be rolled back or will those remain.?

5. Is there any thinking else you need to think of that I need to do to identify connection leaks?

Your expertise, suggestions and feedback have been extremely valuable to me. thank you very much for your suggestions and inputs.

- kls

Apache tomcat web app connection pooling issue

kls, July 19, 2014 - 1:31 pm UTC

we have a web based application "A" running on apache tomcat server. The database is Oracle 11.2.3.0. Let's call this database that uses as "P". The web application "A" also views data from a remote database (let's call this database "C") via database links. Database "C" is seeing inactive sessions in v$session for the "user" that database "P" uses via the database link. Database "C" has had to be bounced or their web app had to be restarted in the past because they have had ORA-00020 maximum processes error. People who use/manager database "C" think it is caused because database "P" is leaking connections via the database link it uses to connect to database "C". Hence the DBA for database "P" set the following "max_sessions" and "sessions_per_user" to 50 and "idle_time" to 30min. Setting "idle_time" has caused errors "ORA-02396, ORA-02050" on the web app "A" that uses database "P" because of broken connections being returned to the connection pool after session inactive period. My recommendation was to remove the "idle_time".

I checked with the DBA who administers database "P" and "C" he looked at the Process usage and indicated database "P" on an average used 30% since Januuary until now and he did not see any connection leak issues in database "P". However database "C" seems to be close to 100% dropped down to 60%, 40% and it has been more erratic.

I have set the min and max connection pool parameter to 1 on web application "A". From the tests I have done so far web app "A" created 1 session in v$session for the connection pool and when I ran a functionality on web app "A" that uses objects in database "B" it created a session for it in database "B". I have not seen the sessions increase from the tests I have done in both database "A" and "B". I see v$session entries for these to be inactive and I understand from this trail that having inactive sessions from the connection pool is okay as long as the application is going to be using it and it can use it. Until I shutdown apache/tomcat services for the web app "A" the v$session entries generated from the web app "A" persisted to exist. Now I have the following questions.

1. Is it okay to have v$sessions entries generated via the connection pool in database "P" and "C" which are in inactive state remain until the web app "A" is shutdown ?
My thought is it is okay to leave the v$session entries as such as long as the v$session entries does not keep on increasing on database "P" and "C" and hit the max processes error.

2. I have not seen connection leaks in database "P" but it could also be because of databae bounce done for patches/web application restart when new releases are done. But looking at the "process" usage sent by the DBA for database "P" it does not appear that the processes keeps on increasing. It is steady at 30% approimatelly.
My question is how do I determine on database "C" that connection leaks are happening via the database link tfrom database "P"?
After the DBA set the sessions_per_user and max_session to 50 web app "A" has encountered maximum sessions reached error.

The maximum processes "PROCESSES" has been set to 350 on both database "P" and "C".

3. When running DML using database link do you need to always have to commit to release connections? I read this somewhere. Can you please elaborate on this?

4. Eventhough I dont plan to use it in the application if idle_time is set on the remote database "C" for the database user that database "P" connects to will the transaction via a dblink be rolled back? if there were other transactions made before the database link was used what happens to those? will it be rolled back or will those remain.?

5. Is there any thinking else you need to think of that I need to do to identify connection leaks?

Your expertise, suggestions and feedback have been extremely valuable to me. thank you very much for your suggestions and inputs.

- kls