Recover from a pacman lock left behind by a power cut
A machine switched off mid-update leaves /var/lib/pacman/db.lck behind. Nothing removed it, so every subsequent run deferred on it - one power cut would have stopped updates permanently and silently, which on an unattended machine is the worst outcome there is. A lock older than the current boot is provably abandoned: no process that could hold it still exists. Those are now removed and the interrupted upgrade is repeated, with pacman reinstalling anything caught half-written. A lock that is merely unheld within the same boot stays untouched and is only reported, since removing it could corrupt a live transaction; the boot-time test is what makes the difference between a proof and a guess. A fuser check is kept alongside it so a backwards clock jump cannot make a live lock look abandoned. Documented what each layer can actually promise: suspend and normal shutdown are blocked by the existing inhibitor, a hard power-off cannot be prevented by anything, and snap-pac's pre/post snapshots remain the backstop.
This commit is contained in:
1 parent
6514c4d859
commit
0f91a79ba6
7 files changed
+120
-5
No files matched your search
@@ -100,6 +100,26 @@ running are skipped.
|
||||
The machine is never restarted automatically. When a kernel update makes a
|
||||
restart necessary, a notification says so.
|
||||
|
||||
# INTERRUPTED UPDATES
|
||||
|
||||
While a transaction is running, *cachy-auto-update* holds a
|
||||
*systemd-inhibit*(1) lock on _sleep_ and _shutdown_ in blocking mode, so a
|
||||
suspend, a lid close or a normal shutdown request cannot cut it short.
|
||||
|
||||
A hard power-off - holding the power button, or losing mains power - is not
|
||||
preventable. On the next run a leftover _/var/lib/pacman/db.lck_ is removed if
|
||||
it is older than the current boot, since no process able to hold it can still
|
||||
exist; the upgrade is then repeated and pacman reinstalls whatever was caught
|
||||
half-written. A lock file that is unheld but was created during the current
|
||||
boot is reported rather than removed, because there is no way to prove it is
|
||||
abandoned.
|
||||
|
||||
Without that recovery a single power cut would leave a lock that makes every
|
||||
subsequent run defer, silently stopping updates for good.
|
||||
|
||||
On Btrfs with *snapper*(8) and *snap-pac*, each pacman transaction is bracketed
|
||||
by a pre and post snapshot, so a broken upgrade remains rollbackable.
|
||||
|
||||
# FILES
|
||||
|
||||
_/etc/cachy-auto-update/cachy-auto-update.conf_
|
||||
|
||||
Reference in new issue
Block a user