UDE-00008 ORA-31626 ORA-06512 ORA-25254

本文介绍了解决Oracle数据库中遗留DataPump任务的问题,包括如何查找这些任务、确认其状态,并提供了一套完整的清理步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在导出一个模式的时候,约140GB,出现如下错误:

UDE-00008: operation generated ORACLE error 31626
ORA-31626: job does not exist
ORA-06512: at "SYS.KUPC$QUE_INT", line 536
ORA-25254: time-out in LISTEN while waiting for a message
ORA-06512: at "SYS.DBMS_DATAPUMP", line 2772
ORA-06512: at "SYS.DBMS_DATAPUMP", line 3886
ORA-06512: at line 1

MOS上面给的解释:

CAUSE

The problem is due to the fact that there are so-called orphaned Datapump jobs (i.e. Datapump actions that failed but are not cleaned up properly) still in the database.

SOLUTION

The solution is to clean the traces of these orphaned jobs by using the steps outlined in 
Note 336014.1 - How To Cleanup Orphaned DataPump Jobs In DBA_DATAPUMP_JOBS ?

After that, restart the Datapump operation.

 


UDE-00008 ORA-31626 ORA-06512 ORA-25254 - 第1张  | Life Is Easy

UDE-00008 ORA-31626 ORA-06512 ORA-25254 - 第2张  | Life Is Easy
How To Cleanup Orphaned DataPump Jobs In DBA_DATAPUMP_JOBS ? (文档 ID 336014.1)UDE-00008 ORA-31626 ORA-06512 ORA-25254 - 第3张  | Life Is Easy转到底部

 

In this Document


Goal

Solution

Additional Resources

APPLIES TO:

Oracle Database – Enterprise Edition – Version 10.1.0.2 to 12.1.0.1 [Release 10.1 to 12.1]
Oracle Database – Standard Edition – Version 10.1.0.2 to 12.1.0.1 [Release 10.1 to 12.1]
Oracle Database – Personal Edition – Version 10.1.0.2 to 12.1.0.1 [Release 10.1 to 12.1]
Enterprise Manager for Oracle Database – Version 10.1.0.2 to 12.1.0.6.0 [Release 10.1 to 12.1]
Information in this document applies to any platform.
***Checked for relevance on 29-Apr-2014***

GOAL

How to cleanup orphaned Data Pump jobs in DBA_DATAPUMP_JOBS ?

SOLUTION

The jobs used in this example:
- Export job SCOTT.EXPDP_20051121 is a schema level export that is running
- Export job SCOTT.SYS_EXPORT_TABLE_01 is an orphaned table level export job
- Export job SCOTT.SYS_EXPORT_TABLE_02 is a table level export job that was stopped
- Export job SYSTEM.SYS_EXPORT_FULL_01 is a full database export job that is temporary stopped


Step 1. Determine in SQL*Plus which Data Pump jobs exist in the database:

%sqlplus /nolog

 

CONNECT / as sysdba 
SET lines 200 
COL owner_name FORMAT a10; 
COL job_name FORMAT a20 
COL state FORMAT a12
COL operation LIKE state 
COL job_mode LIKE state 
COL owner.object for a50

– locate Data Pump jobs: 

SELECT owner_name, job_name, rtrim(operation) "OPERATION", 
       rtrim(job_mode) "JOB_MODE", state, attached_sessions
  FROM dba_datapump_jobs
 WHERE job_name NOT LIKE 'BIN$%'
 ORDER BY 1,2;

OWNER_NAME JOB_NAME            OPERATION JOB_MODE  STATE       ATTACHED
———- ——————- ——— ——— ———– ——–
SCOTT      EXPDP_20051121      EXPORT    SCHEMA    EXECUTING          1
SCOTT      SYS_EXPORT_TABLE_01 EXPORT    TABLE     NOT RUNNING        0 
SCOTT      SYS_EXPORT_TABLE_02 EXPORT    TABLE     NOT RUNNING        0 
SYSTEM     SYS_EXPORT_FULL_01  EXPORT    FULL      NOT RUNNING        0

Step 2. Ensure that the listed jobs in dba_datapump_jobs are not export/import Data Pump jobs that are active: status should be 'NOT RUNNING'.

Step 3. Check with the job owner that the job with status 'NOT RUNNING' in dba_datapump_jobs is not an export/import Data Pump job that has been temporary stopped, but is actually a job that failed. (E.g. the full database export job by SYSTEM is not a job that failed, but was deliberately paused with STOP_JOB).

Step 4. Determine in SQL*Plus the related master tables:

– locate Data Pump master tables: 

 

