24 LockTimeout: Operation exceeded time limit waiting for a lock (락 대기 중 작업 시간 한도 초과)
MongoDB의미
작업이 필요한 락(예: 데이터베이스/컬렉션 수준)을 기다리는 중 시간 한도를 초과해 중단되었다. 락을 제때 획득할 수 없었다.
원인
장시간 실행 작업이나 DDL 명령(예: 컬렉션에 대한 충돌하는 관리 작업)이 필요한 락을 보유하거나, 동시 쓰기가 많거나, maxTimeMS로 제한된 작업이 락을 기다리는 중 만료된 경우다. 충돌하는 인덱스/컬렉션 작업에서 나타난다.
해결 방법
락을 보유한 작업을 찾는다: db.currentOp()로 활성 및 대기 중인 작업을 확인하고 필요하면 db.killOp()로 종료한다. 충돌하는 관리 명령(인덱스 생성, collMod, compact)은 비피크 시간으로 옮긴다. 작업을 짧게 유지하고 불필요하게 긴 트랜잭션을 피한다. 필요하면 워크로드에 맞게 maxTimeMS를 조정한다.
같은 데이터베이스의 다른 항목
- 10107 NotWritablePrimarynot master / not writable primary
- 91 ShutdownInProgressThe server is in the process of shutting down (서버가 종료 중)
- 189 PrimarySteppedDownPrimary stepped down while operation was in progress (작업 진행 중 primary가 step down됨)
- 7 HostNotFoundCould not find host
- 175 QueryPlanKilledQuery plan killed during execution
- 11602 InterruptedDueToReplStateChangeOperation interrupted due to a replication state change (복제 상태 변경으로 작업 중단)
- 136 CappedPositionLostCapped collection position lost