aw-server 0.13.2 startup loop on corrupt SQLite DB; .recover restores data
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Look at the aw-server startup code, likely in aw_server or aw_core, to see where the SQLite database is opened and how errors are handled. The issue suggests adding a recovery fallback when corruption is detected. You'll need to understand the existing storage backend (Peewee/SQLite) and design a safe recovery flow that preserves the corrupt file and either automatically recovers or shows instructions. Check for related code from issue #271. Testing will involve simulating a corrupt database file and verifying the new behavior.
Written by the indexing model from the issue text.
Description
Environment
- ActivityWatch /
aw-server: 0.13.2 - macOS 15.7.3 (24G419), arm64
- Storage backend: Peewee / SQLite
Observed behavior
aw-server repeatedly exited during startup with:
sqlite3.DatabaseError: database disk image is malformed
peewee.DatabaseError: database disk image is malformed
The bundled app's restart action produced the same startup failure. The database file was last modified on July 25, and the first retained log containing this error was July 27. I do not know what originally caused the corruption.
An independent read-only SQLite check reproduced it:
$ sqlite3 -readonly peewee-sqlite.v2.db 'PRAGMA quick_check;'
Error: in prepare, database disk image is malformed (11)
There was no -wal, -journal, or backup file beside the database.
Recovery result
After preserving the original file, the standard SQLite recovery path succeeded:
sqlite3 corrupt.db '.recover' | sqlite3 recovered.db
sqlite3 -readonly recovered.db 'PRAGMA integrity_check;'
# ok
Recovered data:
- 2 buckets
- 148,065 events
- Event range: 2026-01-30 through 2026-07-25
- 0 invalid event JSON rows
- 0 orphaned event rows
After replacing the corrupt database with the recovered one, the actual bundled aw-server started successfully. Both /api/0/info and /api/0/buckets/ returned HTTP 200, and the full ActivityWatch app then launched normally.
Suggested improvement
Could aw-server or aw-qt preserve the corrupt file and offer an automatic recovery/backup fallback (or at least show actionable recovery instructions) instead of remaining in a restart loop? This appears related to the older closed issue #271, but reproduces on 0.13.2 and the SQLite .recover path preserved the data successfully.
- Dominant language
- Python
- Stars
- 19.7k
- Forks
- 1.1k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 14
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 ActivityWatch/activitywatch
-
Folder created in home directory (clashes with documented location)Possibly taken A pull request linked to this issue is open or already merged. Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ActivityWatch/activitywatch#1418 · 5 comments ·
Maintainers usually reply within 4 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ActivityWatch/activitywatch#1568 · 1 comment ·
Maintainers usually reply within 4 days
-
type: bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
ActivityWatch/activitywatch#1564 · 2 comments ·
Maintainers usually reply within 4 days
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ActivityWatch/activitywatch#1563 · 1 comment ·
Maintainers usually reply within 4 days
-
type: bug
Difficulty 3/5 1-2 days Newbie friendliness 54/100
ActivityWatch/activitywatch#1538 · 7 comments ·
Maintainers usually reply within 4 days
All issues in ActivityWatch/activitywatch
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
ActivityWatch/docs#223 ·
-
[Bug]: OpenCode v2 skips an assistant message that gains text after an earlier capturePossibly taken @jianyx1 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
volcengine/OpenViking#8354 ·
Maintainers usually reply within 1 day
-
comp/tools P2 tool/skills type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NousResearch/hermes-agent#159541 ·
Maintainers usually reply within 1 day
-
bot-triaged module: correctness (silent) module: cpu module: empty tensor module: loss triage review
Difficulty 1/5 Under an hour Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
request-theme
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
LizardByte/ThemerrDB#10167 · 1 comment ·