Garbage collection

The Garbage Collector (GC) is a set of stored procedures written in PL/SQL that runs in the database on a schedule. The GC procedures look at the AUDIT_PARAMS table to determine the retention period to use to delete the old data. The GC PL/SQL procedures are managed by Oracle's dba_scheduler_jobs.

Data retention period

When GC runs, it looks at the values in the AUDIT_PARAMS table to determine what retention period to use when deleting objects.

Note: The AUDIT_PARAMS table is not replicated, so there is a possibility that these retention periods may become unsynchronized, which can cause severe Multimaster conflict issues. You must ensure that the values in the AUDIT_PARAMS table are exactly the same for all the cores in a mesh.
# Sqlplus "/ as sysdba"
SQL> col name format a20;
SQL> col value format a20;
SQL> col AUDIT_PARAM_ID format a15;
SQL> select AUDIT_PARAM_ID, NAME, VALUE from audit_params;

The parameters from AUDIT_PARAMS table and their default values are:

AUDIT_PARAM_ID  NAME                 VALUE
--------------- -------------------- --------------------
2               DAYS_WAY		30		(These are the completed way sessions)
3               DAYS_CHANGE_LOG      	180		(These are the server history events)
4               LAST_DATE_WAY 		02-NOV-16
5               LAST_DATE_CHANGE_LOG 	05-JUN-16
6               DAYS_AUDIT_LOG       	180		(These are the audit logs)
7               LAST_DATE_AUDIT_LOG 	180		
8               DAYS_WLM             	30 		(These are completed WLM jobs)
9               LAST_DATE_WLM        	02-NOV-16

 

Note: As of SA 9.10, the DAY_TRAN parameter that controlled retention time for transactions was removed. To control transaction retention time, instead use the system configuration parameter vault.garbageCollector.daysToPreserve.

Select the Administration tab in the SA Client, then select System Configuration in the navigation panel. Select Model Repository Multimaster Component. Locate and change the value.
The value for LAST_DATE_WAY , LAST_DATE_CHANGE_LOG , LAST_DATE_AUDIT_LOG , and LAST_DATE_WLM parameters should be the date when the system was installed - 30 days.
For a fresh core installation, the default value of LAST_DATE_AUDIT_LOG is 180. After the audit is run, the value will be the date of the last audit job.

Modifying the retention period values

To update the data, run a SQL command similar to the following example as user LCREP:

# su - oracle
# sqlplus "/ as sysdba" 
SQL> grant create session to lcrep;
SQL> connect lcrep/<password>
SQL> update AUDIT_PARAMS set value=30 where name = 'DAYS_AUDIT_LOG';
SQL> commit;
Note: The values in the AUDIT_PARAMS table must be exactly the same for all the cores in a mesh.

Viewing GC DBA_SCHEDULER_JOBS

When the Model Repository is installed, the SA Installer sets up these jobs, which perform garbage collection.

GC jobs can be viewed by logging in to SQL*Plus and running the following SQL commands:

# Su - oracle
# Sqlplus "/ as sysdba"
SQL> set line 200
SQL> col job_name format a50
SQL> col owner format a14
SQL> col last_date format a17
SQL> col next_date format a17
SQL> col job_action format a50

 

SQL>select job_name, owner, to_char(LAST_START_DATE, 'MM/DD/YY HH:MI:SS') last_date,to_char(next_run_date, 'MM/DD/YY HH:MI:SS') next_date, job_action
from dba_scheduler_jobs where owner='GCADMIN';
JOB_NAME                 OWNER   LAST_DATE         NEXT_DATE         JOB_ACTION
------------------------ ------- ----------------- ----------------- ----------------------------------------
WLMPURGE_GC              GCADMIN 04/02/12 09:00:02 04/04/12 09:00:00 WLMPURGE.GC_JOBS
STORAGEINITIATORPURGE_GC GCADMIN 04/02/12 09:47:30 04/03/12 10:47:30 STORAGEINITIATORPURGE.GC_
STORAGEINITIATORS
AUDITPURGE_GC            GCADMIN 04/02/12 09:00:02 04/04/12 09:00:00 AUDITPURGE.GC_AUDITLOGS
CHANGELOGPURGE_GC        GCADMIN 04/02/12 09:00:02 04/04/12 09:00:00 CHANGELOGPURGE.GC_CHANGELOGS
WAYPURGE_GC              GCADMIN 04/02/12 09:00:02 04/04/12 09:00:00 WAYPURGE.GC_SESSIONS
 

where:

WAYPURGE.GC_SESSIONS - Performs a sessions garbage collection

CHANGELOGPURGE.GC_CHANGELOGS - Performs a changelogs garbage collection

AUDITPURGE.GC_AUDITLOGS - Performs auditlogs garbage collection

STORAGEINITIATORPURGE.GC_STORAGEINITIATORS - Performs storage data garbage collection

WLMPURGE.GC_JOBS - Performs WLM garbage collection

Manually running GC jobs

You can run GC jobs by logging in to SQL*Plus and entering the following:

# Su - oracle
# Sqlplus "/ as sysdba"
 
SQL> grant create session to gcadmin
SQL> connect gcadmin/<password>
SQL> exec dbms_scheduler.run_job('<job_name_value>');
For example, this sample command runs the waypurge_gc job:
SQL> exec dbms_scheduler.run_job('WAYPURGE_GC');