Skip to content

Fix SQLite "database is locked" errors during concurrent task execution#21

Merged
Hexagon merged 2 commits intomainfrom
copilot/investigate-database-locked-error
Nov 26, 2025
Merged

Fix SQLite "database is locked" errors during concurrent task execution#21
Hexagon merged 2 commits intomainfrom
copilot/investigate-database-locked-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 26, 2025

Multiple scheduled jobs (price updates, currency updates, outage updates, consumption/production updates) accessing the database simultaneously cause SQLite locking errors.

Changes

  • Enable WAL mode (PRAGMA journal_mode = WAL) - allows concurrent readers/writers without blocking
  • Set busy timeout (PRAGMA busy_timeout = 30000) - wait 30s for locks instead of failing immediately

Applied to both database entry points:

  • backend/db/minimal.ts (scheduled jobs)
  • backend/db/index.ts (main app)
const database = new Database(fileName, options);

database.exec("PRAGMA journal_mode = WAL");
database.exec("PRAGMA busy_timeout = 30000");

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.jsdelivr.net
    • Triggering command: /usr/local/bin/deno /usr/local/bin/deno check main.ts (dns block)
    • Triggering command: /usr/local/bin/deno deno test tests/ (dns block)
  • dl.deno.land
    • Triggering command: /usr/bin/curl curl -s REDACTED (dns block)
  • esm.sh
    • Triggering command: /usr/local/bin/deno /usr/local/bin/deno check main.ts (dns block)
  • jsr.io
    • Triggering command: /usr/local/bin/deno /usr/local/bin/deno check main.ts (dns block)
    • Triggering command: /usr/local/bin/deno deno test tests/ (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Tasks often gives "database is locked" error, especially if many rasks is running at the same time. Investigate.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate database is locked error during tasks Fix SQLite "database is locked" errors during concurrent task execution Nov 26, 2025
Copilot AI requested a review from Hexagon November 26, 2025 23:26
@Hexagon Hexagon marked this pull request as ready for review November 26, 2025 23:29
@Hexagon Hexagon merged commit 45f9513 into main Nov 26, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants