Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6869472

FileChannel.tryLock leaves FileLock on lockList if I/O error occurs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 5.0u17
    • core-libs
    • None
    • sparc
    • solaris_10

      There is a problem with >2 application servers trying to lock a file on a clustered file system at the same time.

      A test case (attached) was delivered and 2 copies were executed concurrently. truss output was gathered.

      From the truss1.txt
      4095, 29259/1: 14.4381 open64("xxx", O_RDWR|O_CREAT, 0666) = 5
      4106, 29259/1: 14.4428 fcntl(5, F_SETLK64, 0xFFBFEBC8) Err#13 EACCES
      This shows the code trying to lock a file, which has already been locked by another process. The fcntl call returns an EACCES, instead of EAGAIN, which is normally expected. This results in an IOException to the JVM.

      A subsequent call of tryLock, results in an OverlappingFileLockException, even though the previous lock has not succeeded.
      4493, 29259/1: 24.4575 write(2, 0xFFBFC5E0, 46) = 46
      29259/1: j a v a . n i o . c h a n n e l s . O v e r l a p p i n g F i l
      29259/1: e L o c k E x c e p t i o n

      The modified test case with lock method instead of tryLock, works as expected.

            dsamersoff Dmitriy Samersoff
            fchoong Fui-Shien Choong (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: