redisson icon indicating copy to clipboard operation
redisson copied to clipboard

Two serious issues

Open cat-debot opened this issue 12 years ago • 31 comments

1.Sentinel not support auth password.(I have solve this problem) 2.When redis sentinel occur failover,redisson can not failover to new master automatic。

cat-debot avatar Jul 11 '14 08:07 cat-debot

1.Sentinel not support auth password.(I have solve this problem)

fixed

mrniko avatar Jul 11 '14 09:07 mrniko

  1. When redis sentinel occur failover,redisson can not failover to new master automatic

Could you provide more details about this case? Sentinel not switching master at a moment it waits down-after-milliseconds

Have you seen "+switch-master ..." command in your sentinel log?

mrniko avatar Jul 11 '14 09:07 mrniko

@lianghaijian can't reproduce it

mrniko avatar Jul 12 '14 08:07 mrniko

Wait a moment,I will reproduce it,and provide more details.

cat-debot avatar Jul 14 '14 02:07 cat-debot

My test code:

  @Test
    public void testSentinelWithAuth() throws InterruptedException {
        Config config = new Config();
        config.useSentinelConnection().setPassword("foobared")
                .setMasterName("mymaster")
                .addSentinelAddress("192.168.27.111:26379", "192.168.27.112:26379");
        Redisson redisson = Redisson.create(config);
        final List<User> list = redisson.getList("cms_list");
        Runnable r = new Runnable() {
            @Override
            public void run() {
                long begin = System.currentTimeMillis();
                for(int i=0;i<10000;i++){
                    try{
                        list.add(new User());
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
                System.out.println("coast:" + (System.currentTimeMillis() - begin) / 1000);
            }
        };
        List<Thread> threads = new ArrayList<Thread>(Runtime.getRuntime().availableProcessors()*2);
        for(int i=0;i<Runtime.getRuntime().availableProcessors()*2;i++){
            Thread t = new Thread(r);z
            t.start();
            threads.add(t);
        }
        for(Thread t : threads){
            t.join();
        }
    }

After i killed the master redis server process,redis sentinel log:

[19545] 14 Jul 11:17:03.882 # +failover-end master mymaster 192.168.27.111 6379
[19545] 14 Jul 11:17:03.882 # +switch-master mymaster 192.168.27.111 6379 192.168.27.112 6379
[19545] 14 Jul 11:17:03.882 * +slave slave 192.168.27.111:6379 192.168.27.111 6379 @ mymaster 192.168.27.112 6379
[19545] 14 Jul 11:17:08.969 # +sdown slave 192.168.27.111:6379 192.168.27.111 6379 @ mymaster 192.168.27.112 6379

list.add(new User()); will throw timeout exception,next loop can not get new master connection.

com.lambdaworks.redis.RedisException: Command timed out
    at com.lambdaworks.redis.RedisAsyncConnection.await(RedisAsyncConnection.java:1195)
    at com.lambdaworks.redis.RedisConnection.await(RedisConnection.java:852)
    at com.lambdaworks.redis.RedisConnection.rpush(RedisConnection.java:489)
    at org.redisson.RedissonList.addAll(RedissonList.java:134)
    at org.redisson.RedissonList.add(RedissonList.java:85)
    at org.redisson.SentinelAuthTest$1.run(SentinelAuthTest.java:48)
    at java.lang.Thread.run(Thread.java:744)

cat-debot avatar Jul 14 '14 03:07 cat-debot

My computer :2.7 GHz Intel Core i7 16 GB 1600 MHz DDR3, The test result is not satisfactory,an average of 750 times per second

cat-debot avatar Jul 14 '14 03:07 cat-debot

It's a bug,when a connection can not be used,it always be return back to pool

@Override
    public boolean addAll(Collection<? extends V> c) {
        RedisConnection<String, Object> conn = connectionManager.connectionWriteOp();
        try {
            conn.rpush(getName(), c.toArray());
            return true;
        } finally {
            connectionManager.releaseWrite(conn);
        }
    }

Because the pool have connections,i can't get a new master connection from pool

    @Override
    public <K, V> RedisConnection<K, V> connectionWriteOp() {
        acquireMasterConnection();

        RedisConnection<K, V> conn = masterConnections.poll();
        if (conn != null) {
            return conn;
        }

        conn = masterClient.connect(codec);
        if (config.getPassword() != null) {
            conn.auth(config.getPassword());
        }
        return conn;
    }

cat-debot avatar Jul 14 '14 06:07 cat-debot

Oh, could you update from master? i think i fixed this issue. All info about master server now in holds in one entry-object.

mrniko avatar Jul 14 '14 06:07 mrniko

here is my change - https://github.com/mrniko/redisson/commit/9bd40f1363eae2f499fcfc9ec7ee62bfbc22f1e7

mrniko avatar Jul 14 '14 06:07 mrniko

Sorry,i will update and try immediately

cat-debot avatar Jul 14 '14 08:07 cat-debot

com.lambdaworks.redis.RedisException: Command timed out
    at com.lambdaworks.redis.RedisAsyncConnection.await(RedisAsyncConnection.java:1195)
    at com.lambdaworks.redis.RedisConnection.await(RedisConnection.java:852)
    at com.lambdaworks.redis.RedisConnection.rpush(RedisConnection.java:489)
    at org.redisson.RedissonList.addAll(RedissonList.java:134)
    at org.redisson.RedissonList.add(RedissonList.java:85)
    at org.redisson.SentinelTest$1.run(SentinelTest.java:49)
    at java.lang.Thread.run(Thread.java:744)

When redis occur failover,the exception above coast too much time,do you have any plan to resolve it.

cat-debot avatar Jul 14 '14 08:07 cat-debot

Yes, i'll think how to resolve it. What about bug with master change?

mrniko avatar Jul 14 '14 08:07 mrniko

The bug has been resolved, your solution is the same as I think, hahahaha.

cat-debot avatar Jul 14 '14 12:07 cat-debot

What about exception handling how did you done it?

mrniko avatar Jul 14 '14 12:07 mrniko

Try again a few times,if still failed,warning.I have seen your code,if a connection is closed,this connection can still return to the queue?I know in the lastest version jedis,jedis client close() will check if client is close before return to commons pool.

cat-debot avatar Jul 14 '14 12:07 cat-debot

If channel enters to "Inactive" state then com.lambdaworks.redis.protocol.ConnectionWatchdog going to work.

mrniko avatar Jul 14 '14 12:07 mrniko

Check the last commit. Did you mean this problem?

mrniko avatar Jul 14 '14 12:07 mrniko

@lianghaijian i just complete operation auto-repeat for RedissonMap, you don't need to catch exceptions anymore then master or slave is down. Check it out ;)

mrniko avatar Jul 18 '14 15:07 mrniko

I am facing same issue. One of the sentinels in my config is down and i can not start server as redisson always try to connect the last one in config.

prarthanb avatar Aug 11 '15 22:08 prarthanb

@prarthanb

always try to connect the last one in config

and not the server which has down? it's never connects to sentinel which has down?

mrniko avatar Aug 12 '15 06:08 mrniko