[환경]
Microsoft SQL Server 2005 - 9.00.3042.00 (Intel IA-64) Enterprise Edition
[현상]
디스크 공간 부족으로 User Database 의 데이터 파일을 shrink 하였으나 아래와 같은 오류가 발생하며 작업이 진행되지 않음
File ID 1 of database ID 15 cannot be shrunk as it is either being shrunk by another process or is empty.
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
[원인]
SQL Server 2005 SP2 를 사용하는 환경에서 발생할 수 있는 Bug 로써, HOTFIX 설치가 필요합니다.
[해결방법]
이 문제는 Cumulative update package 11 for SQL Server 2005 Service Pack 2 에서 해결되었으며 아래 링크를 통해 다운로드 받을 수 있습니다. 하지만 가능한 최신 버전의 Service Pack 과 누적 업데이트를 테스트 후 설치하실 것을 권장해 드립니다.
Cumulative update package 11 for SQL Server 2005 Service Pack 2
http://support.microsoft.com/kb/958735/en-us
[WORKAROUND]
데이터 파일 크기를 100MB 정도 증가시킨 후 shrink file 작업을 수행할 경우 데이터 파일을 축소할 수 있습니다. 이 방법은 Workaround 로써 근본적인 문제 해결을 위해서는 최신 버전의 서비스팩과 누적 업데이트 설치가 권장됩니다.
GO
ALTER DATABASE [LAIGO] MODIFY FILE ( NAME = N'LAIGODATA', SIZE = 10340000KB )
GO
DBCC shrinkfile('LAIGODATA', TRUNCATEONLY)
[참고자료]
FIX: Error message when you try to shrink a database in SQL Server 2005 Service Pack 2: "File ID <FileID> of database ID <DatabaseID> cannot be shrunk as it is either being shrunk by another process or is empty"
http://support.microsoft.com/kb/960567/en-us
DBCC SHRINKFILE (Transact-SQL)
http://msdn.microsoft.com/en-us/library/ms189493.aspx
Consider the following information when you plan to shrink a file:
A shrink operation is most effective after an operation that creates lots of unused space, such as a truncate table or a drop table operation.
Most databases require some free space to be available for regular day-to-day operations. If you shrink a database repeatedly and notice that the database size grows again, this indicates that the space that was shrunk is required for regular operations. In these cases, repeatedly shrinking the database is a wasted operation.
A shrink operation does not preserve the fragmentation state of indexes in the database, and generally increases fragmentation to a degree. This is another reason not to repeatedly shrink the database.
작성자 : Lai Go / 작성일자 : 2011.08.01