ORA-04021 timeout occurred while waiting to lock object

用户要求删除一个数据库的用户 GREENPASS,在删除的过程中,报错如下:

drop user GREENPASS * ERROR at line 1: ORA-04021: timeout occurred while waiting to lock object NEWDR.HNDR_SMS_LOG

处理过程

1. 首先查询NEWDR.HNDR_SMS_LOG,这是一个‘PROCEDURE‘;

2. 现在报错,不能对此对象进行锁定。

3. 看看什么会话在访问此对象:

select B.SID, b.USERNAME, b.MACHINE   FROM V$ACCESS A, V$SESSION B WHERE A.SID = B.SID    and a.OBJECT = ‘HNDR_SMS_LOG‘    and a.TYPE = ‘PROCEDURE‘;

SID USERNAME     MACHINE ---------- ------------ -------------------        520 NEWDR        WORKGROUP\BONC02

4. 根据sid获取操作系统的进程号

select spid os_sid   from v$process where addr = (select paddr from v$session where sid = &oracle_sid);

old 3: where addr = (select paddr from v$session where sid = &oracle_sid) new   3:  where addr = (select paddr from v$session where sid = 520)

OS_SID ------------ 29360

5. 询问业务人员,可以直接杀掉进程

ps -ef|grep 29360 kill -9 29360

6. 重新尝试 SQL> drop user GREENPASS; 用户已丢弃

-----------------------------------------------

sid 为 520 对应的语句 部分如下:

