pkg icon indicating copy to clipboard operation
pkg copied to clipboard

/var/cache/pkg should be locked while fetching occurs

Open yurivict opened this issue 4 years ago • 2 comments

Currently locking is done based on /var/db/pkg. However, /var/db/pkg and /var/cache/pkg contain different types of information. Package databases may be separate (for example, in different jails), but cache may be shared between them to reduce network downloads.

In such case the errors like this occur:

[4/153] Fetching nvidia-driver-390.87_3.txz: 100%   89 MiB   4.7MB/s    00:20    
pkg: cached package nvidia-driver-390.87_3: size mismatch, cannot continue
failed to install the requested packages into the jail: the command failed with the exit status 768

yurivict avatar Jul 26 '19 08:07 yurivict

Actually, I don't understand why any locking is needed during the fetch phase. With my typical download speeds (~20-100kB/s) it's really a PITA to do any other work on ports (e.g. running portupgrade) while fetching packages because of this.

Feel free to briefly obtain the lock and verify that nothing bad had happened after the download, but please do not hold the lock while download is in progress. It's generally considered bad practice to hold locks for arbitrarily long periods of time.

danfe avatar Jun 28 '20 09:06 danfe

Actually, I don't understand why any locking is needed during the fetch phase.

Because 2 or more different processes would be fetching the same file at the same time and conflict with each other. Currently it's only pkg and it locks the other directory, but pkg can be run from jail that shares /var/cache/pkg with the host system.

yurivict avatar Jun 29 '20 06:06 yurivict