Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 358448

Summary: [Subsystems] Garbage collection of InstallArtifacts
Product: [RT] Virgo Reporter: Glyn Normington <glyn.normington>
Component: runtimeAssignee: Glyn Normington <glyn.normington>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: 3.0.0.RELEASE   
Target Milestone: 3.5.0.M03   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 371427, 358441    

Description Glyn Normington CLA 2011-09-21 11:34:39 EDT
Garbage collection involves scanning from "roots" representing artifacts that have been explicitly deployed or which are parts of the base system which must always be present. Any artifacts which do not belong to the transitive dependencies of the roots may be uninstalled.

This approach is preferred over reference counting since counts are prone to diverging from reality and since there are a number of distinct kinds of dependency which may keep an artifact live including package wiring, bundle wiring, service wiring, and generic requirements.
Comment 1 Glyn Normington CLA 2011-09-22 08:58:40 EDT
The other kind of dependency that can keep an artefact live is belonging to a plan (or subsystem).
Comment 2 Glyn Normington CLA 2011-09-23 05:46:44 EDT
Targeting 4.0.
Comment 3 Glyn Normington CLA 2011-11-29 05:59:03 EST
The initial implementation of this feature should probably avoid garbage collecting transitive dependencies, i.e. bundles which are auto-installed because they are needed to resolve a graph of artifacts which is being deployed.

GC of transitive dependencies will be needed for full subsystems support but Virgo does not uninstall transitive dependencies today, so the initial implementation should continue with that policy.

Plans which share strict subgraphs of each other are the most straightforward case. For example, suppose two plans share a bundle. Then uninstalling one of the plans must not uninstall the shared bundle. However, if both plans are uninstalled, then the shared bundle must be uninstalled.

A somewhat more difficult case is a plan which refers to a top-level deployed artefact. The demonstrates that we need to keep track of the roots independently of the DAG data structure. The reason for this is that if we allow an existing root to become a child a new install artefact graph, then we will have forgotten the "rootness" of the existing root and we will garbage collect it prematurely.

A complex case which will need designing is where a bundle is part of an install artefact graph and also providing a transitive dependency of some (i.e. the same or another) install artefact graph. We really don't want to break a transitive dependency when uninstalling a graph containing such a bundle. So we probably need to track transitive dependencies in some way. If the transitive dependency was created before the install artefact graph was deployed, it is easy to determine that the bundle is providing a transitive dependency (we can record this when we auto-install the bundle). However, it is harder to keep track of transitive dependencies that are formed on existing bundles which are part of an install artefact graph. It therefore seems necessary to examine the package and bundle wiring as part of garbage collection as this is the true indication that a bundle is providing a transitive dependency.
Comment 4 Glyn Normington CLA 2012-02-13 16:35:09 EST
Garbage collection of the transitive dependencies of install artifacts is deferred to the larger effort to implement OSGi subsystems. This bug covers just the garbage collection of install artifacts and their descendants.