Skip to main content

Cleanup orphaned datapump jobs from DBA_DATAPUMP_JOBS

Cleanup orphaned datapump jobs from DBA_DATAPUMP_JOBS



In many cases you sometimes stop data pump job or in case of an abnormal end of the Data Pump job (we call it the orphaned job) or using undocumented parameter KEEP_MASTER=Y, the master table remain in the database.

It is good to know several things before doing cleanup jobs.

1) You can check the orphaned data pump from the STATE COLUMN of the view dba_datapump_jobs. And DBA_DATAPUMP_JOBS is based on gv$datapump_job, obj$, com$, and user$. Orphaned Data Pump jobs do not have an impact on new Data Pump jobs. 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) For a new data pump job without any job name it is used a system generated name. From the dba_datapump_jobs it is checked for existing data pump jobs and then obtain a unique new system generated jobname.

3) If you drop the master table while doing the data pump export or data pump import operation then the scenario is discussed below.

In case of export if you drop data pump export operation then export process will abort.

In case of import if you drop data pump import operation then import process will abort while it leads an incomplete import.

If the data pump job is completed and master table exist (a common if you do export operation with KEEP_MASTER=y) then it is safe to drop the master table.
Step by step cleanup orphaned datapump jobs is discussed below.

Step 01: Check the orphaned datapump jobs.

sqlplus / as sysdba
SET lines 140
COL owner_name FORMAT a10;
COL job_name FORMAT a20
COL state FORMAT a12
COL operation LIKE owner_name
COL job_mode LIKE owner_name
SELECT owner_name, job_name, operation, job_mode,
state, attached_sessions
FROM dba_datapump_jobs;

OWNER_NAME JOB_NAME             OPERATION  JOB_MODE   STATE        ATTACHED_SESSIONS
---------- -------------------- ---------- ---------- ------------ -----------------
ULTIMUS       SYS_EXPORT_SCHEMA_01 EXPORT     SCHEMA     NOT RUNNING                  0
ULTIMUS       SYS_EXPORT_SCHEMA_02 EXPORT     SCHEMA     NOT RUNNING                  0


/*This view gives the SADDR that assist in determining why a Data Pump session may be
having problems. Join to the V$SESSION view for further information.*/

SELECT * FROM DBA_DATAPUMP_SESSIONS

/*This view helps determine how well a Data Pump export is doing.
Basically gives you a progress indicator through the MESSAGE column.*/

select username,opname,target_desc,sofar,totalwork,message from V$SESSION_LONGOPS


Step 02: Check the state field. 

For orphaned jobs the state will be NOT RUNNING. So from the output we can say both are orphaned jobs.

Step 03: Drop the master table.

SELECT 'drop table ULTIMUS.'||job_name||';'
FROM dba_datapump_jobs t;
--where t.job_name<>'SYS_EXPORT_SCHEMA_98';


drop table ULTIMUS.SYS_EXPORT_SCHEMA_98;

Step 04: Check for existing data pump jobs by query issued in step 01.

If objects are in recyclebin bin then purge the objects from the recyclebin.


SQL> SELECT owner_name, job_name, operation, job_mode,
   state, attached_sessions
   FROM dba_datapump_jobs;

OWNER_NAME JOB_NAME             OPERATION  JOB_MODE   STATE        ATTACHED_SESSIONS
---------- -------------------- ---------- ---------- ------------ -----------------
ULTIMUS       BIN$xMNQdACzQ6yl22kj EXPORT     SCHEMA     NOT RUNNING                  0
          9U0B8A==$0
ULTIMUS       BIN$BmUy4r5MSX+ojxFk EXPORT     SCHEMA     NOT RUNNING                  0
          sw8ocg==$0


SELECT 'PURGE table ULTIMUS.'||job_name||';'
FROM dba_datapump_jobs t;
--where t.job_name<>'SYS_EXPORT_SCHEMA_98';
PURGE table ULTIMUS.SYS_EXPORT_SCHEMA_98;

