首页 > 代码库 > ORA-20011 ORA-29913 and ORA-29400 with Associated KUP-XXXXX Errors from DBMS_STATS.GATHER_STATS_JOB(Doc ID 1274653.1)

ORA-20011 ORA-29913 and ORA-29400 with Associated KUP-XXXXX Errors from DBMS_STATS.GATHER_STATS_JOB(Doc ID 1274653.1)

首先在alert log裡面頻繁的看見如下錯誤:

DBMS_STATS: GATHER_STATS_JOB encountered errors.  Check the trace file.
Errors in file /oracle/diag/rdbms/phalr/phalr/trace/phalr_j001_5306.trc:
ORA-20011: Approximate NDV failed: ORA-29913: error in executing ODCIEXTTABLEOPEN callout
KUP-11024: This external table can only be accessed from within a Data Pump job.

查看trc文件

oracle@phalrdb1: /oracle/diag/rdbms/phalr/phalr/trace> more /oracle/diag/rdbms/phalr/phalr/trace/phalr_j001_5306.trc
Trace file /oracle/diag/rdbms/phalr/phalr/trace/phalr_j001_5306.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /oracle/product/11.2.0
System name:    Linux
Node name:    phalrdb1
Release:    2.6.32-431.el6.x86_64
Version:    #1 SMP Sun Nov 10 22:19:54 EST 2013
Machine:    x86_64
Instance name: phalr
Redo thread mounted by this instance: 1
Oracle process number: 46
Unix process pid: 5306, image: oracle@phalrdb1 (J001)


*** 2016-11-19 06:00:13.568
*** SESSION ID:(2209.51473) 2016-11-19 06:00:13.568
*** CLIENT ID:() 2016-11-19 06:00:13.568
*** SERVICE NAME:(SYS$USERS) 2016-11-19 06:00:13.568
*** MODULE NAME:(DBMS_SCHEDULER) 2016-11-19 06:00:13.568
*** ACTION NAME:(ORA$AT_OS_OPT_SY_2339) 2016-11-19 06:00:13.568
 
ORA-20011: Approximate NDV failed: ORA-29913: error in executing ODCIEXTTABLEOPEN callout
KUP-11024: This external table can only be accessed from within a Data Pump job.

*** 2016-11-19 06:00:13.568
DBMS_STATS: GATHER_STATS_JOB: GATHER_TABLE_STATS(‘"PHALWDA1"‘,‘"ET$081400230001"‘,‘""‘, ...)
DBMS_STATS: ORA-20011: Approximate NDV failed: ORA-29913: error in executing ODCIEXTTABLEOPEN callout
KUP-11024: This external table can only be accessed from within a Data Pump job.

不太看得明白,去MOS搜索到一篇文章

ORA-20011 ORA-29913 and ORA-29400 with Associated KUP-XXXXX Errors from DBMS_STATS.GATHER_STATS_JOB (Doc ID 1274653.1)

该文详尽的描述了解决这个异常,我们在datadump导入导出的都是,都会产生一个类似SYS_EXPORT_TABLE_02的表,如果是正常导完oracle会自动清除这个表,那么如果导入导出的时候中断,那么这个表就不会被清除,这个ora错误的引起就与这个有关系。

Temporary Datapump external tables have not been cleaned up properly. The dictionary information should have been dropped when the DataPump jobs completed.

解决方案就是清除Datapump遗留的临时外部表,下面是详细过程

[BEGIN] 2016/11/25 下午 05:19:51
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
SQL>
-- locate Data Pump jobs:
SQL>
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$%‘
  5   ORDER BY 1,2;

OWNER_NAME JOB_NAME        OPERATION    JOB_MODE      STATE        ATTACHED_SESSIONS
---------- -------------------- ------------ ------------ ------------ -----------------
PHALWDA1   SYS_EXPORT_TABLE_01    EXPORT         TABLE      NOT RUNNING               0
PHALWDA1   SYS_EXPORT_TABLE_02    EXPORT         TABLE      NOT RUNNING               0
PHALWDA1   SYS_IMPORT_FULL_01    IMPORT         FULL      NOT RUNNING               0

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
  5     AND j.job_name NOT LIKE ‘BIN$%‘ ORDER BY 4,2;

STATUS               OBJECT_ID OBJECT_TYPE                           OWNER.OBJECT
--------------------- ---------- --------------------------------------------------------- --------------------------------------------------
VALID               76494 TABLE                               PHALWDA1.SYS_EXPORT_TABLE_01
VALID               76497 TABLE                               PHALWDA1.SYS_EXPORT_TABLE_02
VALID               81868 TABLE                               PHALWDA1.SYS_IMPORT_FULL_01

