8651: Could not perform the operation because the requested memory grant was not available (요청한 memory grant를 사용할 수 없어 작업을 수행할 수 없음)
SQL Server의미
쿼리에 필요한 memory grant를 사용할 수 없어 작업을 수행할 수 없었다. 8645와 달리 대기가 아니라 요청한 큰 메모리 블록을 아예 제공하지 못한 것이며, 보통 심각한 메모리 압박을 나타낸다.
원인
서버의 사용 가능한 쿼리 메모리가 단일 연산자(예: 매우 큰 sort/hash)가 요청한 grant를 충족하지 못한다. 과도하게 높은 메모리 추정, 낮은 max server memory, 외부 메모리 압박, 또는 낮은 Resource Governor 한도인 REQUEST_MAX_MEMORY_GRANT_PERCENT(workload group)나 MAX_MEMORY_PERCENT(resource pool)가 원인일 수 있다.
해결 방법
memory grant를 부풀리는 쿼리를 최적화한다(통계 갱신, 적절한 인덱싱, 쿼리 분할). 전체 및 사용 가능한 메모리를 모니터링하고, max server memory 설정과 외부 애플리케이션의 메모리 압박을 확인한다. Resource Governor를 사용 중이라면 workload group의 REQUEST_MAX_MEMORY_GRANT_PERCENT와 pool의 MAX_MEMORY_PERCENT 설정을 검토한다. 메모리를 많이 사용하는 배치 작업은 비피크 시간으로 옮긴다.
같은 데이터베이스의 다른 항목
- 7202Could not find server 'name' in sys.servers (sys.servers에서 서버를 찾을 수 없음)
- 40501The service is currently busy. Retry the request after 10 seconds (서비스가 현재 바쁨. 10초 후 재시도)
- 8645A time out occurred while waiting for memory resources to execute the query (쿼리 실행을 위한 메모리 리소스를 기다리는 중 타임아웃 발생)
- 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이 스키마를 소유하고 있어 삭제 불가)
- 1934INSERT/UPDATE failed because the following SET options have incorrect settings (다음 SET 옵션의 설정이 잘못되어 INSERT/UPDATE 실패)