<matrixBuild _class='hudson.matrix.MatrixBuild'><action _class='hudson.model.CauseAction'><cause _class='hudson.triggers.SCMTrigger$SCMTriggerCause'><shortDescription>Started by an SCM change</shortDescription></cause></action><action></action><action _class='hudson.model.ParametersAction'><parameter _class='hudson.model.StringParameterValue'><name>BRANCH</name><value>master</value></parameter><parameter _class='hudson.model.StringParameterValue'><name>EMAIL_NOTIFICATIONS</name><value>jenkins-notifications@lists.osmocom.org laforge@gnumonks.org</value></parameter></action><action _class='jenkins.metrics.impl.TimeInQueueAction'><blockedDurationMillis>0</blockedDurationMillis><blockedTimeMillis>0</blockedTimeMillis><buildableDurationMillis>0</buildableDurationMillis><buildableTimeMillis>0</buildableTimeMillis><buildingDurationMillis>125199</buildingDurationMillis><executingTimeMillis>125199</executingTimeMillis><executorUtilization>1.0</executorUtilization><subTaskCount>0</subTaskCount><waitingDurationMillis>9094</waitingDurationMillis><waitingTimeMillis>9094</waitingTimeMillis></action><action></action><action _class='hudson.plugins.git.util.BuildData'><buildsByBranchName><originmaster _class='hudson.plugins.git.util.Build'><buildNumber>13484</buildNumber><marked><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><branch><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><name>origin/master</name></branch></marked><revision><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><branch><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><name>origin/master</name></branch></revision></originmaster><refsremotesoriginmaster _class='hudson.plugins.git.util.Build'><buildNumber>8893</buildNumber><marked><SHA1>63eefabdde87df4dac9ed071df6535eed4f748c3</SHA1><branch><SHA1>63eefabdde87df4dac9ed071df6535eed4f748c3</SHA1><name>refs/remotes/origin/master</name></branch></marked><revision><SHA1>63eefabdde87df4dac9ed071df6535eed4f748c3</SHA1><branch><SHA1>63eefabdde87df4dac9ed071df6535eed4f748c3</SHA1><name>refs/remotes/origin/master</name></branch></revision></refsremotesoriginmaster></buildsByBranchName><lastBuiltRevision><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><branch><SHA1>2ef24d62ab9c1489eb87ac3aaeece084676e76b5</SHA1><name>origin/master</name></branch></lastBuiltRevision><remoteUrl>https://gerrit.osmocom.org/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>#13484</displayName><duration>125199</duration><estimatedDuration>119887</estimatedDuration><fullDisplayName>master-osmo-hlr #13484</fullDisplayName><id>13484</id><inProgress>false</inProgress><keepLog>false</keepLog><number>13484</number><queueId>169525</queueId><result>SUCCESS</result><timestamp>1784118249540</timestamp><url>https://jenkins.osmocom.org/jenkins/view/no-generated/job/master-osmo-hlr/13484/</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>contrib/systemd/osmo-hlr.service</affectedPath><affectedPath>debian/osmo-hlr.install</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/postinst</file></path><path><editType>edit</editType><file>contrib/Makefile.am</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><path><editType>edit</editType><file>debian/osmo-hlr.install</file></path><path><editType>delete</editType><file>contrib/osmo-hlr-post-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>13484</number><url>https://jenkins.osmocom.org/jenkins/view/no-generated/job/master-osmo-hlr/a1=default,a2=default,a3=default,a4=default,label=osmocom-master/13484/</url></run></matrixBuild>