Redis Cluster: CROSSSLOT Keys in request don't hash to the same slot
A multi key command touched keys living on different shards. Redis Cluster splits the keyspace into 16384 slots by hashing the key, and commands like MGET, transactions and Lua scripts must stay inside one slot, so code that worked on a single node breaks on a cluster.
Quick fix
Read the commands before running them. Anything that restarts a service, deletes data or changes permissions should be tried on a non-production system first.
# Force related keys into one slot with a hash tag
SET {user:42}:profile ...
SET {user:42}:sessions ...
MGET {user:42}:profile {user:42}:sessions # same slot, allowed
# Check where a key lives
redis-cli -c cluster keyslot 'user:42:profile'
# Or issue one command per key and pipeline them
pipe = client.pipeline(transaction=False)
for k in keys: pipe.get(k)
pipe.execute()
How to diagnose Database errors
Database errors group into connection exhaustion, lock contention and deadlocks, constraint violations, and resource limits. Connection errors under load are the most misdiagnosed: "too many connections" is almost never fixed by raising max_connections, because each connection costs memory. It is fixed by putting a pooler in front and finding the code path that leaks connections.
If the quick fix above does not resolve it, work through these steps. They apply to this whole class of error, not just to this one message, which is usually what saves the time.
- Look at what the server currently sees:
SELECT * FROM pg_stat_activityin PostgreSQL,SHOW FULL PROCESSLISTin MySQL. Sessions sitting inidle in transactionare the usual culprit behind connection exhaustion. - For deadlocks, read the deadlock report the database logs. It names both transactions and the exact lock order. The fix is nearly always to make all code paths acquire locks in the same order.
- Check whether the error is from the database or from a pooler. PgBouncer, ProxySQL and RDS Proxy return their own errors that look database-native but need pooler-side fixes.
- Run
EXPLAIN (ANALYZE, BUFFERS)on slow queries. Lock-wait timeouts are often just very slow queries holding locks longer than they should. - Verify you are connected to the writer, not a read replica.
READONLYand "cannot execute in a read-only transaction" errors mean traffic is reaching the wrong endpoint.
Tools worth reaching for
pg_stat_activitySHOW ENGINE INNODB STATUSEXPLAIN ANALYZEslow query logpgbadger
Authoritative references
Primary documentation for this error, worth reading before applying any fix in production.
Related Database errors
- Cassandra: NoHostAvailableThe driver could not reach any node: wrong contact points, the node is down, a…
- ClickHouse: Memory limit (total) exceededA query tried to use more memory than max_memory_usage (or the server total) allows, common…
- CockroachDB: restart transaction (SQLSTATE 40001)A SerialisABLE transaction conflicted and must be retried. Contended transactions can be…
- DynamoDB: ProvisionedThroughputExceededExceptionThe table or a hot partition exceeded its read/write capacity. A skewed partition key can…
- Elasticsearch: flood stage disk watermark exceededDisk usage >95%. Node effectively read-only to prevent data corruption. Requires manual reset…
- Elasticsearch: mapper_parsing_exception, failed to parse fieldA document's value does not fit the field's mapped type. Dynamic mapping fixes a type from…
- Elasticsearch: Shard allocation failedCannot allocate shards to nodes. Disk space low, node disconnected, or allocation settings…
- MongoDB: E11000 duplicate key errorAn insert or upsert violated a unique index. Common during retries, imports, or migrations…
Browse other categories
- HTTP 494xx client errors, 5xx server errors, redirects, headers and protocol problems.
- JavaScript 42npm resolution, async pitfalls, hydration, memory limits and runtime type…
- AI 35Rate limits, context windows, GPU memory and model-serving failures.
- Network 35Refused connections, timeouts, resets, MTU problems and port exhaustion.
- Python 35Imports, virtual environments, encoding, concurrency and dependency conflicts.
- Kubernetes 34CrashLoopBackOff, ImagePullBackOff, OOMKilled, RBAC, scheduling and storage.
- Docker 27Daemon connectivity, disk space, image pulls, ports and architecture mismatches.
- System 26Disk space, systemd units, file descriptors, OOM killer and scheduled jobs.
- Cloud 25IAM permissions, quotas, service limits and credential failures.
- Security 25JWT validation, CSRF, OAuth grants, SELinux, SSH host keys and CSP.
- TLS 24Untrusted authorities, expiry, hostname mismatch, chains and cipher negotiation.
- Frontend 23Hydration mismatches, bundler resolution, layout shift and font loading.
Something missing or wrong?
This entry is maintained by hand. If the fix is out of date, incomplete, or you have a better one, email a correction and it will be reviewed.