Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
2 Major
-
Resolution: Fixed
-
Affects Version/s: 2.6.0
-
Fix Version/s: 2.6.2
-
Component/s: DSO:L1
-
Labels:None
-
Severity:2 Feature failure (but system usable), no workaround available
-
Fix In Branch:trunk, 2.6
-
Fixed In Revision:8706, 8713 (trunk) and 8726 (2.6 branch)
-
Bug Type:Race Condition
-
Bug Found In Detail:2.6.0
Description
From forum thread http://forums.terracotta.org/forums/posts/list/1107.page
synchronization in StandardDSOClientConfigHelperImpl.getInstrumentationDescriptorFor() method can lead to deadlocks, because the call to InstrumentationDescriptor.matches(..) within the synchronized block triggers many more method calls which can contend for locks. In the case of this forum post, the other lock belonged to a ClassLoader instance that was already held by another thread, which was trying to acquire the lock for the LinkedList of InstrumentationDescriptors.
It would be nice to go to a copy-on-write data structure to hold those InstrumentationDescriptors, so synchronization wasn't necessary on the read operations. If nothing else, you could always copy-on-read within the synchronized block, then iterate and check after relinquishing the lock. Tim points out that there may be additional more complicated synchronization and atomicity requirements around the addIncludeAndLockIfRequired() method (but we could use a different lock there).
Assigning to Scott as he has been hashing through some options with Tim.