fix(daemon): prevent zombie state after database file replacement (#1213)

fix(daemon): prevent zombie state after database file replacement

Adds checkFreshness() to health check paths (GetMetadata, GetConfig, GetAllConfig) and refactors reconnect() to validate new connection before closing old.

PR-URL: https://github.com/steveyegge/beads/pull/1213
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Roland Tritsch
2026-01-22 06:46:59 +00:00
committed by GitHub
parent 78e1d6f229
commit 5264d7aa60
8 changed files with 588 additions and 23 deletions

View File

@@ -2,6 +2,7 @@
package sqlite
import (
"log"
"os"
"sync"
"time"
@@ -112,10 +113,11 @@ func (fc *FreshnessChecker) Check() bool {
return false
}
// debugPrintf is a no-op in production but can be enabled for debugging
// debugPrintf conditionally logs debug messages when BD_DEBUG_FRESHNESS is set
var debugPrintf = func(format string, args ...interface{}) {
// Uncomment for debugging:
// fmt.Printf(format, args...)
if os.Getenv("BD_DEBUG_FRESHNESS") != "" {
log.Printf("[freshness] "+format, args...)
}
}
// DebugState returns the current tracked state for testing/debugging.