英文:
Unexpected error occurred in scheduled task, None of slaves were synced - Java/Spring/Redis
问题
Applying locks on Kafka events using Redis so that the same Kafka event will not be processed by multiple pods.
java.lang.IllegalStateException: None of slaves were synced at
org.redisson.RedissonBaseLock.lambda$evalWriteAsync$0(RedissonBaseLock.java:225)
at java.util.concurrent.CompletableFuture.uniHandle(Unknown Source)
at java.util.concurrent.CompletableFuture$UniHandle.tryFire(Unknown Source) at
java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
at java.util.concurrent.CompletableFuture.complete(Unknown Source)
at org.redisson.command.CommandBatchService.lambda$executeAsync$7(CommandBatchService.java:322)
at java.util.concurrent.CompletableFuture.uniWhenComplete(Unknown Source) at
java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(Unknown Source) at
java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
at java.util.concurrent.CompletableFuture.complete(Unknown Source)
at org.redisson.command.RedisCommonBatchExecutor.handleResult(RedisCommonBatchExecutor.java:163)
at org.redisson.command.RedisExecutor.checkAttemptPromise(RedisExecutor.java:524)
at org.redisson.command.RedisExecutor.lambda$execute$4(RedisExecutor.java:176)
at java.util.concurrent.CompletableFuture.uniWhenComplete(Unknown Source) at
java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(Unknown Source) at
java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
at java.util.concurrent.CompletableFuture.complete(Unknown Source)
at org.redisson.client.handler.CommandDecoder.decodeCommandBatch(CommandDecoder.java:318)
at org.redisson.client.handler.CommandDecoder.decodeCommand(CommandDecoder.java:210)
at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:137)
at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:113)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:510)
at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:366)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279)
at io.netty.channel.Abstract...
英文:
Applying locks on kafka events using redis so that same kafka event will not process by multiple pods.
> java.lang.IllegalStateException: None of slaves were synced at
> org.redisson.RedissonBaseLock.lambda$evalWriteAsync$0(RedissonBaseLock.java:225)
> at java.util.concurrent.CompletableFuture.uniHandle(Unknown Source)
> at java.util.concurrent.CompletableFuture$UniHandle.tryFire(Unknown
> Source) at
> java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
> at java.util.concurrent.CompletableFuture.complete(Unknown Source)
> at
> org.redisson.command.CommandBatchService.lambda$executeAsync$7(CommandBatchService.java:322)
> at java.util.concurrent.CompletableFuture.uniWhenComplete(Unknown
> Source) at
> java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(Unknown
> Source) at
> java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
> at java.util.concurrent.CompletableFuture.complete(Unknown Source)
> at
> org.redisson.command.RedisCommonBatchExecutor.handleResult(RedisCommonBatchExecutor.java:163)
> at
> org.redisson.command.RedisExecutor.checkAttemptPromise(RedisExecutor.java:524)
> at
> org.redisson.command.RedisExecutor.lambda$execute$4(RedisExecutor.java:176)
> at java.util.concurrent.CompletableFuture.uniWhenComplete(Unknown
> Source) at
> java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(Unknown
> Source) at
> java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
> at java.util.concurrent.CompletableFuture.complete(Unknown Source)
> at
> org.redisson.client.handler.CommandDecoder.decodeCommandBatch(CommandDecoder.java:318)
> at
> org.redisson.client.handler.CommandDecoder.decodeCommand(CommandDecoder.java:210)
> at
> org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:137)
> at
> org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:113)
> at
> io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:510)
> at
> io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:366)
> at
> io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279)
> at io.netty.channel.Abstract...
答案1
得分: 1
我猜你的方法是错误的。你不需要Redis或其他带锁的工具。通过正确设置Kafka消费者组,消息不会被不同的Pod获取。
英文:
I guess your approach is wrong. You don't need Redis or other tools with locks for that. With proper setup of kafka consumer groups message won't be picked up by different pod
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论