ORA-00030: User session ID does not exist.

   同事在Toad里面执行SQL语句时,突然无线网络中断了,让我检查一下具体情况,如下所示(有些信息,用xxx替换,因为是在处理那些历史归档数据,使用的一个特殊用户,所以可以用下面SQL找到对应的会话信息):














执行了kill会话的语句后,检查发现对应的会话仍然存在,只是SERIAL#值变化了,再次去kill会话时,出现ORA-00030错误,如下所示

SQL> alter system kill session '523, 41890' immediate;
 
System altered.
 
 
SQL> SELECT  A.ORACLE_USERNAME  ,
  2          A.OS_USER_NAME     ,
  3          B.OWNER            ,
  4          B.OBJECT_NAME      , 
  5          A.SESSION_ID       ,
  6          A.PROCESS          ,
  7          A.LOCKED_MODE
  8    FROM V$LOCKED_OBJECT A, DBA_OBJECTS B
  9   WHERE B.OBJECT_ID = A.OBJECT_ID AND  B.OWNER=&OWNER
 10  ORDER BY  A.ORACLE_USERNAME,
 11            A.OS_USER_NAME;
 
ORACLE_USERNAME   OS_USER_NAME     OWNER       OBJECT_NAME        SESSION_ID PROCESS   LOCKED_MODE
---------------- ------------- -----------   ----------------- ----------------------  -------------
xxxxxxxxxxxxxxx    ZhanxxxnL   xxxxxxxxxxxx    INV_xxxx_HD       523 6208:7548               3
xxxxxxxxxxxxxxx    ZhanxxxxL   xxxxxxxxxxxx    INV_xxxx_LINES    523 6208:7548               3
 
SQL> SELECT B.USERNAME    , 
  2      B.SID            , 
  3      B.SERIAL#        ,
  4      LOGON_TIME       ,
  5      A.OBJECT_ID
  6    FROM V$LOCKED_OBJECT A, V$SESSION B
  7   WHERE A.SESSION_ID = B.SID
     AND  B.USERNAME=&USERNAME
  8   ORDER BY B.LOGON_TIME;
 
USERNAME                              SID    SERIAL# LOGON_TIM  OBJECT_ID
------------------------------ ---------- ---------- --------- ----------
xxxxxxxxxxxxxx                        523      41891 06-MAY-16     825892
xxxxxxxxxxxxxx                        523      41891 06-MAY-16     825891
 
 
SQL> alter system kill session '523, 41891' immediate;
alter system kill session '523, 41891' immediate
*
ERROR at line 1:
ORA-00030: User session ID does not exist.

在metalink上,查看了ORA-00030错误的描述、原因、解决方案。如下所示

SQL> ho oerr ora 30

00030, 00000, "User session ID does not exist."

// *Cause: The user session ID no longer exists, probably because the

// session was logged out.

// *Action: Use a valid session ID.

 

The command may have been issued for one or more of the following reasons:

1. The process no longer exists at the os level, but does show up as active in v$session.

2. The user reboots the client machine without logging off, leaving a shadow process.

3. That session is holding onto a lock that needs to be released.

CAUSE

This error occurs because PMON is already trying to kill the session.

This is indicated by the fact that the serial number keeps changing.

When PMON attempts to cleanup a dead session, it will increase the serial number.

PMON may take a long time to clean up the process. If the process was doing a very large transaction at the time it aborted, then PMON has to rollback the large transaction.

When PMON makes progress, i.e. if it manages to free at least some of the process's resource, it will repeatedly keep trying to delete the process. When it finally gets to the point where it can't free up any of the process's resource (i.e. there are no more free buffers), it will print a message to the trace file and try to delete that process a second time. 

The problem is encountered when PMON lacks the resources needed to remove the process. If there are not enough buffers, then the removal of  the process is delayed. This is a free buffer problem in the data cache.

SOLUTION

Encountering an ORA-30 when attempting to manually kill a process is not necessarily a bug but a result of trying to kill a process already marked as killed. 

PMON can take anywhere from 5 minutes to over 24 hours to clean up a job. The impact is that often the process being cleaned up is holding locks that prevents others from performing certain operations.

The solution is to wait for PMON to clean up the process.

 

基本上只能等待pmon进程回收处理这个进程,等了十来分钟,这个会话进程还是没有被清理,于是我查看了一下会话的相关信息,在网上查看到相关资料,可以从系统层面kill掉会话

SQL> 
 
SQL> select event from v$session_wait where sid=523;
 
EVENT
----------------------------------------------------------------
db file sequential read
 
SQL> select sql_text from v$session a,v$sqltext_with_newlines b
  2    where decode(a.sql_hash_value, 0, prev_hash_value, sql_hash_value)=b.hash_value
  3    and a.sid=&sid order by piece;
Enter value for sid: 523
old   3:   and a.sid=&sid order by piece
new   3:   and a.sid=523 order by piece
 
