I have following error, Redis forces me to count keys at same node. Is there a new and modern way to handle this lack feature in Redis?
org.springframework.dao.InvalidDataAccessApiUsageException: All keys must map to same slot for pfcount in cluster mode.
at org.springframework.data.redis.connection.jedis.JedisClusterConnection.pfCount(JedisClusterConnection.java:3610)
at org.springframework.data.redis.core.DefaultHyperLogLogOperations$2.doInRedis(DefaultHyperLogLogOperations.java:68)
at org.springframework.data.redis.core.DefaultHyperLogLogOperations$2.doInRedis(DefaultHyperLogLogOperations.java:64)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:207)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:169)
at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:91)
at org.springframework.data.redis.core.DefaultHyperLogLogOperations.size(DefaultHyperLogLogOperations.java:64)
Spring Source COde:
@Override
public long countAll(List<String> keys) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
LOGGER.debug("Calculating keys -> {} ", keys);
long size = 0;
try {
size = hyperLogLogOperations.size(keys.toArray(new String[0]));
redisInTrouble = false;
} catch (Exception e) {
LOGGER.error("Having Redis Error with key: {}", keys, e);
redisInTrouble = true;
} finally {
metricObserver.observe(SummaryMetric.REDIS_RESPONSE_PFCOUNT_TIME, stopWatch.getTotalTimeMillis());
stopOrStartKafkaUpOnRedisError();
}
return size;
}
Here is redis-cli prompt:
172.18.182.82:6379> pfcount XMPP-LI-09270934
(integer) 4
172.18.182.82:6379> pfcount XMPP-LI-09270936
(error) MOVED 3842 172.18.182.82:7379
172.18.182.82:6379> pfcount XMPP-LI-09270936 XMPP-LI-09270934
(error) CROSSSLOT Keys in request don't hash to the same slot
Force the keys to be in the same slot by enclosing the key in {}. For example, pfcount {XMPP-LI}-09270936 {XMPP-LI}-09270934
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.