(No) Tomcat Restart After Xwiki LTS Debian Package Upgrade

We just upgraded Xwiki vom 14.10.18 to 14.10.19 on a Debian server:

Xwiki is 14.10.19, Debian Bookworm/Bullseye, Tomcat 9, Debian packages

As far as we can remember, installing the new package versions using apt and possibly manually merging the config files was all which was needed to get the new Xwiki up an running.

This time, we ended up with lots of file not found errors in the logs, were the applicatin apparently was still looking for 14.10.18 versioned jars - a simple restart of Tomcat 9 fixed this, but we can’t remember that this was necessary during previous updates.

Did something change in the Tomcat packages, maybe when the new Jetty-based packages were introduced?

Yes, but it was supposed to increase the cases where Tomcat was restarted (it was sometimes not restarted at first install anymore): Tomcat used to be restarted only when already running and the criteria changed for simply being enabled. Also, the service is now restarted using deb-systemd-invoke restart tomcat9.service (instead of the old services). You did not notice any warning or error during upgrade ?

Would be great if you could try to following commands:

  • systemctl is-enabled tomcat9.service: the command used by postinst to check if it should restart
  • echo $?: just to make sure the previous command exits with 0 (as expected when enabled)

The post install script is on https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/postinst if you are curious. Don’t hesitate if you have improvements ideas.

Actually, that change was only on 15.9. The way to restart 14.10.19 did not change, only the criteria to know if it should be restarted: see the more accurate https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-14.10.19/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/postinst.

@tmortagne: Yes, that’s the relevant change which broke it for me:

root@XXX:~# systemctl -q is-active tomcat9.service
root@XXX:~# echo $?
0
root@XXX:~# systemctl -q is-enabled tomcat9.service
root@XXX:~# echo $?
1

The systemd service is not enabled on this server, as it (currently) requires a manual start script to run after a reboot, which performs some setup and starts the dependend services manually…

So checking for whether the service runs works, but checking if it’s enable then won’t restart it.

Maybe check for both to also catch messed-up setups like mine?

if ( systemctl -q is-active tomcat9.service || systemctl -q is-enabled tomcat9.service )
then
 echo "Should restart..."
fi

Yes, seems to be the best.

Do you feel like providing a pull request ?

(I can definitely take care of it, but I usually prefer it so that the improvement is attributed to you right in the history)

Not that easy if you’re never using GitHub.com, but I think I managed to do it: Make tomcat restart after XWiki installation / upgrade more reliable. by gohrner · Pull Request #2653 · xwiki/xwiki-platform · GitHub

Shall I also create one against GitHub - xwiki/xwiki-platform at stable-14.10.x , or can you just cherry-pick the commit if satisfied?

Almost perfect, yes. The only missing piece is that we try to always associated a commit with a functional impact to a jira issue dedicated to give more details about the fixed problem (when it’s started, when it was fixed, details about what is fixed, etc.) and indicate the jira issue in the commit log. See for example XWIKI-18624: xwiki-tomcat9-mysql postinstall fails at upgrade on Debi… · xwiki/xwiki-platform@4fc2ba2 · GitHub.

Yes, I will take care of this part.

Ok, second attempt: XWIKI-18624: more reliable Tomcat restart after XWiki installation / … by gohrner · Pull Request #2654 · xwiki/xwiki-platform · GitHub

I had mentioned the Jira issue XWIKI-18624 in the commit description, but not at its beginning.

To my knowledge, there isn’t yet a separate issue for the restart problem I had.

Actually, we need a new jira issue to describe the problem currently being fixed. XWIKI-18624 was released a long time ago.

https://github.com/xwiki/xwiki-platform/pull/2655

Actually, XWIKI-18624 was the wrong reference in the title anyway (though I think it’s the right one to reference in the text, as the reson why we need to check for both aspects, enabled and active).

(BTW, sorry for the messup in XWIKI-18624 - the wrong window was in focus and Jira seems to have interesting hotkeys which react creatively if you’r accidentally typing some text intended for some console session…)

Now all Jira issues are mentioned: A new one serving as a reference point for this problem, the one which broke the upgrade, and the one which broke fresh installs which triggered the one which broke the upgrade. :wink:

Perfect, thanks !