redisson Unexpected exception while processing command Only 1 of 2 slaves were synced

这篇具有很好参考价值的文章主要介绍了redisson Unexpected exception while processing command Only 1 of 2 slaves were synced。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

目录

背景:

现象:

问题定位:

问题原因:

解决:


背景:

生产环境一个活动给某个用户发送积分失败,核心业务接口使用Redisson分布式锁
同事答复:redis主从切换导致的问题。

个人表示怀疑,所以想定位下真实原因。

redisson 3.17.3
sentinel模式:master slave1 slave2

     <dependency>
                <groupId>org.redisson</groupId>
                <artifactId>redisson-spring-boot-starter</artifactId>
                <version>3.17.3</version>
     </dependency>

    RLock  rLock = redisson.getLock("xxxxxx");
    rLock.lock(15, TimeUnit.SECONDS);

现象:

rLock.lock(15, TimeUnit.SECONDS);

没走到下边的业务代码就报错

16:52:58.382 2023-11-14 16:52:57 [http-nio-8080-exec-142] ERROR c.c.p.configure.aspect.ApiAspect 60 - Failed to invoke interface [Map cn.xx.xx.api.customer.xx.yyy(String)]
16:52:58.382 org.redisson.client.RedisException: Unexpected exception while processing command
16:52:58.382  at org.redisson.command.CommandAsyncService.convertException(CommandAsyncService.java:276) ~[redisson-3.17.3.jar!/:3.17.3]
16:52:58.382  at org.redisson.command.CommandAsyncService.get(CommandAsyncService.java:115) ~[redisson-3.17.3.jar!/:3.17.3]
16:52:58.382  at org.redisson.RedissonObject.get(RedissonObject.java:82) ~[redisson-3.17.3.jar!/:3.17.3]
16:52:58.382  at org.redisson.RedissonLock.tryAcquire(RedissonLock.java:144) ~[redisson-3.17.3.jar!/:3.17.3]


16:52:58.486 Caused by: java.lang.IllegalStateException: Only 1 of 2 slaves were synced
16:52:58.486  at org.redisson.RedissonBaseLock.lambda$evalWriteAsync$0(RedissonBaseLock.java:226) ~[redisson-3.17.3.jar!/:3.17.3]
16:52:58.486  at java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:822) ~[na:1.8.0_201]
16:52:58.486  at java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:797) ~[na:1.8.0_201]
16:52:58.487  at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474) ~[na:1.8.0_201]
16:52:58.487  at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1962) ~[na:1.8.0_201]
16:52:58.487  at org.redisson.command.CommandBatchService.lambda$executeAsync$7(CommandBatchService.java:322) ~[redisson-3.17.3.jar!/:3.17.3]
16:52:58.487  at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760) ~[na:1.8.0_201]

关键错误日志

c.c.p.configure.aspect.ApiAspect 60 - Failed to invoke interface [Map cn.xx.xx.api.customer.xx.yyy(String)]

org.redisson.client.RedisException: Unexpected exception while processing command

16:52:58.486 Caused by: java.lang.IllegalStateException: Only 1 of 2 slaves were synced

问题定位:

找运维同学,看监控,没看到异常,反馈其他应用没问题。从自己代码定位问题。

带着问题看源码
org.redisson.command.CommandBatchService#executeAsync

org.redisson.client.redisexception: unexpected exception while processing co,java,redis,分布式


org.redisson.RedissonBaseLock#createCommandBatchService

org.redisson.client.redisexception: unexpected exception while processing co,java,redis,分布式

org.redisson.client.redisexception: unexpected exception while processing co,java,redis,分布式

问题原因:

分布式锁,默认值是等1秒全部slave 同步成功master再继续,如果slave没全部成功就报错(本例中一台slave成功一台没在1s内成功)。

经过和运维确认,那个时间点redis在进行数据持久化,持久化策略RDB,运维侧看,不能避免1秒内全部完成所有节点。

org.redisson.client.redisexception: unexpected exception while processing co,java,redis,分布式

解决:


升级客户端版本,3.21以上,据说3.21.* 以上,只要一个slave成功即可(懒得贴代码了)。
 

if (getServiceManager().getCfg().isCheckLockSyncedSlaves()&& res.getSyncedSlaves() == 0 && availableSlaves > 0) {
    throw new CompletionException(
            new IllegalStateException("None of slaves were synced"));
}


 文章来源地址https://www.toymoban.com/news/detail-766714.html

