#933335 aptitude: Please add support for dpkg frontend lock

Package:
aptitude
Source:
aptitude
Description:
terminal-based package manager
Submitter:
Vincent Lefevre
Date:
2025-12-28 16:47:03 UTC
Severity:
important
Tags:
#933335#5
Date:
2019-07-29 11:47:05 UTC
From:
To:
I wanted to upgrade with aptitude, but it failed with the error
"dpkg: error: dpkg frontend lock is locked by another process".

In the terminal:

Performing actions...
Retrieving bug reports... Done
Parsing Found/Fixed information... Done
Retrieving bug reports... Done
Parsing Found/Fixed information... Done
Reading changelogs... Done
apt-listchanges: Do you want to continue? [Y/n]
Extracting templates from packages: 100%
Preconfiguring packages ...
(Reading database ... 588715 files and directories currently installed.)
Preparing to unpack .../bsdutils_1%3a2.34-0.1_amd64.deb ...
Unpacking bsdutils (1:2.34-0.1) over (1:2.33.1-0.1) ...
Setting up bsdutils (1:2.34-0.1) ...
(Reading database ... 588715 files and directories currently installed.)
Preparing to unpack .../0-uuid-dev_2.34-0.1_amd64.deb ...
Unpacking uuid-dev:amd64 (2.34-0.1) over (2.33.1-0.1) ...
Preparing to unpack .../1-libuuid1_2.34-0.1_amd64.deb ...
De-configuring libuuid1:i386 (2.33.1-0.1) ...
Unpacking libuuid1:amd64 (2.34-0.1) over (2.33.1-0.1) ...
Preparing to unpack .../2-libuuid1_2.34-0.1_i386.deb ...
Unpacking libuuid1:i386 (2.34-0.1) over (2.33.1-0.1) ...
Preparing to unpack .../3-libblkid-dev_2.34-0.1_amd64.deb ...
Unpacking libblkid-dev:amd64 (2.34-0.1) over (2.33.1-0.1) ...
Preparing to unpack .../4-libblkid1_2.34-0.1_i386.deb ...
De-configuring libblkid1:amd64 (2.33.1-0.1) ...
Unpacking libblkid1:i386 (2.34-0.1) over (2.33.1-0.1) ...
Preparing to unpack .../5-libblkid1_2.34-0.1_amd64.deb ...
Unpacking libblkid1:amd64 (2.34-0.1) over (2.33.1-0.1) ...
Setting up libblkid1:amd64 (2.34-0.1) ...
Setting up libblkid1:i386 (2.34-0.1) ...
(Reading database ... 588715 files and directories currently installed.)
Preparing to unpack .../libmount-dev_2.34-0.1_amd64.deb ...
Unpacking libmount-dev:amd64 (2.34-0.1) over (2.33.1-0.1) ...
Preparing to unpack .../libmount1_2.34-0.1_amd64.deb ...
De-configuring libmount1:i386 (2.33.1-0.1) ...
Unpacking libmount1:amd64 (2.34-0.1) over (2.33.1-0.1) ...
Preparing to unpack .../libmount1_2.34-0.1_i386.deb ...
Unpacking libmount1:i386 (2.34-0.1) over (2.33.1-0.1) ...
Preparing to unpack .../libsmartcols1_2.34-0.1_amd64.deb ...
Unpacking libsmartcols1:amd64 (2.34-0.1) over (2.33.1-0.1) ...
Setting up libsmartcols1:amd64 (2.34-0.1) ...
(Reading database ... 588715 files and directories currently installed.)
Preparing to unpack .../libfdisk1_2.34-0.1_amd64.deb ...
Unpacking libfdisk1:amd64 (2.34-0.1) over (2.33.1-0.1) ...
Setting up libuuid1:amd64 (2.34-0.1) ...
Setting up libuuid1:i386 (2.34-0.1) ...
Setting up libfdisk1:amd64 (2.34-0.1) ...
(Reading database ... 588715 files and directories currently installed.)
Preparing to unpack .../fdisk_2.34-0.1_amd64.deb ...
Unpacking fdisk (2.34-0.1) over (2.33.1-0.1) ...
Setting up libmount1:amd64 (2.34-0.1) ...
Setting up libmount1:i386 (2.34-0.1) ...
Setting up fdisk (2.34-0.1) ...
(Reading database ... 588715 files and directories currently installed.)
Preparing to unpack .../util-linux_2.34-0.1_amd64.deb ...
Unpacking util-linux (2.34-0.1) over (2.33.1-0.1) ...
dpkg: error: dpkg frontend lock is locked by another process
======  How can you help?  (doc: https://wiki.debian.org/how-can-i-help ) ======

New bugs where assistance is requested (tagged 'help'):
 - bsdutils - https://bugs.debian.org/198559 - script should set an environment variable that shells can use
 - bsdutils - https://bugs.debian.org/254199 - /usr/bin/script: please consider setting an envvar
 - mount - https://bugs.debian.org/863373 - mount: option to use losetup -P when mounting
 - mount - https://bugs.debian.org/870364 - say "... is already mounted rw elsewhere. Cannot mount ro."
 - mount - https://bugs.debian.org/907536 - Update fstab template & docs to mention systemctl daemon-reload
-----  Show old opportunities as well as new ones: how-can-i-help --old  -----
E: Sub-process /usr/bin/dpkg returned an error code (2)
Setting up uuid-dev:amd64 (2.34-0.1) ...
Setting up util-linux (2.34-0.1) ...
Setting up libblkid-dev:amd64 (2.34-0.1) ...
Setting up libmount-dev:amd64 (2.34-0.1) ...
Processing triggers for libc-bin (2.28-10) ...
Processing triggers for systemd (241-7) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for mime-support (3.62) ...
Press Return to continue, 'q' followed by Return to quit.

Note: I was not using dpkg/aptitude/... in another terminal.

/var/log/dpkg.log shows:

[...]
2019-07-29 13:19:11 upgrade util-linux:amd64 2.33.1-0.1 2.34-0.1
2019-07-29 13:19:11 status half-configured util-linux:amd64 2.33.1-0.1
2019-07-29 13:19:11 status unpacked util-linux:amd64 2.33.1-0.1
2019-07-29 13:19:11 status half-installed util-linux:amd64 2.33.1-0.1
2019-07-29 13:19:11 status triggers-pending systemd:amd64 241-7
2019-07-29 13:19:11 status triggers-pending mime-support:all 3.62
2019-07-29 13:19:12 status unpacked util-linux:amd64 2.34-0.1
2019-07-29 13:19:15 startup packages configure
2019-07-29 13:19:15 configure uuid-dev:amd64 2.34-0.1 <none>
[...]

Thus the error occurred around 13:19:12 (BTW, error messages should
include the date/time).

In "journalctl -b" logs, I can see:

Jul 29 13:19:12 cventin systemd[1]: Reloading.
Jul 29 13:19:12 cventin systemd[1]: Starting Daily apt download activities...
Jul 29 13:19:13 cventin systemd[1]: apt-daily.service: Succeeded.
Jul 29 13:19:13 cventin systemd[1]: Started Daily apt download activities.
Jul 29 13:19:15 cventin systemd[1]: Reloading.
Jul 29 13:19:15 cventin systemd[1]: Reloading.
Jul 29 13:19:16 cventin systemd[1]: Reloading.

I can see other "Starting Daily apt download activities...", and
another one also occurred just before "startup packages configure":

Jul 23 10:19:45 cventin systemd[1]: Starting Daily apt download activities...

2019-07-23 10:19:46 startup packages configure

So I would say that this is not just random.

In any case, the lock should start at the beginning of the upgrade
so that the upgrade cannot be interrupted.

#933335#10
Date:
2019-07-29 16:55:54 UTC
From:
To:
Hi!

This is a problem with aptitude, which I'm told has not been modified
to make use of the new frontend locks, so it suffers from the
historical race conditions when more than one frontend are running
concurrently. I've lowered the severity due to this.

I'm leaving all report for context.

Thanks,
Guillem

#933335#37
Date:
2023-05-26 01:22:48 UTC
From:
To:
Just to say that this still occurs.

The error message is now

[...]
Setting up apt (2.6.1) ...
dpkg: error: dpkg frontend lock was locked by another process with pid 4191235
Note: removing the lock file is always wrong, can damage the locked area
and the entire system. See <https://wiki.debian.org/Teams/Dpkg/FAQ#db-lock>.
E: Sub-process /usr/bin/dpkg returned an error code (2)
[...]

#933335#44
Date:
2025-12-28 16:45:24 UTC
From:
To:
Control: tag -1 patch

Please find attached a patch for aptitude that reworks the locking
logic to keep the frontend lock once acquired and only release the
inner lock; adjusting the manual dpkg --set-selections call as well
to adhere to the protocol of passing DPKG_FRONTEND_LOCKED as needed.

I've done some testing with the remove command in text mode and
curses UI, and it seems to do the right thing, but please do some
more testing.

Thanks!