Can Not Delete Archive Log Used in a CONTINUOUS_MINE Mode Logminer Session (Doc ID 763700.1)

Last updated on NOVEMBER 28, 2016

Applies to:

Oracle Server - Enterprise Edition - Version: 10.2.0.1 to 10.2.0.4 - Release: 10.2 to 10.2
Information in this document applies to any platform.
***Checked for relevance on 21-FEB-2012***

Symptoms

When a Logminer ad-hoc session was started, then the initial set of logfiles opened by the call to start the session would remain open for the duration of the query.

In continuous mode (DBMS_LOGMNR.CONTINUOUS_MINE ) this could be days, weeks or months, leading to problems with purging of old archive logs.

Using an OS utility it can be seen that the shadow process for a SQL query against V$LOGMNR_CONTENTS is keeping old logfiles open. For instance, on UNIX you can verify this with the OS command 'fuser'. If running 'fuser *' on the archive directory you will see the file handle is still open.

The next example demonstrates this:

connect / as sysdba
 
create user test identified by test default tablespace users temporary tablespace temp;
grant connect, resource to test;
 
connect test/test

create table testtab
(
   first  varchar2(10),
   second varchar2(10)
)
nocompress logging
storage (pctincrease 0 buffer_pool keep) tablespace users;
 
connect / as sysdba
 
alter database add Supplemental log data;

begin
  dbms_logmnr_d.build (options => dbms_logmnr_d.store_in_redo_logs);
end;
/

select name from v$archived_log where dictionary_begin='YES';
 
-- NAME
-- ------------------------------------------------------
-- D:\Oracle\oradata\ORCL102\Arch\ARC00803_0608575866.001
-- D:\Oracle\oradata\ORCL102\Arch\ARC00804_0608575866.001
 
alter system switch logfile;

variable n number;
begin
  :n := dbms_flashback.get_system_change_number;
end;
/
print n -->> shows 498758
 
truncate table test.testtab;
 
insert into test.testtab (first, second) values ('jose', 'jimeniz');
insert into test.testtab (first, second) values ('fred', 'flinstone');
commit;
 
update test.testtab set first = 'jacob' where first = 'jose';
delete from test.testtab where second = 'flintstone';
commit;

begin
  :n := dbms_flashback.get_system_change_number;
end;
/
print n -->> shows 498860

begin
  dbms_logmnr.add_logfile (logfilename => 'D:\Oracle\oradata\ORCL102\Arch\ARC00803_0608575866.001', options => dbms_logmnr.new);
  dbms_logmnr.add_logfile (logfilename => 'D:\Oracle\oradata\ORCL102\Arch\ARC00804_0608575866.001', options => dbms_logmnr.addfile);
  dbms_logmnr.add_logfile (logfilename => 'D:\Oracle\oradata\ORCL102\Arch\ARC00805_0608575866.001', options => dbms_logmnr.addfile);
end;
/

begin
  dbms_logmnr.start_logmnr (startscn => 498758, options => dbms_logmnr.dict_from_redo_logs + dbms_logmnr.continuous_mine + dbms_logmnr.print_pretty_sql + dbms_logmnr.ddl_dict_tracking);
end;
/
 
-- From another session and executed at OS level
del D:\Oracle\oradata\ORCL102\Arch\ARC00803_0608575866.001
del D:\Oracle\oradata\ORCL102\Arch\ARC00804_0608575866.001
del D:\Oracle\oradata\ORCL102\Arch\ARC00805_0608575866.001
 
-- Second and Third file can be removed without problem !
-- First file gives following error:
-- Error msg: Cannot delete ARC00803_0608575866.001:
-- It is being used by another person or program
-- Close any programs that might be using the file and try again

-- First session again
begin
  dbms_logmnr.end_logmnr;
end;
/

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms