mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
Redis sentinel kill pubsub client connections as well
When a redis instance becomes a slave, sentinel also kills pubsub clients. Closes #6545
This commit is contained in:
parent
0f026af185
commit
9593ffde2e
@ -465,6 +465,12 @@ struct redisCommand sentinelcmds[] = {
|
|||||||
{"hello",helloCommand,-2,"no-script fast",0,NULL,0,0,0,0,0}
|
{"hello",helloCommand,-2,"no-script fast",0,NULL,0,0,0,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* List of client types that are killed when an instance becomes a slave */
|
||||||
|
const char* killedClientTypes[] = {
|
||||||
|
"normal",
|
||||||
|
"pubsub"
|
||||||
|
};
|
||||||
|
|
||||||
/* This function overwrites a few normal Redis config default with Sentinel
|
/* This function overwrites a few normal Redis config default with Sentinel
|
||||||
* specific defaults. */
|
* specific defaults. */
|
||||||
void initSentinelConfig(void) {
|
void initSentinelConfig(void) {
|
||||||
@ -3949,6 +3955,7 @@ char *sentinelGetLeader(sentinelRedisInstance *master, uint64_t epoch) {
|
|||||||
int sentinelSendSlaveOf(sentinelRedisInstance *ri, char *host, int port) {
|
int sentinelSendSlaveOf(sentinelRedisInstance *ri, char *host, int port) {
|
||||||
char portstr[32];
|
char portstr[32];
|
||||||
int retval;
|
int retval;
|
||||||
|
unsigned int curType;
|
||||||
|
|
||||||
ll2string(portstr,sizeof(portstr),port);
|
ll2string(portstr,sizeof(portstr),port);
|
||||||
|
|
||||||
@ -3993,11 +4000,14 @@ int sentinelSendSlaveOf(sentinelRedisInstance *ri, char *host, int port) {
|
|||||||
* an issue because CLIENT is variadic command, so Redis will not
|
* an issue because CLIENT is variadic command, so Redis will not
|
||||||
* recognized as a syntax error, and the transaction will not fail (but
|
* recognized as a syntax error, and the transaction will not fail (but
|
||||||
* only the unsupported command will fail). */
|
* only the unsupported command will fail). */
|
||||||
retval = redisAsyncCommand(ri->link->cc,
|
for (curType = 0; curType < sizeof(killedClientTypes)/sizeof(killedClientTypes[0]); ++curType) {
|
||||||
sentinelDiscardReplyCallback, ri, "%s KILL TYPE normal",
|
retval = redisAsyncCommand(ri->link->cc,
|
||||||
sentinelInstanceMapCommand(ri,"CLIENT"));
|
sentinelDiscardReplyCallback, ri, "%s KILL TYPE %s",
|
||||||
if (retval == C_ERR) return retval;
|
sentinelInstanceMapCommand(ri,"CLIENT"),
|
||||||
ri->link->pending_commands++;
|
killedClientTypes[curType]);
|
||||||
|
if (retval == C_ERR) return retval;
|
||||||
|
ri->link->pending_commands++;
|
||||||
|
}
|
||||||
|
|
||||||
retval = redisAsyncCommand(ri->link->cc,
|
retval = redisAsyncCommand(ri->link->cc,
|
||||||
sentinelDiscardReplyCallback, ri, "%s",
|
sentinelDiscardReplyCallback, ri, "%s",
|
||||||
|
Loading…
Reference in New Issue
Block a user