[Bug]: Lock file is already being held #844

Closed
opened 2026-04-24 23:23:50 +02:00 by adam · 31 comments
Owner

Originally created by @barelylit on GitHub (Dec 28, 2022).

Describe the issue

image

Lots and lots of lock file already being held, happens quite freqeuently, restarting the container is the only thing that seems to sort it, temporarily

Steps to reproduce the issue

  1. Just playing using the android app

Audiobookshelf version

v2.2.11

How are you running audiobookshelf?

Docker

Originally created by @barelylit on GitHub (Dec 28, 2022). ### Describe the issue ![image](https://user-images.githubusercontent.com/101836977/209783542-81adb34e-6dec-4ef0-8e6d-df20605d7169.png) Lots and lots of lock file already being held, happens quite freqeuently, restarting the container is the only thing that seems to sort it, temporarily ### Steps to reproduce the issue 1. Just playing using the android app ### Audiobookshelf version v2.2.11 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:23:50 +02:00
adam closed this issue 2026-04-24 23:23:51 +02:00
Author
Owner

@advplyr commented on GitHub (Dec 30, 2022):

Are you using a USB connected hard drive on Windows file system? As mentioned here #1095

@advplyr commented on GitHub (Dec 30, 2022): Are you using a USB connected hard drive on Windows file system? As mentioned here #1095
Author
Owner

@barelylit commented on GitHub (Dec 30, 2022):

For library, yes. For config, no:

version: "3.7"
services:
audiobookshelf:
image: ghcr.io/advplyr/audiobookshelf:latest
environment:
- AUDIOBOOKSHELF_UID=99
- AUDIOBOOKSHELF_GID=100
ports:
- 4517:80
volumes:
- z:\Books:/audiobooks
- Z:\Family\JoeyBooks:/joey
- c:\docker\audiobookshelf\config:/config
- c:\docker\audiobookshelf\metadata:/metadata

c:\ is a 500gb Crucial SSD

@barelylit commented on GitHub (Dec 30, 2022): For library, yes. For config, no: version: "3.7" services: audiobookshelf: image: ghcr.io/advplyr/audiobookshelf:latest environment: - AUDIOBOOKSHELF_UID=99 - AUDIOBOOKSHELF_GID=100 ports: - 4517:80 volumes: - z:\Books\:/audiobooks - Z:\Family\JoeyBooks:/joey - c:\docker\audiobookshelf\config:/config - c:\docker\audiobookshelf\metadata:/metadata c:\ is a 500gb Crucial SSD
Author
Owner

@advplyr commented on GitHub (Dec 30, 2022):

Are you running Docker from Windows

@advplyr commented on GitHub (Dec 30, 2022): Are you running Docker from Windows
Author
Owner

@barelylit commented on GitHub (Dec 30, 2022):

Yeah, Docker Desktop v4.15.0

@barelylit commented on GitHub (Dec 30, 2022): Yeah, Docker Desktop v4.15.0
Author
Owner

@advplyr commented on GitHub (Dec 30, 2022):

This issue is specific to windows file systems and I'm not sure what it is. It only impacts a very small percent of users so it is something uncommon with the way the file system is setup I'm guessing.

@advplyr commented on GitHub (Dec 30, 2022): This issue is specific to windows file systems and I'm not sure what it is. It only impacts a very small percent of users so it is something uncommon with the way the file system is setup I'm guessing.
Author
Owner

@barelylit commented on GitHub (Dec 30, 2022):

File system on that drive is NTFS, so ive opened up the permissions to "everyone" to have full control of c:\docker, see if that helps
(only me on the system so not concerned about security on that folder)

@barelylit commented on GitHub (Dec 30, 2022): File system on that drive is NTFS, so ive opened up the permissions to "everyone" to have full control of c:\docker\, see if that helps (only me on the system so not concerned about security on that folder)
Author
Owner

@Poundsy82 commented on GitHub (Dec 31, 2022):