SELECT o.status, o.object_id, o.object_type, 
       o.owner||'.'||object_name "OWNER.OBJECT" 
  FROM dba_objects o, dba_datapump_jobs j 
 WHERE o.owner=j.owner_name AND o.object_name=j.job_name 
   AND j.job_name NOT LIKE 'BIN$%' ORDER BY 4,2; 

STATUS   OBJECT_ID OBJECT_TYPE  OWNER.OBJECT 
——- ———- ———— ————————- 
VALID        85283 TABLE        SCOTT.EXPDP_20051121 
VALID        85215 TABLE        SCOTT.SYS_EXPORT_TABLE_02 
VALID        85162 TABLE        SYSTEM.SYS_EXPORT_FULL_01

Step 5. For jobs that were stopped in the past and won't be restarted anymore, delete the master table. E.g.:

DROP TABLE scott.sys_export_table_02;

 

– For systems with recycle bin additionally run:
purge dba_recyclebin;

Step 6. Re-run the query on dba_datapump_jobs and dba_objects (step 1 and 4). If there are still jobs listed in dba_datapump_jobs, and these jobs do not have a master table anymore, cleanup the job while connected as the job owner. E.g.:

CONNECT scott/tiger 

 

SET serveroutput on 
SET lines 100 
DECLARE 
   h1 NUMBER; 
BEGIN 
   h1 := DBMS_DATAPUMP.ATTACH('SYS_EXPORT_TABLE_01','SCOTT'); 
   DBMS_DATAPUMP.STOP_JOB (h1); 
END; 
/
 

Note that after the call to the STOP_JOB procedure, it may take some time for the job to be removed. Query the view user_datapump_jobs to check whether the job has been removed:

CONNECT scott/tiger 

 

SELECT * FROM user_datapump_jobs;
 

Step 7. Confirm that the job has been removed:

CONNECT / as sysdba 
SET lines 200  
COL owner_name FORMAT a10;  
COL job_name FORMAT a20  
COL state FORMAT a12  
COL operation LIKE state  
COL job_mode LIKE state  
COL owner.object for a50

 

– locate Data Pump jobs:  

SELECT owner_name, job_name, rtrim(operation) "OPERATION", 
       rtrim(job_mode) "JOB_MODE", state, attached_sessions
  FROM dba_datapump_jobs
 WHERE job_name NOT LIKE 'BIN$%'
 ORDER BY 1,2;

OWNER_NAME JOB_NAME            OPERATION JOB_MODE  STATE       ATTACHED 
———- ——————- ——— ——— ———– ——– 
SCOTT      EXPDP_20051121      EXPORT    SCHEMA    EXECUTING          1 
SYSTEM     SYS_EXPORT_FULL_01  EXPORT    FULL      NOT RUNNING        0 

– locate Data Pump master tables: 

SELECT o.status, o.object_id, o.object_type, 
       o.owner||'.'||object_name "OWNER.OBJECT" 
  FROM dba_objects o, dba_datapump_jobs j 
 WHERE o.owner=j.owner_name AND o.object_name=j.job_name 
   AND j.job_name NOT LIKE 'BIN$%' ORDER BY 4,2; 

STATUS   OBJECT_ID OBJECT_TYPE  OWNER.OBJECT 
——- ———- ———— ————————- 
VALID        85283 TABLE        SCOTT.EXPDP_20051121 
VALID        85162 TABLE        SYSTEM.SYS_EXPORT_FULL_01


Remarks:
1. Orphaned Data Pump jobs do not have an impact on new Data Pump jobs. The view dba_datapump_jobs is a view, based on gv$datapump_job, obj$, com$, and user$. The view shows the Data Pump jobs that are still running, or jobs for which the master table was kept in the database, or in case of an abnormal end of the Data Pump job (the orphaned job). If a new Data Pump job is started, a new entry will be created, which has no relation to the old Data Pump jobs.

2. When starting the new Data Pump job and using a system generated name, we check the names of existing Data Pump jobs in the dba_datapump_job in order to obtain a unique new system generated jobname. Naturally, there needs to be enough free space for the new master table to be created in the schema that started the new Data Pump job.

3. A Data Pump job is not the same as a job that is defined with DBMS_JOBS. Jobs created with DBMS_JOBS use there own processes. Data Pump jobs use a master process and worker process(es). In case a Data Pump still is temporary stopped (STOP_JOB while in interactive command mode), the Data Pump job still exists in the database (status: NOT RUNNING), while the master and worker process(es) are stopped and do not exist anymore. The client can attach to the job at a later time, and continue the job execution (START_JOB).

4. The possibility of corruption when the master table of an active Data Pump job is deleted, depends on the Data Pump job.

