mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

boli
23.33.2008 43337ecac9365309ad8cd593611e619f36fab39f
refs
author boli <boli@localhost>
Wednesday, April 23, 2008 00:33 +0200
committer boli <boli@localhost>
Wednesday, April 23, 2008 00:33 +0200
commit43337ecac9365309ad8cd593611e619f36fab39f
tree dfa930a992ee2cb653b08189156e2d9eefe94618 tree | zip | gz
parent e08afd7823bd5ea3d13982ac8845e3aebeac6bf6 view | diff
Fixed an issue where deadlocks could occur in the LockManager when the server is in heavy add/mod load. An add operation takes a read lock on the parent DN and a write lock on the target DN in that order. However, mod operations first takes an write lock on the target DN then inadvertantly tries takes an read lock on the parent DN through the entryExists method. This could cause a deadlock in the following case with the fair ordering reentrant read write lock:

Thread 1 is performing a modify operation on cn=dep2,cn=dep1,dc=example,dc=com (entry 2)
Thread 2 is performing an add operation on cn=dep2,cn=dep1,dc=example,dc=com
Thread 3 is performing an modify operation on cn=dep1,dc=example,dc=com (entry 1)

Thread 1 takes a write lock on target entry 2
Thread 2 takes a read lock on parent entry 1
Thread 3 tries to acquire write lock on target entry 1
Thread 2 blocks trying to acquire write lock on target entry 2
Thread 1 blocks trying to acquire read lock on parent entry 1

Threads 1, 2, and 3 deadlocks since thread 3's write lock request is before thread 1's read request in the wait queue.

The entryExists method in Backend.java does not need to acquire an read lock on the DN before checking for the entry's existance in the DB, much like the getEntry method. Removing the lock acquisition in entryExists ensures all locks are acquired down the DIT.

The DependencyTest unit-test now passes and is enabled.

Fix for issue 2852
3 files modified
112 ■■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/api/Backend.java 30 ●●●●● diff | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java 80 ●●●●● diff | view | raw | blame | history
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java 2 ●●● diff | view | raw | blame | history