DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCCORE-774
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Andy Jefferson
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Core

L2 cache locking strategy can lead to deadlock

Created: 27/Oct/11 12:54 PM   Updated: 07/Nov/11 02:57 PM   Resolved: 28/Oct/11 11:11 AM
Component/s: Cache
Affects Version/s: 2.0.5, 2.1.4, 2.2.4, 3.0.0.release, 3.0.1, 3.0.2
Fix Version/s: 3.0.3

 Description  « Hide
We currently have a mixed strategy for locking the L2 cache. Whenever an object is accessed we lock the cache, and similarly when we are doing the update in txn.commit. Similarly when updating the CachedPC object in JDOStateManagerImpl we lock the PC object that is part of the CachedPC. If we have bidirectional relations this could easily lead to

Thread 1 : locks A and waits for B
Thread 2 : locks B and waits for A

The locking strategy needs rewriting, and locking the L2 cache itself as little as possible. Likely the best way would be to just lock the CachedPC when accessing some info, though even this would not prevent reads from fields of the contained "pc" while something else was updating it.

Andy Jefferson added a comment - 28/Oct/11 11:11 AM
SVN trunk attempts to fix this issue by splitting the "get values from cache" process into two parts; nonrelation fields first and lock the cached PC object while accessing it, then relation fields and don't lock anything (since the keys of the related objects are stored in a Map).

Andy Jefferson made changes - 28/Oct/11 11:11 AM
Field Original Value New Value
Status Open [ 1 ] Resolved [ 5 ]
Assignee Andy Jefferson [ andy ]
Fix Version/s 3.0.3 [ 11345 ]
Resolution Fixed [ 1 ]
Andy Jefferson added a comment - 30/Oct/11 03:42 PM
SVN trunk now represents phase 4 of L2 cache. This implementation stores a Map of the field values (keyed by abs field number). When an object is put in the L2 cache a CachedPC is created from the ObjectProvider of that object, dumping in its fields, and then an ObjectProvider can be created using the map of field values from the CachedPC when getting it out.

Andy Jefferson made changes - 07/Nov/11 02:57 PM
Status Resolved [ 5 ] Closed [ 6 ]