Bug 59852 - Two DeltaProcessors running at once
Summary: Two DeltaProcessors running at once
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-23 17:41 EDT by John Arthorne CLA
Modified: 2004-04-26 12:30 EDT (History)
2 users (show)

See Also:


Attachments
Stack traces (22.85 KB, text/plain)
2004-04-23 17:43 EDT, John Arthorne CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2004-04-23 17:41:59 EDT
I20040422

I got into a state where Eclipse appeared to be hung. On further analysis, it
was essentially this deadlock:

- Thread Worker-1 is doing a resource change notification, so it owns the core
workspace lock. It is trying to load classes in JDT core.
- Thread Worker-0 is loading a class in JDT core. This calls JDTCore.startup(),
which is trying to do a IWorkspace.run

This is not actually a deadlock, because the Eclipse class loaders detect this
by "timing out" after waiting for another thread to start for more than 5
seconds. However, this time out multiplied by the number of class loads can be
quite large, and the result is that Eclipse is hung for several minutes.  I will
attach the stack traces
Comment 1 John Arthorne CLA 2004-04-23 17:43:15 EDT
Created attachment 9918 [details]
Stack traces
Comment 2 John Arthorne CLA 2004-04-23 17:46:54 EDT
Another interesting thing we observed here is that the exact same resource
change listener instance is currently processing deltas in both threads. This
should be avoided because it leads to this precise race condition (and probably
other race conditions). While there is no technical problem with doing this from
a core perspective, I think we should fix this in core because it is not
something that resource change listener implementors will expect.
Comment 3 John Arthorne CLA 2004-04-23 17:54:26 EDT
Even after fixing this listener problem in core, it is still risky to be doing
workspace.run from within JavaCore.startup(). If another thread that owns the
workspace lock tries to load classes in JDT core, this same problem will occur.
Jerome, is this something that has always been possible, or was it just
introduced during the fix to bug 38658? Since this involves resolving
classpaths, it also has the side-effect of loading classpath container providers
such as PDE during startup.
Comment 4 Jerome Lanneluc CLA 2004-04-26 05:11:58 EDT
Yes this is new behavior introduced during the fix to bug 38658. To avoid this 
we would need some post-startup hook from Platform Core to process the saved 
state delta.
Comment 5 Jerome Lanneluc CLA 2004-04-26 09:03:58 EDT
I will try to process the delta in the indexer thread instead.
Comment 6 Jerome Lanneluc CLA 2004-04-26 09:50:30 EDT
Entered bug 59937 against JDT Core.
Comment 7 John Arthorne CLA 2004-04-26 12:30:18 EDT
Released a fix in core.resources to prevent the possibility of resource change
notifications happening concurrently (one save participant and one POST_CHANGE
event).