"apt-get update" fails if another instance is running

Bug #1939665 reported by Avi Kivity
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Triaged
Wishlist
Unassigned

Bug Description

This snippet:

     sudo apt-get update & sudo apt-get update & wait; wait

will result in one apt-get run succeeding and the other failing on the lock:

[1] 3006473
[2] 3006474
Hit:1 http://ports.ubuntu.com/ubuntu-ports groovy InRelease
Hit:2 http://ports.ubuntu.com/ubuntu-ports groovy-backports InRelease
Hit:3 http://ports.ubuntu.com/ubuntu-ports groovy-security InRelease
Hit:4 http://ports.ubuntu.com/ubuntu-ports groovy-updates InRelease
Reading package lists... Done
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 3006476 (apt-get)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to lock directory /var/lib/apt/lists/
Reading package lists... Done
[1]- Done sudo apt-get update
[2]+ Exit 100 sudo apt-get update

Note that apt-get upgrade will correctly wait.

ProblemType: Bug
DistroRelease: Ubuntu 20.10
Package: apt 2.1.10ubuntu0.3
ProcVersionSignature: Ubuntu 5.8.0-48.54-generic 5.8.18
Uname: Linux 5.8.0-48-generic aarch64
ApportVersion: 2.20.11-0ubuntu50.7
Architecture: arm64
CasperMD5CheckResult: skip
Date: Thu Aug 12 07:50:16 2021
ProcEnviron:
 LC_TIME=C.UTF-8
 TERM=xterm-256color
 PATH=(custom, no user)
 LANG=C.UTF-8
 SHELL=/bin/bash
SourcePackage: apt
UpgradeStatus: Upgraded to groovy on 2021-03-25 (139 days ago)

Revision history for this message
Avi Kivity (a-avi) wrote :
Revision history for this message
Chris Guiver (guiverc) wrote :

Thank you for reporting this bug to Ubuntu.

Ubuntu 20.10 (groovy) reached end-of-life on July 22, 2021.

See this document for currently supported Ubuntu releases:
https://wiki.ubuntu.com/Releases

We appreciate that this bug may be old and you might not be interested in discussing it any more. But if you are then please upgrade to the latest Ubuntu version and re-test. If you then find the bug is still present in the newer Ubuntu version, please re-report the issue using `ubuntu-bug`.

Changed in apt (Ubuntu):
status: New → Invalid
Revision history for this message
Chris Guiver (guiverc) wrote :

Please note: I see your issue as being opinion & expected behavior. Many users use the conditional "&&" in commands like yours as it can be considered safer.

Revision history for this message
Julian Andres Klode (juliank) wrote (last edit ):

Please ignore Chris (well, do upgrade though, 20.10 is oooold, it hasn't seen security updates in months)

I understand your report, I only implemented lock waiting for the dpkg lock, not for the list lock that update holds.

Note that apt-get generally doesn't wait for the lock, only apt does (you can pass/set options to make apt-get behave the same).

I'm not sure update lock waiting is necessary - there's little point in running update again if you are already updating. It makes sense for install, because you might just want to schedule two installs.

OTOH, I can see you writing a script that does update and install, and which breaks because apt-daily.service is running in the background.

Changed in apt (Ubuntu):
status: Invalid → Triaged
importance: Undecided → Wishlist
Revision history for this message
Avi Kivity (a-avi) wrote :

In practice the two processes that run apt-get update are unaware of each other. When I'm updating of course I wouldn't intentionally run two instances in parallel. Indeed the other process is likely apt-daily.service.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.