Bug 51583 - Failed updates due to two simultaneous updates
Failed updates due to two simultaneous updates
Status: NEW
Product: UCS
Classification: Unclassified
Component: Update - univention-updater
UCS 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: UCS maintainers
UCS maintainers
:
Depends on:
Blocks: 39824
  Show dependency treegraph
 
Reported: 2020-06-26 10:51 CEST by Dirk Schnick
Modified: 2022-03-14 13:39 CET (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.114
Enterprise Customer affected?: Yes
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2020051521000734, 2020052221000284, 2020062221000488
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Schnick univentionstaff 2020-06-26 10:51:47 CEST
Within the last 6 weeks the update failed at three customers due to two parallel running update processes. The effects were different but I always found the two competing update processes as the cause. As far as I know the customers started the update via the UMC; there were no cron controlled updates on at least two systems.

Two systems were on UCS 4.4-4 (err602) at the time, one 4.4-3 err455.

In the first ticket, a complete USI is attached, and the second ticket I surly can get more logfiles if necessary
Comment 1 Arvid Requate univentionstaff 2020-07-06 20:31:10 CEST
This should work:

root@master10:~# univention-upgrade 

Starting univention-upgrade. Current UCS version is 4.4-4 errata644

Another updater process is currently running - abort
Locked by PID 11246. Check lockfile /var/lock/univention-updater


There is a Python context manager for that:

arequate@braeda:~/git/ucs on feature/ucs5$ rgrep UpdaterLock base/univention-updater
base/univention-updater/debian/changelog:  * Bug #43625: Acquire an UpdaterLock also for --check
base/univention-updater/python/univention-upgrade:from univention.updater.locking import UpdaterLock
base/univention-updater/python/univention-upgrade:    with UpdaterLock():
base/univention-updater/python/univention-repository-update:from univention.updater.locking import UpdaterLock
base/univention-updater/python/univention-repository-update:    with UpdaterLock():
base/univention-updater/python/univention-repository-create:from univention.updater.locking import UpdaterLock
base/univention-updater/python/univention-repository-create:    with UpdaterLock():
base/univention-updater/python/univention-updater:from univention.updater.locking import UpdaterLock
base/univention-updater/python/univention-updater:                with UpdaterLock():
base/univention-updater/python/univention-actualise:from univention.updater.locking import UpdaterLock
base/univention-updater/python/univention-actualise:        with UpdaterLock():
base/univention-updater/modules/univention/updater/locking.py:class UpdaterLock(object):
Comment 3 Arvid Requate univentionstaff 2020-07-07 17:58:27 CEST
This is exactly what happens when I start /usr/share/univention-updater/univention-updater-umc-dist-upgrade twice:

===================================================================================================================
Starting dist-upgrade at Di 7. Jul 17:51:50 CEST 2020
E: Konnte Sperre /var/lib/dpkg/lock-frontend nicht bekommen - open (11: Die Ressource ist zur Zeit nicht verfügbar)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

ERROR: An error occurred during update. Please check the logfiles.
===================================================================================================================

And the first process continues to update. This looks to me like the lock mechanism works exactly as intended.
The same happens when I start univention-upgrade while univention-updater-umc-dist-upgrade is running.


The second issue looks different and we will have to investigate this further:
==================================
Another case (second ticket) was quite more inconvenient; apt was broken:

Entpacken von apt (1.4.10A~4.4.0.202005191916) über (1.4.9A~4.3.3.201901230932) ...
dpkg: Fehler: dpkg-Status-Datenbank ist von einem anderen Prozess gesperrt
E: Sub-process /usr/bin/dpkg returned an error code (2
==================================
Comment 4 Arvid Requate univentionstaff 2020-07-07 18:27:17 CEST
We fixed a similar thing in Bug 43625#c2, where univention-upgrade --check, run periodically via cron, interfered. In this case it seems to be something else.

Maybe something like this, but I have no clue about the exact flow of this issue:

The shell script /usr/share/univention-updater/univention-updater-umc-dist-upgrade relies only on the apt-get/dpkg lock mechanisms, but doesn't check/use the locking mechanism that univention-upgrade (and the legacy script /usr/share/univention-updater/univention-updater-check) uses today, which uses the Python context manager univention.updater.locking.UpdaterLock to manage the file /var/lock/univention-updater.

This is the situation while univention-updater-umc-dist-upgrade relies is running:
===============================================================================
root@master10:~# lsof /var/lib/dpkg/lock-frontend
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
apt-get 19662 root    4uW  REG  253,0        0 523532 /var/lib/dpkg/lock-frontend

root@master10:~# lsof /var/lib/dpkg/lock
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
dpkg    19953 root    3uW  REG  253,0        0 523516 /var/lib/dpkg/lock

root@master10:~# lsof /var/lock/univention-updater
lsof: status error on /run/lock/univention-updater: No such file or directory

root@master10:~# ps fax
[...]
19659 pts/1    T      0:00  |       \_ /bin/sh /usr/share/univention-updater/univention-updater-umc-dist-upgrade
19662 pts/1    T      0:01  |       |   \_ apt-get -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-overwrite -o DPkg::Options::=--force-overwrite-dir --trivial-o
nly=no --assume-yes --quiet=1 -u dist-upgrade
19953 pts/2    Ss+    0:01  |       |       \_ /usr/bin/dpkg [...] --install [...]
[...]
===============================================================================
Comment 5 Dirk Schnick univentionstaff 2020-07-09 10:54:56 CEST
All customers started the update via UMC.
Second customer reports during phone call, that also app-updates did not work in the immediate past. After click on update button nothing happens in gui.