Error: failed to synchronize all databases (unable to lock database)

Hello Garuda users.

Please read the following template before requesting assistance:

Please post the terminal/konsole input and output as text (no pictures) from the the following command:

[πŸ”΄] Γ— garuda-inxi
System:
Kernel: 5.18.15-zen1-2-zen arch: x86_64 bits: 64
compiler: gcc v: 12.1.1
parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
root=UUID=e08ba235-2d5b-4752-aa8a-d6235cb506f3 rw
[email protected] quiet quiet splash
rd.udev.log_priority=3 vt.global_cursor_default=0
resume=UUID=7b1d8874-5890-4209-abcb-ae4c25bdcc93 loglevel=3
ibt=off systemd.unified_cgroup_hierarchy=1
Desktop: KDE Plasma v: 5.25.4 tk: Qt v: 5.15.5
info: latte-dock wm: kwin_x11 vt: 1 dm: SDDM
Distro: Garuda Linux base: Arch Linux
Machine:
Type: Desktop Mobo: Micro-Star model: B450M PRO-M2 MAX
(MS-7B84) v: 2.0 serial: <superuser required>
UEFI: American Megatrends v: A.70 date: 06/10/2020
CPU:
Info: model: AMD Ryzen 7 3800X bits: 64 type: MT MCP
arch: Zen 2 gen: 3 built: 2020-22 process: TSMC n7 (7nm)
family: 0x17 (23) model-id: 0x71 (113) stepping: 0
microcode: 0x8701021
Topology: cpus: 1x cores: 8 tpc: 2 threads: 16 smt: enabled
cache: L1: 512 KiB desc: d-8x32 KiB; i-8x32 KiB L2: 4 MiB
desc: 8x512 KiB L3: 32 MiB desc: 2x16 MiB
Speed (MHz): avg: 4111 high: 4342 min/max: 2200/4559
boost: enabled scaling: driver: acpi-cpufreq
governor: performance cores: 1: 4342 2: 4273 3: 3994
4: 4192 5: 3966 6: 4054 7: 4089 8: 4260 9: 3657 10: 3818
11: 4338 12: 4321 13: 4280 14: 4054 15: 3809 16: 4333
bogomips: 124805
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2
sse4a ssse3 svm
Vulnerabilities:
Type: itlb_multihit status: Not affected
Type: l1tf status: Not affected
Type: mds status: Not affected
Type: meltdown status: Not affected
Type: mmio_stale_data status: Not affected
Type: retbleed mitigation: untrained return thunk; SMT
enabled with STIBP protection
Type: spec_store_bypass mitigation: Speculative Store
Bypass disabled via prctl
Type: spectre_v1 mitigation: usercopy/swapgs barriers and
__user pointer sanitization
Type: spectre_v2 mitigation: Retpolines, IBPB: conditional,
STIBP: always-on, RSB filling
Type: srbds status: Not affected
Type: tsx_async_abort status: Not affected
Graphics:
Device-1: NVIDIA TU117 [GeForce GTX 1650] driver: nvidia
v: 515.57 alternate: nouveau,nvidia_drm non-free: 515.xx+
status: current (as of 2022-07) arch: Turing code: TUxxx
process: TSMC 12nm built: 2018-22 pcie: gen: 3
speed: 8 GT/s lanes: 16 bus-ID: 29:00.0 chip-ID: 10de:1f82
class-ID: 0300
Device-2: Sunplus Innovation FULL HD webcam type: USB
driver: snd-usb-audio,uvcvideo bus-ID: 1-5:2
chip-ID: 1bcf:2283 class-ID: 0102 serial: <filter>
Display: x11 server: X.Org v: 21.1.4 with: Xwayland
v: 22.1.3 compositor: kwin_x11 driver: X: loaded: nvidia
unloaded: modesetting alternate: fbdev,nouveau,nv,vesa
gpu: nvidia display-ID: :0 screens: 1
Screen-1: 0 s-res: 4920x2160 s-dpi: 156
s-size: 801x352mm (31.54x13.86") s-diag: 875mm (34.45")
Monitor-1: DP-0 pos: primary,right res: 3840x2160 hz: 60
dpi: 161 size: 607x345mm (23.9x13.58") diag: 698mm (27.49")
modes: N/A
Monitor-2: DP-2 pos: primary,left res: 1080x1920 hz: 60
dpi: 96 size: 286x509mm (11.26x20.04") diag: 584mm (22.99")
modes: N/A
OpenGL: renderer: NVIDIA GeForce GTX 1650/PCIe/SSE2 v: 4.6.0
NVIDIA 515.57 direct render: Yes
Audio:
Device-1: NVIDIA driver: snd_hda_intel v: kernel
bus-ID: 1-5:2 pcie: gen: 3 chip-ID: 1bcf:2283 speed: 8 GT/s
class-ID: 0102 serial: <filter> lanes: 16 bus-ID: 29:00.1
chip-ID: 10de:10fa class-ID: 0403
Device-2: AMD Starship/Matisse HD Audio
vendor: Micro-Star MSI driver: snd_hda_intel v: kernel pcie:
gen: 4 speed: 16 GT/s lanes: 16 bus-ID: 2b:00.4
chip-ID: 1022:1487 class-ID: 0403
Device-3: Sunplus Innovation FULL HD webcam type: USB
driver: snd-usb-audio,uvcvideo
Sound Server-1: ALSA v: k5.18.15-zen1-2-zen running: yes
Sound Server-2: PulseAudio v: 16.1 running: no
Sound Server-3: PipeWire v: 0.3.56 running: yes
Network:
Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit
Ethernet vendor: Micro-Star MSI driver: r8169 v: kernel
pcie: gen: 1 speed: 2.5 GT/s lanes: 1 port: f000
bus-ID: 25:00.0 chip-ID: 10ec:8168 class-ID: 0200
IF: enp37s0 state: up speed: 100 Mbps duplex: full
mac: <filter>
IF-ID-1: br-657335f7a75a state: up speed: 10000 Mbps
duplex: unknown mac: <filter>
IF-ID-2: docker0 state: up speed: 10000 Mbps
duplex: unknown mac: <filter>
IF-ID-3: veth540d873 state: up speed: 10000 Mbps
duplex: full mac: <filter>
IF-ID-4: veth5a6f624 state: up speed: 10000 Mbps
duplex: full mac: <filter>
IF-ID-5: veth814cdb9 state: up speed: 10000 Mbps
duplex: full mac: <filter>
IF-ID-6: veth86cc3d9 state: up speed: 10000 Mbps
duplex: full mac: <filter>
IF-ID-7: veth922ac7e state: up speed: 10000 Mbps
duplex: full mac: <filter>
IF-ID-8: vethaf95155 state: up speed: 10000 Mbps
duplex: full mac: <filter>
IF-ID-9: vethd08a5e8 state: up speed: 10000 Mbps
duplex: full mac: <filter>
IF-ID-10: virbr0 state: down mac: <filter>
Bluetooth:
Device-1: Realtek Bluetooth Radio type: USB driver: btusb
v: 0.8 bus-ID: 1-6:3 chip-ID: 0bda:8771 class-ID: e001
serial: <filter>
Report: bt-adapter ID: hci0 rfk-id: 0 state: up
address: <filter>
Drives:
Local Storage: total: 5.46 TiB used: 324.39 GiB (5.8%)
SMART Message: Unable to run smartctl. Root privileges
required.
ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Kingston
model: SA2000M81000G size: 931.51 GiB block-size:
physical: 512 B logical: 512 B speed: 31.6 Gb/s lanes: 4
type: SSD serial: <filter> rev: S5Z42105 temp: 46.9 C
scheme: GPT
ID-2: /dev/sda maj-min: 8:0 vendor: Samsung model: SSD 860
EVO 1TB size: 931.51 GiB block-size: physical: 512 B
logical: 512 B speed: 6.0 Gb/s type: SSD serial: <filter>
rev: 4B6Q scheme: GPT
ID-3: /dev/sdb maj-min: 8:16 vendor: Seagate
model: ST4000DM004-2CV104 size: 3.64 TiB block-size:
physical: 4096 B logical: 512 B speed: 6.0 Gb/s type: HDD
rpm: 5425 serial: <filter> rev: 0001 scheme: GPT
Partition:
ID-1: / raw-size: 175.44 GiB size: 175.44 GiB (100.00%)
used: 96.81 GiB (55.2%) fs: btrfs dev: /dev/nvme0n1p7
maj-min: 259:7
ID-2: /boot/efi raw-size: 350.3 MiB size: 349.5 MiB
(99.80%) used: 576 KiB (0.2%) fs: vfat dev: /dev/nvme0n1p4
maj-min: 259:4
ID-3: /home raw-size: 273.44 GiB size: 273.44 GiB (100.00%)
used: 207.85 GiB (76.0%) fs: btrfs dev: /dev/nvme0n1p6
maj-min: 259:6
ID-4: /var/log raw-size: 175.44 GiB size: 175.44 GiB
(100.00%) used: 96.81 GiB (55.2%) fs: btrfs
dev: /dev/nvme0n1p7 maj-min: 259:7
ID-5: /var/tmp raw-size: 175.44 GiB size: 175.44 GiB
(100.00%) used: 96.81 GiB (55.2%) fs: btrfs
dev: /dev/nvme0n1p7 maj-min: 259:7
Swap:
Kernel: swappiness: 133 (default 60)
cache-pressure: 100 (default)
ID-1: swap-1 type: zram size: 31.3 GiB used: 5.2 MiB (0.0%)
priority: 100 dev: /dev/zram0
ID-2: swap-2 type: partition size: 15.82 GiB used: 0 KiB
(0.0%) priority: -2 dev: /dev/nvme0n1p5 maj-min: 259:5
Sensors:
System Temperatures: cpu: 66.2 C mobo: N/A gpu: nvidia
temp: 47 C
Fan Speeds (RPM): N/A gpu: nvidia fan: 32%
Info:
Processes: 724 Uptime: 50m wakeups: 0 Memory: 31.3 GiB
used: 17.22 GiB (55.0%) Init: systemd v: 251
default: graphical tool: systemctl Compilers: gcc: 12.1.1
alt: 11 clang: 14.0.6 Packages: pacman: 2111 lib: 558
Shell: fish v: 3.5.1 default: Bash v: 5.1.16
running-in: konsole inxi: 3.3.20
Garuda (2.6.5-1):
System install date:     2022-06-07
Last full system update: 2022-08-03
Is partially upgraded:   No
Relevant software:       NetworkManager
Windows dual boot:       Probably (Run as root to verify)
Snapshots:               Snapper
Failed units:

