在预定任务中发生了意外错误,没有任何从属项同步 – Java/Spring/Redis。

huangapple go评论79阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年3月7日 14:17:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75658579.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定