bd sync creates sync_base.jsonl every time + db closed errors
GitHub Issue: bd sync creates sync_base.jsonl every time + db closed errors
File this at: https://github.com/steveyegge/beads/issues/new
Title
bd sync always creates sync_base.jsonl (triggers doctor warning) + "database is closed" errors
Description
Two related issues with bd sync in sync-branch mode:
Issue 1: sync_base.jsonl always recreated
Every bd sync creates .beads/sync_base.jsonl. This file:
- Is already in
.beads/.gitignore - Triggers
bd doctorwarning about "multiple JSONL files" - Cannot be fixed by following
bd doctor --fixinstructions (git rm doesn't work since it's untracked, and sync recreates it anyway)
Issue 2: sync-state.json thrashing + db closed error
During bd sync, the file .beads/sync-state.json is:
- Created and deleted approximately 10 times during a single sync operation
- Ends up containing a "database is closed" error:
{
"last_failure": "2026-01-11T19:58:30.689745-08:00",
"failure_count": 1,
"backoff_until": "2026-01-11T19:59:00.689745-08:00",
"needs_manual_sync": false,
"failure_reason": "failed to get sync branch: failed to get sync.branch from config: get config: sql: database is closed"
}
Environment
- bd version: 0.47.0
- Mode: sync-branch (
beads-sync) - Daemon: running
- OS: macOS
Steps to Reproduce
- Configure sync-branch:
bd config set sync.branch beads-sync - Run
bd sync - Observe: sync_base.jsonl created, sync-state.json thrashing
- Run
bd doctor- see warning about multiple JSONL files - Check sync-state.json - see "database is closed" error
Expected Behavior
-
sync_base.jsonlshould either:- Not trigger a doctor warning (recognized as internal file), OR
- Not be created in the repo directory (use temp location)
-
sync-state.jsonshould not thrash or end with db closed errors
Actual Behavior
- sync_base.jsonl always created, always triggers doctor warning
- sync-state.json written/deleted ~10 times per sync
- Sync completes but sync-state.json shows failure
- Doctor warning cannot be resolved
Related Issues
-
#607 - "Potential race condition in FreshnessChecker causing intermittent 'database is closed' errors" (closed Dec 18, 2025)
- That fix used
sync.RWMutexto protect database operations during reconnection - The error I'm seeing may be a regression or different code path (reading
sync.branchconfig)
- That fix used
Analysis
The error occurs when reading config:
failed to get sync.branch from config: get config: sql: database is closed
This suggests the race condition fix in #607 may not cover the config-reading code path, or there's a separate issue when accessing config during sync operations.
sync_base.jsonl purpose
Based on v0.47.0 release notes mentioning "pull-first sync with 3-way merge", sync_base.jsonl appears to be the base file for 3-way merge (comparing base/local/remote). This is expected behavior for 3-way merge - the issue is that:
-
bd doctordoesn't recognize it as an internal working file - It's always recreated even when no sync occurs
Workaround
Ignoring the doctor warning since sync actually works. But the UX is confusing.