Apt lists lock held by python
In my laptop I run Debian Sid. A long time ago I decided to update it only on Sundays afternoon, so if any bugs that
might have appeared during the week would have most probability of being either known or already fixed (but probably
also means that more bugs can be introduced, assuming Debian Developers work mostly during weekends, so...). I mostly
use aptitude
but if I have to be honest, I miss the dependency dialogs from dselect
: when you selected a package with
missing dependencies, a new window showing the automatically added dependencies and also the Recommends
and
Suggests
(mostly because I configured it so Recommends
were not selected automatically).
Yesterday I forgot to do the upgrade, so I tried it today. To my surprise, I got this error:
┌────────────────────────────────────────────────────────────────────────────────────────┐ │E: Could not get lock /var/lib/apt/lists/lock. It is held by process 2415644 (python3) ▒│ │W: 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/ ▒│ │ [ Ok ] │ └────────────────────────────────────────────────────────────────────────────────────────┘
I checked all my open terminals for any stray apt
or aptitude
running, but I didn't find any. Then I realized it was
talking about a python3
process, but both tools are developed in C++. Who's the culprit?
$ ps faux | grep -C 5 2415644 root 2415643 0.0 0.0 9468 3500 ? Ss 13:04 0:00 /bin/bash -c /usr/share/prometheus-node-exporter-collectors/apt_info.py | sponge /var/lib/prometheus/node-exporter/apt.prom root 2415644 0.5 0.2 90600 76512 ? S 13:04 0:00 \_ python3 /usr/share/prometheus-node-exporter-collectors/apt_info.py _apt 2415651 0.0 0.0 27652 12856 ? S 13:04 0:00 | \_ /usr/lib/apt/methods/https _apt 2415652 0.0 0.0 27628 12820 ? S 13:04 0:00 | \_ /usr/lib/apt/methods/https _apt 2415653 0.0 0.0 17452 5840 ? S 13:04 0:00 | \_ /usr/lib/apt/methods/file _apt 2415654 0.0 0.0 24400 9564 ? S 13:04 0:00 | \_ /usr/lib/apt/methods/https _apt 2415655 0.0 0.0 27624 12972 ? S 13:04 0:00 | \_ /usr/lib/apt/methods/https
prometheus-node-exporter-collectors
runs every 15m and locks the db. So this is a transient error, although it doesn't
go away very quickly. I think I tried 2 or 3 times, then I started writing this post, then I tried again and it worked.
Good to know.