SQL> PURGE TABLE ULTIMUS.SYS_EXPORT_SCHEMA_01;

SQL> PURGE TABLE ULTIMUS.SYS_EXPORT_SCHEMA_02;

Check if there is any orphaned jobs again.
SQL> SELECT owner_name, job_name, operation, job_mode,
state, attached_sessions
FROM dba_datapump_jobs;

no rows selected

Step 05: In this stage you did not get any orphaned jobs if the jobs have a master table.

If there are still jobs listed in dba_datapump_jobs do cleanup process like below.


SET serveroutput on
SET lines 100
DECLARE
  job1 NUMBER;
BEGIN
  job1 := DBMS_DATAPUMP.ATTACH('SYS_EXPORT_SCHEMA_01','ULTIMUS');
  DBMS_DATAPUMP.STOP_JOB (job1);
END;
/

DECLARE
  job2 NUMBER;
BEGIN
  job2 := DBMS_DATAPUMP.ATTACH('SYS_EXPORT_SCHEMA_02','ULTIMUS');
  DBMS_DATAPUMP.STOP_JOB (job2);
END;
/
__________________________________________________________________________

Comments

Popular posts from this blog

EXPDP/IMPDP Export/Import dumpfile to a Remote Server Using Network_Link.

EXPDP/IMPDP Export/Import dumpfile to a Remote Server Using Network_Link. Step 1:   First you have to create a TNS entry at destination database which will be used to connect to the remote target database. pumplink =   (DESCRIPTION =     (ADDRESS_LIST =       (ADDRESS = (PROTOCOL = TCP)(HOST = 172.17.1.171)(PORT = 1521))     )     (CONNECT_DATA =       (SERVER = DEDICATED)       (SERVICE_NAME = Ultimus)     )   ) Step 2:   Connect to SQL plus: --Issue the following command to create db link on destination database: CREATE PUBLIC DATABASE LINK pumplink    connect to scott identified by tiger USING 'pumplink'; Step 3:   Issue the expdp command on the destination server using Network_link parameter: expdp scott/tiger directory= dumpdir logfile=impi_temp.log network_link= pumplink  schemas=scott dump...

Solution of problem: Resultset Exceeds the Maximum Size (100 MB)

Solution of problem: Resultset Exceeds the Maximum Size (100 MB) I was running a select statement in PL/SQL Developer. it was a short query but the data volume that the query was fetching was huge. But when ever i Click the button Fetch Last Page or press 'ALT+End' button a message box comes after a while saying: Then I started looking for the exact reason of this sort of problem in Google. When I realized there was no direct solution in the web, I started looking the PL/SQL Developer Software menu and found the ultimate solution. The reason of this problem is there is a parameter of maximum result set size in PL/SQL Developer Software which is by default set to 100 MB. To change this parameter you have to go to the following location: 1. Goto Edit Menu and click ' PL/SQL Beautifier Options '. A new window will open. 2. Click SQL Window of " Window Types ". 3. Now Change the value of "Maximum Result Set Size( 0 is unlimited)"  ...

10g Release 2 (10.2.0.5) Patch Set 4 for Solaris Operating System (x86-64)

10g Release 2 (10.2.0.5) Patch Set 4 for Solaris Operating System (x86-64) PART ONE: Applying Patch___________________________________________________ Step 1:  Shut Down Oracle Databases SQL> shutdown immediate;  Shut down any existing Oracle Database instances with normal or immediate priority. On Oracle RAC systems, shut down all instances on each node. Step 2: Stopping All Processes for a Single Instance Installation Shut down the following Oracle Database 10g processes in the order specified before installing the patch set:  Shut down all processes in the Oracle home that might be accessing a database; for example, Oracle Enterprise Manager Database Control: $ emctl stop dbconsole $ lsnrctl stop Step 3: To install the Oracle Database 10g patch set interactively: a. Log in as the oracle user. b. Enter the following commands to start Oracle Universal Installer, where patchset_directory is the directory where you unpac...