成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

Redis-jedis客戶端報(bào)Too many Cluster redirections異常

imtianx / 2517人閱讀

摘要:客戶端報(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

相關(guān)文章

  • java 連接 redis 拋出一些異常及處理,和搭建集群時(shí)出現(xiàn)的一些錯(cuò)誤

    摘要:集群時(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...

    shadajin 評論0 收藏0

發(fā)表評論

0條評論

最新活動(dòng)
閱讀需要支付1元查看
<