到了这里,关于redisson Unexpected exception while processing command Only 1 of 2 slaves were synced的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Appium如何解决报错:An unknown server-side error occurred while processing the command. Original error: Er

    使用appium客户端连接小米手机失败,完整报错信息如下: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘{已隐藏}/Library/Android/sdk/platform-tools/adb -P 5037 -s fca2117a shell settings delete global hidden_api_policy_pre_p_apps’ exited with c

    2024年04月15日
    浏览(53)
  • 记一次 Redisson 线上问题 → ERR unknown command 'WAIT' 的排查与分析

    昨晚和一个朋友聊天 我:处对象吗,咱俩试试? 朋友:我有对象 我:我不信,有对象不公开? 朋友:不好公开,我当的小三 程序在生产环境稳定的跑着 直到有一天,公司执行组件漏洞扫描,有漏洞的  jar  要进行升级修复 然后我就按着扫描报告将有漏洞的  jar  修复到指

    2024年02月09日
    浏览(43)
  • Docker Desktop-Unexpected WSL error An unexpected error was encountered while executing a WSL comman

    windows安装docker报错: Docker Desktop - Unexpected WSL error An unexpected error was encountered while executing a WSL command. Common causes include access rights issues, which occur after waking the computer or not being connected to your domain/active directory. Please try shutting WSL down (wl --shutdown) and/or rebooting your computer. If not suff

    2024年03月10日
    浏览(56)
  • 已解决:Unexpected exception during bean creation; nested exception is java.lang.IllegalStateException:

    这个异常通常是由于在使用 Spring Cloud Feign 客户端进行负载均衡时缺少相关的依赖引起的。具体来说,它提示你忘记在项目的依赖中包含  spring-cloud-starter-loadbalancer 。 spring-cloud-starter-loadbalancer  是用于支持负载均衡功能的 Spring Cloud Starter 组件之一。它提供了负责将请求分发

    2024年02月08日
    浏览(31)
  • 【问题解决】电脑突然/总蓝屏,终止代码显示:UNEXPECTED_STORE_EXCEPTION

    如果觉得文章有帮助到你, Thanks♪(・ω・)ノ 请 一键 三 连 吧!点赞收藏加关注!(文章末尾) 【注意】请读者在阅读文章的时候多多利用浏览器的页面搜索功能:Ctrl+F唤出搜索框(esc键退出搜索功能)。如此可以快速搜索到你想要的文章重点内容。 “你的设备遇到问题,需

    2024年02月04日
    浏览(124)
  • ERROR: Error processing tar file(exit status 1): unexpected EOF

    问题 :在本地加载镜像的时候,输入\\\"sudo docker load -i rknn-toolkit2-1.2.0-cp36-docker.tar.gz\\\" 报错\\\"ERROR: Error processing tar file(exit status 1): unexpected EOF\\\" 解决办法 : 强烈推荐这篇文章的解决办法,这个博主写的很好的一篇文章,简单直接的解决问题。(侵权删) Docker使用的一些烂问题

    2024年02月13日
    浏览(48)
  • Git clone fetch-pack unexpected disconnect while reading sideband packet

    在执行 git clone 命令遇到以下错误: 参考 Github - unexpected disconnect while reading sideband packet,对于 CMD,执行 对于 Linux,执行 对于 PowerShell,执行 然后执行 注意:这里的仓库 URI 必须为 HTTP(https://github.com/),不能为 SSH(git@github.com:)。

    2024年02月11日
    浏览(32)
  • docker load -i导入镜像失败:Error processing tar file(exit status 1): unexpected EOF

    导入镜像失败了,不知道啥原因。。。 后来发现,我的tar包大小不对,只有50多兆,正常应该400多兆的,可能是什么时候拷文件时,拷失败了。。。 把正确的tar包换过来就好了 20230816 Docker 是一种开源的应用容器引擎,允许开发者将应用及其依赖打包到一个可移植的容器中,

    2024年02月06日
    浏览(40)
  • Elasticsearch8.6启动异常:fatal exception while booting Elasticsearch

    fatal exception while booting Elasticsearch java.nio.file.InvalidPathException: Trailing char at index 48: C:Program FilesJavajdk1.8.0_181libtools.jar at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:191) ~[?:?] at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153) ~[?:?] at sun.nio.fs.WindowsPathParser.parse(WindowsPathParse

    2024年02月04日
    浏览(30)
  • 解决报错SyntaxError:Unexpected end of JSON input

    跳转页面传递参数 报错提示 SyntaxError:Unexpected end of JSON input 原因:若对象的参数或数组的元素中遇到地址中包括? - _ . ! ~ * \\\' ( )等特殊符号时,对象/数组先要通过JSON.stringify转化为字符串再通过 encodeURIComponent 编码,接收时,先通过 decodeURIComponent 解码再通过JSON.parse转换为

    2024年02月11日
    浏览(45)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包