I'm seeing the same issue.

Windows server 2022 with NTFS file system. Docker and container installed on an NVME drive while the library is stored on a traditional spinning drive.

There is nothing unusual about my setup, it's just a standalone sata connected drive, no raid arrays or anything else unusable like that.

@Poundsy82 commented on GitHub (Dec 31, 2022): I'm seeing the same issue. Windows server 2022 with NTFS file system. Docker and container installed on an NVME drive while the library is stored on a traditional spinning drive. There is nothing unusual about my setup, it's just a standalone sata connected drive, no raid arrays or anything else unusable like that.
Author
Owner

@barelylit commented on GitHub (Jan 3, 2023):

FWIW, this seems to have resolved the issue, have not seen it re-occuring since opening up the permissions.

Interestingly, I was getting 2 to 3 failures to open a book on first hitting play, it would give error that server playback unavailabile - I had put this down to a moment for a USB drive to spin up perhaps, but this also seems to have been resolved, havent see this since the permissions were opened up

@barelylit commented on GitHub (Jan 3, 2023): FWIW, this seems to have resolved the issue, have not seen it re-occuring since opening up the permissions. Interestingly, I was getting 2 to 3 failures to open a book on first hitting play, it would give error that server playback unavailabile - I had put this down to a moment for a USB drive to spin up perhaps, but this also seems to have been resolved, havent see this since the permissions were opened up
Author
Owner

@Poundsy82 commented on GitHub (Jan 4, 2023):

@barelylit

I tried giving full access perms to users on my config and metadata folders but it didn't fix it.
I'll try everyone instead of users on those folders and see if that works.

Like you my system is only me so it's not a big deal.

@Poundsy82 commented on GitHub (Jan 4, 2023): @barelylit I tried giving full access perms to users on my config and metadata folders but it didn't fix it. I'll try everyone instead of users on those folders and see if that works. Like you my system is only me so it's not a big deal.
Author
Owner

@Poundsy82 commented on GitHub (Jan 5, 2023):

Gave permissions to everyone in both my config and metadata as well as my library folders and also my docker folder as well.

Same problem persisting.

@Poundsy82 commented on GitHub (Jan 5, 2023): Gave permissions to everyone in both my config and metadata as well as my library folders and also my docker folder as well. Same problem persisting.
Author
Owner

@barelylit commented on GitHub (Jan 5, 2023):

@Poundsy82 When i changed the permissions on mine, i removed inheritance and replaced permissions on all child objects to ensure there wasnt something burried with the tighter permissions, perhaps worth a try on that?

I only did it on the c:\docker\audiobookshelf folder, which is effectively just the metadata and config

@barelylit commented on GitHub (Jan 5, 2023): @Poundsy82 When i changed the permissions on mine, i removed inheritance and replaced permissions on all child objects to ensure there wasnt something burried with the tighter permissions, perhaps worth a try on that? I only did it on the c:\docker\audiobookshelf folder, which is effectively just the metadata and config
Author
Owner

@Poundsy82 commented on GitHub (Jan 5, 2023):

Thanks, will try that. I didn't do that but now have.

@Poundsy82 commented on GitHub (Jan 5, 2023): Thanks, will try that. I didn't do that but now have.
Author
Owner

@barelylit commented on GitHub (Jan 6, 2023):

Scratch that, seems its back again this morning, was just in a lull

image