I saw this error initially when I ran my morning update command:

[πŸ”΄] Γ— update
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)

--> Refreshing mirrorlists using rate-mirrors, please be patient..
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)

Failed to update mirrorlist
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)
spawn pacman -Su -y
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)
expect: spawn id exp4 not open
while executing
"expect {
-re {Replace \S+ with \S+ \[Y\/n\]} { send "y\r"; exp_continue }
"resolving dependencies..." { }
timeout { }
eof doExit
}"
(file "/usr/lib/garuda/garuda-update/auto-pacman" line 48)

Then I tried updating garuda-update:

[πŸ”΄] Γ— sudo pacman -Syu garuda-update
[sudo] password for can:       
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)

pacman worked fine yesterday, not sure what changed. It runs fine in my other system.

I tried refreshing my mirror list with Garuda Assistant, didn't help.

So, you've tried neither forum search nor internet search, yes?
I suggest you start there.
And I see you haven't tried a reboot either, yes?

2 Likes

I just booted my PC, why would I reboot? I have checked the forum, and nothing coincides with my errors.

Saw one post where the person deletes the .db file, but pacman prompts this as safe if no other instance of the package manager is running. It didn't for me.

Furthermore, I deemed it unsafe to delete the db.lck (edited to correct file name) file. Am I wrong? Excuse me for being cautious, I don't want to destroy my work-env during work hours.