4.a. If the job is an export job, corruption is unlikely as the drop of the master table will only cause the Data Pump master and worker processes to abort. This situation is similar to aborting an export of the original export client.

4.b. If the job is an import job then the situation is different. When dropping the master table, the Data Pump worker and master processes will abort. This will probably lead to an incomplete import: e.g. not all table data was imported, and/or table was imported incomplete, and indexes, views, etc. are missing. This situation is similar to aborting an import of the original import client.

The drop of the master table itself, does not lead to any data dictionary corruption. If you keep the master table after the job completes (using the undocumented parameter: KEEP_MASTER=Y), then a drop of the master table afterwards, will not cause any corruption

<think>我们正在解决Oracle数据泵导出时出现的UDE-31623和ORA-31623错误。根据用户提供的引用(特别是文档ID1907256.1),这个错误的具体描述是:“a jobis notattached tothis sessionvia thespecified handle”(作业没有通过指定的句柄附加到当前会话)。这通常发生在尝试控制(如停止、重启或监控)一个数据泵作业时,但当前会话并没有附加到这个作业。错误原因分析:1.会话未附加作业:可能因为之前的会话已经断开,而作业在后台继续运行,此时在新的会话中尝试重新附加该作业就会失败。2.作业句柄无效:在数据泵操作中,作业句柄(handle)是唯一标识作业的。如果句柄不正确或已失效,就会导致此错误。3.作业已完成或失败:如果作业已经完成(成功或失败)而用户仍尝试附加,也会出现此错误。 解决方案: 根据Oracle官方文档(文档ID1907256.1)[^1][^2],我们可以采取以下步骤:步骤1:检查数据泵作业的状态使用以下SQL查询当前数据库中的数据泵作业状态:```sqlSELECTowner_name, job_name,operation,job_mode, stateFROM dba_datapump_jobs; ```或者(如果没有DBA权限): ```sqlSELECT *FROM user_datapump_jobs; ```步骤2:根据作业状态采取相应措施-如果作业状态(STATE)为`NOTRUNNING`、`FAILED`或`COMPLETED`,则说明作业已经结束,无法重新附加。此时,如果需要重新运行,应该使用新的作业名重新启动导出。-如果作业状态为`EXECUTING`,说明作业正在运行,但当前会话无法附加。这时,我们可以尝试重新附加到作业(见步骤3)。 步骤3:重新附加到运行中的作业(如果作业仍在运行) 在数据泵导出命令中,使用`attach`参数附加到现有作业:```bashexpdp username/passwordATTACH=<job_name> ```其中`<job_name>`是步骤1中查询到的作业名。 步骤4:如果附加成功,则可以在交互模式下控制作业(如停止、重启等)。如果附加失败(例如作业名错误或作业已不存在),则考虑终止该作业并重新启动。 步骤5:终止无法附加的作业(如果作业已挂起且无法附加) 如果作业确实存在但无法附加,且需要停止它,可以使用以下PL/SQL命令(以SYS或拥有权限的用户执行):```sqlDECLAREhdlNUMBER;BEGINhdl :=DBMS_DATAPUMP.ATTACH('<job_name>', '<owner_name>'); --作业名和所有者(从步骤1中获取)DBMS_DATAPUMP.STOP_JOB(hdl,1,0); --立即停止作业END; /``` 注意:如果作业所有者不是当前用户,需要指定所有者。步骤6:重新启动导出作业在清理了无效作业后,使用新的作业名重新启动导出: ```bashexpdpusername/password DIRECTORY=dpump_dirDUMPFILE=export.dmp LOGFILE=export.logJOB_NAME=new_job_name ...``` 预防措施:1.在脚本中使用数据泵时,确保作业名唯一(例如包含时间戳)。 2.在会话中断(如网络断开)后,先检查作业状态再尝试重新附加。3.定期清理已完成的数据泵作业。注意事项: -如果作业已经完成(成功或失败),则不需要终止,直接重新运行即可。-如果作业状态为`DEFINING`,表示作业正在创建,可以稍等片刻再尝试附加。如果上述步骤无法解决问题,可能需要检查数据泵的日志文件(通常位于DIRECTORY参数指定的目录中)以获取更多信息。 相关问题: 1.如何查看Oracle数据泵作业的详细日志?2.如何永久删除Oracle数据泵作业? 3.在Oracle数据泵中,如何从网络故障中恢复导出作业?</think>### 解决 Oracle 数据泵导出错误 UDE-31623 ORA-31623 "job not attached to session handle" 根据您提供的引用文档 ID 1907256.1[^1][^2],这个错误的核心是数据泵作业未能正确附加到当前会话句柄。以下是针对此错误的完整解决方案: #### 错误原因分析 ```mermaid graph TD A[UDE-31623/ORA-31623] --> B[会话句柄丢失] B --> C1[网络中断] B --> C2[会话超时] B --> C3[客户端异常退出] B --> C4[并行操作冲突] B --> C5[作业名重复] A --> D[作业状态不一致] D --> E1[作业仍在运行] D --> E2[作业已停止但未清除] ``` 主要触发场景: 1. **会话中断**:导出过程中网络断开或客户端异常关闭 2. **作业状态残留**:作业仍在数据库后台运行,但会话句柄丢失[^1] 3. **句柄冲突**:多个会话尝试附加同名作业(常见于脚本重复执行) 4. **权限问题**:用户权限变更导致会话无法重新附加作业 #### 解决方案步骤 ##### 1. 检查作业状态(关键步骤) ```sql -- 查询所有数据泵作业状态 SELECT owner_name, job_name, operation, job_mode, state, attached_sessions FROM dba_datapump_jobs WHERE job_name = '<your_job_name>'; -- 替换为实际作业名 -- 若无作业名,查询所有运行中作业 SELECT * FROM dba_datapump_jobs WHERE state = 'EXECUTING'; ``` - ✅ **正常状态**:`STATE = 'EXECUTING'` 且 `ATTACHED_SESSIONS > 0` - ❌ **错误状态**:`STATE = 'NOT RUNNING'` 但作业实际在运行(需强制清理) ##### 2. 重新附加作业(首选方案) ```bash expdp username/password@db \ ATTACH=<job_name> # 从步骤1获取的作业名 ``` - 成功附加后进入交互模式,可选择: - `CONTINUE_CLIENT` 恢复作业 - `STOP_JOB` 安全停止 - 若附加失败,继续下一步 ##### 3. 强制清理残留作业 ```sql DECLARE hdl NUMBER; BEGIN -- 尝试附加作业 hdl := DBMS_DATAPUMP.ATTACH('<job_name>', '<owner_name>'); -- 立即停止并删除作业 DBMS_DATAPUMP.STOP_JOB(hdl, 1, 0); EXCEPTION WHEN OTHERS THEN -- 当附加失败时直接删除作业 DBMS_DATAPUMP.DETACH('<job_name>'); END; / ``` ##### 4. 重启导出作业(预防措施) ```bash expdp username/password@db \ DIRECTORY=dpump_dir \ DUMPFILE=export_%U.dmp \ LOGFILE=export.log \ JOB_NAME=exp_$(date +%s) \ # 使用时间戳确保唯一性 PARALLEL=4 \ CLUSTER=N # 禁用集群选项(规避常见Bug) ``` 关键参数优化: - `JOB_NAME`:添加时间戳保证唯一性(避免 ORA-31623) - `CLUSTER=N`:禁用集群模式(解决引用[2]提到的并发Bug) - `PARALLEL`:根据 CPU 核心数设置(公式:$ \text{parallel} \leq \text{CPU\_cores}/2 $) ##### 5. 网络中断处理 若错误由网络中断引起: ```bash # 使用mosh替代ssh(防止会话超时) mosh user@dbserver # 在tmux/screen中启动导出 tmux new-session -s expdp expdp ... # 按Ctrl+B D脱离会话 ``` #### 预防措施 1. **会话管理**: - 使用 `nohup expdp ... &` 或 `tmux` 启动作业 - 设置 SQLNET.EXPIRE_TIME=10(分钟级心跳检测) 2. **作业监控脚本**: ```bash #!/bin/bash # 自动检测并重新附加作业 if ! expdp attach=<job_name>; then echo "Reattaching failed, restarting job..." expdp ... JOB_NAME=exp_$(date +%s) fi ``` 3. **参数优化**(`expdp` 命令行): ```bash COMPRESSION=ALL # 减少网络传输量 NETWORK_LINK=db_link # 远程导出避免客户端中断 ENCRYPTION_PASSWORD=pass # 防止凭据失效 ``` > **重要提示**:如果问题反复出现,请检查 Oracle 集群配置。引用[2]指出该错误常与 Bug 5663241/4173696 相关(集群环境下的句柄同步问题),需应用补丁或设置 `CLUSTER=N`[^2]。 #### 故障排除流程图 ```mermaid graph LR A[出现 ORA-31623] --> B{作业是否存在?} B -->|Yes| C[尝试ATTACH] B -->|No| D[重启新作业] C -->|成功| E[交互控制] C -->|失败| F[强制清理] F --> G[重启新作业] G --> H[添加唯一JOB_NAME] ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值