"Handling" Killed Sessions
I'm curious as to if anybody has some insight to killed sessions. I have a procedure that looks like this:
procedure x
lv_result number;
lv_msg varchar2(4000);
for x in cursor
loop
lv_result := NULL;
lv_msg := NULL;
begin
execute immediate x.sql into lv_result;
exception
when others then
lv_msg := dbms_utility.format_error_stack;
lv_result = NULL;
end;
log_result; --autonomous transaction that inserts to table and commits;
end loop;
print_summary;
end x;What struck me as odd was that even though I'd kill the session while it was in the middle of processing rec 10 out of 30, it would still log the remaining 20 records with a "ORA-00028: your session has been killed" message. But it didn't print the results. So modified it a bit...
procedure x
SESSION_KILLED exception ;
pragma exception_init(SESSION_KILLED, -28);
lv_result number;
lv_msg varchar2(4000);
lv_session_killed boolean := FALSE;
for x in cursor
loop
lv_result := NULL;
lv_msg := NULL;
begin
execute immediate x.sql into lv_result;
exception
when session_killed then
lv_session_killed := TRUE;
lv_msg := dbms_utility.format_error_stack;
lv_result = NULL;
when others then
lv_msg := dbms_utility.format_error_stack;
lv_result = NULL;
end;
log_result; --autonomous transaction that inserts to table and commits;
exit when lv_session_killed;
end loop;
print_summary;
end x;...which effectively stopped the loop at the first record in the cursor at which the session was killed, and still didn't print the summary. But it's obvious that processing still "continues" in the background even though the session was killed. Does killing the session just terminate communications between the client and the DB, letting the procedure to continue on it's own? Is there any way to get DBMS_OUTPUT calls to work before the procedure actually dies?
Database is 10.2.0.4.0
Here's a quickie example:
drop table tst_output;
create table tst_output (num number, msg varchar2(4000));
create or replace procedure p1
as
-- Make killed session named exception
SESSION_KILLED exception ;
pragma exception_init(SESSION_KILLED, -28);
-- Random query to generate string (a little slowly on my dev box).
lv_sql varchar2(4000) := 'select case when cnt is not null then ''SUCCESS!'' end as dummy_data ' ||
'from (select count(*) cnt from all_objects ' ||
'where last_ddl_time > (select min(last_analyzed) from all_tables))';
lv_return tst_output.msg%type; --result of execute immedaite
lv_session_killed boolean := FALSE; --stop processing if session killed.
procedure insert_rec (
p_num in tst_output.num%type,
p_msg in tst_output.msg%type)
as
pragma autonomous_transaction;
begin
insert into tst_output (num, msg)
values (p_num, p_msg);
commit;
end insert_rec;
procedure print_something
as
begin
for x in (select msg from tst_output)
loop
dbms_output.put_line(x.msg);
end loop;
end print_something;
begin
execute immediate 'truncate table tst_output';
for x in 1 .. 30 -- or however many loops it takes that you can jump to another window
loop
begin
execute immediate lv_sql into lv_return;
exception
when SESSION_KILLED then
lv_session_killed := TRUE;
lv_return := dbms_utility.format_error_stack;
dbms_output.put_line('Kill Time: ' || to_char(sysdate, 'dd-mon-yyyy'));
when OTHERS then
lv_return := dbms_utility.format_error_stack;
end;
insert_rec(x, lv_return);
--exit when lv_session_killed;
end loop;
print_something;
dbms_output.put_line('Finish Time: ' || to_char(sysdate, 'dd-mon-yyyy'));
end p1;Run this with a high enough loop count that you can jump to another window and kill that session...
ALTER SYSTEM KILL SESSION 'SID, SERIAL'If you log back in (disconnected from the session kill) and look a the tst_output table, you'll still see 1 record for every loop. If you uncomment the EXIT towards the end of the actual executable portion and do it again, the program will break from the loop when you kill the session.
So that means that the inner exception handler is catching the SESSION_KILLED_EXCEPTION, but
1) DBMS_OUTPUT in the exception is not displayed
2) It doesn't return to the normal flow after it is handled because the print at the bottom isn't displaying either.
The session running the procedure is killed (and disconnected), but doesn't get the DBMS_OUTPUT before it's disconnected...and the procedure continues processing till it's done?
Similar Messages
-
Hi,
I kill a session with the commands:
select username, sid, serial#, status from v$session where username like 'RION%'
alter system kill session 'sid, serial#'
and if I give again the first select command at the status column appears KILLED. I want not to have KILLED in the status column.
Thank you,
Mihaelahi all,
As u know you are seeing the status of at v$session view as killed, I wanna confirm that this will exists in two senario.
When a Session is in inactive state and a kill command on that session is issued then the "status" column of v$session will be updated as killed as to indicate/mark as it is killed, and the "server " column will be updated as psuedo. when the user again try to connect to the session user will receive 0ra-00028 error and the entry will be removed from v$session.
Another senario is that the transaction is at its half way, either in commiting or at the roleback stage for that partucular session then also you can find that the v$table is updated as above.
more information, go through the documentation, at the Server Process handling section.
i hope it cleared your confussion, -
How to find and kill session similar to forms user session
We have a forms and reports based system that uses the oracle sessions. Sometimes if a form takes a long time we have the need to navigate to iAS>Forms>User Sessions, find the IP of the machine where the form is not responding and kill it based on the IP of the troublesome machine.
I want to add this into our forms environemnt so people can kill their own sessions if need be but not sure how this is handled
is it a simple alter system kill session in the db or something different.
also how is the ip found to match the session?
Thankshi,
Instead Set session timeout parameters..So that user gets logged off automatically from the application after a particular interval of time
For this you have to make changes in httpd.conf file,web.xml file and env file
Regards
Fabian -
hi,
i am using oracle 11gr1 in windows server service pack2.i have generated scripts to kill the user using alter system kill session 'sid,serial# and then dropping the same user.But at times i get the error that cannot drop user who is currently connected .when i check the state of the user in v$session it is in killed state.i want to avoid this and kill the user perfectly.
can anyone tell me the solution or suggestion for this????
thanks in advance
Edited by: 793097 on Dec 17, 2010 3:12 AMA remote session open a server session, this is the one you must kill.
I'm not sure, but when you kill a session the relation between v$process and v$session disapear. Then all you can do is wait.
Perhaps I am wrong. Try this,
select 'kill -9 ' || b.spid from v$process where b.addr = <v$session killed paddr>;
And run the kill in OS, if OS is linux or unix...
I am very sorry that we never help to you...
793097 Newbie
Handle: 793097
Status Level: Newbie (15)
Registered: Sep 6, 2010
Total Posts: 94
Total Questions: 57 (49 unresolved)
Read this http://forums.oracle.com/forums/ann.jspa?annID=718 -
In my application I want to kill session if any user
is idle for 2 minutes.
I am using oracle forms 6i and database oracle 9iYou have to use D2KWutil.pll
In when new form instance write the following code
declare
hWind PLS_INTEGER;
CheckTimer TIMER;
begin
hWind := get_window_property(FORMS_MDI_WINDOW,WINDOW_HANDLE);
Win_API_Session.Timeout_Start_Timer(hWind);
CheckTimer := Create_Timer('CheckTimeout',1000,repeat);
end;
and in when timer expired trigger write the following code
begin
if upper(get_application_property(TIMER_NAME)) = 'CHECKTIMEOUT' then
:timer.t1 := Win_api_session.Timeout_Get_Inactive_Time;
if :timer.t1 > 120 then -- timer is a block and t1 is text item (don't assign a canvas to it, make it invisible)
Win_API_Session.timeout_delete_timer;
exit_form (NO_VALIDATE);
end if;
end if;
end;
hope this helps !! -
How to handle multiple sessions in Script recorder
Hi,
I have a requirement to update certain records from a program. For that I have to put a breakpoint the program (which I did manually).
Now when I use the scripting tool to record the events, only events related to the original session gets recorded. Any events on the newly opened debugger mode is not recorded !
However, I can record the events in the debugger separately.
So I have 2 scripts which are session dependent. In Session 1 my program runs and in session 2 (which opens the debugger in runtime) my edits need to be done.
How to create a VB script which can handle this session issue?
Went through this blog by Scriptman and since i am new couldnt get it working !!
Please help me with a framework to handle this issue.
Activate a session via Gui scripting
Thanks,
JaywantHi Thomas,
Yes I have to handle both the session simultaneously. Let me illustrate further.
I have to update some (10k- 15k) products from a z table in CRM. We have a custom program for this.
So, i use se38 and insert a breakpoint in the program (to make the updates to a field) and then execute it. Now I start my script recorder. Provide inputs to the program and hit execute.
At this point my script recorder is running on the se38 window and not on the debugger window !
I change the values and press F8. These manual updates do not get captured by script recorder.
But, if I start my recorder once the debugger window was opened already, I can capture all these changes.
So we have things like this...
Script1.vbs --> Events captured in se38
Script2.vbs --> Events captured in the debugger
If I merge them and run, the recorder is not handling the new debugger session and the execution halts to get the "excel is waiting for another ole action"
Thanks,
Jaywant -
Urgent-how to run 'alter system kill session 'sid, serial#' in form 6i ?
I want to write a procedure in Form 6i so that user can kill the session by herself.
I know kill session sql is 'alter system kill session 'sid, serial#'', however, I fould that I can only run it it sql plus screen, how can I run it in Form or in Stored procedure?
Urgent....Please!try using Forms_ddl('alter system......'); in the forms. it will execute the dml statements in the form.
zaibi. -
How to Handle user Session in JSP
Help me,
How to handle user session in JSP.......Prakash_Pune wrote:
tell me some Debugging tech. so i can overcome from my problem.....Do you use an IDE? Any IDE ships with a decent debugger where in you can just execute the code step by step, explore the current variable values and check what exactly is happening. For example Eclipse or IntelliJ. If you don´t use an IDE, then just place some System.out.println() or Logger.debug() statements at strategic locations printing the variables of relevance so that you can track in logs what exactly is happening.
or tell any other way to find is my page is thread safe or not...Just write correct code and narrow the scope of the variables as much as possible. If you for example assigned the user object to a static variable or as a servlet´s instance variable, then exactly the same user object would be used everywhere in the application. That kind of logical things. -
How to handle expired sessions in portals
Hai all,
we have implemented a logic which is given in the following blog (to handle expired sessions).
(Blog from--Thomas Jung)
/people/thomas.jung3/blog/2004/12/06/bsp-developers-journal-part-xv--stateful-bsp-and-timeouts
this is working fine when we run application from workbench organizer.but when i run the same application through Portal,it was failed.
if someone comeacross this situation please kindly send your comments and solution to this problem.
Thanks in advance,
Innu.Hai Durai,
Thanks for the immediate response.
Here i will give the clear idea about the failure situation.
IF gv_load IS INITIAL.
DATA: fields TYPE tihttpnvp.
FIELD-SYMBOLS: <wa_fields> LIKE LINE OF fields.
CALL METHOD request->get_form_fields
CHANGING
fields = fields.
LOOP AT fields ASSIGNING <wa_fields>.
IF <wa_fields>-name CS 'htmlb' OR
<wa_fields>-name CS 'HTMLB'.
gv_load = '-'. "False - Problem with ABAP_FALSE
appearing the same as initial.
ENDIF.
ENDLOOP.
IF gv_load IS INITIAL.
gv_load = abap_true.
ENDIF.
ENDIF.
IF gv_load NE abap_true.
DATA: url TYPE string.
DATA: page TYPE string.
page = 'reload.htm'.
DATA: params TYPE tihttpnvp.
FIELD-SYMBOLS: <wa_params> LIKE LINE OF params.
APPEND INITIAL LINE TO params ASSIGNING <wa_params>.
<wa_params>-name = 'url1'.
CONCATENATE 'http://sapcrmdev.server.com:8080/sap/bc/bsp/sap/'
'salesord/default.htm'
INTO <wa_params>-value.
CONCATENATE ' ' ' ' INTO <wa_params>-value.
<b> CALL METHOD
cl_http_ext_webapp=>create_url_for_bsp_application
EXPORTING
bsp_application = 'SALESORD'
bsp_start_page = page
bsp_start_parameters = params
IMPORTING
abs_url = url.
navigation->exit( url ).
ENDIF.</b>
The imported parameter URL,which loads the reload page with parameter URL1.
Exactly here i am getting the problem.
[My application is launching through iViews as external services.Clearly, when i launch the portals that displays different bsp applications as menu options.when i click on my application that opens another window and from there on my application runs in that window.]
As we are constructing URL1 above, we are unable to construct Portal url to reload from reload page.]
so what should exactly i send value through url1 parameter to launch my application through portal..?
if you have any sample code plz send.
Thanks,
Innu. -
Oracle 10g r2
I killed a session after fetching the sid and serial from the v$session as under
select * from v$session where username='SAM';
alter system kill session '530,7420'
Now the status showed killed.
But again after some time one i query the v$session the status turn to inactive.
Why so?Yeah Madrid....
Thanks for that.. at the developer side.. they did get session killed.
But actually my doubt here was. that once i killed the session then i go the status as "killed" in the v$session
but less then a minute when i again query the v$session then i see the status aa inactive. This is what is not clear to me. -
RAR 5.3 - kill session of another user
how can RAR admin kill session of another user?
Hi Partha,
There is no way out to kill a user's session in RAR, nor in UME. The only place you can kill a user's session is in backend (R/3 side of a particular system) in T-code: SM04->select a particular session of any user-> end session.
Regards,
Gurugobinda -
Problem in implements ADF Faces: Detecting and handling user session expiry
Hello everybody
I´m trying to implement a method to handle user session expiry as explained by frank nimphius in his blog.
http://thepeninsulasedge.com/frank_nimphius/2007/08/22/adf-faces-detecting-and-handling-user-session-expiry/
I have implemented the class bellow and add the filters in web.xml. However when I add the JavaServer Faces Servlet to sign the filter, my hole application get nuts. I try to publish the applicatoin in the OAS and it seems that it already starts expired.
Someone konw what I´m doing wrong?
I use the filter
<filter>
<filter-name>ApplicationSessionExpiryFilter</filter-name>
<filter-class>adf.sample.ApplicationSessionExpiryFilter</filter-class>
<init-param>
<param-name>SessionTimeoutRedirect</param-name>
<param-value>SessionExpired.jspx</param-value>
</init-param>
</filter>
then I add
XML:
<filter-mapping>
<filter-name>ApplicationSessionExpiryFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
package adf.sample;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
this is the class
public class ApplicationSessionExpiryFilter implements Filter {
private FilterConfig _filterConfig = null;
public void init(FilterConfig filterConfig) throws ServletException {
_filterConfig = filterConfig;
public void destroy() {
_filterConfig = null;
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
String requestedSession = ((HttpServletRequest)request).getRequestedSessionId();
String currentWebSession = ((HttpServletRequest)request).getSession().getId();
boolean sessionOk = currentWebSession.equalsIgnoreCase(requestedSession);
// if the requested session is null then this is the first application
// request and "false" is acceptable
if (!sessionOk && requestedSession != null){
// the session has expired or renewed. Redirect request
((HttpServletResponse) response).sendRedirect(_filterConfig.getInitParameter("SessionTimeoutRedirect"));
else{
chain.doFilter(request, response);
I'm really having trouble controlling user sessions. if someone know where I can get materials to learn how to implements session in Jdev ADF + BC, I´m very grateful.
Thank you MarnieThe class works fine.. the issue is when I add the this code into web.xml
<filter-mapping>
<filter-name>ApplicationSessionExpiryFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
bellow the web.xml
<?xml version = '1.0' encoding = 'windows-1252'?>
<web-app>
<description>Empty web.xml file for Web Application</description>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>CpxFileName</param-name>
<param-value>userinterface.DataBindings</param-value>
</context-param>
<filter>
<filter-name>ApplicationSessionExpiryFilter</filter-name>
<filter-class>view.managedBean.ApplicationSessionExpiryFilter</filter-class>
</filter>
<filter>
<filter-name>adfFaces</filter-name>
<filter-class>oracle.adf.view.faces.webapp.AdfFacesFilter</filter-class>
</filter>
<filter>
<filter-name>adfBindings</filter-name>
<filter-class>oracle.adf.model.servlet.ADFBindingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ApplicationSessionExpiryFilter</filter-name> ==> the problem occurs when I try to add this code
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>adfFaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>adfBindings</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>adfBindings</filter-name>
<url-pattern>*.jspx</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>resources</servlet-name>
<servlet-class>oracle.adf.view.faces.webapp.ResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>resources</servlet-name>
<url-pattern>/adf/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>1</session-timeout>
</session-config>
<mime-mapping>
<extension>html</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>txt</extension>
<mime-type>text/pain</mime-type>
</mime-mapping>
</web-app>
By the way, how can I post code on the forum properly? -
ALTER SYSTEM KILL SESSION privilege
Hi All,
Is there any possibility to use this command from a without having DBA priviileges, what is the privilege to be grantd to the ordinary users to execute ALTER SYSTEM KILL SESSION... statement..
Thanks in advanceThe procedure proposed by Rusell would be more or less so:
SQL> create or replace procedure kill_session
2 ( v_sid number, v_serial number )
3 as
4 v_varchar2 varchar2(100);
5 begin
6 execute immediate 'ALTER SYSTEM KILL SESSION '''
7 || v_sid || ',' || v_serial || '''';
8 end;
9 /
Procedure created.
SQL> select username, sid, serial# from v$session;
USERNAME SID SERIAL#
147 5078
SYS 148 6161
151 6769
156 1
158 1
159 1
REPOS_OWNER 161 14502
163 1
164 1
165 1
166 1
USERNAME SID SERIAL#
167 1
168 1
169 1
170 1
15 rows selected.
SQL>
SQL> exec kill_session(161,14502);
PL/SQL procedure successfully completed.
SQL>Joel Pérez
http://otn.oracle.com/experts -
Kill session permission without alter system permission?
Syntax to kill session is
ALTER SYSTEM KILL SESSION 'session info';
Is there a way to allow a user to kill his/her own session without granting rights to SYSTEM? I don't want anyone to be able to drop the database, but they need to be able to kill their own session. I've looked everywhere...
Thanks in advance!Yes, assuming you are using standard definer's rights stored procedures. Only if you specify AUTHID CURRENT_USER when creating the stored procedure will you get an invoker's rights stored procedure, which would run with the privileges of the caller, not of the definer.
Justin -
To kill session in one schema from another schema
Hi Team,
I got a problem like a table from one of my schema has been locked. I am getting 'ORA-00054: resource busy and acquire with NOWAIT specified' error when trying to delete rows from that table or even when trying to truncate that table.
Let the table be 'T1' present in schema 'VIEW'
I tried to kill the session which is active for that schema by below query
select sid,serial#,status from v$session where username='VIEW' and STATUS = 'ACTIVE';
alter system kill session '681,2586';
But i couldn't do the above as i don't have DBA privilege for that. But i have DBA privilege for another schema let it be 'ADMIN'
Now how can i kill the session in schema 'VIEW' from schema 'ADMIN'
can any one get me solution.
Thanks in Advance
11081985I got a problem like a table from one of my schema has been locked. I am getting 'ORA-00054: resource busy and acquire with NOWAIT specified' error when trying to delete rows from that table or even when trying to truncate that table.
Before you do anything why don't you actually find out WHY that table has been locked.
You generally should NOT be killing sessions without knowing what is causing the problem to begin with.
Then you also need to determine if you should use KILL SESSION or instead use DISCONNECT SESSION and well as whether the use of IMMEDIATE is appropriate.
Each of those choices acts differently. Many people use KILL when they should really use DISCONNECT.
See DISCONNECT SESSION Clause and KILL SESSION Clause in the ALTER SESSION chapter of the SQL Language doc
http://docs.oracle.com/cd/E11882_01/server.112/e17118/statements_2014.htm#i2282145
Maybe you are looking for
-
XI 3.0 : java is not active error and dispacter is not working
Dear Experts.............. Pls help me in solving this... the ..log file says.. XI01\saploc\XI1\DVEBMGS00\work\dev_disp trc file: "dev_disp", trc level: 1, release: "640" Tue Apr 18 19:39:04 2006 kernel runs with dp version 128(ext=102) (@(#) DPLIB-I
-
Unable to store SecretKey in KeyStore
Hi there. I am trying to store a SecretKey in a KeyStore, and that doesn't work. I create a secret key, wrap it up in KeyStore.SecretKeyEntry to add it into my key store. Looking at the API for KeyStore class, we have a method setEntry(String alias,
-
Will iWork apps ever be updated for Apple's 'Open In...' API?
I use Apple's 'Open In...' feature from DropBox to send documents to Pages/Numbers. Then, Apple doesn't support their own 'Open In...' API feature to send back to DropBox, Adobe or other. Feedback submitted at apple.com/feedback but still =( So I em
-
Have a pdf that i populate using a cold fusion app. It all appears correctly , however, on some fields I get a + sign in a box printing. I'm guessing that means the data didn't all ap pear, however it does all appear. Is there and easy way to get
-
Extended Transport Control Usage??
Hello All, "Extended Transport Control is another way to set up the Transport Route so that the route is system and CLIENT specific"..I m not able to understand this concept so unable to implement Extended Transport Control in my SAP L