JDK-6869472 : FileChannel.tryLock leaves FileLock on lockList if I/O error occurs
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 5.0u17
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2009-08-07
  • Updated: 2011-02-16
  • Resolved: 2009-08-07
Related Reports
Duplicate :  
Description
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.

Comments
EVALUATION This is a duplicate of 6620010 which is fixed in jdk7 by way of 4313887. I've created a sub-CR on 6620010 for the escalation.
07-08-2009