모르는 SMON 기능 알아보기(1): 임시 세그먼트 정리

SMON(system monitor process) 시스템은 백엔드 프로세스를 감시하고 때로는 시스템 클렌징 프로세스라고도 부른다. 이렇게 부르는 이유는 많은 정리(cleanup) 작업을 책임지기 때문이다.그러나 Oracle 기초 지식을 배운 기술자는 이 백그라운드 프로세스의 기능에 대해 많거나 적게 알고 있다.한때 SMON 기능에 대한 이해도가 DBA 이론 지식을 평가하는 중요한 요소로 작용한 적이 있다. 지금까지도 많은 회사들이 DBA 면접에서 SMON이 어떤 기능을 가지고 있는지 이런 질문을 한다.우선 이것은 개방적인 문제이기 때문에 면접자가 완전무결을 바라지 않는다(당신이 이 글을 읽은 후에도) 얼마나 많은 지식을 평가할 수 있는 근거가 될 수 있는지(면접인이 특별히 이 문제를 준비한 적이 있다면 그것도 좋다. 이것은 그가 이미 체계적으로 문제를 고려할 수 있다는 것을 의미한다).이어서 구체적인 어떤 기능에 대해 말하자면 면접자의 지식 깊이를 이해할 수 있다. 물론 이것은 멀다.우리가 잘 알고 있는 SMON은 몇몇 시스템 등급의 임무를 완수하는 부지런한 녀석이다.PMON(Process Monitor) 백엔드 프로세스와 달리 SMON은 전체 시스템과 관련된 일을 더 많이 완성하는 것을 책임지기 때문에 이름 모를'힘든 일'을 하게 된다. 시스템에 이런'쓰레기 임무'가 빈번하게 발생하면 SMON은 바빠서 어쩔 수 없을 것이다.따라서 SMON은 10g에서 조금 게으르게 변했다. 단기간에 과도한 업무 알림(SMON: system monitor process posted)을 받으면 너무 바쁘지 않도록 소극적으로 태업할 수도 있다(SMON: Posted too frequently,trans recovery disabled). 이후에 상세하게 소개할 것이다.SMON의 주요 역할은 다음과 같습니다. 1.임시 세그먼트 정리(SMON cleanup temporary segments)
촉발 장면에서 많은 사람들이 여기에서 말한 임시 단락temporary segments를 잘못 이해했다. temporary segments는temporary tablespace 임시 테이블 공간의 정렬 임시 단락(sort segment)을 가리킨다고 주장했다.사실 이곳의 임시 세그먼트는 영구 테이블 공간(permanent tablespace)의 임시 세그먼트를 가리킨다. 물론 임시 테이블 공간의temporary segments도 SMON이 청소(cleanup)하지만 이러한 청소는 데이터베이스 실례가 시작될 때(instance startup)에만 발생한다.영구 테이블 공간에도 임시 세그먼트가 존재한다. 예를 들어 우리가 특정한 영구 테이블 공간에create table/index 등DDL 명령을 사용하여 특정한 테이블/인덱스를 만들 때 서비스 프로세스는 처음에 지정한 영구 테이블 공간에 충분한 구간(Extents)을 분배한다. 이 구간은 명령이 끝나기 전에 임시(Temporary Extents)이다.테이블/인덱스가 완전히 완성될 때까지 이temporary segment를permanent segment로 변환합니다.또한drop 명령을 사용하여 세그먼트를 삭제하면 먼저 해당 세그먼트를temporary segment로 변환한 다음 DROP object converts the segment to temporary and then cleans up the temporary segment 를 정리합니다.일반적인 상황에서 청소 작업은 누가 temporary segment를 만들고 청소를 책임지는 원칙에 따른다.다시 말하면 서비스 프로세스rebuild index로 인한temporary segment는rebuild가 완성된 후에 서비스 프로세스가 스스로 책임지고 정리해야 한다.서비스 프로세스가temporary segment를 성공적으로 정리하기 전에 의외로 종료되거나 서비스 프로세스가 작업 과정에서 일부 ORA 오류가 발생하여 문장에 실패하면 SMON은 temporary segment의 정리 작업을 완성하도록 요구됩니다.영구표 공간에 있는temporary segment에 대해 SMON은 3분에 한 번(post를 받았다는 전제 조건)을 정리합니다. SMON이 너무 바쁘면 장기간 정리되지 않을 수 있습니다.temporary segment가 장기적으로 정리되지 않으면 전형적인 문제를 일으킬 수 있습니다.rebuild index 온라인이 실패한 후에 후속으로 실행되는rebuild index 명령이 요구되기 전에 발생한temporary segment는 이미 cleanup이 되었습니다. cleanup이 완성되지 않으면 계속 기다려야 합니다.10gR2에서는 dbms 를 사용할 수 있습니다.repair.online_index_clean에서 온라인index rebuild에 남아 있는 문제를 수동으로 정리합니다.
4
The dbms_repair.online_index_clean function has been created to cleanup online index rebuilds.
Use the dbms_repair.online_index_clean function to resolve the issue.
Please note if you are unable to run the dbms_repair.online_index_clean function it is due to the fact
that you have not installed the patch for Bug 3805539 or are not running on a release that includes this fix.
The fix for this bug is a new function in the dbms_repair package called dbms_repair.online_index_clean,
which has been created to cleanup online index [[sub]partition] [re]builds.

New functionality is not allowed in patchsets;
therefore, this is not available in a patchset but is available in 10gR2.

Check your patch list to verify the database is patched for Bug 3805539
using the following command and patch for the bug if it is not listed:

opatch lsinventory -detail

Cleanup after a failed online index [re]build can be slow to occurpreventing subsequent such operations
until the cleanup has occured.
이어서 우리는 smon이 영구표 공간에 있는temporary segment를 어떻게 정리하는지 실천을 통해 살펴본다.
4
  10500     smon  ,           

SQL> alter system set events '10500 trace name context forever,level 10';
System altered.

         create table  ,        Temorary Extents

SQL> create table smon as select * from ymon;

          DBA_EXTENTS     ,             

SQL> SELECT COUNT(*) FROM DBA_EXTENTS WHERE SEGMENT_TYPE='TEMPORARY';

COUNT(*)
----------
117

    create table session,         smon     trc        :

*** 2011-06-07 21:18:39.817
SMON: system monitor process posted msgflag:0x0200 (-/-/-/-/TMPSDROP/-/-)

*** 2011-06-07 21:18:39.818
SMON: Posted, but not for trans recovery, so skip it.

*** 2011-06-07 21:18:39.818
SMON: clean up temp segments in slave

SQL> SELECT COUNT(*) FROM DBA_EXTENTS WHERE SEGMENT_TYPE='TEMPORARY';

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

    smon  slave      temporary segment   
영구 테이블 공간의 임시 세그먼트와 달리 성능을 고려하여 임시 테이블 공간의 Extents는 작업(operations)이 끝난 후 즉시 방출되고 반환되지 않습니다.대신 이러한 Temporary Extents는 다음 정렬 작업에 사용할 수 있도록 표시됩니다.SMON은 이 Temporary segments를 정리합니다. 그러나 이 정리는 인스턴스가 시작될 때만 발생합니다(instance startup).
For performance issues, extents in TEMPORARY tablespaces are not released ordeallocated
once the operation is complete.Instead, the extent is simply marked as available for the next sort operation.
SMON cleans up the segments at startup.

A sort segment is created by the first statement that used a TEMPORARY tablespacefor sorting, after startup.
A sort segment created in a TEMPOARY tablespace is only released at shutdown.
The large number of EXTENTS is caused when the STORAGE clause has been incorrectly calculated.

현상은 아래의 조회를 통해 데이터베이스에 있는 Temporary Extent의 총수를 파악하고 일정 시간 동안 그 총수를 비교할 수 있다. 만약에 감소하면 SMON이 Temporary segment를 정리하고 있음을 의미한다.
4
SELECT COUNT(*) FROM DBA_EXTENTS WHERE SEGMENT_TYPE='TEMPORARY';
v$sysstat 보기의 "SMON posted for dropping temp segment"이벤트 통계 정보를 통해 SMON이 정리 요청을 받은 상황을 파악할 수 있습니다.
4

SQL> select name,value from v$sysstat where name like '%SMON%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
total number of times SMON posted                                         8
SMON posted for undo segment recovery                                     0
SMON posted for txn recovery for other instances                          0
SMON posted for instance recovery                                         0
SMON posted for undo segment shrink                                       0
SMON posted for dropping temp segment                                     1
또한 정리 과정에서 SMON은 Space Transacton(ST) 대기열 자물쇠를 장기간 보유하고 있으며, 다른 세션에서는 ST 자물쇠를 얻지 못해 대기 시간 초과로 ORA-01575 오류가 발생할 수 있습니다.
01575, 00000, "timeout waiting for space management resource"
// *Cause: failed to acquire necessary resource to do space management.
// *Action: Retry the operation.

SMON 정리 임시 세그먼트를 금지하는 방법은 진단 이벤트 이벤트='10061 trace name context forever, level 10'을 설정하면 SMON 정리 임시 세그먼트(disable SMON from cleaning temp segments)를 비활성화할 수 있습니다.
alter system set events '10061 trace name context forever, level 10';

관련 진단 이벤트는 10061 이벤트를 제외하고 10500 이벤트로 smon의post 정보를 추적할 수 있습니다. 구체적인 이벤트 설정 방법은 참조

좋은 웹페이지 즐겨찾기