8645: A time out occurred while waiting for memory resources to execute the query (쿼리 실행을 위한 메모리 리소스를 기다리는 중 타임아웃 발생)
SQL Server의미
쿼리가 실행에 필요한 memory grant를 위해 resource semaphore에서 대기하다가 타임아웃되었다. 메모리 압박으로 grant를 할당할 수 없어 작업이 취소되었다.
원인
메모리를 많이 사용하는 동시 쿼리(대규모 sort, hash join, hash aggregate)가 쿼리 메모리 풀 전체를 소비해 새 쿼리가 semaphore에서 대기하다 타임아웃되었다. 과도한 memory grant 추정(오래된 통계, 잘못된 실행 계획)이나 부족한 서버 메모리가 근본 원인이다.
해결 방법
sys.dm_exec_query_memory_grants와 resource semaphore DMV로 메모리를 기다리거나 보유한 쿼리를 식별한다. 통계를 갱신하고 memory grant를 부풀리는 실행 계획을 수정한다(적절한 인덱스, 더 나은 추정). 메모리를 많이 사용하는 쿼리의 동시성을 줄이고, 필요하면 Resource Governor로 memory grant를 제한한다. 서버 메모리 구성(max server memory)을 검토한다.
같은 데이터베이스의 다른 항목
- 4922ALTER TABLE ALTER COLUMN failed because one or more objects access this column (하나 이상의 객체가 이 컬럼에 접근하므로 ALTER TABLE ALTER COLUMN 실패)
- 7202Could not find server 'name' in sys.servers (sys.servers에서 서버를 찾을 수 없음)
- 40501The service is currently busy. Retry the request after 10 seconds (서비스가 현재 바쁨. 10초 후 재시도)
- 8651Could not perform the operation because the requested memory grant was not available (요청한 memory grant를 사용할 수 없어 작업을 수행할 수 없음)
- 5061ALTER DATABASE failed because a lock could not be placed on database (데이터베이스에 락을 걸 수 없어 ALTER DATABASE 실패)
- 3702Cannot drop database because it is currently in use (사용 중이어서 데이터베이스 삭제 불가)
- 15138The database principal owns a schema in the database, and cannot be dropped (database principal이 스키마를 소유하고 있어 삭제 불가)