Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

APPLIES TO:

Oracle SOA Suite - Version 11.1.1.1.0 to 12.2.1.0.0 [Release 11gR1 to 12c]


Information in this document applies to any platform.

GOAL

Show how to run the purge scripts step by step.

Show also how to monitoring the current purge script execution.

Also include queries to get information before and after running the purge scripts.

SOLUTION

This note show how to run the purge script step by step and other tips to do
understand the purge scripts execution.

 This is the first query executed by the purge scripts to know the ecid feasible to
be delete.

select unique(ecid) from composite_instance where (

bitand(state,127)=1 or

bitand(state,16)=16 or

bitand(state,64)=64 or state between 32 and 63 or

state = 3 or state =19)

and created_time >= to_timestamp('2012-12-01','YYYY-MM-DD')

and created_time <= to_timestamp('2012-12-31','YYYY-MM-DD')

and ecid not in (select ecid from prune_running_insts );

As example you will got something like the following output:

ECID
----------------------------------------------------------------------------------------------------
1357a44e35b4c3cd:32b103ab:13bb5484207:-8000-0000000000a29180
1357a44e35b4c3cd:32b103ab:13bb5484207:-8000-000000000091348b
1357a44e35b4c3cd:32b103ab:13bb5484207:-8000-0000000000a01bb9
1357a44e35b4c3cd:32b103ab:13bb5484207:-8000-00000000008eea46
1357a44e35b4c3cd:78cfa31f:13b62df6c03:-8000-0000000000000bee
1357a44e35b4c3cd:32b103ab:13bb5484207:-8000-00000000009cdc93
1357a44e35b4c3cd:32b103ab:13bb5484207:-8000-00000000008f015f
1357a44e35b4c3cd:-5f256b44:13bb540af47:-8000-000000000000065f
1357a44e35b4c3cd:32b103ab:13bb5484207:-8000-00000000008edb01
1357a44e35b4c3cd:32b103ab:13bb5484207:-8000-000000000091923b
1357a44e35b4c3cd:32b103ab:13bb5484207:-8000-00000000008ebfd7
1357a44e35b4c3cd:32b103ab:13bb5484207:-8000-0000000000918485
1357a44e35b4c3cd:78cfa31f:13b62df6c03:-8000-00000000000008f4
1357a44e35b4c3cd:32b103ab:13bb5484207:-8000-00000000008f112a

 and also this query executed give 0 records:


select ecid from prune_running_insts;

with that we can assume that doesn't exists running instances.

 C. To know the potential rows to be deleted on the cube instance we execute the following:
select to_char(CREATION_DATE, 'MM-YYYY'), state, count(*) from
BD25_SOAINFRA.cube_instance where state >= 5 group by
to_char(CREATION_DATE, 'MM-YYYY'), state;

TO_CHAR(CREATION_DATE,'MM-YYYY') STATE COUNT(*)

-------------------------------- -------------------------------------- --------


03-2013 5 224372
11-2012 10 2
01-2013 8 1
05-2013 5 10
04-2013 5 28
03-2013 8 1
03-2013 9 4
03-2013 10 58
12-2012 5 3632
05-2013 10 11
04-2013 10 165

On the month of March exists 224372 potential to be dropped. If we execute the purge scripts for that month in particular

 If we want to know the days in particular to be more exactly.

TO_CHAR(CREATION_DATE,'DD-MM-YYYY') STATE COUNT(*)

----------------------------------- -------------------------------------- --------


21-03-2013 10 15
27-03-2013 5 7
26-04-2013 10 3
07-01-2013 8 1
28-03-2013 5 5
20-03-2013 5 17
14-03-2013 10 1
15-03-2013 5 1
29-04-2013 10 1
09-03-2013 10 12
16-04-2013 10 9
14-03-2013 5 7
23-04-2013 10 2
05-03-2013 5 53742
08-03-2013 10 9
04-04-2013 5 6
08-04-2013 10 24
01-05-2013 5 2
21-03-2013 5 11
28-04-2013 10 3
23-04-2013 5 4
04-03-2013 8 1
16-04-2013 5 8
02-05-2013 10 1
22-03-2013 10 21
24-04-2013 10 11
07-12-2012 5 3632
04-03-2013 5 39708
10-04-2013 10 48
12-04-2013 5 7
17-04-2013 10 1
13-03-2013 5 8
01-03-2013 5 8
06-03-2013 5 53542
07-03-2013 5 53752
08-03-2013 5 23564
15-04-2013 10 27
22-04-2013 5 1
12-04-2013 10 1
10-04-2013 5 2
02-05-2013 5 8
01-05-2013 10 10
25-04-2013 10 2
19-11-2012 10 2
04-03-2013 9 4
11-04-2013 10 30
22-04-2013 10 3

 We will execute the purge scExecuting the purge scripts for that period in
