Message Boards

Initial Database Creation runs when upgrading plugins SDK to OSGI

thumbnail
Ian Gosling, modified 4 Years ago.

Initial Database Creation runs when upgrading plugins SDK to OSGI

New Member Posts: 8 Join Date: 3/19/12 Recent Posts
I've upgraded a 6.2 service builder plugin to OSGI modular form. I've included a BundleActivator according to https://portal.liferay.dev/docs/7-2/frameworks/-/knowledge_base/f/upgrade-processes-for-former-service-builder-plugins and an UpgradeStepRegistrator for upgrading the entity class names, etc.  As I understand it , the BundleActivator is supposed to create an initial Release entry with a version of 0.0.1 ready for other upgrade steps to work on the existing 6.2 tables and disabling initial database creation (which is implemented as an automatically created upgrade step from version 0.0.0, i.e. non-existent Release entity, the situation for new installations where there is no inherited 6.2 table data).

What seems to be happening is that InitialUpgradeExecutor.addingBundle() runs during module activation, registering the initial database creation upgrade step as expected, but it also immediately runs that upgrade step, trying to create the database. This causes an exception to be thrown because the tables already exist. My BundleActivator runs afterwards in the bundle activation process, which is too late. So far I haven't found a solution for this - I can't see any difference between what I'm doing and OOB modules such as knowledge-base-service are doing.

Has anyone experienced this problem and if so, how did you solve it?

Thanks in advance,

Ian
thumbnail
Alberto Chaparro, modified 4 Years ago.

RE: Initial Database Creation runs when upgrading plugins SDK to OSGI

Liferay Master Posts: 549 Join Date: 4/25/11 Recent Posts
Hi Ian,

I never experienced this but I think this can be a bug because the bundleActivator is executed in the STARTING phase and the InitialUpgradeExtender tracks bundles in status ACTIVE but also in STARTING phase:

https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal/portal-spring-extender-impl/src/main/java/com/liferay/portal/spring/extender/internal/upgrade/InitialUpgradeExtender.java#L96

So, it could be a race condition, can you open a Jira ticket and attach it here to see if we can reproduce it and fix it?

In the meantime, can you somehow modify the release table in the RESOLVED phase or, if this is not possible, in any other way before reaching the STARTING phase, this will prevent the initial upgrade step to be executed. You can also try the property autoUpgrade set to false but that can impact other modules which are also upgrading.

Looking forward to your thoughts.

Thanks.
thumbnail
Ian Gosling, modified 4 Years ago.

RE: Initial Database Creation runs when upgrading plugins SDK to OSGI

New Member Posts: 8 Join Date: 3/19/12 Recent Posts
Thanks Alberto.
   
I've now opened a ticket under https://help.liferay.com/hc/requests/18811 . I've performed further test runs, and it seems there is indeed a race condition between the bundle tracker and the new module's bundle activator. I think there is also a problem with caching, because some database operations during startup use SQL via the database connection directly, and some use the service layer which is cached and doesn't know about these other operations. Maybe one solution to is to put the code from the optional upgradeServiceModuleRelease class into the core bundle tracker. The problem then is that it slows down portal startup because it introduces a database read operation for all modules that have a Liferay-Service=true manifest header, not just those that are wanting to upgrade from a previous life as a legacy plugin.

Ian
thumbnail
Alberto Chaparro, modified 4 Years ago.

RE: Initial Database Creation runs when upgrading plugins SDK to OSGI

Liferay Master Posts: 549 Join Date: 4/25/11 Recent Posts
Hi Ian,
Thank you for opening the support ticket, it is the correct and fastest way to fix the issue if you have an EE subscription.
We are currently working in Support to fix it. We will keep you updated there.
Cheers.
thumbnail
Alberto Chaparro, modified 4 Years ago.

RE: Initial Database Creation runs when upgrading plugins SDK to OSGI

Liferay Master Posts: 549 Join Date: 4/25/11 Recent Posts
For the record, the issue has been addressed here:

https://issues.liferay.com/browse/LPS-107845