Additionally, I don't want to step out of the Garuda forum for issues like this. I usually get the door slapped on my face when saying I am coming from Garuda on Arch forums. This should be documented on the Garuda side anyway, I really don't get the reason for the attitude.

Just don't bother with posts if it conflicts with your principles.

You just made my point, yet you get gave your peer a like. Why? What is wrong guys, I am not impatient. I just wanted to document my issue, and get some help in return. Fine, I'll fix it myself, this community is too pedantic.

Can't we just learn together? I did absolutely nothing to my pacman install, and this occurred. I find that very interesting, I hoped you would too.

Have you tried

sudo rm  /var/lib/pacman/db.lck

This removes the lock of the db not the db.
Close the currently open update sessions before.

3 Likes

As mentioned, I deemed it unsafe because I didn't get a prompt for deletion upon the error.

I noticed that I referred to the db file in my earlier post, but I meant the lck file.

https://wiki.archlinux.org/title/Pacman#"Failed_to_init_transaction_(unable_to_lock_database)"_error

https://forum.garudalinux.org/search?context=topic&context_id=21202&q=%22unable%20to%20lock%20database%22%20status:solved&skip_context=true

All saying the same...
Enough?

3 Likes

I didn't get this part:

 if you're sure a package manager is not already
 running, you can remove /var/lib/pacman/db.lck

Re-ran it just for you:

╰─λ sudo pacman -Syu
Garuda Linux is updated via the "garuda-update" command instead of pacman -Syu. https://wiki.garudalinux.org/en/garuda-update
Would you like to run "garuda-update" instead? (i = never ask again/ignore) [y/N/i]
[sudo] password for can:
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)

I am not just going to copy-paste some code, and hope it works. Does garuda-update re-lock the db?

PS: I like the prompt to use garuda-update!

Yes, actually pacman does it, then release it. From the wiki link

When pacman is about to alter the package database, for example installing a package, it creates a lock file

ps -A | grep pacman
31227 pts/1    00:00:00 auto-pacman
31228 pts/2    00:00:00 pacman

So deleting the .lck file is 100% safe?

I must admit, I could've found this out by myself. Apologies.

Some text for discourse.

1 Like

If you are ever unsure about how safe it is to remove a file that is owned by root, you can always reame it, rather than deleting it. That way you can always restore it if there is a problem. This is a habit you should get into, especially before altering/deleting any root configuration file. Best to always back it up first.

1 Like

No, it's safe under the conditions written on the arch wiki. Otherwise it could corrupt your local database, which is, trust me, not a good time.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.