NOREPLICAS error
The primary accepts writes only when enough replicas are connected, and there aren't enough.
A primary returns this error when you send a write, but fewer replicas are connected than its min-replicas-to-write setting requires. This setting limits how much data you can lose if the primary fails. Reads still work. Writes start working again when enough replicas are connected.
A replica only counts if it's up to date. Each replica reports to its primary every second. If a replica hasn't reported for more than min-replicas-max-lag seconds, the primary doesn't count it.
NOREPLICAS Not enough good replicas to write.
In client libraries
| Client library | Exception or error type | Message |
|---|---|---|
| redis-py | ResponseError |
NOREPLICAS Not enough good replicas to write. |
| Jedis | JedisDataException |
NOREPLICAS Not enough good replicas to write. |
| node-redis | SimpleErrorTest with err.message.startsWith('NOREPLICAS') |
NOREPLICAS Not enough good replicas to write. |
| Lettuce The async API wraps the exception in an ExecutionException (get()) or a CompletionException (join()). |
RedisCommandExecutionException |
NOREPLICAS Not enough good replicas to write. |
| go-redis | redis.ErrorTest with redis.IsNoReplicasError(err) |
NOREPLICAS Not enough good replicas to write. |
| ioredis | ReplyErrorTest with err.message.startsWith('NOREPLICAS') |
NOREPLICAS Not enough good replicas to write. |
| StackExchange.Redis NRedisStack uses StackExchange.Redis, so it raises the same exceptions. The sync and async APIs raise the same exceptions. |
RedisServerException |
NOREPLICAS Not enough good replicas to write. |
| Predis | Predis\Response\ServerExceptionTest with $e->getErrorType() === 'NOREPLICAS' |
NOREPLICAS Not enough good replicas to write. |
| redis-rb | Redis::CommandError |
NOREPLICAS Not enough good replicas to write. (redis://<host>:<port>) |
| redis-rs The sync and async APIs raise the same errors. |
ErrorKind::ExtensionTest with err.code() == Some("NOREPLICAS") |
"NOREPLICAS": Not enough good replicas to write. |
How to fix it
- On the primary, run
INFO replication.connected_slavesshows how many replicas are connected. Eachslave0,slave1, and so on line shows a replica's address and itslagin seconds. - Fix the replicas that are missing or lagging. Check that they're running and can reach the primary. On a replica,
INFO replicationshows the state of its link to the primary. - If writes must work with fewer replicas, lower
min-replicas-to-write. Set it to0to turn the check off.