Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

KILL/DISCONNECT SESSION doubts

foxhoundAug 9 2019 — edited Aug 12 2019

Hey, I have doubts about KILL vs DISCONNECT SESSION. I found valuable information in https://community.oracle.com/thread/1052847 (especially explanations and examples given by @"Billy~Verreynne" ) and https://blog.tanelpoder.com/2009/08/13/alter-system-kill-session-and-ora-00031-session-marked-for-kill/ but those still missing some details.

As I understand KILL SESSION will 'just set a bit in the target sessions state object, which marks that the target session should end.'. When target session is in 'Active' state then KILL SESSION will hang for 60 seconds and after that time will return control to the user saying that session is marked to be killed. Then the target session will kill itself as it will be able to read the bit of its session state object ... or never if it failed for any reason, hang or something similar.

But KILL SESSION has IMMEDIATE clause that according to https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/ALTER-SYSTEM.html#GUID-2C638517-D73A-41CA-9D8E-A62D1A0B7ADB

: 'Specify IMMEDIATE to instruct Oracle Database to roll back ongoing transactions, release all session locks, recover the entire session state, and return control to you immediately.'. But now it means that IMMEDIATE will terminate the target session by force no matter if the session is in Active or Inactive state or will just return control to user immediately but still behave in same way as KILL SESSION - mark target session to be killed without waiting 60 seconds before returning control to the user?

There is second way to terminate the session: DISCONNECT SESSION. According to above doc link it kills server process to terminate the target session. But when session has some ongoing transaction then it will be terminated in hard way with rollback and full session restore? DISCONNECT SESSION also has IMMEDIATE clause. The doc link says that 'Use the DISCONNECT SESSION clause to disconnect the current session by destroying the dedicated server process' and then about IMMEDIATE clause 'The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without waiting for ongoing transactions to complete.'. If you destroy server process there is no more communication with the client and database activity possible? How it differs then if you provide or not IMMEDIATE clause???

The last question is about difference between entire and partial recover session resources?

Doc link says nothing about session recovery in DISCONNECT SESSION, entire session in case of DISCONNECT SESSION IMMEDIATE and KILL SESSION IMMEDIATE, partial for KILL SESSION. From that context KILL and DISCONNECT act same when IMMEDIATE clause is used?

I work on Oracle 12.2.

Comments
Post Details
Added on Aug 9 2019
6 comments
2,960 views