<matrixBuild _class='hudson.matrix.MatrixBuild'><action _class='hudson.model.CauseAction'><cause _class='org.jenkinsci.plugins.workflow.support.steps.build.BuildUpstreamCause'><shortDescription>Started by upstream project "gerrit-osmo-hlr" build number 154</shortDescription><upstreamBuild>154</upstreamBuild><upstreamProject>gerrit-osmo-hlr</upstreamProject><upstreamUrl>job/gerrit-osmo-hlr/</upstreamUrl></cause></action><action></action><action _class='hudson.model.ParametersAction'><parameter _class='hudson.model.StringParameterValue'><name>COMMENT_TYPE</name><value></value></parameter><parameter _class='hudson.model.StringParameterValue'><name>DISTRO</name><value></value></parameter><parameter _class='hudson.model.StringParameterValue'><name>GERRIT_BRANCH</name><value>master</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>GERRIT_CHANGE_NUMBER</name><value>43010</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>GERRIT_HOST</name><value>gerrit.osmocom.org</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>GERRIT_PATCHSET_NUMBER</name><value>2</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>GERRIT_PATCHSET_REVISION</name><value>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>GERRIT_PATCHSET_UPLOADER_NAME</name><value>osmith</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>GERRIT_PORT</name><value>29418</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>GERRIT_PROJECT</name><value>osmo-hlr</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>GERRIT_REFSPEC</name><value>refs/changes/10/43010/2</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>GERRIT_REPO_URL</name><value>ssh://jenkins@gerrit.osmocom.org:29418/osmo-hlr</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>PIPELINE_BUILD_URL</name><value>https://jenkins.osmocom.org/jenkins/job/gerrit-osmo-hlr/154/</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>PROJECT_NAME</name><value>osmo-hlr</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>BRANCH_CI</name><value>master</value></parameter></action><action _class='jenkins.metrics.impl.TimeInQueueAction'><blockedDurationMillis>0</blockedDurationMillis><blockedTimeMillis>0</blockedTimeMillis><buildableDurationMillis>0</buildableDurationMillis><buildableTimeMillis>0</buildableTimeMillis><buildingDurationMillis>115995</buildingDurationMillis><executingTimeMillis>115995</executingTimeMillis><executorUtilization>1.0</executorUtilization><subTaskCount>0</subTaskCount><waitingDurationMillis>6822</waitingDurationMillis><waitingTimeMillis>6822</waitingTimeMillis></action><action></action><action _class='hudson.plugins.git.util.BuildData'><buildsByBranchName><osmith1.9.1 _class='hudson.plugins.git.util.Build'><buildNumber>144</buildNumber><marked><SHA1>addc0dc1fd76c9868a774d2532faa2995eafff31</SHA1><branch><SHA1>addc0dc1fd76c9868a774d2532faa2995eafff31</SHA1><name>osmith/1.9.1</name></branch></marked><revision><SHA1>addc0dc1fd76c9868a774d2532faa2995eafff31</SHA1><branch><SHA1>addc0dc1fd76c9868a774d2532faa2995eafff31</SHA1><name>osmith/1.9.1</name></branch></revision></osmith1.9.1><osmith1.6.2 _class='hudson.plugins.git.util.Build'><buildNumber>56</buildNumber><marked><SHA1>a6e983b98550adda992d821f8c0daf92e63ddc1e</SHA1><branch><SHA1>a6e983b98550adda992d821f8c0daf92e63ddc1e</SHA1><name>osmith/1.6.2</name></branch></marked><revision><SHA1>a6e983b98550adda992d821f8c0daf92e63ddc1e</SHA1><branch><SHA1>a6e983b98550adda992d821f8c0daf92e63ddc1e</SHA1><name>osmith/1.6.2</name></branch></revision></osmith1.6.2><osmith1.5.1 _class='hudson.plugins.git.util.Build'><buildNumber>34</buildNumber><marked><SHA1>81335271b9f8c74cbafceeb11ccede5074bc93cc</SHA1><branch><SHA1>81335271b9f8c74cbafceeb11ccede5074bc93cc</SHA1><name>osmith/1.5.1</name></branch></marked><revision><SHA1>81335271b9f8c74cbafceeb11ccede5074bc93cc</SHA1><branch><SHA1>81335271b9f8c74cbafceeb11ccede5074bc93cc</SHA1><name>osmith/1.5.1</name></branch></revision></osmith1.5.1><osmith1.6.1 _class='hudson.plugins.git.util.Build'><buildNumber>31</buildNumber><marked><SHA1>42f82975f23b381a2fcfb42aacbd72660a0ee7f4</SHA1><branch><SHA1>42f82975f23b381a2fcfb42aacbd72660a0ee7f4</SHA1><name>osmith/1.6.1</name></branch></marked><revision><SHA1>42f82975f23b381a2fcfb42aacbd72660a0ee7f4</SHA1><branch><SHA1>42f82975f23b381a2fcfb42aacbd72660a0ee7f4</SHA1><name>osmith/1.6.1</name></branch></revision></osmith1.6.1><master _class='hudson.plugins.git.util.Build'><buildNumber>154</buildNumber><marked><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><branch><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><name>master</name></branch></marked><revision><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><branch><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><name>master</name></branch></revision></master></buildsByBranchName><lastBuiltRevision><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><branch><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><name>master</name></branch></lastBuiltRevision><remoteUrl>ssh://jenkins@gerrit.osmocom.org:29418/osmo-hlr</remoteUrl><scmName></scmName></action><action></action><action></action><action></action><action _class='org.jenkinsci.plugins.displayurlapi.actions.RunDisplayAction'></action><building>false</building><displayName>#154</displayName><duration>115995</duration><estimatedDuration>117471</estimatedDuration><fullDisplayName>gerrit-osmo-hlr-build #154</fullDisplayName><id>154</id><inProgress>false</inProgress><keepLog>false</keepLog><number>154</number><queueId>169375</queueId><result>SUCCESS</result><timestamp>1784109326400</timestamp><url>https://jenkins.osmocom.org/jenkins/job/gerrit-osmo-hlr-build/154/</url><builtOn></builtOn><changeSet _class='hudson.plugins.git.GitChangeSetList'><item _class='hudson.plugins.git.GitChangeSet'><affectedPath>debian/postinst</affectedPath><affectedPath>contrib/osmo-hlr-post-upgrade.sh</affectedPath><affectedPath>debian/osmo-hlr.install</affectedPath><affectedPath>contrib/systemd/osmo-hlr.service</affectedPath><affectedPath>contrib/osmo-hlr-db-upgrade.sh</affectedPath><affectedPath>contrib/Makefile.am</affectedPath><commitId>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</commitId><timestamp>1784109296000</timestamp><author><absoluteUrl>https://jenkins.osmocom.org/jenkins/user/osmith</absoluteUrl><fullName>Oliver Smith</fullName></author><authorEmail>osmith@sysmocom.de</authorEmail><comment>systemd: run db-upgrade script in ExecStartPre

We have seen in CI jobs that calling the DB upgrade script from
debian/postinst does not work reliably.

When doing a fresh install of osmo-hlr, it usually works as expected:

  Setting up osmo-hlr (1.9.2) ...
  osmo-hlr-post-upgrade: nothing to do (no existing database)

But sometimes:

  Setting up osmo-hlr (1.9.2) ...
  osmo-hlr-post-upgrade: database upgrade is required
  osmo-hlr-post-upgrade: stopping osmo-hlr service
  osmo-hlr-post-upgrade: creating backup: /var/lib/osmocom/hlr.db.20260706135658.bak
  osmo-hlr-post-upgrade: performing database upgrade
  &lt;0001&gt; db.c:600 using database: /var/lib/osmocom/hlr.db
  &lt;0001&gt; db.c:103 (283) recovered 4 frames from WAL file /var/lib/osmocom/hlr.db-wal
  &lt;0001&gt; db.c:679 Database '/var/lib/osmocom/hlr.db' has HLR DB schema version 0
  &lt;0001&gt; db.c:103 (1) duplicate column name: last_lu_seen in "ALTER TABLE subscriber ADD COLUMN last_lu_seen TIMESTAMP default NULL"
  &lt;0001&gt; db.c:248 Unable to prepare SQL statement 'ALTER TABLE subscriber ADD COLUMN last_lu_seen TIMESTAMP default NULL'
  &lt;0001&gt; db.c:318 Unable to update HLR database schema to version 1
  &lt;0001&gt; db.c:685 Failed to upgrade HLR DB schema to version 1: (rc=1) duplicate column name: last_lu_seen
  &lt;0000&gt; hlr_db_tool.c:509 Error opening database

It seems that osmo-hlr can get started before the osmo-hlr-post-upgrade
script runs, then starts to create the database with the current schema,
and gets stopped before it is done, leading to the failure above.

Rename the script to osmo-hlr-db-upgrade.sh, remove logic for stopping
and starting the service and let systemd call it in ExecStartPre. That
way we are sure that it runs *before* osmo-hlr starts up.

Related: SYS#8125
Change-Id: If13f4c8b49397e6630956e92a7825843c7d55ebd
</comment><date>2026-07-15 11:54:56 +0200</date><id>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</id><msg>systemd: run db-upgrade script in ExecStartPre</msg><path><editType>edit</editType><file>debian/osmo-hlr.install</file></path><path><editType>edit</editType><file>debian/postinst</file></path><path><editType>edit</editType><file>contrib/Makefile.am</file></path><path><editType>delete</editType><file>contrib/osmo-hlr-post-upgrade.sh</file></path><path><editType>edit</editType><file>contrib/systemd/osmo-hlr.service</file></path><path><editType>add</editType><file>contrib/osmo-hlr-db-upgrade.sh</file></path></item><kind>git</kind></changeSet><culprit><absoluteUrl>https://jenkins.osmocom.org/jenkins/user/osmith</absoluteUrl><fullName>Oliver Smith</fullName></culprit><run><number>154</number><url>https://jenkins.osmocom.org/jenkins/job/gerrit-osmo-hlr-build/a1=default,a2=default,a3=default,a4=default,label=osmocom-gerrit/154/</url></run></matrixBuild>