Database on SMB share is locked

Hello,

I am trying to setup SilverBullet on my Linux machine, while having the Space on a network drive (accessed through an SMB share). The mount of the space works properly, but SilverBullet seems incapable of accessing the database.

The user of the remote machine - the one I use to mount the folder - is UID 1000 and GID 100. For troubleshooting purposes, I ran chmod 777 on my Space directory, and .silverbullet.db, but I still get the same error.

Here is the command I am running on my machine, and the error:

➜  /mnt sudo docker run -it -p 3000:3000 -v /mnt/space:/space -e PUID=1000 -e PGID=100 zefhemel/silverbullet
Running SilverBullet as silverbullet (configured as PUID 1000 and PGID 100)
Unhandled rejection: PromiseRejectionEvent {
  bubbles: false,
  cancelable: true,
  composed: false,
  currentTarget: Window {},
  defaultPrevented: false,
  eventPhase: 2,
  srcElement: null,
  target: Window {},
  returnValue: true,
  timeStamp: 0,
  type: "unhandledrejection",
  promise: Promise {
    <rejected> Error: database is locked
    at async Object.openKv (ext:deno_kv/01_db.ts:10:15)
    at async ZX (file:///silverbullet.js:135:13238961)
    at async U.Nj [as actionHandler] (file:///silverbullet.js:135:13240503)
    at async U.execute (file:///silverbullet.js:24:8601)
    at async U.parseCommand (file:///silverbullet.js:24:6314)
    at async file:///silverbullet.js:183:6492
  },
  reason: Error: database is locked
    at async Object.openKv (ext:deno_kv/01_db.ts:10:15)
    at async ZX (file:///silverbullet.js:135:13238961)
    at async U.Nj [as actionHandler] (file:///silverbullet.js:135:13240503)
    at async U.execute (file:///silverbullet.js:24:8601)
    at async U.parseCommand (file:///silverbullet.js:24:6314)
    at async file:///silverbullet.js:183:6492
}

Any help would be greatly appreciated, thanks in advance.

It seems your database is locked. Possibly a network error in the middle of a write?

I’d suggest not having the db on a network share to avoid locking issues. You could map the db in the container to a local file and keep the rest of your space on a share.

You can try to unlock it with:

echo ".dump" | sqlite old.db | sqlite new.db

How could I separate the database and the space? I was under the impression that I have to mount the whole volume to the space, and that includes the .db file.

I fixed it, here is the modified command:

sudo docker run -it -p 3000:3000 \
  -v /home/john/Documents/space:/space \
  -v /home/john/Documents/db:/var/lib/silverbullet \
  -e PUID=1000 \
  -e PGID=100 \
  -e SB_KV_DB=/var/lib/silverbullet/silverbullet.db \
  zefhemel/silverbullet

I added -e SB_KV_DB=/var/lib/silverbullet/silverbullet.db and -v /home/john/Documents/db:/var/lib/silverbullet according to the documentation on this page: https://silverbullet.md/Install/Configuration#Database

1 Like

It’s not well known but you can also mount single file in docker container. However, the file needs to exist or docker will default to creating a folder.

So you could:

touch /home/john/Documents/db/silverbullet.db
sudo docker run -it -p 3000:3000 \
  -v /home/john/Documents/space:/space \
  -v /home/john/Documents/db/silverbullet.db:/space/.silverbullet.db \
  -e PUID=1000 \
  -e PGID=100 \
  zefhemel/silverbullet

2 Likes