apt frontend locking

Bug #1781169 reported by Julian Andres Klode on 2018-07-11
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Undecided
Unassigned
Xenial
Undecided
Unassigned
Bionic
Undecided
Unassigned

Bug Description

[Impact]
apt acquires /var/lib/dpkg/lock but has to release it while running dpkg, offering a short window for other clients to acquire the lock. This implements /var/lib/dpkg/lock-frontend which will be acquired earlier and not released by apt for dpkg to run.

dpkg will try to acquire the frontend lock as well, unless told not to do so via an environment variable, which apt does; hence concurrent runs of dpkg without other locking can't happen.

[Test case]
Run strace apt install $something and check that lock-frontend is acquired at the beginning and not released until the end.

[Regression potential]
Frontend locking failures are in English, as there are no translations yet. More locks also mean more potential for locking to go wrong across programs, but since we don't have any waiting locks we at least won't deadlock.

[Other info]
This is part of a wider series of SRUs for frontend locking

- dpkg (bug 1796081)
- apt (bug 1781169)
- python-apt (bug 1795407)
- packagekit (bug 1795614)
- unattended-upgrades (bug 1789637)
- aptdaemon (no bug filed yet)

Further details about frontend locking can be found in https://lists.debian.org/debian-dpkg/2017/01/msg00044.html

Changed in dpkg (Ubuntu):
status: New → In Progress
Changed in apt (Ubuntu):
status: New → In Progress
Changed in apt (Ubuntu):
status: In Progress → Fix Released
Changed in dpkg (Ubuntu):
status: In Progress → Fix Released
Changed in apt (Ubuntu Xenial):
status: New → Triaged
Changed in apt (Ubuntu Bionic):
status: New → Triaged
description: updated
Changed in apt (Ubuntu Xenial):
status: Triaged → In Progress
Changed in apt (Ubuntu Bionic):
status: Triaged → In Progress
tags: added: id-5bae2d02f32c4e3b0a036f61
no longer affects: dpkg (Ubuntu)

Hello Julian, or anyone else affected,

Accepted apt into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/apt/1.6.5 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in apt (Ubuntu Bionic):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-bionic
Łukasz Zemczak (sil2100) wrote :

Hello Julian, or anyone else affected,

Accepted apt into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/apt/1.2.28 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in apt (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed-xenial
Julian Andres Klode (juliank) wrote :

dpkg is moving to its own bug to be able to better track the SRUs

no longer affects: dpkg (Ubuntu Xenial)
no longer affects: dpkg (Ubuntu Bionic)
summary: - frontend locking
+ apt frontend locking
description: updated
description: updated
Julian Andres Klode (juliank) wrote :

Frontend locking causes a regression: dpkg::post-invoke and other related scripts can no longer install/remove packages, as they are now called with 'lock' released, but 'lock-frontend' not.

This needs a further change to set DPKG_FRONTEND_LOCKED for those scripts when the frontend lock is acquired.

tags: added: verification-failed verification-failed-bionic verification-failed-xenial
removed: verification-needed verification-needed-bionic verification-needed-xenial
Brian Murray (brian-murray) wrote :

Hello Julian, or anyone else affected,

Accepted apt into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/apt/1.2.29 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

tags: added: verification-needed verification-needed-xenial
removed: verification-failed verification-failed-xenial
Brian Murray (brian-murray) wrote :

Hello Julian, or anyone else affected,

Accepted apt into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/apt/1.6.6 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

tags: added: verification-needed-bionic
removed: verification-failed-bionic
Julian Andres Klode (juliank) wrote :

apt 1.6.6 from bionic: I verified that lock-frontend was opened and locked at the beginning, that lock was locked after it, lock released before dpkg is called, and that lock-frontend was not released until the end.

[...]
openat(AT_FDCWD, "/var/lib/dpkg/lock-frontend", O_RDWR|O_CREAT|O_NOFOLLOW, 0640) = 4
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
fcntl(4, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
openat(AT_FDCWD, "/var/lib/dpkg/lock", O_RDWR|O_CREAT|O_NOFOLLOW, 0640) = 5
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
fcntl(5, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
[ ... Reading files ... ]
close(5) = 0
[... running dpkg and rebuilding cache; no close(4) ]
close(4) = 0
close(5) = -1 EBADF (Bad file descriptor)
close(3) = 0
+++ exited with 0 +++

tags: added: verification-done-bionic
removed: verification-needed-bionic
Julian Andres Klode (juliank) wrote :

Same with 1.2.29 from xenial:

open("/var/lib/dpkg/lock-frontend", O_RDWR|O_CREAT|O_NOFOLLOW, 0640) = 4
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
fcntl(4, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
open("/var/lib/dpkg/lock", O_RDWR|O_CREAT|O_NOFOLLOW, 0640) = 5
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
fcntl(5, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
[...] reading files ]
close(5) = 0
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
fcntl(37, F_SETFD, FD_CLOEXEC) = 0
close(5) = 0
fcntl(37, F_GETFL) = 0x1 (flags O_WRONLY)
close(37) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3741, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
[ reading files and writing extended_states stuff; no close(4) ]
close(4) = 0
close(5) = -1 EBADF (Bad file descriptor)
close(3) = 0
+++ exited with 0 +++

tags: added: verification-done verification-done-xenial
removed: verification-needed verification-needed-xenial
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers