Fix a issue where adding entries below a parent entry and modifying the parent entry causes lock expirations. All writer threads for the modify
operations were being starved by the reader threads for the add operations. Changed the LockManager to observe fairness rules when granting
locks so waiting write locks are granted before read locks.
Fix for issue 1896
| | |
| | | // and either return it or return null. |
| | | readLock.unlock(); |
| | | readLock = existingLock.readLock(); |
| | | if (readLock.tryLock()) |
| | | |
| | | try |
| | | { |
| | | return readLock; |
| | | if (readLock.tryLock(0, TimeUnit.SECONDS)) |
| | | { |
| | | return readLock; |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | else |
| | | catch(InterruptedException ie) |
| | | { |
| | | // This should never happen. Just return null |
| | | return null; |
| | | } |
| | | } |
| | |
| | | // and either return it or return null. |
| | | writeLock.unlock(); |
| | | writeLock = existingLock.writeLock(); |
| | | if (writeLock.tryLock()) |
| | | try |
| | | { |
| | | return writeLock; |
| | | if (writeLock.tryLock(0, TimeUnit.SECONDS)) |
| | | { |
| | | return writeLock; |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | else |
| | | catch(InterruptedException ie) |
| | | { |
| | | // This should never happen. Just return null |
| | | return null; |
| | | } |
| | | } |