INSERT /*+ APPEND */                                                   INTO FACT_INFO_USER_BEFORE                                               (ACCT_MONTH,                                                            USER_NO,                                                               DEVICE_NUMBER,                                                         SERVICE_CODE,                                                          AREA_ID,                                                               CITY_ID,                                                               USER_DINNER,                                                           INNET_MONTH,                                                           AVG_ARPU,                                                              ACCT_ARPU,                                                             IS_ACCT,                                                               USER_TYPE,                                                             EXPIRE_MONTH)                                                         SELECT /*+ USE_HASH(A,B,C,D,E,F,G)*/                                    :B1,                                                                   C.USER_NO,                                                             C.DEVICE_NUMBER,                                                       C.TELE_TYPE,                                                           C.AREA_NO,                                                             C.CITY_NO,                                                             C.USER_DINNER,                                                         C.INNET_MONTH,                                                         A.AVG_FEE,                                                             B.ALL_FEE,                                                             NVL2(B.USER_NO, ‘1‘, ‘0‘),                                             (CASE                                                                    WHEN F.CLUBMEM_LEVEL_SUB_CODE_LAST IN (‘1‘, ‘2‘) AND                        F.CLUBMEM_LEVEL_SUB_CODE = ‘1‘ AND G.USER_NO IS NULL THEN          ‘1‘                                                                   WHEN F.CLUBMEM_LEVEL_SUB_CODE_LAST IN (‘1‘, ‘2‘) AND                        F.CLUBMEM_LEVEL_SUB_CODE = ‘2‘ AND G.USER_NO IS NULL THEN          ‘2‘                                                                   WHEN F.CLUBMEM_LEVEL_SUB_CODE = ‘3‘ AND C.INNET_MONTH >= 4 AND              A.AVG_FEE >= D.HIGH_STANDARD AND G.USER_NO IS NULL THEN            ‘3‘                                                                   WHEN C.INNET_MONTH >= 4 AND A.AVG_FEE >= D.HIGH_STANDARD AND                G.USER_NO IS NULL THEN                                             ‘4‘                                                                   WHEN C.INNET_MONTH >= 4 AND A.AVG_FEE < D.HIGH_STANDARD AND                 A.AVG_FEE >= D.HIGH_STANDARD * 0.8 AND E.USER_TYPE <= ‘5‘ AND           G.USER_NO IS NULL THEN                                             ‘5‘                                                                   WHEN C.INNET_MONTH >= 4 AND A.AVG_FEE < D.HIGH_STANDARD AND                 A.AVG_FEE >= D.HIGH_STANDARD * 0.8 AND E.USER_TYPE > ‘5‘ THEN       ‘6‘                                                                   WHEN C.INNET_MONTH >= 4 AND A.AVG_FEE < D.HIGH_STANDARD * 0.8 AND           A.AVG_FEE >= 30 THEN                                               ‘6‘

时间: 2024-10-27 06:59:16

ORA-04021 timeout occurred while waiting to lock object的相关文章

关于ORA-04021解决办法(timeout occurred while waiting to lock object)

某个应用正在锁定该表或者包 表为 select b.SID,b.SERIAL#,c.SQL_TEXT from v$locked_object a, v$session b, v$sqlarea c where a.SESSION_ID = b.SID and b.SQL_ADDRESS = c.ADDRESS and c.sql_text like '%table_name%' 包为 select B.SID,b.USERNAME,b.MACHINE FROM V$ACCESS A, V$SE

关于等待多长时间会引发ORA-04021: timeout occurred while waiting to lock object错误的猜测

本文的实验环境为: [[email protected] ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 10 07:18:11 2015 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 -

ORA-04021:timeout occurred while waiting to lock object

编译某存储过程 ORA-04021 timeout occurred while waiting to lock object stringstringstringstringstring Cause: While waiting to lock a library object, a timeout is occurred. Action: Retry the operation later. 查找是否有用户类型的锁,即 TM                DML排队 TX          

oracle plsql 上对package 包执行重新编译时,超时无响应:(4021)time-out occurred while waiting to lock object

问题处理过程: 开发反应包存在问题, 我一看他们的用户没对应的权限,给赋予了以下权限: GRANT debug any procedure, debug connect session TO CMSOPR; GRANT EXECUTE any procedure TO CMSOPR; 开发进行调试后没执行结果. 于是我想重新编译,先重新编译的包,半天报个响应超时,当时也没想太多,以为有死锁,于是查数据库锁 -没锁. 查数据库审计表: select * from dba_audit_trail w

org.eclipse.jdi.TimeoutException:Timeout occurred while waiting for packet 1983.occurred

1.错误描述 2.错误原因 3.解决办法

Eclipse项目导入Android Stuio 配置出现 Timeout waiting to lock buildscript class cache for build file &#39;H:\studioproject\Generic_SN\build.gradle&#39;

Eclipse项目导入Android Stuio 配置出现 Error:Timeout waiting to lock buildscript class cache for build file 'H:\studioproject\Generic_SN\build.gradle' (C:\Users\Administrator\.gradle\caches\2.2.1\scripts\build_81ep6udn3nlzszbotl32uedjz\ProjectScript\buildscri

jedis异常:NoSuchElementException: Timeout waiting for idle object

项目线上环境发现:java.util.NoSuchElementException: Timeout waiting for idle object 问题原因:不应该在try中释放资源,而应该在finally中处理.虽然是非常基础的语法,但还是有可能会写错,维护老系统时发现很几处都存在这种潜在的Bug,引以为戒.在try中释放资源,每当出现一次异常将会导致一个jedis对象无法释放,pool池中可用的jedis对象资源会越来越少,最终将会导致java.util.NoSuchElementExce

ORA-12170: TNS:Connect timeout occurred

VM 作为ORACLE 服务器,客户端登陆提示超时,本地连接使用网络连接正常. D:>sqlplus system/[email protected]//192.168.63.121:15021/pdb01 SQL*Plus: Release 11.2.0.4.0 Production on Thu Nov 10 12:00:05 2016 Copyright (c) 1982, 2013, Oracle.  All rights reserved. ERROR: ORA-12170: TNS:

Cannot get a connection, pool error Timeout waiting for idle object

Cannot get a connection, pool error Timeout waiting for idle object 异常原因 一直有hibernate的session在开启并偿试打开新连接,导致最终没有空闲链接可用. PCISV7-VHL [2017-09-07 19:10:13,625]>>>ERROR>>>[ com.isoftstone.fwk.dao.BaseDao.getNewConnection(BaseDao.java:1534) ]-