SQL_TEXT
----------------------------------------------------------------
DELETE from inv_xxx_lines WHERE (xxx) IN ( SELECT tr
ans_line_id FROM xxxx GROUP BY trans_line_id HAVING C
OUNT(xxxxx) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FRO
M xxxx GROUP BY xxx HAVING COUNT(*) > 1)

 

于是我尝试从系统层面kill掉对应的系统进程。执行完成后,验证发现对应的会话已经Kill掉了。不知道是凑巧pmon进程回收了这个会话进程还是真的能从系统进程能kill掉(因为不能重新这种场景),如果下次碰到这种场景,就可以测试、验证了。特此记录一下

 

SQL> ! kill -9 4884

 

参考资料:

https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=533785808734847&id=1011386.6&_afrWindowMode=0&_adf.ctrl-state=13ipo04jjr_4

http://www.linuxidc.com/Linux/2011-09/43730.htm

 

时间: 2024-08-18 07:12:19

ORA-00030: User session ID does not exist.的相关文章

php中session_id()函数详细介绍,会话id生成过程及session id长度_php实例

php中session_id()函数原型及说明session_id()函数说明:stringsession_id([string$id])session_id() 可以用来获取/设置 当前会话 ID.为了能够将会话 ID 很方便的附加到 URL 之后, 你可以使用常量 SID 获取以字符串格... php中session_id()函数原型及说明 session_id()函数说明: string session_id ([ string $id ] ) session_id() 可以用来获取/设置

PHP通过session id 实现session共享和登录验证的代码_php技巧

先说说,这个机制的用途吧,到现在为止战地知道这个机制有两个方面的用途: 首先,多服务器共享session问题,这个大家应该都能够理解的,当一个网站的用户量过大,就会使用服务器集群,例如专门有一个登录用的服务器.用户通过登录服务器登录之后,登录服务器保存了用户的登录信息session,而其他受访问的服务器,例如电影服务器没有这个session,那么我们就要通过一个session的唯一标识来共享这个session了--具体session的共享超出了本文的范围,请自行查阅资料. 第二个用途就是,验证同

websphere session id 在哪里设置?

问题描述 如题.was6.1的环境.找了半天没有找到. 解决方案 解决方案二:该回复于2010-12-22 15:16:09被版主删除解决方案三:该回复于2010-12-22 15:16:08被版主删除解决方案四:这个问题不好回答

oracle ora-00054:resource busy and acquire with nowait specified解决方法_oracle

当某个数据库用户在数据库中插入.更新.删除一个表的数据,或者增加一个表的主键时或者表的索引时,常常会出现ora-00054:resource busy and acquire with nowait specified这样的错误. 主要是因为有事务正在执行(或者事务已经被锁),所有导致执行不成功. 1.用dba权限的用户查看数据库都有哪些锁 select t2.username,t2.sid,t2.serial#,t2.logon_time from v$locked_object t1,v$s

php查看当前Session的ID实例

 这篇文章主要介绍了php查看当前Session的ID的方法,实例分析了两种常见的获取session中ID的技巧,非常具有实用价值,需要的朋友可以参考下     本文实例讲述了php查看当前Session的ID的方法.分享给大家供大家参考.具体如下: 有两种方法可以得到用户的session id,第一是使用session_id()函数,另外一种是使用内置的常量SID获得,SID包含了session id和session值 ? 1 2 3 4 5 6 7 8 9 10 11 <?php sessi

php查看当前Session的ID实例_php技巧

本文实例讲述了php查看当前Session的ID的方法.分享给大家供大家参考.具体如下: 有两种方法可以得到用户的session id,第一是使用session_id()函数,另外一种是使用内置的常量SID获得,SID包含了session id和session值 <?php session_start(); print("<html><b>"); $sid = session_id(); print("Session ID returned by

alert日志中的两种ORA错误分析

今天在巡检系统的时候,发现alert日志中有两种类型的ora错误. Errors in file /U01/app/oracle/diag/rdbms/XX/XX/trace/xxdb_j002_20401.trc: ORA-12012: error on auto execute of job "XXDATA"."S_XXXX_HIST_OPS_SERINFO_K" ORA-12170: TNS:Connect timeout occurred ORA-06512

ORA-00022: 无效的会话 ID; 访问被拒绝

遇到错误: ORA-02068: following severe error from BUSISYS.REGRESS.RDBMS.DEV.US.ORACLE.COMORA-00022: 无效的会话 ID; 访问被拒绝   Error:  ORA 22   Text:   invalid session id; access denied ------------------------------------------------------------------------------

Oracle 错误总结及问题解决 ORA

参考地址 ORA-00001: 违反唯一约束条件 (.)错误说明:当在唯一索引所对应的列上键入重复值时,会触发此异常.ORA-00017: 请求会话以设置跟踪事件ORA-00018: 超出最大会话数ORA-00019: 超出最大会话许可数ORA-00020: 超出最大进程数 ()ORA-00021: 会话附属于其它某些进程:无法转换会话ORA-00022: 无效的会话 ID:访问被拒绝ORA-00023: 会话引用进程私用内存:无法分离会话ORA-00024: 单一进程模式下不允许从多个进程注册