question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sqlite3.OperationalError: database is locked error

See original GitHub issue

Hi there,

I’m attempting to run this in portainer and getting the following error whenever starting the container:

Outdated jbos table, cleaning up and recreating
Traceback (most recent call last):
  File "./youtube-dl-server.py", line 114, in <module>
    JobsDB.init_db()
  File "/usr/src/app/ydl_server/logdb.py", line 72, in init_db
    cursor.execute("CREATE TABLE if not exists jobs \
sqlite3.OperationalError: database is locked

Any ideas?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
damntouristscommented, Jan 10, 2021

Ok, that seems to have worked! This is what I wound up using:

---
version: "2.1"
services:
  youtube-dl:
    image: "nbr23/youtube-dl-server:latest"
    container_name: youtube-dl
    environment:
      - YDL_CONFIG_PATH=/usr/src/app/config.yml
    volumes:
      - /mnt/nas/sync/youtube-dl:/youtube-dl
      - /mnt/nas/projects/homelab/configurations/youtube-dl-server/config.yml:/usr/src/app/config.yml:ro
    ports:
      - 8888:8080
    restart: always

I added in the environment variable because it appears it was defaulting to /app_config/config.yml.

Thanks again for your help! It’s working perfectly now!

1reaction
damntouristscommented, Jan 10, 2021

Hi there, sorry to revive a previously closed ticket – I think I’ve figured out why this was causing errors and figured I’d let you know in case you weren’t aware.

I had mounted a volume pointing to my network SMB 2 share which is mounted on ubuntu using cifs. It appears that sqlite does not behave well using NFS mounts, which is why I have been encountering this error.

2.1. Filesystems with broken or missing lock implementations

SQLite depends on the underlying filesystem to do locking as the documentation says it will. But some filesystems contain bugs in their locking logic such that the locks do not always behave as advertised. This is especially true of network filesystems and NFS in particular. If SQLite is used on a filesystem where the locking primitives contain bugs, and if two or more threads or processes try to access the same database at the same time, then database corruption might result.

source: https://sqlite.org/howtocorrupt.html

Is it possible to write the downloads out to a different directory instead of keeping them along side the db files?

Read more comments on GitHub >

github_iconTop Results From Across the Web

OperationalError: database is locked - python - Stack Overflow
OperationalError: database is locked errors indicate that your application is experiencing more concurrency than sqlite can handle in default configuration.
Read more >
sqlite3.OperationalError: database is locked - Pyrogram
This error occurs when more than one process is using the same session file, that is, when you run two or more clients...
Read more >
How to Fix SQLite Error Database is Locked - Error Code 5
This error code occurs when the user tries to perform two inappropriate operations on a database at the same detail and on the...
Read more >
Fix SQLite Database File is Locked Error - Kernel Data Recovery
Normally, the error occurs when two users try to run transactions on the same tables and change the content. SQLite engine finds it...
Read more >
Resolve Error and Unlock SQLite Database - ConverterTools
This is an Operational error which indicates that the application is handling more concurrency than the default configuration. it means that one thread...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found