Bug 217111 - Deadlocks updating dependencies while POM is open in editor
Deadlocks updating dependencies while POM is open in editor
Product: projects
Classification: Unclassified
Component: Maven
PC Linux
: P3 (vote)
: 7.3
Assigned To: Milos Kleint
: 216978 (view as bug list)
Depends on:
  Show dependency treegraph
Reported: 2012-08-20 15:23 UTC by Jesse Glick
Modified: 2012-08-23 16:06 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT

Tried to remove a dep (21.60 KB, text/plain)
2012-08-20 15:23 UTC, Jesse Glick
A couple minutes before, when adding a dep (23.92 KB, text/plain)
2012-08-20 15:24 UTC, Jesse Glick

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2012-08-20 15:23:20 UTC
Created attachment 123316 [details]
Tried to remove a dep

47bac66aa192. Seems if I have a POM open in the editor, making additions or removals in the Dependencies node is more likely than not to result in a deadlock.
Comment 1 Jesse Glick 2012-08-20 15:24:19 UTC
Created attachment 123317 [details]
A couple minutes before, when adding a dep
Comment 2 Milos Kleint 2012-08-22 12:08:08 UTC
I believe the fix http://hg.netbeans.org/main/rev/3dfb067533e2 it completely flawed.
At least according to the xam/xdm documentation isInTransaction() means that some other thread holds the lock and is in transaction. But that has no relationship to the current thread whatsoever. The lock only applies to the thread that started the transaction. The transaction could be ended right after this check. or in the middle of it.. but we still query the model from the other thread.

I suggest we remove these checks and just acquire the transaction, or not even bother since transactions are supposedly to be started only for mutations, which we don't do in the StatusProvider. 

also please note that model.synch() which is called by StatusProvider.checkModelValid() will in it's body start a blocking transaction.

to solve this problem I suggest 2 solutions (should be aplied together, not mutually exclusive):
1. Utilities.performPOMModelOperations() will wrap the xam transaction in ((BaseDocument)model.getBaseDocument()).runAtomicAsUser(Runnable) to have the document locked first.
2. in status provider, remove all the transaction related code and just read the models.
Comment 3 Milos Kleint 2012-08-22 13:56:21 UTC

but I also filed issue 217234 to finally create order in the way threading is done with the xam pom models.
Comment 4 Milos Kleint 2012-08-22 13:56:43 UTC
*** Bug 216978 has been marked as a duplicate of this bug. ***
Comment 5 Quality Engineering 2012-08-23 16:06:10 UTC
Integrated into 'main-golden', will be available in build *201208231248* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/03bf71617ea5
User: Milos Kleint <mkleint@netbeans.org>
Log: #217111 post code to RP thread to avoid document lock in awt

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo