Fix bd-1ezg: Prevent import/export from hanging when daemon is running
Root cause: Import and export commands tried to open the database directly while the daemon already held the lock, causing indefinite blocking. Solution: Both commands now explicitly close the daemon connection before opening direct database access, avoiding SQLite lock contention. Changes: - import.go: Close daemon connection and open direct SQLite connection - export.go: Close daemon connection before direct access - Added debug logging to help diagnose similar issues Tests: Existing TestImport and TestExport tests pass
This commit is contained in:
@@ -95,10 +95,18 @@ Output to stdout by default, or use -o flag for file output.`,
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Export command doesn't work with daemon - need direct access
|
||||
// Export command requires direct database access for consistent snapshot
|
||||
// If daemon is connected, close it and open direct connection
|
||||
if daemonClient != nil {
|
||||
if os.Getenv("BD_DEBUG") != "" {
|
||||
fmt.Fprintf(os.Stderr, "Debug: export command forcing direct mode (closes daemon connection)\n")
|
||||
}
|
||||
_ = daemonClient.Close()
|
||||
daemonClient = nil
|
||||
}
|
||||
|
||||
// Ensure we have a direct store connection
|
||||
if store == nil {
|
||||
// Initialize store directly even if daemon is running
|
||||
var err error
|
||||
if dbPath == "" {
|
||||
fmt.Fprintf(os.Stderr, "Error: no database path found\n")
|
||||
|
||||
Reference in New Issue
Block a user