Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340003 - Refactoring dialog hung at AbstractIndexManager.waitForConsistent
Summary: Refactoring dialog hung at AbstractIndexManager.waitForConsistent
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.sse (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.2.4   Edit
Assignee: Ian Tewksbury CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
: 340676 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-03-15 07:53 EDT by Robert Munteanu CLA
Modified: 2011-04-01 11:07 EDT (History)
5 users (show)

See Also:
nsand.dev: review+


Attachments
Thread dump (34.02 KB, text/plain)
2011-03-15 07:54 EDT, Robert Munteanu CLA
no flags Details
.preservedResourceEvents from the workspace (31.70 KB, application/octet-stream)
2011-03-15 11:06 EDT, Robert Munteanu CLA
no flags Details
Thread dump after pressing cancel in the 'Rename Method' dialog (36.79 KB, text/plain)
2011-03-15 11:16 EDT, Robert Munteanu CLA
no flags Details
Thread dump after pressing cancel in the progress dialog button in the bottom bar (31.09 KB, text/plain)
2011-03-15 11:17 EDT, Robert Munteanu CLA
no flags Details
Fix Patch (15.49 KB, patch)
2011-03-18 14:47 EDT, Ian Tewksbury CLA
no flags Details | Diff
Fix Patch - Update 1 (17.85 KB, patch)
2011-03-18 16:01 EDT, Ian Tewksbury CLA
nsand.dev: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Munteanu CLA 2011-03-15 07:53:48 EDT
Build Identifier: M20110210-1200

When performing a refactoring in a project with JSP files the dialog hangs with a stack trace which ends at

org.eclipse.wst.sse.core.indexing.AbstractIndexManager.waitForConsistent(AbstractIndexManager.java:376)

Possibly related is an error which is logged:

!ENTRY org.eclipse.core.jobs 4 2 2011-03-15 13:42:06.992
!MESSAGE An internal error occurred during: "Processing JSP changes since last activation".
!STACK 0
java.lang.IllegalArgumentException: Path must include project and resource name: /
        at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63)
        at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:1801)
        at org.eclipse.core.internal.resources.Container.getFile(Container.java:207)
        at org.eclipse.wst.sse.core.indexing.AbstractIndexManager$ResourceEventProcessingJob.loadPreservedReceivedResourceEvents(AbstractIndexManager.java:1549)
        at org.eclipse.wst.sse.core.indexing.AbstractIndexManager$ResourceEventProcessingJob.start(AbstractIndexManager.java:1138)
        at org.eclipse.wst.sse.core.indexing.AbstractIndexManager.start(AbstractIndexManager.java:237)
        at org.eclipse.jst.jsp.core.internal.JSPCorePlugin$1.run(JSPCorePlugin.java:179)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1957)
        at org.eclipse.jst.jsp.core.internal.JSPCorePlugin$PluginInitializerJob.run(JSPCorePlugin.java:151)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


Reproducible: Sometimes

Steps to Reproduce:
1. Work on project with JSPs
2. Perform Java refactoring

Please note that only Java files are affected, i.e. no JSP/taglib etc changes.
Comment 1 Robert Munteanu CLA 2011-03-15 07:54:32 EDT
Created attachment 191203 [details]
Thread dump
Comment 2 Robert Munteanu CLA 2011-03-15 07:55:19 EDT
Additionally, canceling the dialog does not cancel the refactoring.
Comment 3 Ian Tewksbury CLA 2011-03-15 10:16:22 EDT
The problem is something either went wrong with preserving resource change events that happened just before a workspace shut down, or there is a problem reading back these preserved resource change events.  In  either case when the read back happens what ever path its reading is not valid and is causing the logged error which then causes start up to fail and leave the indexer in the "starting' state, then any task, such as refactoring, that waits on the starting to be finished is infinitely blocked.

I am very surprised the cancel button did not work because the waitForConsistent rigorously checks the cancel state of the given progress monitor.

