redis / lettuce

Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
https://lettuce.io
MIT License
5.39k stars 970 forks source link

I put a little big object to redis,maybe 300kb,lettuce make mistake; #1174

Closed zuoqi1993125 closed 4 years ago

zuoqi1993125 commented 4 years ago

Bug Report

I check my problem for github,stackoverflow,but they don`t solve my problem and recommend me use jedis.I want to you give me some solutions;

Current Behavior

I put a little big object to redis()maybe 300kb) and use jackson2JsonRedisSerializer,then lettuce make mistake;

Stack trace ```java 2019-11-05 19:45:41 logback-tgm [lettuce-nioEventLoop-4-4] WARN i.l.core.protocol.DefaultEndpoint -- Unexpected exception during request: java.io.IOException: 远程主机强迫关闭了一个现有的连接。 java.io.IOException: 远程主机强迫关闭了一个现有的连接。 at sun.nio.ch.SocketDispatcher.write0(Native Method) at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51) at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) at sun.nio.ch.IOUtil.write(IOUtil.java:51) at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:405) at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:931) at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:354) at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:898) at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1384) at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:749) at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:741) at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:727) at io.netty.channel.DefaultChannelPipeline.flush(DefaultChannelPipeline.java:979) at io.netty.channel.AbstractChannel.flush(AbstractChannel.java:241) at io.lettuce.core.protocol.DefaultEndpoint.channelFlush(DefaultEndpoint.java:324) at io.lettuce.core.protocol.DefaultEndpoint.writeToChannelAndFlush(DefaultEndpoint.java:315) at io.lettuce.core.protocol.DefaultEndpoint.flushCommands(DefaultEndpoint.java:472) at io.lettuce.core.protocol.DefaultEndpoint.lambda$notifyChannelActive$0(DefaultEndpoint.java:381) at io.lettuce.core.protocol.SharedLock.lambda$doExclusive$0(SharedLock.java:82) at io.lettuce.core.protocol.SharedLock.doExclusive(SharedLock.java:103) at io.lettuce.core.protocol.SharedLock.doExclusive(SharedLock.java:81) at io.lettuce.core.protocol.DefaultEndpoint.notifyChannelActive(DefaultEndpoint.java:363) at io.lettuce.core.protocol.CommandHandler.channelActive(CommandHandler.java:276) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:225) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:211) at io.netty.channel.AbstractChannelHandlerContext.fireChannelActive(AbstractChannelHandlerContext.java:204) at io.netty.channel.ChannelInboundHandlerAdapter.channelActive(ChannelInboundHandlerAdapter.java:69) at io.lettuce.core.ChannelGroupListener.channelActive(ChannelGroupListener.java:40) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:225) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:211) at io.netty.channel.AbstractChannelHandlerContext.fireChannelActive(AbstractChannelHandlerContext.java:204) at io.netty.channel.ChannelInboundHandlerAdapter.channelActive(ChannelInboundHandlerAdapter.java:69) at io.lettuce.core.PlainChannelInitializer$1.channelActive(PlainChannelInitializer.java:109) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:225) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:211) at io.netty.channel.AbstractChannelHandlerContext.fireChannelActive(AbstractChannelHandlerContext.java:204) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelActive(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:225) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:211) at io.netty.channel.DefaultChannelPipeline.fireChannelActive(DefaultChannelPipeline.java:907) at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:305) at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:335) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:688) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:635) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:552) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514) at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748) 2019-11-05 19:45:41 logback-tgm [lettuce-nioEventLoop-4-4] INFO i.l.c.protocol.ReconnectionHandler -- Reconnected to localhost:6379 2019-11-05 19:45:41 logback-tgm [main] ERROR o.s.boot.SpringApplication -- Application run failed org.springframework.dao.QueryTimeoutException: Redis command timed out; nested exception is io.lettuce.core.RedisCommandTimeoutException: Command timed out after 5 second(s) at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:70) at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41) at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44) at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42) at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:269) at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.convertLettuceAccessException(LettuceStringCommands.java:799) at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.set(LettuceStringCommands.java:148) at org.springframework.data.redis.connection.DefaultedRedisConnection.set(DefaultedRedisConnection.java:281) at com.cpic.framework.admin.cache.manage.redis.RedisCacheWriter.lambda$put$1(RedisCacheWriter.java:126) at com.cpic.framework.admin.cache.manage.redis.RedisCacheWriter.execute(RedisCacheWriter.java:342) at com.cpic.framework.admin.cache.manage.redis.RedisCacheWriter.put(RedisCacheWriter.java:121) at com.cpic.framework.admin.cache.manage.redis.IRedisCacheBaseImpl.put(IRedisCacheBaseImpl.java:64) at com.cpic.framework.admin.sys.service.MenuManageService.cacheMenuTreesToCache(MenuManageService.java:477) at com.cpic.framework.admin.sys.service.MenuManageService$$FastClassBySpringCGLIB$$641fd34e.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:685) at com.cpic.framework.admin.sys.service.MenuManageService$$EnhancerBySpringCGLIB$$6d939b06.cacheMenuTreesToCache() at com.cpic.framework.admin.sys.service.ModuleService.initRedis(ModuleService.java:105) at com.cpic.framework.admin.sys.runner.RedisRunner.onApplicationEvent(RedisRunner.java:25) at com.cpic.framework.admin.sys.runner.RedisRunner.onApplicationEvent(RedisRunner.java:14) at com.cpic.framework.admin.sys.runner.RedisRunner$$EnhancerBySpringCGLIB$$69fbe8f0.onApplicationEvent() at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) at org.springframework.boot.context.event.EventPublishingRunListener.running(EventPublishingRunListener.java:103) at org.springframework.boot.SpringApplicationRunListeners.running(SpringApplicationRunListeners.java:77) at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) at com.cpic.framework.admin.sys.AdminApplication.main(AdminApplication.java:22) ```

Input Code

Input Code ```java public void put(String name, byte[] key, byte[] value, @Nullable Duration ttl, Boolean flag) { Assert.notNull(name, NAME_NOT_NULL); Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); execute(name, connection -> { connection.set(key, value); return "OK"; }); } ```

Expected behavior/code

Environment

Possible Solution

Additional context

mp911de commented 4 years ago

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem.

Please note that we're not able to understand Chinese.

zuoqi1993125 commented 4 years ago

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem.

Please note that we're not able to understand Chinese.

Sorry for wasting your time, I found the cause of the problem was the object loop dependency causing the serialization oom(using jackson)