BUG: Folder deletion fails with "database is locked" during indexing
Maintainers usually reply within 3 days
@Krishna41357 is already working on this.
Since Sep 21, 2026.
Assessment
This issue has not been assessed yet.
Description
Is there an existing issue for this?
- I have searched the existing issues
What happened?
Description
Deleting a folder while it (or another folder) is still being indexed in the background fails with a SQLite "database is locked" error. Retrying a few times eventually succeeds once indexing finishes and the lock clears — no data corruption occurs, since each attempt is a single atomic transaction.
Steps to Reproduce
- Add a large folder with many subfolders/images to the photo library.
- While background indexing is still running, delete the root folder.
- Observe:
Internal server error - Unable to delete folders: database is locked. - Retry a few times — it eventually succeeds and cascades correctly.
Root Cause
- Indexing runs in a
ProcessPoolExecutor(backend/main.py) with nofolder_id → Futuretracking, so a job can't be cancelled on delete (backend/app/routes/folders.py). db_delete_folders_batch()(backend/app/database/folders.py) opens a rawsqlite3.connect()with notimeout=, defaulting to SQLite's 5s lock wait.- No WAL mode and no retry/backoff anywhere in the codebase, so any concurrent write blocks the delete and fails immediately.
Why this matters (not just "an error occurred")
- Deleting a folder mid-scan is an expected, normal situation — not an edge case — and it shouldn't surface as a raw, unhandled SQLite exception with no guidance for the user.
- Right now the user has to manually retry (observed: 4 attempts) until the lock happens to clear — the app should handle this itself instead of pushing that burden onto the user.
- Behavior is non-deterministic: it can fail once or several times depending purely on how long the background scan takes, which is a poor experience on its own regardless of the error message.
- Even when the delete eventually succeeds, the background scan keeps running and writing rows for a folder that's about to be deleted anyway — wasted CPU/disk/DB work with no benefit.
Suggested Fix
Confirmed immediate cause: the raw sqlite3.connect() in db_delete_folders_batch() has no timeout=, so it inherits SQLite's default 5s lock wait. There are a few reasonable ways to fix this properly (connection handling, job cancellation, WAL mode, bounded retries), each with its own trade-offs — happy to discuss the best approach once the issue itself is confirmed valid.
Environment
- PictoPy v1.3.0-alpha, Windows
Record
- I agree to follow this project's Code of Conduct
- Dominant language
- Python
- Stars
- 322
- Forks
- 793
- Avg merge
- 6d 10h
- Merged PRs (30d)
- 20
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AOSSIE-Org/PictoPy
-
bug enhancement
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AOSSIE-Org/PictoPy#1802 · 2 comments ·
Maintainers usually reply within 3 days
-
BUG: XMP metadata export permanently overwrites file modification timestamp (mtime), destroying photo datesPossibly taken @swastiksharma45 claimed this 2 days ago. Openbug enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
AOSSIE-Org/PictoPy#1788 · 6 comments ·
Maintainers usually reply within 3 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
AOSSIE-Org/PictoPy#1786 · 1 comment ·
Maintainers usually reply within 3 days
-
BUG: Semantic search sees portrait phone photos sideways (SigLIP ignores EXIF orientation)Possibly taken @omkar-suryavanshi claimed this 3 days ago. Openbug enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
AOSSIE-Org/PictoPy#1780 · 5 comments ·
Maintainers usually reply within 3 days
-
BUG: Share password loses leading/trailing spaces so the password you set doesn't workPossibly taken @ManyaJain111 claimed this 2 days ago. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
AOSSIE-Org/PictoPy#1779 · 2 comments · 1 assignee ·
Maintainers usually reply within 3 days
All issues in AOSSIE-Org/PictoPy
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
hermes hooks doctor smoke test never checks the hook exit code — a crashing hook (exit=1) renders ✓ "ran clean" and "All shell hooks look healthy"Possibly taken @cestercian claimed this today. Opencomp/cli P2 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NousResearch/hermes-agent#162259 · 1 comment ·
Maintainers usually reply within 1 day
-
upstream update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
conan-io/conan-center-index#31597 ·
Maintainers usually reply within 1 day
-
community-request
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA-NeMo/Run#727 ·
Maintainers usually reply within 1 day
-
bot-triaged module: higher order operators module: pickle module: pt2-dispatcher oncall: pt2 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
pytorch/pytorch#207247 · 1 comment ·
Maintainers usually reply within 1 day