SYSAUX Tablespace Growth Analysis

SYSAUX Tablespace Growing Rapidly due to SCHEDULER$_JOB_OUTPUT Table and ORA-01031 Error in Automatic segment advisor task

Recently, I was asked for help with a database experiencing an unexpected growth issue in the SYSAUX tablespace. For troubleshooting space usage issues in the SYSAUX tablespace, V$SYSAUX_OCCUPANTS is the primary reference.

It is a dynamic performance view in Oracle databases that provides information about the occupants (or components) and their space usage within the SYSAUX tablespace.

The SYSAUX tablespace is used to store data for various database components. Additionally, there is an excellent document on reducing SYSAUX tablespace occupancy due to fragmented tables and indexes, which is worth investigating.

This view can be useful for diagnosing issues related to SYSAUX tablespace growth, like the one we encountered. We can query this view to see which components are using the most space and determine whether any action is needed or not, such as moving components to other tablespaces or managing the space they use more effectively.

The root cause was the SYS.SCHEDULER$_JOB_OUTPUT table’s OUTPUT column. In our case, the table contained 25 million rows and was consuming 13.8 GB space.

I used the queries provided below to diagnose the issue.

While diagnosing the issue, I learned that when the DBMS_OUTPUT.PUT_LINE command is run in a scheduler job, the output is directed to SCHEDULER$_JOB_OUTPUT table. In our case, the DBMS_OUTPUT.PUT_LINE command was called inside a loop that executed 6 million times whenever the job was triggered.

I informed the developer about the issue and removed the related line, which stopped the generation of new rows. To remove the old records, the DBMS_SCHEDULER.PURGE_LOG procedure should be used.

This procedure purges rows from the job and window logs that were not automatically purged by the Scheduler.

By default, the Scheduler automatically purges all rows in the job and window logs that are older than 30 days. The PURGE_LOG procedure can be used to purge additional rows from these logs.

Rows in the job log table related to the steps of a chain are only purged when the entry for the main chain job is purged, either manually or automatically.

Purging the log does not immediately release the space. A TRUNCATE operation is required to lower the high water mark and reclaim the space.

Also there is a document in Oracle Support SYSAUX Tablespace Growing Due to SYS.SCHEDULER$_JOB_OUTPUT LOB Column (Doc ID 2095104.1 related with the issue.

The story so far we no so much exciting, but the surprising part is just about to unfold.

After truncating the table and removing the unwanted noisy data from the SCHEDULER$_JOB_OUTPUT table, I checked the table the next day to ensure no new records had been generated from a DBMS_OUTPUT command. Indeed, there were no records related to the scheduler jobs that had previously generated rows. However, a log record from an advisor task run of a maintenance job, stored in the SCHEDULER$_JOB_OUTPUT table, caught my attention.

This record (ORA$AT_SA_SPC_SY_57806 ) belongs to the auto space advisor task.

Automatic Segment Advisor identifies segments that have space available for reclamation, and makes recommendations on how to defragment those segments.

You can also run the Segment Advisor manually to obtain more up-to-the-minute recommendations or to obtain recommendations on segments that the Automatic Segment Advisor did not examine for possible space reclamation.

The task status was recorded as ‘SUCCEEDED’ in the SYS.SCHEDULER$_EVENT_LOG table, and the errors column in SYS.SCHEDULER$_JOB_OUTPUT was null. There were no anomalies until this point. However, in the output column of the record, there was a significant number of errors, like the one provided below.

Owner :XXX Tabname :YYY Partname : Segtype :TABLE Tbsname :USERS

Exception in get_compressible_size code: -1031 msg: ORA-01031: Insufficient privileges

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 1313

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 1307

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 1026

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 252

ORA-06512: at “SYS.DBMS_COMPRESSION”, line 250

ORA-06512: at line 1

Segment Information :

Owner :XXX Tabname :ZZZ Partname : Segtype :TABLE Tbsname :USERS

Exception in get_compressible_size code: -1031 msg: ORA-01031: Insufficient privileges

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 1313

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 1307

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 1026

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 252

ORA-06512: at “SYS.DBMS_COMPRESSION”, line 250

ORA-06512: at line 1

Segment Information :

Owner :XXX Tabname :GGG Partname : Segtype :TABLE Tbsname :USERS

Exception in get_compressible_size code: -1031 msg: ORA-01031: Insufficient privileges

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 1313

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 1307

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 1026

ORA-06512: at “SYS.PRVT_COMPRESSION”, line 252

ORA-06512: at “SYS.DBMS_COMPRESSION”, line 250

ORA-06512: at line

The Automatic Segment Advisor was encountering ORA-01031 errors while running. I searched Oracle Support for similar cases but found nothing relevant. This advisor can be triggered manually by executing the DBMS_SPACE.AUTO_SPACE_ADVISOR_JOB_PROC procedure.

To identify the root cause of the privilege error, I enabled 10046 tracing and the 1031 error stack, then executed the DBMS_SPACE.AUTO_SPACE_ADVISOR_JOB_PROC procedure.

The procedure was attempting to create a temporary table behind the scenes, requiring the CREATE TABLE privilege to be granted directly to the user who owns the segment (table or index). The CREATE TABLE privilege inherited through the RESOURCE role was insufficient due to the difference in privilege contexts (INVOKER vs. DEFINER rights).

The solution I applied was to grant the privilege explicitly using GRANT CREATE TABLE TO XXX. Another workaround is to disable the related advisor task, as shown in the command below.

Edited on November 6th, 2024:

There is also a blog post worth checking out by Connor McDonald about DBMS_OUTPUT and the scheduler. Additionally, there is a useful comment that provides a workaround to prevent the DBMS_OUTPUT.PUT_LINE command, when run in a scheduler job, from directing output to the SCHEDULER$_JOB_OUTPUT table and instead directing it to stdout.” With this workaround, you can control it in a granular way at the level of each scheduler job. You may refer to Database Administrator’s Guide for Oracle Database release 19c.

Hope it helps.


Discover More from Osman DİNÇ


Comments

Leave your comment