Monday, June 23, 2014

Instant Data file growth - KTSJ - SMCO (Space Management Coordinator)

I have encountered an issue last weekend which was all datafiles in tablespace extended without reason. There was lots of wasted space approximetaly 125 GB.Firstly i have thougth that there was a procedure or job which processed big data and it caused this instant growth. But no clear point or anything like this i could not find in AWR reports in related time.

In order to detect this issue firstly i have queried exact time when this occured. Below sql helped me to find it.

select f1.snap_id,
       f1.sumts,f2.sumts2,((f1.sumts-f2.sumts2)*8)/1024/1024 diff
  from (select d1.snap_id, sum(tablespace_size) sumts
          from dba_hist_tbspc_space_usage d1, v$tablespace v1
         where d1.tablespace_id = v1.TS#
           and rtime >= '06/22/2014'
           and rtime < '06/23/2014'
         group by d1.snap_id) f1 ,       (select snap_id,sum(tablespace_size) sumts2
          from dba_hist_tbspc_space_usage d1
         group by d1.snap_id) f2   
where f2.snap_id=f1.snap_id-1  

This sql gave me issue occured between 05:00 AM - 06:00 AM. I have to find which session(s) caused this and best way to find was dba_hist_active_session_history with below sql

select d3.sample_id,
       d3.sample_time,
       d3.session_type,
       d5.USERNAME,
       d3.session_id,
       d3.session_serial#,
       d3.sql_opname,
       d3.sql_id,
       d3.event,
       d3.module,
       d3.action,
       d3.delta_read_io_requests,
       d3.delta_write_io_requests,
       d3.delta_read_io_bytes,
       d3.delta_write_io_bytes,
       d4.sql_text
  from dba_hist_active_sess_history d3, dba_hist_sqltext d4, dba_users d5
 where d3.sample_time >=
       to_date('22/06/2014 05:00:00', 'dd/mm/yyyy hh24:mi:ss')
   and d3.sample_time <
       to_date('22/06/2014 06:00:00', 'dd/mm/yyyy hh24:mi:ss')
   and d3.sql_id = d4.sql_id(+)
   and d3.user_id = d5.USER_ID(+)
 order by d3.sample_id

By ordering delta_write_io_bytes column ,interesting session  KTSJ Slave listed with highest delta_write_io_bytes . Sum of the delta_write_io_bytes of KTSJ was 119 GB and this was what i was looking for. Key word  was KTSJ or KTSJ Slave. After googling and with Oracle support , lastly i have found myself reading SMCO (Space Management Coordinator) master note :) 

Duty of this coordinator is coordinating execution of space management tasks , such as proactive space allocation and space reclamation. If datafiles have autoextend Yes property this coordinator can extend datafilesize to its max size even it has not reached maxsize. This is of course fine that sessions need not wait for space allocation that has already done. But instant growing like this may  make storage admin angry :) To be in safe disable option is available.

"Tablespace-level space (Extent) pre-allocation" feature provided by SMCO process can be disabled by setting "_enable_space_preallocation" to 0 as below,

alter system set "_enable_space_preallocation"=0;

To enable this feature, parameter can be set to 3 which is the default value,

alter system set "_enable_space_preallocation"=3;


No comments:

Post a Comment