成人无码视频,亚洲精品久久久久av无码,午夜精品久久久久久毛片,亚洲 中文字幕 日韩 无码

資訊專欄INFORMATION COLUMN

Redis-jedis客戶端報Too many Cluster redirections異常

imtianx / 2667人閱讀

摘要:客戶端報異常很困擾不知道是什么問題請看以下文章,為你一一解答。解決方案暫沒發(fā)現(xiàn)比較好的解決方案。環(huán)境場景問題現(xiàn)象請求間歇性穿透緩存。與該錯誤關系不大。

jedis客戶端報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);
    }
  }

當發(fā)生JedisConnectionException或者JedisRedirectionException時,會重新調用當前方法。

JedisConnectionException

與該錯誤關系不大。

因為該錯誤是:連接Redis錯誤,如果連接第一個節(jié)點失敗,嘗試第二個節(jié)點也失敗,會直接推斷成全部節(jié)點down掉拋出錯誤,中斷處理。

JedisRedirectionException

和該錯誤關系很大。

對該錯誤處理時,并處理了以下兩個異常:
JedisMovedDataException:節(jié)點重置/遷移后,會拋出該異常
JedisAskDataException: 數(shù)據(jù)遷移,發(fā)生asking問題, 獲取asking的Jedis

從此推斷,發(fā)生該問題的原因為:

節(jié)點主從切換/遷移后,客戶端與redis的slot不一致導致一直重試

asking 一直失敗,當槽點數(shù)值分布在兩個節(jié)點上時,容易引起該錯誤

因此,導致該錯誤的原因可為:

節(jié)點主從切換/遷移后,網(wǎng)絡等各種原因導致更新slot信息失敗

asking時一直指向同一個節(jié)點,導致asking一直失敗(該幾率較少?)

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉載請注明本文地址:http://m.hztianpu.com/yun/77194.html

相關文章

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

    摘要:集群時發(fā)生的錯誤搭建集群發(fā)生的錯誤在搭建完集群,重啟了,拋出了。具體解決方法參考 1、集群時發(fā)生的錯誤 1.1、搭建集群發(fā)生的錯誤 在搭建完redis集群,重啟了redis,拋出了127.0.0.1:6379 is not empty 。 解決方法:刪除對應的redis下面的 dump.rdb 和aof 已經nodes.conf文件(如果沒修改redis中的cluster-confi...

    shadajin 評論0 收藏0

發(fā)表評論

0條評論

閱讀需要支付1元查看
<