摘要:客戶端報(bào)異常很困擾不知道是什么問題請看以下文章,為你一一解答。解決方案暫沒發(fā)現(xiàn)比較好的解決方案。環(huán)境場景問題現(xiàn)象請求間歇性穿透緩存。與該錯(cuò)誤關(guān)系不大。
jedis客戶端報(bào)Too many Cluster redirections異常?很困擾?不知道是什么問題?請看以下文章,為你一一解答。
1.解決方案暫沒發(fā)現(xiàn)比較好的解決方案。
2.環(huán)境Redis 3.x Cluster
Jedis 2.8
Jdk1.8
3.場景 4.問題現(xiàn)象請求間歇性穿透緩存。
錯(cuò)誤信息redis.clients.jedis.exceptions.JedisClusterMaxRedirectionsException: Too many Cluster redirections? at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:34) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:85) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:68) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:85) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:68) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:85) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:68) at redis.clients.jedis.JedisClusterCommand.run(JedisClusterCommand.java:29) at redis.clients.jedis.JedisCluster.set(JedisCluster.java:75)5.問題原因
通過分析以下代碼得知錯(cuò)誤原因:
private T runWithRetries(byte[] key, int redirections, boolean tryRandomNode, boolean asking) { if (redirections <= 0) { throw new JedisClusterMaxRedirectionsException("Too many Cluster redirections?"); } Jedis connection = null; try { if (asking) { // TODO: Pipeline asking with the original command to make it // faster.... connection = askConnection.get(); connection.asking(); // if asking success, reset asking flag asking = false; } else { if (tryRandomNode) { connection = connectionHandler.getConnection(); } else { connection = connectionHandler.getConnectionFromSlot(JedisClusterCRC16.getSlot(key)); } } return execute(connection); } catch (JedisConnectionException jce) { if (tryRandomNode) { // maybe all connection is down throw jce; } // release current connection before recursion releaseConnection(connection); connection = null; // retry with random connection return runWithRetries(key, redirections - 1, true, asking); } catch (JedisRedirectionException jre) { // if MOVED redirection occurred, if (jre instanceof JedisMovedDataException) { // it rebuilds cluster"s slot cache // recommended by Redis cluster specification this.connectionHandler.renewSlotCache(connection); } // release current connection before recursion or renewing releaseConnection(connection); connection = null; if (jre instanceof JedisAskDataException) { asking = true; askConnection.set(this.connectionHandler.getConnectionFromNode(jre.getTargetNode())); } else if (jre instanceof JedisMovedDataException) { } else { throw new JedisClusterException(jre); } return runWithRetries(key, redirections - 1, false, asking); } finally { releaseConnection(connection); } }
當(dāng)發(fā)生JedisConnectionException或者JedisRedirectionException時(shí),會(huì)重新調(diào)用當(dāng)前方法。
JedisConnectionException與該錯(cuò)誤關(guān)系不大。
因?yàn)樵撳e(cuò)誤是:連接Redis錯(cuò)誤,如果連接第一個(gè)節(jié)點(diǎn)失敗,嘗試第二個(gè)節(jié)點(diǎn)也失敗,會(huì)直接推斷成全部節(jié)點(diǎn)down掉拋出錯(cuò)誤,中斷處理。
JedisRedirectionException和該錯(cuò)誤關(guān)系很大。
對該錯(cuò)誤處理時(shí),并處理了以下兩個(gè)異常:
JedisMovedDataException:節(jié)點(diǎn)重置/遷移后,會(huì)拋出該異常
JedisAskDataException: 數(shù)據(jù)遷移,發(fā)生asking問題, 獲取asking的Jedis
從此推斷,發(fā)生該問題的原因?yàn)椋?/p>
節(jié)點(diǎn)主從切換/遷移后,客戶端與redis的slot不一致導(dǎo)致一直重試
asking 一直失敗,當(dāng)槽點(diǎn)數(shù)值分布在兩個(gè)節(jié)點(diǎn)上時(shí),容易引起該錯(cuò)誤
因此,導(dǎo)致該錯(cuò)誤的原因可為:
節(jié)點(diǎn)主從切換/遷移后,網(wǎng)絡(luò)等各種原因?qū)е赂聅lot信息失敗
asking時(shí)一直指向同一個(gè)節(jié)點(diǎn),導(dǎo)致asking一直失?。ㄔ搸茁瘦^少?)
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/77194.html
摘要:集群時(shí)發(fā)生的錯(cuò)誤搭建集群發(fā)生的錯(cuò)誤在搭建完集群,重啟了,拋出了。具體解決方法參考 1、集群時(shí)發(fā)生的錯(cuò)誤 1.1、搭建集群發(fā)生的錯(cuò)誤 在搭建完redis集群,重啟了redis,拋出了127.0.0.1:6379 is not empty 。 解決方法:刪除對應(yīng)的redis下面的 dump.rdb 和aof 已經(jīng)nodes.conf文件(如果沒修改redis中的cluster-confi...
閱讀 3803·2021-09-23 11:32
閱讀 2470·2021-09-06 15:01
閱讀 1630·2021-08-18 10:24
閱讀 3468·2019-12-27 11:44
閱讀 3615·2019-08-30 15:52
閱讀 2522·2019-08-30 11:11
閱讀 695·2019-08-29 17:27
閱讀 608·2019-08-29 16:22