SQL> drop table PHALWDA1.SYS_EXPORT_TABLE_01;

Table dropped.

SQL> drop table PHALWDA1.SYS_EXPORT_TABLE_02;

Table dropped.

SQL> drop table PHALWDA1.SYS_IMPORT_FULL_01;

Table dropped.


SQL> purge dba_recyclebin;

DBA Recyclebin purged.

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
SQL>
-- locate Data Pump jobs:
SQL>
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$%‘
  5   ORDER BY 1,2;

no rows selected

spool obj.out
set linesize 200 trimspool on
set pagesize 2000
col owner form a30
col created form a25
col last_ddl_time form a25
col object_name form a30
col object_type form a25
SQL>
select OWNER,OBJECT_NAME,OBJECT_TYPE, status,
to_char(CREATED,‘dd-mon-yyyy hh24:mi:ss‘) created
,to_char(LAST_DDL_TIME , ‘dd-mon-yyyy hh24:mi:ss‘) last_ddl_time
from dba_objects
where object_name like ‘ET$%‘
/

select owner, TABLE_NAME, DEFAULT_DIRECTORY_NAME, ACCESS_TYPE

OWNER                   OBJECT_NAME              OBJECT_TYPE        STATUS              CREATED            LAST_DDL_TIME
------------------------------ ------------------------------ ------------------------- --------------------- ------------------------- -------------------------
PHALWDA1               ET$081400230001              TABLE            VALID              01-oct-2016 08:35:49    01-oct-2016 08:35:49

from dba_external_tables
order by 1,2
/


OWNER                   TABLE_NAME
------------------------------ ------------------------------------------------------------------------------------------
DEFAULT_DIRECTORY_NAME                                       ACCESS_TYPE
------------------------------------------------------------------------------------------ ---------------------
PHALWDA1               ET$081400230001
BACKUP                                               CLOB


SQL> SQL> spool off
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
oracle@phalrdb1: /home/oracle> ls
cc  chk_cmd  chk_lst  dba_cmd  obj.out
oracle@phalrdb1: /home/oracle> more obj.out
SQL> set linesize 200 trimspool on
SQL> set pagesize 2000
SQL> col owner form a30
SQL> col created form a25
SQL> col last_ddl_time form a25
SQL> col object_name form a30
SQL> col object_type form a25
SQL>
SQL> select OWNER,OBJECT_NAME,OBJECT_TYPE, status,
  2  to_char(CREATED,‘dd-mon-yyyy hh24:mi:ss‘) created
  3  ,to_char(LAST_DDL_TIME , ‘dd-mon-yyyy hh24:mi:ss‘) last_ddl_time
  4  from dba_objects
  5  where object_name like ‘ET$%‘
  6  /

OWNER                          OBJECT_NAME                    OBJECT_TYPE               STATUS                CREATED                   LAST_DDL_TIME
------------------------------ ------------------------------ ------------------------- --------------------- ------------------------- --------------------
-----
PHALWDA1                       ET$081400230001                TABLE                     VALID                 01-oct-2016 08:35:49      01-oct-2016 08:35:49

SQL>
SQL> select owner, TABLE_NAME, DEFAULT_DIRECTORY_NAME, ACCESS_TYPE
  2  from dba_external_tables
  3  order by 1,2
  4  /

OWNER                          TABLE_NAME
------------------------------ ------------------------------------------------------------------------------------------
DEFAULT_DIRECTORY_NAME                                                                     ACCESS_TYPE
------------------------------------------------------------------------------------------ ---------------------
PHALWDA1                       ET$081400230001
BACKUP                                                                                     CLOB


SQL>
SQL> spool off
oracle@phalrdb1: /home/oracle> sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 25 17:33:55 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> drop table PHALWDA1.ET$081400230001 purge;

Table dropped.


[END] 2016/11/25 下午 05:35:40

参考:

ORA-20011 ORA-29913 and ORA-29400 with Associated KUP-XXXXX Errors from DBMS_STATS.GATHER_STATS_JOB (Doc ID 1274653.1)

How To Cleanup Orphaned DataPump Jobs In DBA_DATAPUMP_JOBS ? (Doc ID 336014.1)

ORA-20011 ORA-29913 and ORA-29400 with Associated KUP-XXXXX Errors from DBMS_STATS.GATHER_STATS_JOB(Doc ID 1274653.1)