Bug 43625 - Update to UCS 4.2 interim-1 (+x) aborts: dpkg : status database locked
Update to UCS 4.2 interim-1 (+x) aborts: dpkg : status database locked
Product: UCS
Classification: Unclassified
Component: Update - Release updates
UCS 4.2
Other Linux
: P2 major (vote)
: UCS 4.2
Assigned To: Arvid Requate
Stefan Gohmann
: interim-3
Depends on:
Blocks: 42057 43917
  Show dependency treegraph
Reported: 2017-02-23 14:02 CET by Arvid Requate
Modified: 2017-04-04 18:28 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:

updater.log (7.60 MB, text/x-log)
2017-02-23 14:06 CET, Arvid Requate

Note You need to log in before you can comment on or make changes to this bug.
Description Arvid Requate univentionstaff 2017-02-23 14:02:33 CET
My latest attempt of an update to UCS 4.2 interim-1 (+x) aborts with

dpkg : status database area is locked by another process

Vorbereitung zum Entpacken von .../ncurses-base_5.9+20140913-1_all.deb ...
Entpacken von ncurses-base (5.9+20140913-1) über (5.9-10.17.201403180024) ...
ncurses-base (5.9+20140913-1) wird eingerichtet ...
dpkg: Fehler: dpkg-Status-Datenbank ist von einem anderen Prozess gesperrt
Checking for app updates:                              E: Sub-process /usr/bin/dpkg returned an error code (2)
Error: Failed to execute "apt-get -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-overwrite -o DPkg::Options::=--force-overwrite-dir --trivial-only=no --assume-yes --quiet=1 -u dist-upgrade"

I updated from

Comment 1 Arvid Requate univentionstaff 2017-02-23 14:06:19 CET
Created attachment 8453 [details]
Comment 2 Arvid Requate univentionstaff 2017-03-14 20:11:49 CET
One potential culprit could be this cron job:

/etc/cron.d/univention-updater-check calls /usr/share/univention-updater/univention-updater-check, which calls univention-upgrade --check --setucr.

I've adjusted univention-upgrade to aquire an UpdaterLock also for --check, but I doubt that that fixes the issue.
Comment 3 Arvid Requate univentionstaff 2017-03-15 17:19:01 CET
I guess that's it. I've checked it the other way around:

I've manually locked the status file by

python -c 'import apt_pkg; fd = apt_pkg.get_lock("/var/lib/dpkg/lock"); raw_input("hit return to unlock")'

When I run apt-get update in this situation, it returns the dreaded "is locked by another process" error. Out univention-upgrade script doesn't setup logging properly, so the univention-debug log messages from univention.updater.tools.UniventionUpdater.component_update_get_packages()
disappear into byte-nirvana. But from printf-debugging I can see that the apt-get update calls fail there too in this situation (obviously).

So by inverse reasoning, I assume the the apt-get update calls made by "univention-upgrade --check" every hour may be the ones interfering with the proper "univention-upgrade" too.

I've also opened Bug #43882 for another improvement of locking.
Comment 4 Stefan Gohmann univentionstaff 2017-03-17 07:45:18 CET
OK, it looks good and makes sense. I was able to reproduce it with the following parallel script:
 while true; do univention-upgrade --check; sleep 30; done

I've added a changelog entry: r77866

We also need to backport this issue to UCS 4.1-4: Bug #43917
Comment 5 Stefan Gohmann univentionstaff 2017-04-04 18:28:14 CEST
UCS 4.2 has been released:

If this error occurs again, please use "Clone This Bug".