particular. But before that, let's elaborate this file with the following:

[oracle@dbcomputer SQL]$ cat purgescript-month.sql

ALTER PROCEDURE debug_purge COMPILE PLSQL_CCFLAGS = 'debug_on:TRUE' REUSE SETTINGS;


ALTER PROCEDURE log_info COMPILE PLSQL_CCFLAGS = 'debug_on:TRUE' REUSE SETTINGS;

SET SERVEROUTPUT ON;

spool '/home/oracle/PurgeLogs/spool.log';

select to_char(CREATION_DATE, 'MM-YYYY'), state, count(*) from BD25_SOAINFRA.cube_instance where state >= 5
group by to_char(CREATION_DATE, 'MM-YYYY'), state order by 1;

DECLARE

MAX_CREATION_DATE timestamp;
MIN_CREATION_DATE timestamp;
batch_size integer;
max_runtime integer;
retention_period timestamp;
BEGIN

MIN_CREATION_DATE := to_timestamp('2013-03-01','YYYY-MM-DD');
MAX_CREATION_DATE := to_timestamp('2013-03-31','YYYY-MM-DD');
max_runtime := 60;
retention_period := to_timestamp('2013-05-01','YYYY-MM-DD');
batch_size := 10000;
soa.delete_instances(
min_creation_date => MIN_CREATION_DATE,
max_creation_date => MAX_CREATION_DATE,
batch_size => batch_size,
max_runtime => max_runtime,
retention_period => retention_period,
purge_partitioned_component => false);
END;

select to_char(CREATION_DATE, 'MM-YYYY'), state, count(*) from BD25_SOAINFRA.cube_instance where state >= 5
group by to_char(CREATION_DATE, 'MM-YYYY'), state order by 1;

spool off;

ALTER PROCEDURE debug_purge COMPILE PLSQL_CCFLAGS = 'debug_on:false' REUSE SETTINGS;


ALTER PROCEDURE log_info COMPILE PLSQL_CCFLAGS = 'debug_on:false' REUSE SETTINGS;

 Create also the following file: sqlview.sql


column status format a10

set feedback off

set serveroutput on

select username, sid, serial#, process, status from v$session


where username is not null

column username format a20


column sql_text format a55 word_wrapped

set serveroutput on size 1000000

declare

x number;

begin
for x in

( select username||'('||sid||','||serial#||') ospid = ' || process ||' program = ' || program


username, to_char(LOGON_TIME,' Day HH24:MI') logon_time, to_char(sysdate,' Day HH24:MI')
current_time, sql_address, LAST_CALL_ET

from v$session where status = 'ACTIVE' and rawtohex(sql_address) <> '00' and username is not null
order by last_call_et )

loop

for y in ( select max(decode(piece,0,sql_text,null)) || max(decode(piece,1,sql_text,null)) ||


max(decode(piece,2,sql_text,null)) || max(decode(piece,3,sql_text,null)) sql_text from
v$sqltext_with_newlines where address = x.sql_address and piece < 4)

loop

if ( y.sql_text not like '%listener.get_cmd%' and y.sql_text not like '%RAWTOHEX(SQL_ADDRESS)%')

then

dbms_output.put_line( '--------------------' );
dbms_output.put_line( x.username );
dbms_output.put_line( x.logon_time || ' ' || x.current_time|| ' last et = ' || x.LAST_CALL_ET);
dbms_output.put_line(substr( y.sql_text, 1, 250 ) );

end if;

end loop;
end loop;

end;

column username format a15 word_wrapped


column module format a15 word_wrapped
column action format a15 word_wrapped
column client_info format a30 word_wrapped

select username||'('||sid||','||serial#||')' username, module, action, client_info from v$session


where module||action||client_info is not null;

quit;

 Executing the previous script you will be able to inspect what is doing the purge scripts as example I got the following output
when I waiting for ending the purge scripts.

BD25_SOAINFRA(148,53) ospid = 13945 program = sqlplus@dbcomputer.localdomain (TNS V1-V3)

Miércoles 18:27 Miércoles 18:33 last et = 347


DELETE FROM HEADERS_PROPERTIES WHERE MESSAGE_GUID IN (SELECT MESSAGE_GUID FROM
TEMP_DOCUMENT_DLV_MSG_REF)

 And Finally this is the way to run the purge scripts:

