• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • DSO:L1
  • hhuynh
  • Reporter: sbale
  • May 30, 2008
  • 0
  • Watchers: 1
  • July 01, 2008
  • June 02, 2008

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).

Comments

Alex Miller 2008-06-02

Assigning to Scott as he has been hashing through some options with Tim.

Scott Bale 2008-06-02

Switched to using a CopyOnWriteArrayList for “instrumentationDescriptors”. This should prevent the deadlock which the forum user experienced, which happened when trying to read (iterate) this List.

Fiona OShea 2008-06-02

This fix will be available in trunk-nightly builds after revision 8706

Scott Bale 2008-06-03

Added revision 8713 to this JIRA, which was additional correction to synchronization within the same class as was modified in 8706. Merged to 2.6 branch (revision 8726).

Fiona OShea 2008-06-17

I believe someone on the forums is using this successfully with a nightly build.