Data Pump Monitor

Export Jobs

A simple way to gain insight into the status of a Data Pump job is to look into a few views maintained within the Oracle instance the Data Pump job is running. These views are DBA_DATAPUMP_JOBS, DBA_DATAPUMP_SESSIONS, and V$SESSION_LOGOPS. These views are critical in the monitoring of your export jobs so, as we will see in a later article, you can attach to a Data Pump job and modify the execution of the that job. DBA_DATAPUMP_JOBS

This view will show the active Data Pump jobs, their state, degree of parallelism, and the number of sessions attached.

SQL> select * from dba_datapump_jobs

OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE DEGREE ATTACHED_SESSIONS
---------- ---------------------- ---------- ---------- ------------- --------- -----------------
JKOOP SYS_EXPORT_FULL_01 EXPORT FULL EXECUTING 1 1
JKOOP SYS_EXPORT_SCHEMA_01 EXPORT SCHEMA EXECUTING 1 1
DBA_DATAPUMP_SESSIONS

This view give 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.

SQL> SELECT * FROM DBA_DATAPUMP_SESSIONS


OWNER_NAME JOB_NAME SADDR
---------- ------------------------------ --------
JKOOPMANN SYS_EXPORT_FULL_01 225BDEDC
JKOOPMANN SYS_EXPORT_SCHEMA_01 225B2B7C
V$SESSION_LONGOPS

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

USERNAME OPNAME TARGET_DES SOFAR TOTALWORK MESSAGE
-------- -------------------- ---------- ----- ---------- ------------------------------------------------
JKOOP SYS_EXPORT_FULL_01 EXPORT 132 132 SYS_EXPORT_FULL_01:EXPORT:132 out of 132 MB done
JKOOP SYS_EXPORT_FULL_01 EXPORT 90 132 SYS_EXPORT_FULL_01:EXPORT:90 out of 132 MB done
JKOOP SYS_EXPORT_SCHEMA_01 EXPORT 17 17 SYS_EXPORT_SCHEMA_01:EXPORT:17 out of 17 MB done
JKOOP SYS_EXPORT_SCHEMA_01 EXPORT 19 19 SYS_EXPORT_SCHEMA_01:EXPORT:19 out of 19 MB done

select sid, serial#, sofar, totalwork, dp.owner_name, dp.state, dp.job_mode
from gv$session_longops sl, gv$datapump_job dp
where sl.opname = dp.job_name and sofar != totalwork;

SID SERIAL# SOFAR TOTALWORK OWNER_NAME STATE JOB_MODE
———- ———- ———- ———- —————————— —————————— ——————————
122 64151 1703 2574 SYSTEM EXECUTING FULL


Import Job

You can monitor an Oracle import in several ways:

select sid, serial#
from v$session s, dba_datapump_sessions d
where s.saddr = d.saddr;

select sid, serial#, sofar, totalwork
from v$session_longops;

select x.job_name,b.state,b.job_mode,b.degree
, x.owner_name,z.sql_text, p.message
, p.totalwork, p.sofar
, round((p.sofar/p.totalwork)*100,2) done
, p.time_remaining
from dba_datapump_jobs b
left join dba_datapump_sessions x on (x.job_name = b.job_name)
left join v$session y on (y.saddr = x.saddr)
left join v$sql z on (y.sql_id = z.sql_id)
left join v$session_longops p ON (p.sql_id = y.sql_id)
WHERE y.module='Data Pump Worker'
AND p.time_remaining > 0;
SELECT w.sid, w.event, w.seconds_in_wait
FROM V$SESSION s, DBA_DATAPUMP_SESSIONS d, V$SESSION_WAIT w
WHERE s.saddr = d.saddr AND s.sid = w.sid;

Kill, cancel and resume or restart datapump expdp and impdp jobs

The expdp and impdp utilities are command-line driven, but when starting them from the OS-prompt, one does not notice it. When you want to kill, cancel, start or resume a job, you will and up in the datapump command prompt… now what?! All command shown here can be used with expdp and impdp datapump.

Identifying datapump jobs

Do a select from dba_datapump_jobs in sqlplus to get the job name: > expdp system full=y

SELECT owner_name, job_name, operation, job_mode, state FROM dba_datapump_jobs;

OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE
---------- -------------------- ---------- ---------- ------------
SYSTEM SYS_EXPORT_FULL_01 EXPORT FULL EXECUTING

Or when you use the JOB_NAME parameter when datapumping, you already identified the job with a name. You don’t need to look up afterwards…

expdp system full=y JOB_NAME=EXP_FULL

OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE
---------- -------------------- ---------- ---------- ------------
SYSTEM EXP_FULL EXPORT FULL EXECUTING

Killing or stopping a running datapump job

The difference between Kill and Stop is simple to explain. When killing a job, you won’t be able to resume or start it again. Also logs and dumpfiles will be removed! When exporting (or importing), press Ctrl-c to show the datapump prompt and type KILL_JOB or STOP_JOB[=IMMEDIATE]. You will be prompted to confirm if you are sure… Adding ‘=IMMEDIATE‘ to STOP_JOB will not finish currently running ‘sub-job’ and must be redone when starting it again.

Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
[Ctrl-c]
Export> KILL_JOB
..or..
Export> STOP_JOB=IMMEDIATE
Are you sure you wish to stop this job ([yes]/no): yes
Resuming a stopped job
Identify your job with SQL or you already knew it because you used ‘JOB_NAME=‘ ;)
SELECT owner_name, job_name, operation, job_mode, state
FROM dba_datapump_jobs;

OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE
---------- -------------------- ---------- ---------- ------------
SYSTEM EXP_FULL EXPORT FULL NOT RUNNING
Now we can ATTACH to the job using it as a parameter to the expdp or impdp command, and a lot of gibberish is shown:
> expdp system ATTACH=EXP_FULL

Job: EXP_FULL
Owner: SYSTEM
Operation: EXPORT
Creator Privs: TRUE
GUID: A5441357B472DFEEE040007F0100692A
Start Time: Thursday, 08 June, 2011 20:23:39
Mode: FULL
Instance: db1
Max Parallelism: 1
EXPORT Job Parameters:
Parameter Name Parameter Value:
CLIENT_COMMAND system/******** full=y JOB_NAME=EXP_FULL
State: IDLING
Bytes Processed: 0
Current Parallelism: 1
Job Error Count: 0
Dump File: /u01/app/oracle/admin/db1/dpdump/expdat.dmp
bytes written: 520,192

Worker 1 Status:
Process Name: DW00
State: UNDEFINED
(Re)start the job with START_JOB, use ‘=SKIP_CURRENT‘ if you want to skip the current job. To show progress again, type CONTINUE_CLIENT (Job will be restarted if idle).
Export> START_JOB[=SKIP_CURRENT]
Export> CONTINUE_CLIENT
Job EXP_FULL has been reopened at Thursday, 09 June, 2011 10:26
Restarting "SYSTEM"."EXP_FULL": system/******** full=y JOB_NAME=EXP_FULL

Processing object type DATABASE_EXPORT/TABLESPACE
Processing object type DATABASE_EXPORT/PROFILE

Kill Export Job

select sid, serial#, sofar, totalwork, dp.owner_name, dp.state, dp.job_mode
from gv$session_longops sl, gv$datapump_job dp
where sl.opname = dp.job_name and sofar != totalwork;


Analyze Import Log File

Prerequisite: import file is in the "imp_dir"

Step 1: Create external table

create or replace directory imp_dir as '/dba_cloudfs/datapump/vossit01/export/pvos/';

grant read on directory imp_dir to public;
grant write on directory imp_dir to public;

drop table import_log;

create table
   import_log(msg VARCHAR2(160))
organization external (
    type oracle_loader
    default directory imp_dir
   access parameters ( records delimited by newline)
    location ('import_vossit01.log')
)
reject limit 3000;

select * from import_log;

Step 2: Run Analysis

set lines 300
set pages 55

col mssg form a110

-- select substr(substr(msg,24),1,instr(substr(msg,24),':')-1), count(*)
-- from import_log
-- where substr(msg,1,9) = '&err_code'
-- group by substr(substr(msg,24),1,instr(substr(msg,24),':')-1);

select substr(msg,1,9), count(*) tally,
case substr(msg,1,9)
  when 'ORA-12911' then 'permanent tablespace cannot be temporary tablespace'||chr(10)||
                        'ACTIONS: ALTER USER  LOCAL TEMPORARY TABLESPACE ;'
  when 'ORA-39083' then 'Object type failed to create with error'||chr(10)||
                        'ACTIONS: Object type USER failed to create with error - related to local temporary tablespace '||chr(10)||
                        'Investigate missing privilges on DB schema objects such as procedure, package or view.'
  when 'ORA-31684' then 'Object type already exists'||chr(10)||
                        'ACTIONS: No action to take; ignore error message'
  when 'ORA-39082' then 'Object type created with compilation warnings'||chr(10)||
                        'ACTIONS: Investigate missing privilges on DB schema objects such as procedure, package or view.'
  when 'ORA-04042' then 'procedure, function, package, or package body does not exist'||chr(10)||
                        'ACTIONS: ALTER USER  LOCAL TEMPORARY TABLESPACE ;'
  when 'ORA-01775' then 'looping chain of synonyms'||chr(10)||
                        'ACTIONS: Investigate the reason for the synonym being orphaned.'
  when 'ORA-01919' then 'role NONE does not exist'||chr(10)||
                        'ACTIONS: Ignore errors after confirming these missing grants do not impact your import goals'||chr(10)||
                        ' Consult with MOS note: Doc ID 1916469.1'
  when 'ORA-04045' then 'Errors during recompilation/revalidation'||chr(10)||
                        'ACTIONS: No action to take; secondary error message seeen associated withn looping synonyms'
  when 'ORA-01950' then 'no privileges on tablespace'||chr(10)||
                        'ACTIONS: ALTER USER  QUOTA 100M ON '||chr(10)||
                        'GRANT UNLIMITED TABLESPACE TO '
  when 'ORA-27477' then 'DB_AUTOMATIC_MAINTENANCE_WNDW already exists'||chr(10)||
                        'ACTIONS: No action to take; ignore error message'
  when 'ORA-04021' then 'timeout occurred while waiting to lock object SYS.oracle/i18n/data/lx20001.glb'||chr(10)||
                        'ACTIONS: ALTER SESSION SET DDL_LOCK_TIMEOUT'||chr(10)||
                        'Kill the session holding the object'
  when 'ORA-39111' then 'Dependent object type OBJECT_GRANT:SYSTEM. SELECT skipped'||chr(10)||
                        'ACTIONS: Relatd to error messaage ORA-31684'
  when 'ORA-31685' then 'Object type USER:SYS failed due to insufficient privileges. Failing sql is:'||chr(10)||
                        'ACTIONS: Investigate each incident'
  when 'ORA-13830' then 'SQL profile or patch with category DEFAULT already exists for this SQL statement'||chr(10)||
                        'ACTIONS: No action to take ignore error message'
  else '** unknown **'
END mssg
from import_log
where msg like 'ORA-%'
group by substr(msg,1,9)
order by 2 DESC
/

select msg from import_log where substr(msg,1,9) = '&err_code';

HOME