From bc02fe38310540fe77e4d9d805e52a301bb82271 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Mon, 25 Jul 2022 14:17:40 -0500 Subject: [PATCH] Only unsubscribe from keyspace notifications if the node has the slot --- .../textsecuregcm/storage/MessagesCache.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java index bbe7b564d..17938f661 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java @@ -330,9 +330,12 @@ public class MessagesCache extends RedisClusterPubSubAdapter imp } private void unsubscribeFromKeyspaceNotifications(final String queueName) { - pubSubConnection.usePubSubConnection(connection -> connection.sync().upstream() - .commands() - .unsubscribe(getKeyspaceChannels(queueName))); + final int slot = SlotHash.getSlot(queueName); + + pubSubConnection.usePubSubConnection( + connection -> connection.sync().nodes(node -> node.is(RedisClusterNode.NodeFlag.UPSTREAM) && node.hasSlot(slot)) + .commands() + .unsubscribe(getKeyspaceChannels(queueName))); } private static String[] getKeyspaceChannels(final String queueName) {