6 Replies Latest reply on Mar 19, 2009 9:38 AM by manik

    Locking order when lockParentForChildInsertRemove == true

      As I mentioned in comments to JBCACHE-1449, I have a test that started deadlocking in 3.x but worked fine in 2.x. It turned out that was a classic deadlock situation, of the kind taught in schools ;)

      Normally, when an operation needs to lock a node, it does so progressively from root to the child. When done consistently, this ordering prevents deadlocks on concurrent modifications. The problem with that test was that the lockParentForChildInsertRemove flag was set to true and it reversed the order of locking when adding child because the decision to lock parent was made after the child had been locked. This leads to an easy deadlock with concurrent modifications.

      Is it possible to do the locking in parent->child order when adding or removing child?