Refactor some of ASM and slot-stats functions#4
Conversation
🤖 Augment PR SummarySummary: Refactors cluster/ASM initialization and cluster slot-data verification by moving shared logic into common entry points. Changes:
Technical Notes: Startup slot verification now runs deletion/claim helpers, and slot-stats allocation moved from 🤖 Was this summary useful? React with 👍 or 👎 |
| } | ||
|
|
||
| /* Delete keys in unowned slots */ | ||
| clusterDeleteKeysInUnownedSlots(); |
There was a problem hiding this comment.
In verifyClusterConfigWithData(), clusterDeleteKeysInUnownedSlots() runs before clusterClaimUnassignedSlots(), but clusterDeleteKeysInUnownedSlots() doesn’t appear to exclude unassigned slots. This can cause keys in unassigned slots to be deleted on startup, preventing the later claim step and potentially causing data loss.
🤖 Was this useful? React with 👍 or 👎
| /* This function is called at server startup in order to initialize cluster data | ||
| * structures that are shared between the different cluster implementations. */ | ||
| void clusterCommonInit(void) { | ||
| server.cluster_slot_stats = malloc(CLUSTER_SLOTS*sizeof(clusterSlotStat)); |
There was a problem hiding this comment.
clusterCommonInit() allocates server.cluster_slot_stats via plain malloc() (previously zmalloc() in main()), and then immediately dereferences it via resetClusterStats()/clusterSlotStatResetAll(). If allocation fails, this becomes a NULL deref, and it also bypasses Redis’ zmalloc accounting/oom behavior.
🤖 Was this useful? React with 👍 or 👎
Benchmark PR from agentic-review-benchmarks#4