当前位置:   article > 正文

Dubbo Failed to save registry store file, cause: Can not lock the registry cache file_failed to create file store cache. local file cach

failed to create file store cache. local file cache will be disabled.

启动的Dubbo 服务的时候报错,异常信息如下:

  1. 2016-08-22 16:44:40.588 | DubboSaveRegistryCache-thread-1 | WARN | com.alibaba.dubbo.common.logger.log4j.Log4jLogger:Log4jLogger.java(78) | [DUBBO] Failed to save registry store file, cause: Can not lock the registry cache file /root/.dubbo/dubbo-registry-10.141.4.168.cache, ignore and retry later, maybe multi java process use the file, please config: dubbo.registry.file=xxx.properties, dubbo version: 2.8.3, current host: 127.0.0.1
  2. java.io.IOException: Can not lock the registry cache file /root/.dubbo/dubbo-registry-10.141.4.168.cache, ignore and retry later, maybe multi java process use the file, please config: dubbo.registry.file=xxx.properties
  3. at com.alibaba.dubbo.registry.support.AbstractRegistry.doSaveProperties(AbstractRegistry.java:193) ~[dubbo-2.8.3.jar:2.8.3]
  4. at com.alibaba.dubbo.registry.support.AbstractRegistry$SaveProperties.run(AbstractRegistry.java:150) [dubbo-2.8.3.jar:2.8.3]
  5. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_60]
  6. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_60]
  7. at java.lang.Thread.run(Thread.java:745) [na:1.7.0_60]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

报错的大概意思是 Dubbo在保存服务列表时失败,Can not lock the registry cache file /root/.dubbo/dubbo-registry-10.141.4.168.cache,拿不到文件锁,无法保存服务列表。

错误原因

出现这个的原因是服务向ZK注册的同时,会缓存Consumer的列表,写入user.home/.dubbo/dubbo-registry-” + url.getHost() + “.cache 这个文件,当在同一个机器上启动多个Provider的时候,就会出现文件锁争用的问题,报上面这个错误。

解决办法

既然是由于竞争文件锁导致的,那么让服务模块各自缓存自己的cache文件就可以避免这样的问题了。

具体做法是:在provider的xml配置文件中加入 file=”${catalina.home}/dubbo-registry/dubbo-registry.properties” ,如下:

<dubbo:registry id="zkcenter" protocol="zookeeper" address="${dubbo.zk_address}" file="${catalina.home}/dubbo-registry/dubbo-registry.properties"/>
 
 
  • 1
  • 1

这样就会在catalina.home目录下生成dubbo-registry这个目录,cache文件就缓存在这个里边了。

参考资料

AbstractRegistry lock problem:https://github.com/alibaba/dubbo/issues/81

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/165940
推荐阅读
相关标签
  

闽ICP备14008679号