[oracle@dbcomputer SQL]$ sqlplus BD25_SOAINFRA/welcome1

SQL*Plus: Release 11.2.0.2.0 Production on Wed May 22 18:27:01 2013


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

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

SQL> @purgescript-month.sql

Procedure altered.
Pocedure altered.

TO_CHAR STATE COUNT(*)

------- ---------- ----------


01-2013 8 1
03-2013 5 224372
03-2013 8 1
03-2013 9 4
03-2013 10 58
04-2013 5 28
04-2013 10 165
05-2013 5 10
05-2013 10 11
11-2012 10 2
12-2012 5 3632

11 rows selected.

22-MAY-2013 18:27:52 : procedure delete_instances


22-MAY-2013 18:27:52 : time check
22-MAY-2013 18:27:52 : sysdate = 22/MAY/2013:18/27
22-MAY-2013 18:27:52 : stoptime = 22/MAY/2013:19/27
22-MAY-2013 18:27:52 : checking for partitions
22-MAY-2013 18:27:52 : done checking for partitions
22-MAY-2013 18:27:52 : composite_dn =
22-MAY-2013 18:27:52 : loop count = 1
22-MAY-2013 18:27:52 : deleting non-orphaned instances
22-MAY-2013 18:27:53 Number of rows in table ecid_purge Inserted = 1694
22-MAY-2013 18:27:53 : perform top-level pruning
22-MAY-2013 18:27:53 : total rows before top level pruning = 1694
22-MAY-2013 18:27:53 Number of rows in table prune_running_insts Inserted for open composite instances
0
22-MAY-2013 18:27:53 Number of rows in table prune_running_insts deleted for open composite instances 0
22-MAY-2013 18:27:53 : total rows after top level pruning = 1694
22-MAY-2013 18:27:53 : total rows before pruning 1694
22-MAY-2013 18:27:53 : calling pruneOpenECIDs
22-MAY-2013 18:27:54 Number of rows in table prune_running_insts Inserted (bpel)for open ci 0
22-MAY-2013 18:27:54 Number of rows in table prune_running_insts Inserted (bpel) for dlv_message0
22-MAY-2013 18:27:54 Number of rows in table ecid_purge Deleted (bpel) for dlv_message0
22-MAY-2013 18:27:54 Number of rows in table prune_running_insts Inserted 0
22-MAY-2013 18:27:54 Number of rows in table ecid_purge purged is : 0
22-MAY-2013 18:27:54 Number of rows in table prune_running_insts Workflow inserts into prune table = 0
22-MAY-2013 18:27:54 Number of rows in table ecid_purge Workflow deletes ECIDs for open WFTask = 0
22-MAY-2013 18:27:54 Number of rows in table prune_running_insts Inserted 0
22-MAY-2013 18:27:54 Number of rows in table ecid_purge purged is : 0
22-MAY-2013 18:27:54 : finished pruneOpenECIDs
22-MAY-2013 18:27:54 : total_rows_after_pruning 1694
22-MAY-2013 18:27:54 : calling soa_orabpel.deleteComponentInstances
22-MAY-2013 18:27:54 Number of rows in table temp_cube_instance Inserted = 224420
22-MAY-2013 18:27:54 Number of rows in table temp_document_ci_ref Inserted = 112213
22-MAY-2013 18:27:57 Number of rows in table temp_document_dlv_msg_ref Inserted = 224356
22-MAY-2013 18:35:37 Number of rows in table HEADERS_PROPERTIES purged is : 224356
22-MAY-2013 18:35:37 Number of rows in table AG_INSTANCE purged is : 0
22-MAY-2013 18:35:37 Number of rows in table TEST_DETAILS purged is : 0
22-MAY-2013 18:37:44 Number of rows in table CUBE_SCOPE purged is : 224362
22-MAY-2013 18:38:35 Number of rows in table AUDIT_COUNTER purged is : 224399
22-MAY-2013 18:50:15 Number of rows in table AUDIT_TRAIL purged is : 334639
22-MAY-2013 18:50:56 Number of rows in table AUDIT_DETAILS purged is : 112198
22-MAY-2013 18:50:56 Number of rows in table CI_INDEXES purged is : 0
22-MAY-2013 18:50:56 Number of rows in table WORK_ITEM purged is : 8
22-MAY-2013 19:02:35 Number of rows in table WI_FAULT purged is : 224359
22-MAY-2013 19:15:30 Number of rows in table XML_DOCUMENT purged is : 224361
22-MAY-2013 19:17:40 Number of rows in table DOCUMENT_DLV_MSG_REF purged is : 224356
22-MAY-2013 19:18:01 Number of rows in table DOCUMENT_CI_REF purged is : 112213
22-MAY-2013 19:22:00 Number of rows in table DLV_MESSAGE purged is : 224356
22-MAY-2013 19:22:01 Number of rows in table DLV_SUBSCRIPTION purged is : 4
22-MAY-2013 19:22:01 Number of rows in table DLV_AGGREGATION purged is : 0
22-MAY-2013 19:25:04 Number of rows in table CUBE_INSTANCE purged is : 224420
22-MAY-2013 19:25:05 Number of rows in table BPM_AUDIT_QUERY purged is : 0
22-MAY-2013 19:25:05 Number of rows in table BPM_MEASUREMENT_ACTIONS purged is : 0
22-MAY-2013 19:25:05 Number of rows in table BPM_MEASUREMENT_ACTION_EXCEPS purged is : 0
22-MAY-2013 19:25:05 Number of rows in table BPM_CUBE_AUDITINSTANCE purged is : 0
22-MAY-2013 19:25:06 Number of rows in table BPM_CUBE_TASKPERFORMANCE purged is : 0
22-MAY-2013 19:25:06 Number of rows in table BPM_CUBE_PROCESSPERFORMANCE purged is : 0
22-MAY-2013 19:25:06 : completed soa_orabpel.deleteComponentInstances
22-MAY-2013 19:25:06 : calling workflow.deleteComponentInstances
22-MAY-2013 19:25:06 : workflow.deleteComponentInstance begins
22-MAY-2013 19:25:06 : workflow.truncate_temp_tables
22-MAY-2013 19:25:07 Number of rows in table temp_wftask_purge workflow.deleteComponentInstance
Inserted = 0
22-MAY-2013 19:25:07 : workflow.delete_workflow_instances begins
22-MAY-2013 19:25:07 : Purging WFTask_TL
22-MAY-2013 19:25:07 Number of rows in table WFTask_TL Purge WFTask_TL0
22-MAY-2013 19:25:07 : Purging WFTaskHistory
22-MAY-2013 19:25:07 Number of rows in table WFTaskHistory Purge WFTaskHistory0
22-MAY-2013 19:25:07 : Purging WFTaskHistory_TL
22-MAY-2013 19:25:07 Number of rows in table WFTaskHistory_TL Purge WFTaskHistory_TL0
22-MAY-2013 19:25:07 : Purging WFComments
22-MAY-2013 19:25:07 Number of rows in table WFComments Purge WFComments0
22-MAY-2013 19:25:07 : Purging WFMessageAttribute
22-MAY-2013 19:25:08 Number of rows in table WFMessageAttribute Purge WFMessageAttribute0
22-MAY-2013 19:25:08 : Purging WFAttachment
22-MAY-2013 19:25:08 Number of rows in table WFAttachment Purge WFAttachment0
22-MAY-2013 19:25:08 : Purging WFAssignee
22-MAY-2013 19:25:08 Number of rows in table WFAssignee Purge WFAssignee0
22-MAY-2013 19:25:08 : Purging WFReviewer
22-MAY-2013 19:25:08 Number of rows in table WFReviewer Purge WFReviewer0
22-MAY-2013 19:25:08 : Purging WFCollectionTarget
22-MAY-2013 19:25:08 Number of rows in table WFCollectionTarget Purge WFCollectionTarget0
22-MAY-2013 19:25:08 : Purging WFRoutingSlip
22-MAY-2013 19:25:08 Number of rows in table WFRoutingSlip Purge WFRoutingSlip0
22-MAY-2013 19:25:08 : Purging WFNotification
22-MAY-2013 19:25:08 Number of rows in table WFNotification Purge WFNotification0
22-MAY-2013 19:25:08 : Purging WFTaskTimer
22-MAY-2013 19:25:08 Number of rows in table WFTaskTimer Purge WFTaskTimer0
22-MAY-2013 19:25:08 : Purging WFTaskError
22-MAY-2013 19:25:08 Number of rows in table WFTaskError Purge WFTaskError0
22-MAY-2013 19:25:08 : Purging WFHeaderProps
22-MAY-2013 19:25:08 Number of rows in table WFHeaderProps Purge WFHeaderProps0
22-MAY-2013 19:25:08 : Purging WFEvidence
22-MAY-2013 19:25:08 Number of rows in table WFEvidence Purge WFEvidence0
22-MAY-2013 19:25:08 : Purging WFTaskAssignmentStatistic
22-MAY-2013 19:25:08 Number of rows in table WFTaskAssignmentStatistic Purge WFTaskAssignmentStatistic0
22-MAY-2013 19:25:08 : Purging WFTaskAggregation
22-MAY-2013 19:25:08 Number of rows in table WFTaskAggregation Purge WFTaskAggregation0
22-MAY-2013 19:25:08 : Purging WFTask
22-MAY-2013 19:25:08 Number of rows in table WFTask Purge WFTask0
22-MAY-2013 19:25:08 : workflow.delete_workflow_instances ends
22-MAY-2013 19:25:08 : workflow.deleteComponentInstance ends
22-MAY-2013 19:25:08 : completed workflow.deleteComponentInstances
22-MAY-2013 19:25:08 : calling mediator.deleteComponentInstances
22-MAY-2013 19:25:08 Number of rows in table temp_mediator_instance Inserted = 12
22-MAY-2013 19:25:08 Number of rows in table mediator_payload purged is : 0
22-MAY-2013 19:25:08 Number of rows in table mediator_deferred_message purged is : 0
22-MAY-2013 19:25:09 Number of rows in table mediator_document purged is : 0
22-MAY-2013 19:25:09 Number of rows in table mediator_case_detail purged is : 0
22-MAY-2013 19:25:09 Number of rows in table mediator_case_instance purged is : 0
22-MAY-2013 19:25:09 Number of rows in table mediator_instance purged is : 0
22-MAY-2013 19:25:09 : completed mediator.deleteComponentInstances
22-MAY-2013 19:25:09 : calling decision.deleteComponentInstances
22-MAY-2013 19:25:09 Number of rows in table temp_brdecision_instance Inserted = 0
22-MAY-2013 19:25:09 Number of rows in table BRDecisionFault purged is : 0
22-MAY-2013 19:25:09 Number of rows in table BRDecisionUnitOfWork purged is : 0
22-MAY-2013 19:25:09 Number of rows in table BRDecisonInstance purged is : 0
22-MAY-2013 19:25:09 : completed decision.deleteComponentInstances
22-MAY-2013 19:25:09 : calling fabric.deleteComponentInstances
22-MAY-2013 19:27:07 Number of rows in table reference_instance_purge inserted = 736122
22-MAY-2013 19:50:59 Number of rows in table xml_document purged is : 736080
22-MAY-2013 19:54:29 Number of rows in table instance_payload purged is : 736139
22-MAY-2013 20:27:45 Number of rows in table reference_instance purged is : 736122
22-MAY-2013 20:27:48 Number of rows in table xml_document purged is : 0
22-MAY-2013 20:27:48 Number of rows in table rejected_msg_native_payload purged is : 0
22-MAY-2013 20:27:48 Number of rows in table instance_payload purged is : 0
22-MAY-2013 20:27:48 Number of rows in table composite_instance_fault purged is : 39
22-MAY-2013 20:41:31 Number of rows in table xml_document purged is : 224407
22-MAY-2013 20:43:07 Number of rows in table instance_payload purged is : 224407
22-MAY-2013 20:43:08 Number of rows in table composite_sensor_value purged is : 0
22-MAY-2013 20:43:09 Number of rows in table composite_instance_assoc purged is : 0
22-MAY-2013 20:43:09 Number of rows in table component_instance_purge inserted = 0
22-MAY-2013 20:43:09 Number of rows in table xml_document purged is : 0
22-MAY-2013 20:43:09 Number of rows in table instance_payload purged is : 0
22-MAY-2013 20:43:09 Number of rows in table component_instance purged is : 0
22-MAY-2013 20:43:09 Number of rows in table attachment purged is : 0
22-MAY-2013 20:43:09 Number of rows in table attachment_ref purged is : 0
22-MAY-2013 20:46:31 Number of rows in table composite_instance purged is : 226023
22-MAY-2013 20:46:31 : completed fabric.deleteComponentInstances
22-MAY-2013 20:46:31 : time check
22-MAY-2013 20:46:31 : sysdate = 22/MAY/2013:20/46
22-MAY-2013 20:46:31 : stoptime = 22/MAY/2013:19/27
22-MAY-2013 20:46:32 : delete_instances completed successfully

PL/SQL procedure successfully completed.

TO_CHAR STATE COUNT(*)

------- ---------- ----------


01-2013 8 1
03-2013 5 11
03-2013 9 4
04-2013 5 28
04-2013 10 165
05-2013 5 10
05-2013 10 11
11-2012 10 1
12-2012 5 3632

9 rows selected.
Procedure altered.
Procedure altered.

SQL>

#This is to show the current size of the tablespace.

sqlplus / as sysdba

You might also like