Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use Lettuce with corvus? Maybe there are some bugs! #155

Open
AuroraTwinkle opened this issue Jul 22, 2022 · 1 comment
Open

Can I use Lettuce with corvus? Maybe there are some bugs! #155

AuroraTwinkle opened this issue Jul 22, 2022 · 1 comment

Comments

@AuroraTwinkle
Copy link

AuroraTwinkle commented Jul 22, 2022

client : Lettuce,a aync client base netty nio

corvus version : a Secondary development version base eleme/corvus master(update to date)
redis: redis cluster

problem:
when run my code some time, i got some exceptions like this:
image

tcpdump:

I find some things wrong by tcpdump.

  1. the corvus response do not follow the RESP. like *2 $-1 should be *2 $-1 $-1
  2. the response order is incorrect , so cannot be matched (request) one by one

just like this photos:
image
image

reproducer code:

public class RedisOptionV2 {
    private static RedisAsyncCommands<String, String> ASYNC;
    private static boolean flag = false;
    private static AtomicLong index = new AtomicLong(0);

    static {
        RedisURI redisURI = RedisURI.create("corvus ip",  6666);
        RedisClient redisClient = RedisClient.create(redisURI);
        StatefulRedisConnection<String, String> connection = redisClient.connect();
        ASYNC = connection.async();
    }

    @PostConstruct
    void init() {
        MyExecutorService.schedule(this::lettuceTestTask, 30, TimeUnit.SECONDS);
    }

    private void lettuceTestTask() {
        for (long i = 0; i < Long.MAX_VALUE; i++) {
            try {
                MyExecutorService.submit(this::lettuceDemo);
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    }

    public void lettuceDemo() {
        try {
            List<String> keys = new ArrayList<>();
            keys.add("debugLettuceKey" + index.getAndIncrement());
            if (flag) {
                keys.add("debugLettuceKey2");
                flag = false;
            } else {
                flag = true;
            }

            //core code
            RedisFuture<List<KeyValue<String, String>>> future = ASYNC.mget(keys.toArray(new String[0]));
            future.whenCompleteAsync((e, t) -> {
                if (t == null) {
                    log.info("{} res: {}", keys, e);
                } else {
                    log.error("调用redis失败, {} res : {}", keys, e, t);
                }
            }, MyExecutorService.getExecutorService());

        } catch (Throwable t) {
            log.error("fail to execute task", t);
        }
    }
}

Looking forward to reply!Thanks

@caojiajun
Copy link

you can try camellia-redis-proxy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants