You are not logged in.

#1 2023-06-30 08:12:47

cdwijs
Member
Registered: 2010-04-24
Posts: 289

pacman: can packages be downloaded without locking the database?

I use pacman -Suy to update my system. This causes pacman to Synchronize package databases, then ask for confirmation about replaced packages, and confirmation to proceed with the update. Next pacman downloads the packages, and finally it installs them.

During this entire operation the pacman database is locked. This makes it impossible to install a small package while the updates for the entire system are being downloaded.

I would like to propose pacman to release the lock on the database while the packages are being downloading, and then try to acquire it again just before actually installing the packages.

This would enable my use case, but I wonder if this has the potential to create (big) problems.

Last edited by cdwijs (2023-06-30 08:13:47)

Offline

#2 2023-06-30 09:41:18

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,038

Re: pacman: can packages be downloaded without locking the database?

I expect it would cause big problems, but there are other solutions .

The pacman-contrib package from extra repo includes the checkupdates command .


Apart from checking which updates are needed it can also download them to the pacman cache.
It uses a separate database placed In TMPDIR so pacman database is NOT locked during the download .

This way you can separate downloading and updating, typically resulting in a much faster pacman -Syu run.

Last edited by Lone_Wolf (2023-06-30 09:41:58)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2023-06-30 10:22:09

cdwijs
Member
Registered: 2010-04-24
Posts: 289

Re: pacman: can packages be downloaded without locking the database?

Lone_Wolf wrote:

I expect it would cause big problems, but there are other solutions . The pacman-contrib package from extra repo includes the checkupdates command .

Thanks for the suggestion of checkupdates, I'll look into it.

I can think of two potential problems when the updating pacman drops the database lock while downloading.
1) The other instance of pacman that's installing another package could still hold the lock while the updating pacman finished downloading. The updating pacman should then error out, and the user should then restart the updating pacman, preferably after the installing pacman is finished.

2) There could be a race condition when both the installing and the updating pacman are done downloading at the exact same time, and both trying to obtain the lock of the package database. How robust/atomic is the mechanism for grabbing and releasing the lock? is it possible both pacman's end up obtaining the lock, and then stepping on each others toes, corrupting the database?

i think scenario 1) is no problem. Is scenario 2 possible?

Offline

#4 2023-06-30 12:41:09

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,652
Website

Re: pacman: can packages be downloaded without locking the database?

Those are not the problems you should really be concerned with.  The real problem is that you would - by definition - be doing a partial upgrade which is likely to cause problems.  This is (one of) the reasons the database is locked in the first place: they sync has been completed but the update has not - this is not a good condition to leave it in for other processes to use.

In any case, there's no point in trying to enumerate all the different ways the wrong way of doing something could fail. Just do it the right way as advised (with checkupdates, or a similar tool using it's own db).

Last edited by Trilby (2023-06-30 12:43:42)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2023-06-30 13:10:08

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,931

Re: pacman: can packages be downloaded without locking the database?

Also how often - and why - are you in the situation where you wanted to on a whim install an additional piece of software outside of the standard update transacton while having one running? If you want to install a tool and - correctly - note you'd need to update the system first, what prevents you from adding your desired installation target to the initial -Syu invocation so everything gets updated and installed properly in one go?

Online

Board footer

Powered by FluxBB