Using glowroot during an upgrade

Performance monitoring / debugging

In a recent article, I explained how you can setup glowroot to have some great APM capabilities to monitor Liferay: https://liferay.dev/blogs/-/blogs/setting-up-glowroot-apm

From time to time, I got to help customers understanding failures in their database upgrade from one Liferay version to a new one.

The logs for upgrade can be very long and difficult to analyze.

I've just found that Glowroot could also be useful in that situation.

That's why I wanted to share with you how I was able to monitor an upgrade using Glowroot.

About the upgrade tool and upgrade processes

First of all, please refer to this article about how to use the Liferay upgrade tool: https://learn.liferay.com/dxp/latest/en/installation-and-upgrades/upgrading-liferay/reference/database-upgrade-tool-reference.html

The upgrade tool runs the upgrade processes. Liferay upgrade processes are kind of small upgrade steps which are run during an upgrade to adapt Liferay entities one by one.

As a consequence an upgrade from a given version to another will consist in running all the upgrade processes which are matching the version gap.

Glowroot configuration

By default, Glowroot captures information about transactions triggered by inbound HTTP Servlet Requests.

What we need to do here, is adding some instrumentation so that each UpgradeProcess is treated as a transaction.

Please have a look at this Glowroot config.json file: https://gist.github.com/fabian-bouche-liferay/1de22db4f5ed1c6a80cf805b0418476d

If you replace the default config.json with that one, Glowroot will capture information about your upgrade processes.

Configuring the upgrade tool to use Glowroot as a java agent

You'll need to update tools/portal-tools-db-upgrade-client/portal-upgrade-ext.properties and add this (for the latest 7.4, please check the default value for your liferay version and add the glowroot agent's packages like I've done).

module.framework.properties.org.osgi.framework.bootdelegation=\
__redirected,\
com.liferay.expando.kernel.model,\
com.liferay.portal.servlet.delegate,\
com.liferay.portal.servlet.delegate*,\
com.sun.ccpp,\
com.sun.ccpp.*,\
com.sun.crypto.*,\
com.sun.image.*,\
com.sun.imageio.plugins.*,\
com.sun.jmx.*,\
com.sun.jna,\
com.sun.jndi.*,\
com.sun.mail.*,\
com.sun.management.*,\
com.sun.media.*,\
com.sun.msv.*,\
com.sun.org.*,\
com.sun.tools.*,\
com.sun.xml.*,\
com.yourkit.*,\
jdk.*,\
sun.*,\
weblogic.jndi,\
weblogic.jndi.*,\
org.glowroot.agent,\
org.glowroot.agent.*

And start the upgrade tool with those JVM options:

db_upgrade.bat --jvm-opts="-javaagent:C:/upgrade/glowroot/glowroot.jar"

Reading the results

While the upgrade runs, glowroot is available on port 4000.
However, as soon as it completes, glowroot stops with the process.

You can then just run java -jar glowroot.jar to make the GUI available.

You can also download the glowroot/data folder and execute glowroot locally to watch its data in case the upgrade process has run on a distant machine you cannot easily reach.

Errors in upgrade processes will be logged in the "Errors" tab and you'll be able to monitor execution time in the "Transaction" tab.