A Bug in Unified Auditing

Categories: Oracle Database · Security · Troubleshooting

Translated from Portuguese. Read the original

Hi folks! Working at a client today I found a bug in one of the new features of Oracle Database 12c, Unified Auditing, which I recently wrote an article about at OTN, and you can read it in full with this link.

Let’s get to the bug…
scared-bug.jpg
I got to the office early this morning and right away an alert showed up in the monitoring about the free space in the SYSAUX tablespace. It’s not that common for SYSAUX to get big, depending on what you have installed and what you store in it. SYSAUX at this client was at 9GB, because I had limited its maximum size to 10GB and the monitoring alerted when it reached 90% usage. That’s one reason not to leave your tablespaces with unlimited size. Since this client has no in-house DBA and nobody is always watching the environment, only our monitoring caught this problem.

I immediately thought it was another known bug related to the retention of historical statistics that Oracle can’t remove, so I checked for it with the following query:

SQL> col Mb form 9,999,999
SQL> col SEGMENT_NAME form a40
SQL> col SEGMENT_TYPE form a6
SQL> set lines 120
SQL> select sum(bytes/1024/1024) Mb, segment_name,segment_type from dba_segments
2 where tablespace_name = 'SYSAUX'
3 and segment_name like 'WRI$_OPTSTAT%'
4 and segment_type='TABLE'
5 group by segment_name,segment_type order by 1 asc
6 /

MB         SEGMENT_NAME                             SEGMEN
---------- ---------------------------------------- ------
0          WRI$_OPTSTAT_SYNOPSIS_HEAD$              TABLE
0          WRI$_OPTSTAT_AUX_HISTORY                 TABLE
0          WRI$_OPTSTAT_SYNOPSIS_PARTGRP            TABLE
1          WRI$_OPTSTAT_TAB_HISTORY                 TABLE
1          WRI$_OPTSTAT_IND_HISTORY                 TABLE
3          WRI$_OPTSTAT_OPR_TASKS                   TABLE
3          WRI$_OPTSTAT_OPR                         TABLE

7 rows selected.

I realized this wasn’t the problem, especially because that bug, described in note 14373728.8, was related to Oracle Database versions 11.2.0.2 and 11.2.0.3, but my client was already on version 12.1.0.1.

I ran the following query to check which were the largest segments in the SYSAUX tablespace:

SQL> select * from (select owner,segment_name,segment_type,tablespace_name,
2 round(bytes/1024/1024,1) "size_in_MB"
3 from dba_segments
4 where tablespace_name='SYSAUX'
5 order by bytes/1024/1024 desc) where rownum < 10 order by 5 desc;

OWNER                          SEGMENT_NAME                             SEGMENT_TYPE         TABLESPACE_NAME      size_in_MB
------------------------------ ---------------------------------------- -------------------- -------------------- ----------
AUDSYS                         SYS_LOB0000089459C00014$$                LOBSEGMENT           SYSAUX               4647.1
AUDSYS                         CLI_SWP$ee19fa3c$1$1                     TABLE                SYSAUX               3654
XDB                            SYS_LOB0000018450C00025$$                LOBSEGMENT           SYSAUX               96.2
SYS                            I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST           INDEX                SYSAUX               47
SYS                            SYS_LOB0000005824C00005$$                LOBSEGMENT           SYSAUX               36.2
AUDSYS                         CLI_TIME$ee19fa3c$1$1                    INDEX                SYSAUX               30
AUDSYS                         CLI_SCN$ee19fa3c$1$1                     INDEX                SYSAUX               28
AUDSYS                         CLI_LOB$ee19fa3c$1$1                     INDEX                SYSAUX               27
SYS                            I_WRI$_OPTSTAT_H_ST                      INDEX                SYSAUX               25

9 rows selected.

I identified a LOB and a table in the AUDSYS schema, so it was about auditing. Normally when we need to do auditing in the database we create a dedicated tablespace for that purpose, but in this database there was no need to enable auditing. By default Unified Auditing does not come enabled with all its features, but the ORA_SECURECONFIG policy is enabled by default and it was writing records unexpectedly. That’s the first point. Up to there no problem, since all I had to do was remove the records and disable the policy. In fact, after I took action, I found a note that talks about this subject: 1624051.1.

I ran the following commands to clean up the audit records already written and then disabled the ORA_SECURECONFIG policy, after checking with the client:

SQL> exec DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP ( -
AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED, -
LAST_ARCHIVE_TIME => sysdate)

PL/SQL procedure successfully completed.

SQL> exec DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL( -
AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED, -
USE_LAST_ARCH_TIMESTAMP => TRUE)

PL/SQL procedure successfully completed.

SQL> exec DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL( -
AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED, -
USE_LAST_ARCH_TIMESTAMP => FALSE)

PL/SQL procedure successfully completed.

SQL> noaudit policy ORA_SECURECONFIG;

Noaudit succeeded.

SQL> select count(*) from unified_audit_trail;

COUNT(*)
----------
0

Depending on the size of the audit trails these commands can take a while to finish.

That’s where the problem came in… The records were all removed, as we can see, but the segments stayed the same size. :0

We can see this again with the following query, already used before:

SQL> select * from (select owner,segment_name,segment_type,tablespace_name,
2 round(bytes/1024/1024,1) "size_in_MB"
3 from dba_segments
4 where tablespace_name='SYSAUX'
5 order by bytes/1024/1024 desc) where rownum < 10 order by 5 desc;

OWNER                          SEGMENT_NAME                             SEGMENT_TYPE         TABLESPACE_NAME      size_in_MB
------------------------------ ---------------------------------------- -------------------- -------------------- ----------
AUDSYS                         SYS_LOB0000089459C00014$$                LOBSEGMENT           SYSAUX               4647.1
AUDSYS                         CLI_SWP$ee19fa3c$1$1                     TABLE                SYSAUX               3654
XDB                            SYS_LOB0000018450C00025$$                LOBSEGMENT           SYSAUX               96.2
SYS                            I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST           INDEX                SYSAUX               47
SYS                            SYS_LOB0000005824C00005$$                LOBSEGMENT           SYSAUX               36.2
AUDSYS                         CLI_TIME$ee19fa3c$1$1                    INDEX                SYSAUX               30
AUDSYS                         CLI_SCN$ee19fa3c$1$1                     INDEX                SYSAUX               28
AUDSYS                         CLI_LOB$ee19fa3c$1$1                     INDEX                SYSAUX               27
SYS                            I_WRI$_OPTSTAT_H_ST                      INDEX                SYSAUX               25

9 rows selected.

Checking MOS (My Oracle Support, or Metalink for the old-timers) once more, I found another bug, number 18109788, covered in note 1935169.1, which says that the DBMS_AUDIT_MGMT package does not release the space used by the audit LOB segment. This note also says that this problem cannot be fixed in this version of Oracle Database and that upgrading to 12.1.0.2 won’t solve it either. To bring the objects back to their original size, Oracle recommends recreating the database. But to soften the problem you can simply disable the ORA_SECURECONFIG policy as I did, or, if you leave it enabled, you should frequently run a cleanup maintenance on the records, similar to what I did.

I hope this blog helps you at some point.

Until next time…

Franky

Earlier comments

  1. Fredy Carvalho

    Muito top! Resolveu meu problema!!! MUITO OBRIGADO

    1. Franky Weber Faust

      Boa! Fico feliz em ter ajudado! Abraços.

Comments