RE: Is deleting the osgi/state folder a bad practice?

thumbnail
Charalampos Chrysikopoulos, modified 6 Years ago. Junior Member Posts: 79 Join Date: 12/9/11 Recent Posts
Hallo,

 there are times where while developing, the liferay server can come to a state, in which something is working wrong, but we don't know whan it is. Restarting the server resolves the problem in many cases, but not always. In liferay 6.2 we stoped the server, deleted work and temp folders and then started the server again. Even more, we could delete our plugins from the webapps folder. This "clean" restart was more succesful. In liferay 7 (or 7.1) we can delete the same folders, but there is also the osgi/state folder. This folder contains all the modules/bundles that are deployed in the osgi container. 

If we install all our modules/bundles through the deploy folder as jars, is it a good practice the delete also the state fodler together with work and temp to accieve a clean restart? 

Thank you in advance,
​​​​​​​Harry
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
The osgi/state directory contains all of the meta information OSGi needs to understand individual modules, including those in the .lpkg files, and the relations between the modules.

If the directory doesn't exist, OSGi will rebuild it all at restart.

In general though you don't want to delete it as it will affect your startup times.

I typically will only delete it when something is not acting right.  This happens to me mostly when my bundle modifications change the meta information that OSGi has not updated osgi/state correctly.
thumbnail
Charalampos Chrysikopoulos, modified 6 Years ago. Junior Member Posts: 79 Join Date: 12/9/11 Recent Posts
Thanks David,

so, there are cases as you noticed, where deleting the state folder makes sense. 

Looking into the state folder, under the org.eclipse.osgi subfolder, there are all bundle ids as folders and in those a subfolder with a number that contains mostly the jar in the form of a file named bundleFile.

Do you know what this number means? 
thumbnail
Tobias Liefke, modified 6 Years ago. Junior Member Posts: 78 Join Date: 11/23/12 Recent Posts

The number is the numeric ID of the bundle. You can use it for example in the gogo shell, to reference a bundle with a short number instead of its long symbolic name.

When you enter lb (list bundle) in the shell you can see the ID for each bundle.

If you delete the state folder, each bundle will get a new ID - which is usually no problem, because the IDs are only used during runtime and inside the state folder.

thumbnail
Charalampos Chrysikopoulos, modified 6 Years ago. Junior Member Posts: 79 Join Date: 12/9/11 Recent Posts

Hi Tobias,

 

you are right. Only I wanted to know the following number (I didn't explained it well):

 

/osgi/state/org.eclipse.osgi/[bundleId]/[unknownNumber]/bundleFile

 

So, unknownNumber is the number I was asking about.

 

Checking it out, I saw the values 0 (moslty), but also 1,2,4 or 7.

thumbnail
Tobias Liefke, modified 6 Years ago. Junior Member Posts: 78 Join Date: 11/23/12 Recent Posts

The second number is just the "version" of the bundle (the number starts by 0 and is increased every time the bundle is redeployed). This ensures that even open files of previous versions don't prevent deployment of a new version of a bundle.

Most often you have only the last version of a bundle - and as most of the bundles are never redeployed, the usual number is "0".

But for those of your WAB bundles which contain further third party libraries, you will often find more than one version directory with all the previous versions containing all these libraries and a file ".delete" indicating that this directory may be deleted.

thumbnail
Charalampos Chrysikopoulos, modified 6 Years ago. Junior Member Posts: 79 Join Date: 12/9/11 Recent Posts

Thanks a lot Tobias for the info!