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: to - Release: 10.2 to 10.2
Information in this document applies to any platform.
***Checked for relevance on 21-FEB-2012***


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 (options => dbms_logmnr_d.store_in_redo_logs);

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

variable n number;
  :n := dbms_flashback.get_system_change_number;
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');
update test.testtab set first = 'jacob' where first = 'jose';
delete from test.testtab where second = 'flintstone';

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

  dbms_logmnr.add_logfile (logfilename => 'D:\Oracle\oradata\ORCL102\Arch\ARC00803_0608575866.001', options =>;
  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);

  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);
-- 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


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