| Summary: | Repository settings cannot be persisted if engine is not available | ||
|---|---|---|---|
| Product: | [Eclipse Project] Equinox | Reporter: | John Arthorne <john.arthorne> |
| Component: | p2 | Assignee: | John Arthorne <john.arthorne> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | daniel_megert, dj.houghton, jdmiles, markus.kell.r, matthew, Olivier_Thomann, pascal, pwebster, steffen.pingel |
| Version: | unspecified | ||
| Target Milestone: | 3.6 M6 | ||
| Hardware: | PC | ||
| OS: | Windows Vista | ||
| Whiteboard: | |||
|
Description
John Arthorne
Tracing through the code I can't see why this would happen. If the agent location service is null it means the p2.core bundle has been stopped. The repository bundles join the save job in their stop method, so these jobs should never be running after the p2.core bundle is stopped. I am seeing the same error when running Mylyn headless tests: !SESSION 2009-02-24 16:25:47.965 ----------------------------------------------- eclipse.buildId=I20090224-0800 java.version=1.5.0_15 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US Framework arguments: -application org.eclipse.test.uitestapplication formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,/home/tools/mylyn/eclipse/test-I20090224-0800/eclipse/org.eclipse.mylyn.tests.AllTests.xml -testPluginName org.eclipse.mylyn.tests -className org.eclipse.mylyn.tests.AllTests Command-line arguments: -application org.eclipse.test.uitestapplication -data /home/tools/mylyn/eclipse/test-I20090224-0800/eclipse/mylyn_folder formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,/home/tools/mylyn/eclipse/test-I20090224-0800/eclipse/org.eclipse.mylyn.tests.AllTests.xml -testPluginName org.eclipse.mylyn.tests -className org.eclipse.mylyn.tests.AllTests -os linux -ws gtk -arch x86 -consolelog !ENTRY org.eclipse.core.jobs 4 2 2009-02-24 16:26:12.910 !MESSAGE An internal error occurred during: "Saving repository settings". !STACK 0 java.lang.NullPointerException at org.eclipse.equinox.internal.p2.engine.ProfilePreferences.getDefaultLocation(ProfilePreferences.java:141) at org.eclipse.equinox.internal.p2.engine.ProfilePreferences.save(ProfilePreferences.java:153) at org.eclipse.core.internal.preferences.EclipsePreferences.flush(EclipsePreferences.java:352) at org.eclipse.core.internal.preferences.EclipsePreferences.flush(EclipsePreferences.java:340) at org.eclipse.equinox.internal.p2.core.helpers.AbstractRepositoryManager$SaveJob.run(AbstractRepositoryManager.java:57) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) I get the NPE twice (with I20090224-0800). Me too. Each time I exit. I get it too. *** Bug 266145 has been marked as a duplicate of this bug. *** Same for me. The problem is not that the p2.core bundle has been stopped, but that the engine bundle has been stopped: ->stopped org.eclipse.equinox.p2.engine_1.0.100.qualifier [262] ->stopped org.eclipse.equinox.p2.artifact.repository_1.0.100.qualifier [260] Trying to suspend bundle org.eclipse.equinox.p2.metadata.repository_1.0.100.qualifier [264] !ENTRY org.eclipse.equinox.p2.engine 2 0 2009-02-25 16:49:54.546 !MESSAGE Agent location service not available !STACK 0 java.lang.RuntimeException at org.eclipse.equinox.internal.p2.engine.ProfilePreferences.getDefaultLocation(ProfilePreferences.java:147) (I have replaced the NPE with a logged RuntimeException here). The repository managers cannot save their state after the engine bundle has been stopped. There is a small window between the engine stopping and repositories stopping where any changes to the set of repositories cannot be persisted. *** Bug 266340 has been marked as a duplicate of this bug. *** This can also be found inside the test framework. From the console log of the api plugin tests suite: !ENTRY org.eclipse.core.jobs 4 2 2009-02-27 02:24:45.875 !MESSAGE An internal error occurred during: "Saving repository settings". !STACK 0 java.lang.NullPointerException at org.eclipse.equinox.internal.p2.engine.ProfilePreferences.getDefaultLocation(ProfilePreferences.java:141) at org.eclipse.equinox.internal.p2.engine.ProfilePreferences.save(ProfilePreferences.java:153) at org.eclipse.core.internal.preferences.EclipsePreferences.flush(EclipsePreferences.java:352) at org.eclipse.core.internal.preferences.EclipsePreferences.flush(EclipsePreferences.java:340) at org.eclipse.equinox.internal.p2.core.helpers.AbstractRepositoryManager$SaveJob.run(AbstractRepositoryManager.java:57) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) The root problem here is attempting to persist repository settings after the engine bundle has stopped. I have released a number of changes to mitigate this: - The repository manager previously saved preferences in a job. This increased the gap of time between repository manager changes and calling the engine, and if the engine bundle stopped during that gap the problem would occur. The fix for bug 266205 removed this job from the repository manager, so the engine is invoked immediately when there are repository changes. - There is now a job at the engine level that is responsible for persisting profile preferences. This job is joined in the Engine activator's stop() method, to ensure all changes are flushed prior to shutdown - There was one case where we didn't immediately persist changes to the repository manager (bug 266382). As a result, the change would only be persisted at repository bundle stop() time, which is guaranteed to fail because the engine is not available at this point. - If there are unsaved repository changes when the repository manager is shutting down, a warning is logged rather than throwing an exception. I'm leaving this bug open for now because there are still two possible problems: - If there are any other repository changes that are not persisted immediately, then the persistence on shutdown will attempt to save them and fail. The logging I added will help us find if there are more such cases - If someone changes repository settings after the engine bundle has shut down, they cannot be persisted. Again the logging I added will help us find out if this is a problem. I'm renaming bug and clearing M5 target. The "root" problem of shutdown order is difficult to solve. We would need to have the repository bundles depend on the engine bundle, so that shutdown order is reversed. That is not currently possible but future restructuring of the p2 bundles may help to sort this out. The other potential fix is to persist repository changes in the configuration area in the case where the engine is not available. On startup we would merge the two sets of preferences. This is a bit ugly/complex, but would also handle cases where there is no engine bundle present (for example in the mirroring app). *** Bug 302591 has been marked as a duplicate of this bug. *** I have released a fix for this in HEAD, by making use of the agent lifecycle methods added in bug 300450. This fix was released. |