[GH-ISSUE #2368] Upgrade handling seems fragile #1433

Open
opened 2026-03-02 11:57:19 +03:00 by kerem · 1 comment
Owner

Originally created by @fingon on GitHub (Jan 10, 2026).
Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/2368

Describe the Bug

The sqlite is busy is not retried (after container restart it was fine).

Relevant logs:


2026-01-10 09:36:45.017
Running db migration script

2026-01-10 09:36:45.022
s6-rc: info: service fix-attrs successfully started

2026-01-10 09:36:45.024
s6-rc: info: service legacy-cont-init: starting

2026-01-10 09:36:45.036
s6-rc: info: service legacy-cont-init successfully started

2026-01-10 09:36:50.629
file:///db_migrations/index.js:7864

2026-01-10 09:36:50.629
throw new DrizzleError({ cause: err, message: `Failed to run the query '${staticQuery.sql}'` });

2026-01-10 09:36:50.629
^

2026-01-10 09:36:50.629

2026-01-10 09:36:50.629
DrizzleError: Failed to run the query 'DROP INDEX `bookmarks_archived_idx`;'

2026-01-10 09:36:50.629
at BetterSQLiteSession.run (file:///db_migrations/index.js:7864:13)

2026-01-10 09:36:50.629
at SQLiteSyncDialect.migrate (file:///db_migrations/index.js:5722:21)

2026-01-10 09:36:50.629
... 4 lines matching cause stack trace ...

2026-01-10 09:36:50.629
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5) {

2026-01-10 09:36:50.629
cause: SqliteError: database is locked

2026-01-10 09:36:50.629
at PreparedQuery.run (file:///db_migrations/index.js:7979:22)

2026-01-10 09:36:50.629
at BetterSQLiteSession.run (file:///db_migrations/index.js:7862:74)

2026-01-10 09:36:50.629
at SQLiteSyncDialect.migrate (file:///db_migrations/index.js:5722:21)

2026-01-10 09:36:50.629
at migrator_migrate (file:///db_migrations/index.js:2207:14)

2026-01-10 09:36:50.629
at file:///db_migrations/index.js:14305:1

2026-01-10 09:36:50.629
at ModuleJob.run (node:internal/modules/esm/module_job:413:25)

2026-01-10 09:36:50.629
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:660:26)

2026-01-10 09:36:50.629
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5) {

2026-01-10 09:36:50.629
code: 'SQLITE_BUSY'

2026-01-10 09:36:50.629
}

2026-01-10 09:36:50.629
}

2026-01-10 09:36:50.629

2026-01-10 09:36:50.629
Node.js v24.12.0

2026-01-10 09:36:50.644
s6-rc: warning: unable to start service init-db-migration: command exited 1

How to address it? (Just spitballing here):

  • Perhaps migration should be attempted twice? (In case this clears the 'busy' flag)

  • Health check (running this via docker compose), or terminating container somehow on failure to upgrade.

Disclaimer: Troubleshooting link in the create bug report form is broken.

Steps to Reproduce

Not sure. Probably 'have SQLite locked, kill container, start upgrade' if I had to hazard a guess.

Expected Behaviour

Not failed upgrade :)

Screenshots or Additional Context

No response

Device Details

No response

Exact Karakeep Version

v0.30.0 ( bbdc3274bbe510cac32551b2a8825019f61d23c261ddb8baa9bb4311caed31c4 docker hash)

Have you checked the troubleshooting guide?

  • I have checked the troubleshooting guide and I haven't found a solution to my problem
Originally created by @fingon on GitHub (Jan 10, 2026). Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/2368 ### Describe the Bug The sqlite is busy is not retried (after container restart it was fine). Relevant logs: ``` 2026-01-10 09:36:45.017 Running db migration script 2026-01-10 09:36:45.022 s6-rc: info: service fix-attrs successfully started 2026-01-10 09:36:45.024 s6-rc: info: service legacy-cont-init: starting 2026-01-10 09:36:45.036 s6-rc: info: service legacy-cont-init successfully started 2026-01-10 09:36:50.629 file:///db_migrations/index.js:7864 2026-01-10 09:36:50.629 throw new DrizzleError({ cause: err, message: `Failed to run the query '${staticQuery.sql}'` }); 2026-01-10 09:36:50.629 ^ 2026-01-10 09:36:50.629 2026-01-10 09:36:50.629 DrizzleError: Failed to run the query 'DROP INDEX `bookmarks_archived_idx`;' 2026-01-10 09:36:50.629 at BetterSQLiteSession.run (file:///db_migrations/index.js:7864:13) 2026-01-10 09:36:50.629 at SQLiteSyncDialect.migrate (file:///db_migrations/index.js:5722:21) 2026-01-10 09:36:50.629 ... 4 lines matching cause stack trace ... 2026-01-10 09:36:50.629 at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5) { 2026-01-10 09:36:50.629 cause: SqliteError: database is locked 2026-01-10 09:36:50.629 at PreparedQuery.run (file:///db_migrations/index.js:7979:22) 2026-01-10 09:36:50.629 at BetterSQLiteSession.run (file:///db_migrations/index.js:7862:74) 2026-01-10 09:36:50.629 at SQLiteSyncDialect.migrate (file:///db_migrations/index.js:5722:21) 2026-01-10 09:36:50.629 at migrator_migrate (file:///db_migrations/index.js:2207:14) 2026-01-10 09:36:50.629 at file:///db_migrations/index.js:14305:1 2026-01-10 09:36:50.629 at ModuleJob.run (node:internal/modules/esm/module_job:413:25) 2026-01-10 09:36:50.629 at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:660:26) 2026-01-10 09:36:50.629 at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5) { 2026-01-10 09:36:50.629 code: 'SQLITE_BUSY' 2026-01-10 09:36:50.629 } 2026-01-10 09:36:50.629 } 2026-01-10 09:36:50.629 2026-01-10 09:36:50.629 Node.js v24.12.0 2026-01-10 09:36:50.644 s6-rc: warning: unable to start service init-db-migration: command exited 1 ``` How to address it? (Just spitballing here): - Perhaps migration should be attempted twice? (In case this clears the 'busy' flag) - Health check (running this via docker compose), or terminating container somehow on failure to upgrade. Disclaimer: Troubleshooting link in the create bug report form is broken. ### Steps to Reproduce Not sure. Probably 'have SQLite locked, kill container, start upgrade' if I had to hazard a guess. ### Expected Behaviour Not failed upgrade :) ### Screenshots or Additional Context _No response_ ### Device Details _No response_ ### Exact Karakeep Version v0.30.0 ( bbdc3274bbe510cac32551b2a8825019f61d23c261ddb8baa9bb4311caed31c4 docker hash) ### Have you checked the troubleshooting guide? - [x] I have checked the troubleshooting guide and I haven't found a solution to my problem
Author
Owner

@ClausMunch commented on GitHub (Jan 26, 2026):

So, mine also "broke" during an upgrade (Proxmox LXC) where the LXC was killed during the process.
Just go into the version files (~./karakeep) and change it back, then do your upgrade. Worked for me.

<!-- gh-comment-id:3799064633 --> @ClausMunch commented on GitHub (Jan 26, 2026): So, mine also "broke" during an upgrade (Proxmox LXC) where the LXC was killed during the process. Just go into the version files (~./karakeep) and change it back, then do your upgrade. Worked for me.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#1433
No description provided.