Hi. I've been having a problem with a service using TransactionalIndexedCollection. About once per day, I end up with the service becoming unresponsive. I've taken thread dumps and there are threads blocked waiting at TransactionalIndexedCollection line 161 in the
incrementVersion method where a new writer waits to acquire a writeLock on the previous version. So, waiting for all readers of the previous version to release their locks.
All of my usages of ResultSet are inside a try with resources block. So users of those ResultSets should be releasing their locks.
I've had a look at the src for TransactionalIndexedCollection and I noticed that on line 380 if an exception occurs calling super.close() then the read lock would never be released and so the writer trying to acquire that lock would block indefinitely.
@Override
public void close() {
super.close();
// Release the read lock for this version when ResultSet.close() is called...
thisVersion.lock.readLock().unlock();
}
Do you think that could possibly be causing my issue?
What do you think about wrapping super.close() in a try/finally?
@Override
public void close() {
try {
super.close();
} finally {
// Release the read lock for this version when ResultSet.close() is called...
thisVersion.lock.readLock().unlock();
}
}
Thank you for your time.
- Clay