189 PrimarySteppedDown: Primary stepped down while operation was in progress (작업 진행 중 primary가 step down됨)
MongoDB의미
작업이 실행되는 중에 primary가 step down되어 더 이상 쓰기를 받지 않는다. 따라서 진행 중인 명령이 중단되었다.
원인
replica set에서 election이 트리거되었다: 유지보수를 위해 primary를 수동으로 step down했거나, 과반수와의 연결이 끊겼거나, priority 변경이 있었거나, 네트워크 분할이 발생한 경우다. 페일오버 시점에 진행 중인 작업이 이 오류를 받는다.
해결 방법
보통 재시도 가능한 오류다. 드라이버에서 retryable writes/reads가 활성화되어 있으면 작업이 새 primary로 자동 라우팅될 수 있다. 애플리케이션에서 이 오류를 잡아 재시도한다. 자주 발생한다면 replica set 상태를 조사한다: rs.status()로 멤버 상태, 네트워크 지연, oplog 지연을 확인하고 불필요한 election을 줄인다(heartbeat/timeout 설정).
같은 데이터베이스의 다른 항목
- 79 UnknownReplWriteConcernUnknown replica set write concern
- 10107 NotWritablePrimarynot master / not writable primary
- 91 ShutdownInProgressThe server is in the process of shutting down (서버가 종료 중)
- 24 LockTimeoutOperation exceeded time limit waiting for a lock (락 대기 중 작업 시간 한도 초과)
- 7 HostNotFoundCould not find host
- 175 QueryPlanKilledQuery plan killed during execution
- 11602 InterruptedDueToReplStateChangeOperation interrupted due to a replication state change (복제 상태 변경으로 작업 중단)