189 PrimarySteppedDown: Primary stepped down while operation was in progress
MongoDBWhat does it mean?
The primary stepped down while the operation was running and no longer accepts writes. The in-progress command was therefore aborted.
Why does it happen?
An election was triggered in the replica set: the primary was stepped down manually for maintenance, lost contact with the majority, a priority change occurred, or there was a network partition. In-flight operations at failover time receive this error.
How to fix it
This is typically a retryable error; with retryable writes/reads enabled in the driver, the operation can be routed to the new primary automatically. Catch this error in the application and retry. If it happens frequently, investigate replica set health: check member states, network latency and oplog lag with rs.status(), and reduce unnecessary elections (heartbeat/timeout settings).
More from this engine
- 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