Commit 5ebb853
Fix segfault during Redis Cluster failover
When a Redis Cluster failover occurs, the client detects that the
redirected node was a replica of the old master and calls
cluster_map_keyspace() to remap the cluster topology.
If cluster_map_keyspace() fails (e.g., due to network issues during
the remap), it frees all node objects via zend_hash_clean(c->nodes)
and zeros the master array via memset(c->master, 0, ...).
The bug was that the return value of cluster_map_keyspace() was being
ignored in the failover detection path. This caused the code to
continue with NULL socket pointers, leading to segfaults when
dereferencing c->cmd_sock later.
This fix:
1. Checks the return value of cluster_map_keyspace() in failover
detection and returns FAILURE if it fails
2. Adds defense-in-depth NULL checks after MOVED and ASK redirections
to prevent segfaults if slots become NULL for any reason
Fixes production crashes observed during Redis Cluster failovers.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent f5db01b commit 5ebb853
1 file changed
+14
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1431 | 1431 | | |
1432 | 1432 | | |
1433 | 1433 | | |
1434 | | - | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
1435 | 1438 | | |
1436 | 1439 | | |
1437 | 1440 | | |
| |||
1610 | 1613 | | |
1611 | 1614 | | |
1612 | 1615 | | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
1613 | 1621 | | |
1614 | 1622 | | |
1615 | 1623 | | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
1616 | 1629 | | |
1617 | 1630 | | |
1618 | 1631 | | |
| |||
0 commit comments