diff options
author | Harkrishn Patro <harkrisp@amazon.com> | 2023-02-02 09:06:24 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-02 09:06:24 -0800 |
commit | fd3975684a8e9e45c77d3b14cb1883572956efe7 (patch) | |
tree | 258997a6a9e7651b0b03f3004752aead857aca0b /src/debug.c | |
parent | 023ff42f9853632b94e1fff0e99f0b85ae110ebe (diff) | |
download | redis-fd3975684a8e9e45c77d3b14cb1883572956efe7.tar.gz |
Propagate message to a node only if the cluster link is healthy. (#11752)
Currently while a sharded pubsub message publish tries to propagate the message across the cluster, a NULL check is missing for clusterLink. clusterLink could be NULL if the link is causing memory beyond the set threshold cluster-link-sendbuf-limit and server terminates the link.
This change introduces two things:
Avoids the engine crashes on the publishing node if a message is tried to be sent to a node and the link is NULL.
Adds a debugging tool CLUSTERLINK KILL to terminate the clusterLink between two nodes.
Diffstat (limited to 'src/debug.c')
-rw-r--r-- | src/debug.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/debug.c b/src/debug.c index fe46b5c62..e00263d8e 100644 --- a/src/debug.c +++ b/src/debug.c @@ -492,6 +492,8 @@ void debugCommand(client *c) { " In case RESET is provided the peak reset time will be restored to the default value", "REPLYBUFFER RESIZING <0|1>", " Enable or disable the reply buffer resize cron job", +"CLUSTERLINK KILL <to|from|all> <node-id>", +" Kills the link based on the direction to/from (both) with the provided node." , NULL }; addReplyHelp(c, help); @@ -997,6 +999,33 @@ NULL return; } addReply(c, shared.ok); + } else if(!strcasecmp(c->argv[1]->ptr,"CLUSTERLINK") && + !strcasecmp(c->argv[2]->ptr,"KILL") && + c->argc == 5) { + if (!server.cluster_enabled) { + addReplyError(c, "Debug option only available for cluster mode enabled setup!"); + return; + } + + /* Find the node. */ + clusterNode *n = clusterLookupNode(c->argv[4]->ptr, sdslen(c->argv[4]->ptr)); + if (!n) { + addReplyErrorFormat(c,"Unknown node %s", (char*)c->argv[4]->ptr); + return; + } + + /* Terminate the link based on the direction or all. */ + if (!strcasecmp(c->argv[3]->ptr,"from")) { + freeClusterLink(n->inbound_link); + } else if (!strcasecmp(c->argv[3]->ptr,"to")) { + freeClusterLink(n->link); + } else if (!strcasecmp(c->argv[3]->ptr,"all")) { + freeClusterLink(n->link); + freeClusterLink(n->inbound_link); + } else { + addReplyErrorFormat(c, "Unknown direction %s", (char*) c->argv[3]->ptr); + } + addReply(c,shared.ok); } else { addReplySubcommandSyntaxError(c); return; |