摘要:客戶端報(bào)異常很困擾不知道是什么問題請看以下文章,為你一一解答。解決方案暫沒發(fā)現(xiàn)比較好的解決方案。環(huán)境場景問題現(xiàn)象請求間歇性穿透緩存。與該錯誤關(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)象請求間歇性穿透緩存。
錯誤信息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.問題原因
通過分析以下代碼得知錯誤原因:
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í),會重新調(diào)用當(dāng)前方法。
JedisConnectionException與該錯誤關(guān)系不大。
因?yàn)樵撳e誤是:連接Redis錯誤,如果連接第一個(gè)節(jié)點(diǎn)失敗,嘗試第二個(gè)節(jié)點(diǎn)也失敗,會直接推斷成全部節(jié)點(diǎn)down掉拋出錯誤,中斷處理。
JedisRedirectionException和該錯誤關(guān)系很大。
對該錯誤處理時(shí),并處理了以下兩個(gè)異常:
JedisMovedDataException:節(jié)點(diǎn)重置/遷移后,會拋出該異常
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í),容易引起該錯誤
因此,導(dǎo)致該錯誤的原因可為:
節(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://www.ezyhdfw.cn/yun/77194.html
摘要:集群時(shí)發(fā)生的錯誤搭建集群發(fā)生的錯誤在搭建完集群,重啟了,拋出了。具體解決方法參考 1、集群時(shí)發(fā)生的錯誤 1.1、搭建集群發(fā)生的錯誤 在搭建完redis集群,重啟了redis,拋出了127.0.0.1:6379 is not empty 。 解決方法:刪除對應(yīng)的redis下面的 dump.rdb 和aof 已經(jīng)nodes.conf文件(如果沒修改redis中的cluster-confi...
閱讀 3968·2021-09-23 11:32
閱讀 2646·2021-09-06 15:01
閱讀 1713·2021-08-18 10:24
閱讀 3606·2019-12-27 11:44
閱讀 3679·2019-08-30 15:52
閱讀 2586·2019-08-30 11:11
閱讀 818·2019-08-29 17:27
閱讀 671·2019-08-29 16:22