fix: reconcile pushes even when this node has no seed peers (#8)

The sweep returned early on an empty peer list, which is precisely the
replica case: dhg.lol configures no peers, receives pushes, and never rebuilt
entries. Check for pending pushes before bailing out.
This commit is contained in:
2026-11-04 17:28:29 -08:00
parent 201a49208a
commit 906712cf9a
+10 -11
View File
@@ -854,20 +854,19 @@ func (w *Watcher) extractSnippets() {
// syncGossip runs one anti-entropy sweep against configured peers and rebuilds // syncGossip runs one anti-entropy sweep against configured peers and rebuilds
// derived state if anything new arrived. // derived state if anything new arrived.
func (w *Watcher) syncGossip() { func (w *Watcher) syncGossip() {
peers := PeerAddrs() // Taken before the peer check: a replica with no seed peers still receives
if len(peers) == 0 { // pushes, and that is the only thing that ever changes its log. Returning
return // early on an empty peer list would leave its entries cache empty forever.
pushedIn := w.pendingReconcile.Swap(false)
pulled := 0
if peers := PeerAddrs(); len(peers) > 0 {
pulled = Run(w.knoxDB, w.metrics, peers)
} }
pulled := Run(w.knoxDB, w.metrics, peers)
// A pull only appends to the observation log; the entries cache and
// auto-threads are derived state that reconcile rebuilds. Comparing entry
// counts can never trigger this (pushes/pulls never touch entries directly),
// so reconcile fires on the sweep's newly-inserted observation count.
// Reconcile when this sweep changed the log, in either direction: a pull // Reconcile when this sweep changed the log, in either direction: a pull
// inserts rows here, a peer's push inserted them in the HTTP handler. // inserts rows here, a peer's push inserted them in the HTTP handler. The
pushedIn := w.pendingReconcile.Swap(false) // entries cache and auto-threads are derived state that reconcile rebuilds.
if pulled > 0 || pushedIn { if pulled > 0 || pushedIn {
created, linked, err := Reconcile(w.knoxDB) created, linked, err := Reconcile(w.knoxDB)
if err != nil { if err != nil {