ASK bit not set on ASK redirection #321

Closed
kaibaemon opened this Issue Jul 25, 2016 · 1 comment

Projects

None yet

2 participants

@kaibaemon
kaibaemon commented Jul 25, 2016 edited
  • I'm using Lettuce 4.2.1-Final .
  • I add new nodes into my current redis cluster ,and I import some slots to the new master node.
  • So some slots are set in importing state.
  • at the same time ,I continuously read and write data into these slots which are importing state
  • But the slots can not be read and writed when the slots are set in importing state,
  • Lettuce throw an exception : com.lambdaworks.redis.RedisCommandExecutionException: ASK 15737 172.16.55.66:8201
  • I try to call the asking() before read/write data, but it does not work ,too.

This is the stack trace

2016.07.23 05:39:58 PDT ERROR com.practice.consumer.sink.RedisSink 370 putIntoRedis - com.practice.consumer.sink.RedisSink ; com.lambdaworks.redis.RedisCommandExecutionException: ASK 15737 172.16.43.11:8201
     at com.lambdaworks.redis.LettuceFutures.awaitAll(LettuceFutures.java:52) ~[lettuce-4.2.1.Final.jar:?]
     at com.practice.sink.RedisSink.putIntoRedis(RedisSink.java:367) [ntust-consumer-0.0.1.jar:?]
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_60]
     at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_60]
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_60]
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_60]
     at java.lang.Thread.run(Thread.java:745) [?:1.8.0_60]
Caused by: com.lambdaworks.redis.RedisCommandExecutionException: ASK 15737 172.16.43.11:8201
     at com.lambdaworks.redis.protocol.AsyncCommand.completeResult(AsyncCommand.java:85) ~[lettuce-4.2.1.Final.jar:?]
     at com.lambdaworks.redis.protocol.AsyncCommand.complete(AsyncCommand.java:75) ~[lettuce-4.2.1.Final.jar:?]
     at com.lambdaworks.redis.protocol.CommandWrapper.complete(CommandWrapper.java:32) ~[lettuce-4.2.1.Final.jar:?]
     at com.lambdaworks.redis.cluster.ClusterCommand.complete(ClusterCommand.java:44) ~[lettuce-4.2.1.Final.jar:?]
     at com.lambdaworks.redis.protocol.CommandHandler.decode(CommandHandler.java:187) ~[lettuce-4.2.1.Final.jar:?]
     at com.lambdaworks.redis.protocol.CommandHandler.channelRead(CommandHandler.java:153) ~[lettuce-4.2.1.Final.jar:?]
     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1280) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:890) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:564) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:505) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:419) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:391) ~[netty-transport-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) ~[netty-common-4.0.37.Final.jar:4.0.37.Final]
     at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:145) ~[netty-common-4.0.37.Final.jar:4.0.37.Final]
     ... 1 more

Simply describe the scenario :

step 1 : Set a slot importing state.
step 2 : create RedisClusterClient with RedisClusterClient.create(Iterable<RedisURI> redisURIs);
step 3 : configure ClusterToplogyRefreshOptions and get connection and write data.

ClusterTopologyRefreshOptions options = ClusterTopologyRefreshOptions.builder()//
               .enablePeriodicRefresh(true).refreshPeriod(1, TimeUnit.MINUTES)//
               .dynamicRefreshSources(true) .enableAdaptiveRefreshTrigger(RefreshTrigger.MOVED_REDIRECT,RefreshTrigger.ASK_REDIRECT)//
               .adaptiveRefreshTriggersTimeout(10, TimeUnit.SECONDS)//
               .closeStaleConnections(false)//
               .refreshTriggersReconnectAttempts(2)//
               .build();

 redisclusterclient.setOptions(ClusterClientOptions.builder()
               .topologyRefreshOptions(options)
               .build());

RedisAdvancedClusterAsyncCommands<String, String> command = redisclusterclient.connect().async();

Map<String,RedisFuture<Map<String,String>>> result = new HashMap();

for ( String rediskey : rediskeys) // rediskeys is List<String> object
{
result.put(rediskey,command.hgetall(rediskey));
}

Lettuce.awaitAll(10, TimeUnit.SECOND,result.values().toArray(new RedisFuture[]);// throw an Exception
@mp911de mp911de added the bug label Jul 25, 2016
@mp911de mp911de added this to the Lettuce 4.2.2 milestone Jul 25, 2016
@mp911de mp911de added a commit that referenced this issue Jul 25, 2016
@mp911de Fix ask redirection #321
Lettuce now sets correctly the ASKING bit if a command receives the ASK redirection.
1ead77a
@mp911de mp911de added a commit that referenced this issue Jul 25, 2016
@mp911de Fix ask redirection #321
Lettuce now sets correctly the ASKING bit if a command receives the ASK redirection.
f266988
@mp911de
Owner
mp911de commented Jul 25, 2016

Thanks for the bug report. That's fixed with lettuce 4.2 and 4.3

@mp911de mp911de closed this Jul 25, 2016
@mp911de mp911de changed the title from ASK Redirection does not work!! Lettuce.awaitAll throw "com.lambdaworks.redis.RedisCommandExecutionException: ASK 15737 172.16.55.66:8201" to ASK Redirection does not work: RedisCommandExecutionException: ASK 15737 Oct 26, 2016
@mp911de mp911de changed the title from ASK Redirection does not work: RedisCommandExecutionException: ASK 15737 to ASK bit not set on ASK redirection Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment