dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

AbstractRegistry lock problem

Open dudi123456 opened this issue 12 years ago • 15 comments

环境:

  • suse linux
  • dubbo 2.5.3

dubbo启动时会报:

2014-08-29 19:13:52,325 WARN  com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doSaveProperties:221 -  [DUBBO] Failed to save registry store file, cause: Can not lock the registry cache file /uniiof/tstusers/tstweg02/.dubbo/dubbo-registry-133.0.192.193.cache, ignore and retry later, maybe multi java process use the file, please config: dubbo.registry.file=xxx.properties, dubbo version: 2.5.3, current host: 127.0.0.1
java.io.IOException: Can not lock the registry cache file /uniiof/tstusers/tstweg02/.dubbo/dubbo-registry-133.0.192.193.cache, ignore and retry later, maybe multi java process use the file, please config: dubbo.registry.file=xxx.properties
    at com.alibaba.dubbo.registry.support.AbstractRegistry.doSaveProperties(AbstractRegistry.java:193)
    at com.alibaba.dubbo.registry.support.AbstractRegistry$SaveProperties.run(AbstractRegistry.java:150)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)

从异常看,是多个线程都要写信息,导致不能获取锁,同时也不尝试再次获取

dudi123456 avatar Aug 29 '14 11:08 dudi123456

我也遇到了这个问题,请问你解决了么?

justein avatar Apr 13 '16 02:04 justein

这个只是个warn,但是我们项目中有时候也会碰到这个问题,但是之后再启动,就不会有这个问题,如果可以解决当然是最好了 @dudi123456 @justein

FangOba avatar Apr 13 '16 02:04 FangOba

@dudi123456 @Xiaobaxi 解决了,出现这个的原因是服务向ZK注册的同时,会缓存Consumer的列表,写入user.home/.dubbo/dubbo-registry-" + url.getHost() + ".cache 这个文件,当在同一个机器上启动多个Provider的时候,就会出现文件锁争用的问题,报上面这个错误。解决办法:服务模块各自缓存自己的cache文件,在<dubbo:registry />中加入 file="dubboregistry/dubbo-registry.properties" ,这样就会在bin目录下生成dubboregistry这个目录,cache文件就缓存在这个里边了。

justein avatar Apr 15 '16 02:04 justein

@justein
您好,我也遇到这个的问题,有幸能看到你提供的解决方案,不过有一个地方不太明白: 服务模块各自缓存自己的cache文件,在中加入 file="dubboregistry/dubbo-registry.properties" 不太明白这个配置应该加入在哪里? 期待您的解答,谢谢了。

501956430 avatar Jul 29 '16 06:07 501956430

@501956430 加在你的provider的xml配置里,<dubbo:registry protocol="zookeeper" address="IP:2181" timeout="2000" file="dubboregistry/dubbo-registry.properties"/>

justein avatar Jul 29 '16 08:07 justein

之前在开源中国看到一篇文章,也是很多关于dubbo实际使用的问题和解决方案 《DUBBO 使用问题记录》

changwei0708 avatar Aug 26 '16 11:08 changwei0708

备注一下。

zouchunhui avatar Feb 22 '17 05:02 zouchunhui

备注一下

moxingwang avatar Mar 10 '17 07:03 moxingwang

备注一下,多谢指导。

wlccomeon avatar Aug 17 '17 02:08 wlccomeon

备注一下

lizhixin1992 avatar Nov 15 '17 07:11 lizhixin1992

mark

maczhao avatar Dec 27 '17 03:12 maczhao

consumer 中的.cache文件内容存的是什么啊,如果是生产者信息的话,为什么我三台主机,部署一个zookeeper集群,一个dubbo集群,一个消费者集群,结果每个消费者的.cache文件中只是记录了本机提供的服务啊。

Julvae avatar Jun 10 '18 12:06 Julvae

可以,完美解决

lawliethaoge avatar Sep 19 '18 10:09 lawliethaoge

2018-10-15 22:55:24,780 WARN [DubboSaveRegistryCache-thread-1] c.a.d.c.u.DubboLogger - [DUBBO] Failed to save registry store file, cause: null, dubbo version: 3.2.0, current host: xxx java.nio.channels.OverlappingFileLockException: null at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255) at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152) at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1108) at java.nio.channels.FileChannel.tryLock(FileChannel.java:1155) at com.alibaba.dubbo.registry.support.AbstractRegistry.doSaveProperties(AbstractRegistry.java:187) at com.alibaba.dubbo.registry.support.AbstractRegistry$SaveProperties.run(AbstractRegistry.java:146) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

这个也是由于多进程导致嘛?

yekui avatar Oct 22 '18 07:10 yekui

2018-10-15 22:55:24,780 WARN [DubboSaveRegistryCache-thread-1] c.a.d.c.u.DubboLogger - [DUBBO] Failed to save registry store file, cause: null, dubbo version: 3.2.0, current host: xxx java.nio.channels.OverlappingFileLockException: null at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255) at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152) at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1108) at java.nio.channels.FileChannel.tryLock(FileChannel.java:1155) at com.alibaba.dubbo.registry.support.AbstractRegistry.doSaveProperties(AbstractRegistry.java:187) at com.alibaba.dubbo.registry.support.AbstractRegistry$SaveProperties.run(AbstractRegistry.java:146) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

这个应该不是多进程并发导致的吧

yekui avatar Oct 22 '18 07:10 yekui