Add unit tests for CLUSTER NODES parsing#112
Conversation
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Fix memory issues when the parsing of replicas fails. Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
| @@ -628,12 +628,12 @@ static int cluster_master_slave_mapping_with_name(valkeyClusterContext *cc, | |||
| } | |||
|
|
|||
| if (node_old->slaves != NULL) { | |||
There was a problem hiding this comment.
This is a little odd and maybe fragile.
What about the corner case primaries without any slots? Does the nodes dict own them too?
There was a problem hiding this comment.
It is a bit odd.
The nodes dict owns all valkeyClusterNodes after the parsing is complete, these are nodes with-or-without slots. This dict holds key=address, value=primary node, and each primary owns a list of replicas.
Deleting the nodes dict will delete all its objects, primaries and their known replicas, when there is an error while parsing.
But then there is the temporary nodes_name dict which holds references to all currently parsed cluster nodes.
The found issue is that this dict is the actual owner of an replica node, that has a primary, which is not yet parsed.
So, these are the replica nodes that needs to be deleted while the parsing fails.
I have a coming PR where the cluster nodes parsing is refactored.
| // Connect | ||
| { | ||
| for (int i = 0; i < 128; ++i) { | ||
| for (int i = 0; i < 148; ++i) { |
There was a problem hiding this comment.
Because the stack-allocated iterator uses fewer allocations?
There was a problem hiding this comment.
I added the config to also parse replicas in this testcase, This required a couple of more allocations to succeed.
Includes OOM testing of replica parsing and fixes for memory issues when parsing fails.
Fixes #33