dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

dubbo throws Failed to save registry store file, cause java.nio.channels.OverlappingFileLockException

Open yekui opened this issue 8 years ago • 3 comments

2018-10-22 15:15:54,545 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: 10.1.122.68 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

I have a few questions:

  1. Why is emtpy protocol frequently registered
  2. The empty protocol is generated when the provider does not exist
  3. Why does the empty protocol also write to the cache
  4. Why is there a unified empty agreement and triggered concurrently?

yekui avatar Oct 22 '18 07:10 yekui

can you upload a demo so that we can reproduce the issue.

The demo can directly redisplay the issue.

cvictory avatar Oct 23 '18 08:10 cvictory

@yukui, let me try to answer your questions. Basically you are asking two things:

  1. why OverlappingFileLockException happens
  2. why empty:// URLs appear in the cache

For question one, it looks like there are two or more threads contend for the file lock, for this, you can simple ignore, since eventually all contents will be updated into the cache file. If you are curious about why it happens, you can check here, and javadoc I quote below:

    /**
     * Attempts to acquire an exclusive lock on this channel's file.
     *
     * <p> An invocation of this method of the form <tt>fc.tryLock()</tt>
     * behaves in exactly the same way as the invocation
     *
     * <pre>
     *     fc.{@link #tryLock(long,long,boolean) tryLock}(0L, Long.MAX_VALUE, false) </pre>
     *
     * @return  A lock object representing the newly-acquired lock,
     *          or <tt>null</tt> if the lock could not be acquired
     *          because another program holds an overlapping lock
     *
     * @throws  ClosedChannelException
     *          If this channel is closed
     *
     * @throws  OverlappingFileLockException
     *          If a lock that overlaps the requested region is already held by
     *          this Java virtual machine, or if another thread is already
     *          blocked in this method and is attempting to lock an overlapping
     *          region
     *
     * @throws  IOException
     *          If some other I/O error occurs
     *
     * @see     #lock()
     * @see     #lock(long,long,boolean)
     * @see     #tryLock(long,long,boolean)
     */
    public final FileLock tryLock() throws IOException {
        return tryLock(0L, Long.MAX_VALUE, false);
    }

For question two, most likely the empty:// URLs you see in the cache file are fallen into two categories, which are 'configurator' and 'router'. This is because your Dubbo application doesn't have configuration and routing rule configured on ZooKeeper.

For example:

  • empty://30.5.124.88/org.apache.dubbo.samples.api.GreetingService?application=demo-consumer&category=configurators&default.timeout=3000&dubbo=2.0.2&interface=org.apache.dubbo.samples.api.GreetingService&methods=sayHello&pid=19160&side=consumer&timestamp=1540802240362
  • empty://30.5.124.88/org.apache.dubbo.samples.api.GreetingService?application=demo-consumer&category=routers&default.timeout=3000&dubbo=2.0.2&interface=org.apache.dubbo.samples.api.GreetingService&methods=sayHello&pid=19160&side=consumer&timestamp=1540802240362
  • dubbo://30.5.124.88:20880/org.apache.dubbo.samples.api.GreetingService?anyhost=true&application=demo-provider&dubbo=2.0.2&generic=false&interface=org.apache.dubbo.samples.api.GreetingService&methods=sayHello&pid=18822&side=provider&timestamp=1540802229289
  • empty://30.5.124.88/org.apache.dubbo.samples.api.GreetingService?application=demo-consumer&category=providers,configurators,routers&default.timeout=3000&dubbo=2.0.2&interface=org.apache.dubbo.samples.api.GreetingService&methods=sayHello&pid=19160&side=consumer&timestamp=1540802240362

I hope this answers your questions. If you have further comments/questions on this topic, welcome to discuss with us on [email protected]

beiwei30 avatar Oct 29 '18 09:10 beiwei30