Robert, Do you now hit this every time you open the affected workspace? If so I will have some further instructions/questions to work you around this issue and to help solve it on our end.
Comment 4 Robert Munteanu CLA 2011-03-15 10:39:14 EDT
(In reply to comment #3)
 
> Robert, Do you now hit this every time you open the affected workspace? If so I
> will have some further instructions/questions to work you around this issue and
> to help solve it on our end.

Yes, I hit this every time after the logged error, which also manifests itself as an error dialog. Refactorings started in the brief interval between the Eclipse startup and the error dialog complete successfully.
Comment 5 Ian Tewksbury CLA 2011-03-15 11:00:50 EDT
(In reply to comment #4)
> (In reply to comment #3)
> 
> > Robert, Do you now hit this every time you open the affected workspace? If so I
> > will have some further instructions/questions to work you around this issue and
> > to help solve it on our end.
> 
> Yes, I hit this every time after the logged error, which also manifests itself
> as an error dialog. Refactorings started in the brief interval between the
> Eclipse startup and the error dialog complete successfully.

Robert, could you please grab a Thread dump after you have hit cancel?
Also would it be possible for you to supply us with your workspace?  And if not your workspace some workspace you can reproduce this on?  If not that could you send us the file "YourWorkspace\.metadata\.plugins\org.eclipse.jst.jsp.core\jspsearch\.preservedResourceEvents".  This file only contains the names of files and what happened to them (moved, deleted, added, etc) and is the file that is causing the error.

As far as working around your issue I would suggest the following (if you are going to give us your workspace please do these steps AFTER zipping up your workspace to give to us):
1. delete the ""YourWorkspace\.metadata\.plugins\org.eclipse.jst.jsp.core\jspsearch\" directory
2. open your workspace
3. open the progress view
4. in the progress view use the little down arrow to open the preference and check the box to show sleeping operations
5. wait for the JSP indexing operations to finish before you close your workspace again
6. if your workspace is large this could take some time.

the reason you need to wait for this to finish is that it seems you are hitting some bug with what we do to preserve un-processed events during a workspace shutdown when indexing is not yet finished.
Comment 6 Robert Munteanu CLA 2011-03-15 11:06:09 EDT
Created attachment 191217 [details]
.preservedResourceEvents from the workspace

I am unable to provide a workspace, but I will try to reproduce the problem during this week. The project is medium-sized ( 1000 jsps ) so I will need to find another similar project.
Comment 7 Robert Munteanu CLA 2011-03-15 11:16:14 EDT
Created attachment 191218 [details]
Thread dump after pressing cancel in the 'Rename Method' dialog
Comment 8 Robert Munteanu CLA 2011-03-15 11:17:59 EDT
Created attachment 191219 [details]
Thread dump after pressing cancel in the progress dialog button in the bottom bar

I initially hit this bug when performing the 'inline' rename, which does not bring up a dialog, but performs the refactoring straight away, with a progress indicator and cancel button in the status bar at the bottom.

Just in case it makes a difference, I attach this thread dump as well.
Comment 9 Ian Tewksbury CLA 2011-03-15 11:19:50 EDT
(In reply to comment #8)
> Created attachment 191219 [details]
> Thread dump after pressing cancel in the progress dialog button in the bottom
> bar
> 
> I initially hit this bug when performing the 'inline' rename, which does not
> bring up a dialog, but performs the refactoring straight away, with a progress
> indicator and cancel button in the status bar at the bottom.
> 
> Just in case it makes a difference, I attach this thread dump as well.

Thank you much for all of the extra info, it will definitely help track down the issues.
Comment 10 Robert Munteanu CLA 2011-03-15 11:33:49 EDT
Removing that file did the trick, so I can safely refactor again. Thanks.
Comment 11 Ian Tewksbury CLA 2011-03-15 13:09:30 EDT
(In reply to comment #10)
> Removing that file did the trick, so I can safely refactor again. Thanks.

If you didn't already I would suggest removing the entire folder.  Otherwise the index maybe out of sync and missing some resources causing your re-factor and search actions to return incomplete results.
Comment 12 Robert Munteanu CLA 2011-03-15 16:39:19 EDT
OK, thanks.
Comment 13 Ian Tewksbury CLA 2011-03-18 14:47:39 EDT
Created attachment 191540 [details]
Fix Patch

This patch fixes the following issues:
* cancel not working because the wrong progress monitor was being passed to the index manager

* a fail at startup should be dealt with more gracefully

* if there is an exception while loading the '.preservedResourceEvents' file it should be caught, logged, and then handled, which means the workspace will need to be re-indexed

-----

I can not figure out why this particular '.preservedResourceEvents' file got corrupted without some repeatable steps but at the very lease this patch will protect against such faults in the future and allow the index manager to recover gracefully.
Comment 14 Ian Tewksbury CLA 2011-03-18 14:48:06 EDT
Note this patch also address bug 339711.
Comment 15 Ian Tewksbury CLA 2011-03-18 16:01:08 EDT
Created attachment 191551 [details]
Fix Patch - Update 1

Makes it so that BasicSearchQuery#doQuery is depreciated and calls a new doQuery(IProgressMonitor) so as not to break other people who are using this internal class.
Comment 16 Nick Sandonato CLA 2011-03-18 16:46:29 EDT
Changes checked in. Thanks, Ian.
Comment 17 Nick Sandonato CLA 2011-03-18 16:48:26 EDT
As we discussed, the doQuery() was fixed so that it was still called for those who may have subclassed BasicSearchQuery.
Comment 18 Nick Sandonato CLA 2011-03-22 12:19:33 EDT
*** Bug 340676 has been marked as a duplicate of this bug. ***