From 906712cf9af157b0ae45587305f7da54befd76b3 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Wed, 4 Nov 2026 17:28:29 -0800 Subject: [PATCH] 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. --- internal/watch/watch.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/internal/watch/watch.go b/internal/watch/watch.go index 2dfbad6..fe684d4 100644 --- a/internal/watch/watch.go +++ b/internal/watch/watch.go @@ -854,20 +854,19 @@ func (w *Watcher) extractSnippets() { // syncGossip runs one anti-entropy sweep against configured peers and rebuilds // derived state if anything new arrived. func (w *Watcher) syncGossip() { - peers := PeerAddrs() - if len(peers) == 0 { - return + // Taken before the peer check: a replica with no seed peers still receives + // pushes, and that is the only thing that ever changes its log. Returning + // 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 - // inserts rows here, a peer's push inserted them in the HTTP handler. - pushedIn := w.pendingReconcile.Swap(false) + // inserts rows here, a peer's push inserted them in the HTTP handler. The + // entries cache and auto-threads are derived state that reconcile rebuilds. if pulled > 0 || pushedIn { created, linked, err := Reconcile(w.knoxDB) if err != nil {