Bug 290220 - API tooling keeps lock on files (was: import fails because files cannot be deleted)
Summary: API tooling keeps lock on files (was: import fails because files cannot be de...
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: API Tools (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P1 critical (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks: 292265
  Show dependency tree
 
Reported: 2009-09-23 03:43 EDT by Dani Megert CLA
Modified: 2009-11-17 14:03 EST (History)
2 users (show)

See Also:
Michael_Rennie: review? (darin.eclipse)
daniel_megert: review+


Attachments
Picture of problem dialog (13.50 KB, image/png)
2009-09-23 03:51 EDT, Dani Megert CLA
no flags Details
Fix (12.85 KB, patch)
2009-09-28 09:28 EDT, Dani Megert CLA
no flags Details | Diff
Fix (5.95 KB, patch)
2009-09-28 09:51 EDT, Dani Megert CLA
no flags Details | Diff
proposed fix (15.48 KB, patch)
2009-09-28 11:58 EDT, Michael Rennie CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2009-09-23 03:43:30 EDT
I20090922-0800 (I've also seen it with last weeks I-build but not for the previous few months).


During PDE binary plug-in import (no targets running) I got a dialog (see attached picture) and the log entries below. After that my workspace had tons of errors because those plug-ins were not correctly imported. Sounds familiar? I thought this got fixed (and it looked fixed for quite some time).

Trying to import the plug-ins again in the same session worked.

There are two issues here:
1. PDE should re-try to delete the files (it's a known issue that deletion sometimes fails on WindowsXP) several times before giving up, see e.g. org.eclipse.jdt.testplugin.JavaProjectHelper.delete(IResource) in org.eclipse.jdt.ui.tests.

2. we need to find the code that locks the files. I know that APT changed some algorithms recently. Maybe that's the origin of the problem?


!ENTRY org.eclipse.pde.ui 4 0 2009-09-23 09:31:28.900
!MESSAGE Problems detected while importing plug-ins
!SUBENTRY 1 org.eclipse.core.resources 4 273 2009-09-23 09:31:28.900
!MESSAGE Could not delete 'C:\eclipse\workspaces\Development_HEAD\plugins\com.ibm.icu\com.ibm.icu_4.0.1.v20090822.jar'.
!STACK 1
org.eclipse.core.runtime.CoreException: Problems encountered while deleting files.
	at org.eclipse.core.internal.filesystem.local.LocalFile.delete(LocalFile.java:124)
	at org.eclipse.core.internal.resources.ResourceTree.internalDeleteFile(ResourceTree.java:303)
	at org.eclipse.core.internal.resources.ResourceTree.internalDeleteProject(ResourceTree.java:383)
	at org.eclipse.core.internal.resources.ResourceTree.standardDeleteProject(ResourceTree.java:832)
	at org.eclipse.core.internal.resources.Resource.unprotectedDelete(Resource.java:1816)
	at org.eclipse.core.internal.resources.Resource.delete(Resource.java:731)
	at org.eclipse.core.internal.resources.Project.delete(Project.java:309)
	at org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation.createProject(PluginImportOperation.java:408)
	at org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation.importPlugin(PluginImportOperation.java:190)
	at org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation.runInWorkspace(PluginImportOperation.java:125)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Contains: Could not delete: C:\eclipse\workspaces\Development_HEAD\plugins\com.ibm.icu\com.ibm.icu_4.0.1.v20090822.jar.
!SUBENTRY 2 org.eclipse.core.filesystem 4 273 2009-09-23 09:31:28.900
!MESSAGE Problems encountered while deleting files.
!SUBENTRY 3 org.eclipse.core.filesystem 4 273 2009-09-23 09:31:28.900
!MESSAGE Could not delete: C:\eclipse\workspaces\Development_HEAD\plugins\com.ibm.icu\com.ibm.icu_4.0.1.v20090822.jar.
!SUBENTRY 1 org.eclipse.core.resources 4 273 2009-09-23 09:31:28.900
!MESSAGE Could not delete 'C:\eclipse\workspaces\Development_HEAD\plugins\com.ibm.icu'.
!SUBENTRY 1 org.eclipse.core.resources 4 273 2009-09-23 09:31:28.900
!MESSAGE Could not delete 'C:\eclipse\workspaces\Development_HEAD\plugins\javax.servlet\javax.servlet_2.5.0.v200806031605.jar'.
!STACK 1
org.eclipse.core.runtime.CoreException: Problems encountered while deleting files.
	at org.eclipse.core.internal.filesystem.local.LocalFile.delete(LocalFile.java:124)
	at org.eclipse.core.internal.resources.ResourceTree.internalDeleteFile(ResourceTree.java:303)
	at org.eclipse.core.internal.resources.ResourceTree.internalDeleteProject(ResourceTree.java:383)
	at org.eclipse.core.internal.resources.ResourceTree.standardDeleteProject(ResourceTree.java:832)
	at org.eclipse.core.internal.resources.Resource.unprotectedDelete(Resource.java:1816)
	at org.eclipse.core.internal.resources.Resource.delete(Resource.java:731)
	at org.eclipse.core.internal.resources.Project.delete(Project.java:309)
	at org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation.createProject(PluginImportOperation.java:408)
	at org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation.importPlugin(PluginImportOperation.java:190)
	at org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation.runInWorkspace(PluginImportOperation.java:125)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Contains: Could not delete: C:\eclipse\workspaces\Development_HEAD\plugins\javax.servlet\javax.servlet_2.5.0.v200806031605.jar.
!SUBENTRY 2 org.eclipse.core.filesystem 4 273 2009-09-23 09:31:28.900
!MESSAGE Problems encountered while deleting files.
!SUBENTRY 3 org.eclipse.core.filesystem 4 273 2009-09-23 09:31:28.900
!MESSAGE Could not delete: C:\eclipse\workspaces\Development_HEAD\plugins\javax.servlet\javax.servlet_2.5.0.v200806031605.jar.
!SUBENTRY 1 org.eclipse.core.resources 4 273 2009-09-23 09:31:28.900
!MESSAGE Could not delete 'C:\eclipse\workspaces\Development_HEAD\plugins\javax.servlet'.
Comment 1 Dani Megert CLA 2009-09-23 03:51:03 EDT
Created attachment 147864 [details]
Picture of problem dialog
Comment 2 Dani Megert CLA 2009-09-28 08:12:25 EDT
Trying to find steps reveals that the problem is caused by APT not releasing files. Marking as critical as this not only breaks the import but results in resources being hold on to for nothing.

1. start with new workspace
2. disable auto-build
3. import 'com.ibm.icu' as binary plug-in project
4. check out 'org.eclipse.text' from CVS
5. clean and rebuild all
6. import existing unshared binary plug-ins
==> exception since files are locked

Repeat above test case but after step 3 disable 'API Analysis Builder' on 'org.eclipse.text'
==> works as expected
Comment 3 Dani Megert CLA 2009-09-28 08:55:38 EDT
The fZipFile in org.eclipse.pde.api.tools.internal.model.ArchiveApiTypeContainer is the issue as it keeps the archive open during my whole session and hence the importer cannot delete the JAR file.
Comment 4 Dani Megert CLA 2009-09-28 09:27:11 EDT
Later the workspace baseline gets disposed which would close the ZIP file but at that point it's already too late.
Comment 5 Dani Megert CLA 2009-09-28 09:28:57 EDT
Created attachment 148234 [details]
Fix

This fixes the issue for me and I don't think there's too much performance overhead by not caching the ZIP file itself.
Comment 6 Michael Rennie CLA 2009-09-28 09:43:32 EDT
(In reply to comment #5)
> Created an attachment (id=148234) [details]
> Fix
> 

Thanks for the fix, but the attached patch is for TextMergeViewer.java :)
Comment 7 Dani Megert CLA 2009-09-28 09:51:11 EDT
Created attachment 148235 [details]
Fix
Comment 8 Michael Rennie CLA 2009-09-28 10:33:21 EDT
(In reply to comment #7)
> Created an attachment (id=148235) [details]
> Fix

Thanks Dani, testing the patch I am getting 38 test failures in our non-plugin test suite and 6 failures in our plugin test suite. Most of the failures are around the search engine, I will investigate.
Comment 9 Michael Rennie CLA 2009-09-28 10:41:09 EDT
(In reply to comment #8)

> ... and 6 failures in our plugin test suite. 

I misspoke, I got 26 failures in our plugin test suite.
Comment 10 Michael Rennie CLA 2009-09-28 10:49:28 EDT
The problem is coming from our getContents() and getInputStream() methods. When we close the zip file it also closes any open input streams to it. We should look at an alternate way to get class file contents from zip files instead of returning an input stream...continuing investigation...
Comment 11 Dani Megert CLA 2009-09-28 11:31:13 EDT
>when we close the zip file it also closes any open input streams to it.
Oh, right! Sorry about that.
Comment 12 Michael Rennie CLA 2009-09-28 11:58:39 EDT
Created attachment 148254 [details]
proposed fix

This patch builds on Dani's patch and tosses the getInputStream() method altogether and processes the stream in the getContents() method of each kind of ApiTypeRoot. This is a far safer approach than passing around open (potentially closed) input streams.
Comment 13 Michael Rennie CLA 2009-09-28 12:00:59 EDT
running the performance tests on the patch showed a small deviation, and we will likely have some yellow tests on our enum and annotation tests. Adding the performance tag so we don't forget about this.
Comment 14 Michael Rennie CLA 2009-09-28 12:07:30 EDT
applied last patch to HEAD, please verify Dani and Darin W
Comment 15 Dani Megert CLA 2009-09-29 07:01:34 EDT
Patch looks good and fixes my problem.
Comment 16 Dani Megert CLA 2009-10-28 05:51:33 EDT
Verified in I20091027-0100.