현상

동일한 OS 버전 / 동일한 MSSQL 버전 / 동일한 구조 / 동일한 요청량 

동일한 조건이지만 트랜잭션 로그 및 로그 백업 파일의 사이즈가 약 8배 차이가 나는 경우

원인

Physical Disk Sector 크기의 차이

기존에는 Physical Disk Sector 사이즈를 512 Byte를 사용하였지만, 최근 H/W 스펙이 올라가며 4096 Byte를 디폴트로 설정되어 구성되는 경우가 있음.

 

확인

명령프롬포트(CMD)를 관리자모드로 실행하여 아래 명령어 실행

fsutil fsinfo ntfsinfo yourLogDrive:
fsutil fsinfo sectorinfo yourLogDrive:

------------- 실행 예

C:\WINDOWS\system32>fsutil fsinfo ntfsinfo D:
NTFS 볼륨 일련 번호 :        0x???????????????
NTFS 버전      :                3.1
LFS 버전       :                2.0
총 섹터     :                1,953,519,615  (931.5 GB)
총 클러스터    :                  244,189,951  (931.5 GB)
사용 가능한 클러스터     :                  217,448,760  (829.5 GB)
예약된 총 클러스터 :                  5,087  ( 19.9 MB)
저장소 예약을 위해 예약됨 :                 0  (  0.0 KB)
섹터당 바이트  :                512
실제 섹터당 바이트 :        4096
클러스터당 바이트 :                4096


C:\WINDOWS\system32>fsutil fsinfo sectorinfo D:
LogicalBytesPerSector:                                 512
PhysicalBytesPerSectorForAtomicity:                    4096
PhysicalBytesPerSectorForPerformance:                  4096
FileSystemEffectivePhysicalBytesPerSectorForAtomicity: 4096
장치 맞춤:                                      정렬됨(0x000)
장치 파티션 맞춤:                         정렬됨(0x000)
일반 검색 수행
자르기 지원 안 됨
DAX 지원 안 함
씬 프로비저닝되지 않음

C:\WINDOWS\system32>

 

PhysicalBytesPerSector Transaction Log I/O간의 관계

SQL Server transaction log 파일은 physical sector-aligned boundary  생성되며, sector-aligned sizes  sector-aligned boundaries  데이터가 쓰여집니다.
, PhysicalBytesPerSector 크기에 따라 IO 단위가 달라지며,  값이 512 bytes  경우 트랜잭션 로그는 512 Bytes – 60KB 단위로 저장  있습니다.
또한 PhysicalBytesPerSector 크기가 4KB 경우 4 KB – 60KB 단위로 저장  있습니다.

현상

powershell의 invoke-sqlcmd를 사용하여 DB 쿼리를 실행하는 도중 강제 종료

에러 내용

invoke-sqlcmd : Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the
server is not responding.

원인

쿼리 실행 timeout 설정을 하지 않아, 쿼리 실행 시간이 Default 30초를 초과하여 종료되는 현상

해소

-Querytimeout 옵션으로 쿼리 실행 가능 시간을 설정

-- Query Timeout 제한 없음 : 0
Invoke-Sqlcmd -ServerInstance "$serverInstance" -Querytimeout 0 -Query "Select * from ...."

참고

https://stackoverflow.com/questions/52545013/getting-execution-timeout-expired-running-sql-server-backup-through-invoke-sql/56991850

 


to Top