@barelylit commented on GitHub (Jan 6, 2023): Scratch that, seems its back again this morning, was just in a lull ![image](https://user-images.githubusercontent.com/101836977/210978512-a4e3efe5-3c01-49c4-99b8-e8d37582786d.png)
Author
Owner

@Poundsy82 commented on GitHub (Jan 6, 2023):

Yeah hasn't fixed it for me either.

@Poundsy82 commented on GitHub (Jan 6, 2023): Yeah hasn't fixed it for me either.
Author
Owner

@Poundsy82 commented on GitHub (Jan 9, 2023):

I've also tried moving the config folder to the OS drive just to be sure it wasn't some other weird thing going on. No change

@Poundsy82 commented on GitHub (Jan 9, 2023): I've also tried moving the config folder to the OS drive just to be sure it wasn't some other weird thing going on. No change
Author
Owner

@wtangofoxtrot commented on GitHub (Feb 19, 2023):

Same issue here, when i restart i get the below errors at startup followed by the DB errors when trying to play something.
I am running in docker on a ubuntu 22.04
All disks are mounted via a nfs share (no usb involved)

[2023-02-18 22:50:01] INFO: [Watcher] "Books" Ready
Error: Stale lock or attempt to update it after release
    at process.<anonymous> (/server/libs/njodb/index.js:101:37)
    at process.emit (node:events:513:28)
    at processEmit [as emit] (/server/libs/signalExit/index.js:204:34)
    at process._fatalException (node:internal/process/execution:149:25) {
  code: 'ECOMPROMISED'
}
Error: Stale lock or attempt to update it after release
    at process.<anonymous> (/server/libs/njodb/index.js:101:37)
    at process.emit (node:events:513:28)
    at processEmit [as emit] (/server/libs/signalExit/index.js:204:34)
    at process._fatalException (node:internal/process/execution:149:25) {
  code: 'ECOMPROMISED'
}
[2023-02-18 22:55:01] INFO: [Server] Socket Connected pSt6CdsHEY6iBdw_AAAB
[2023-02-18 22:55:10] ERROR: [DB] Update entity user Failed: Error: Lock file is already being held (Db.js:391)
[2023-02-18 22:55:37] INFO: [Server] Socket pSt6CdsHEY6iBdw_AAAB disconnected from client "xyz" after 36420ms (Reason: transport close)
[2023-02-18 22:55:38] INFO: [Server] Socket Connected UvQ_1znE2qM7Yj-nAAAD
[2023-02-18 22:55:48] ERROR: [DB] Update entity user Failed: Error: Lock file is already being held (Db.js:391)
[2023-02-18 22:56:10] ERROR: [DB] Update entity user Failed: Error: Lock file is already being held (Db.js:391)
@wtangofoxtrot commented on GitHub (Feb 19, 2023): Same issue here, when i restart i get the below errors at startup followed by the DB errors when trying to play something. I am running in docker on a ubuntu 22.04 All disks are mounted via a nfs share (no usb involved) ``` [2023-02-18 22:50:01] INFO: [Watcher] "Books" Ready Error: Stale lock or attempt to update it after release at process.<anonymous> (/server/libs/njodb/index.js:101:37) at process.emit (node:events:513:28) at processEmit [as emit] (/server/libs/signalExit/index.js:204:34) at process._fatalException (node:internal/process/execution:149:25) { code: 'ECOMPROMISED' } Error: Stale lock or attempt to update it after release at process.<anonymous> (/server/libs/njodb/index.js:101:37) at process.emit (node:events:513:28) at processEmit [as emit] (/server/libs/signalExit/index.js:204:34) at process._fatalException (node:internal/process/execution:149:25) { code: 'ECOMPROMISED' } [2023-02-18 22:55:01] INFO: [Server] Socket Connected pSt6CdsHEY6iBdw_AAAB [2023-02-18 22:55:10] ERROR: [DB] Update entity user Failed: Error: Lock file is already being held (Db.js:391) [2023-02-18 22:55:37] INFO: [Server] Socket pSt6CdsHEY6iBdw_AAAB disconnected from client "xyz" after 36420ms (Reason: transport close) [2023-02-18 22:55:38] INFO: [Server] Socket Connected UvQ_1znE2qM7Yj-nAAAD [2023-02-18 22:55:48] ERROR: [DB] Update entity user Failed: Error: Lock file is already being held (Db.js:391) [2023-02-18 22:56:10] ERROR: [DB] Update entity user Failed: Error: Lock file is already being held (Db.js:391) ```
Author
Owner

@JamesOEastern commented on GitHub (Mar 5, 2023):

So I had a similar issue, with playback not syncing. The solution seems to be "not" running Docker with Admin privileges.

@JamesOEastern commented on GitHub (Mar 5, 2023): So I had a similar issue, with playback not syncing. The solution seems to be "not" running Docker with Admin privileges.
Author
Owner

@plague-doctor commented on GitHub (Mar 6, 2023):

This issue has been reported here: https://github.com/advplyr/audiobookshelf/issues/845 and here https://github.com/advplyr/audiobookshelf/issues/653
I workaround this by moving mapping /config out of nfs to local drive.
I think those problems will disappear as soon as the database will be moved to sqlite or any other dedicated database.
@advplyr is this still on your radar? Any progress on that?

@plague-doctor commented on GitHub (Mar 6, 2023): This issue has been reported here: https://github.com/advplyr/audiobookshelf/issues/845 and here https://github.com/advplyr/audiobookshelf/issues/653 I workaround this by moving mapping `/config` out of nfs to local drive. I think those problems will disappear as soon as the database will be moved to sqlite or any other dedicated database. @advplyr is this still on your radar? Any progress on that?
Author
Owner

@advplyr commented on GitHub (Mar 6, 2023):

Definitely still on my radar. No progress on this yet but there are some discussions going on.

@advplyr commented on GitHub (Mar 6, 2023): Definitely still on my radar. No progress on this yet but there are some discussions going on.
Author
Owner

@cadric commented on GitHub (Mar 28, 2023):

I just want to report that I have this error on a Dietpi (debian) server in docker. Just started yesterday :/
Nothing seems to resolve this error and I can no longer add new media.
Log

@cadric commented on GitHub (Mar 28, 2023): I just want to report that I have this error on a Dietpi (debian) server in docker. Just started yesterday :/ Nothing seems to resolve this error and I can no longer add new media. [Log](https://cdn.discordapp.com/attachments/716631234398257215/1090343541751943178/clipboard.png)
Author
Owner

@advplyr commented on GitHub (Mar 28, 2023):

You have to go into the /config folder and delete .lock files. Then restart the server.

@advplyr commented on GitHub (Mar 28, 2023): You have to go into the `/config` folder and delete `.lock` files. Then restart the server.
Author
Owner

@Commiccannon commented on GitHub (Apr 16, 2023):

Tried that, still getting errors. If it helps my config directory is stores on my c drive being an ssd with windows, my audiobooks are stored on a RAID5 array in the same pc mounted as D drive

@Commiccannon commented on GitHub (Apr 16, 2023): Tried that, still getting errors. If it helps my config directory is stores on my c drive being an ssd with windows, my audiobooks are stored on a RAID5 array in the same pc mounted as D drive
Author
Owner

@advplyr commented on GitHub (Apr 16, 2023):

Where is the server running from?

@advplyr commented on GitHub (Apr 16, 2023): Where is the server running from?
Author
Owner

@Commiccannon commented on GitHub (Apr 16, 2023):

Server was running on Windows pc through docker installed via community guidelines. I reinstalled this morning same method however putting the config and metadata folders separately and on the same drive as my audiobooks, will let you know if the issue persists

@Commiccannon commented on GitHub (Apr 16, 2023): Server was running on Windows pc through docker installed via community guidelines. I reinstalled this morning same method however putting the config and metadata folders separately and on the same drive as my audiobooks, will let you know if the issue persists
Author
Owner

@EloquenceWinters commented on GitHub (Apr 30, 2023):

Additional data points for you, in case that helps.

I have this issue (resulting in the error popup about progress not being synced), and I'm running:

  • Windows 10 Pro
  • Docker installed on C: (NVME drive where the OS resides, NTFS)
  • data, config, and audiobook files on D: (16TB SATA HDD, NTFS)

Following the suggestion above, I set permissions for the Docker, data, and config folders to Everyone (clearing inheritance and then applying to all files in the folders), but that doesn't seem to fix the problem for me.

Stopping, closing, and restarting Docker fixes it for a time.

@EloquenceWinters commented on GitHub (Apr 30, 2023): Additional data points for you, in case that helps. I have this issue (resulting in the error popup about progress not being synced), and I'm running: - Windows 10 Pro - Docker installed on C: (NVME drive where the OS resides, NTFS) - data, config, and audiobook files on D: (16TB SATA HDD, NTFS) Following the suggestion above, I set permissions for the Docker, data, and config folders to Everyone (clearing inheritance and then applying to all files in the folders), but that doesn't seem to fix the problem for me. Stopping, closing, and restarting Docker fixes it for a time.
Author
Owner

@Commiccannon commented on GitHub (Apr 30, 2023):

Only thing that worked permanently has been reinstalling audiobookshelf unfortunately, I recommend making a backup then reinstalling with the backup it only takes half hour or so and has been running fine for me for at least 2 weeks

@Commiccannon commented on GitHub (Apr 30, 2023): Only thing that worked permanently has been reinstalling audiobookshelf unfortunately, I recommend making a backup then reinstalling with the backup it only takes half hour or so and has been running fine for me for at least 2 weeks
Author
Owner

@kymahi commented on GitHub (Jun 14, 2023):

To add some more context to this, I'm running Docker on an M1 Mac Mini, USB ExFat drive and getting this error for one client.

@kymahi commented on GitHub (Jun 14, 2023): To add some more context to this, I'm running Docker on an M1 Mac Mini, USB ExFat drive and getting this error for one client.
Author
Owner

@barelylit commented on GitHub (Jun 15, 2023):

FWIW, i followed Commiccannon advice and did the following:

  1. Backup config from within Audiobookshelf UI and download
  2. Took a copy of existing config folders, then deleted
  3. Deleted the docker
  4. Re-ran the docker and let it build configs
  5. Login
  6. Restored the backup
  7. Restarted the docker

Took less than 5 minutes, and seems to be working fine ever since

@barelylit commented on GitHub (Jun 15, 2023): FWIW, i followed [Commiccannon](https://github.com/Commiccannon) advice and did the following: 1) Backup config from within Audiobookshelf UI and download 2) Took a copy of existing config folders, then deleted 3) Deleted the docker 4) Re-ran the docker and let it build configs 5) Login 6) Restored the backup 7) Restarted the docker Took less than 5 minutes, and seems to be working fine ever since
Author
Owner

@barelylit commented on GitHub (Jun 26, 2023):

Spoke to soon, still fubar.

@barelylit commented on GitHub (Jun 26, 2023): Spoke to soon, still fubar.
Author
Owner

@barelylit commented on GitHub (Jun 29, 2023):

So, its a bit of a bodge, but I seem to have sorted this with a workaround

I made a virtual hard drive file, of 1gb. Attached and made a partition with it formatted as Fat32. Moved the config and metadata to the virtual drive to avoid any NTFS permission issues.

Seems to be working fine so far

https://learn.microsoft.com/en-us/windows-server/storage/disk-management/manage-virtual-hard-disks

@barelylit commented on GitHub (Jun 29, 2023): So, its a bit of a bodge, but I seem to have sorted this with a workaround I made a virtual hard drive file, of 1gb. Attached and made a partition with it formatted as Fat32. Moved the config and metadata to the virtual drive to avoid any NTFS permission issues. Seems to be working fine so far https://learn.microsoft.com/en-us/windows-server/storage/disk-management/manage-virtual-hard-disks
Author
Owner

@advplyr commented on GitHub (Jul 21, 2023):

The latest release 2.3.3 is using Sqlite now. The library that was being used where this error was coming from is no longer being used.

@advplyr commented on GitHub (Jul 21, 2023): The latest release 2.3.3 is using Sqlite now. The library that was being used where this error was coming from is no longer being used.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#844