fix: reconcile after a peer push, not only after a pull (#8)
A push-only node — a replica with no peers of its own, which is exactly the dhg.lol deployment — received observations but never rebuilt entries, so search returned nothing while the log filled up. The batch handler now signals the sweep, and reconcile runs when either direction changed the log.
This commit is contained in:
@@ -51,6 +51,9 @@ type Watcher struct {
|
||||
metricsSrv *http.Server
|
||||
quit chan struct{}
|
||||
quitOnce sync.Once
|
||||
// pendingReconcile is set when a peer's push added observations, so the
|
||||
// next sweep rebuilds derived state without reconciling per HTTP request.
|
||||
pendingReconcile atomic.Bool
|
||||
}
|
||||
|
||||
// fileDebouncer schedules one ingest per path a settle-window after the last
|
||||
@@ -158,6 +161,7 @@ func (w *Watcher) Start() error {
|
||||
// seed is still ingesting. Vault/dirs are logged after the seed below.
|
||||
gossipAddr := ListenAddr()
|
||||
node := &Node{Kdb: w.knoxDB, Name: "knox", Addr: AdvertiseAddr(), Metrics: w.metrics}
|
||||
node.OnIngest = func(int) { w.pendingReconcile.Store(true) }
|
||||
srv := &http.Server{
|
||||
Addr: gossipAddr,
|
||||
Handler: httpauth.Middleware(node.Handler()),
|
||||
@@ -861,7 +865,10 @@ func (w *Watcher) syncGossip() {
|
||||
// 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.
|
||||
if pulled > 0 {
|
||||
// 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)
|
||||
if pulled > 0 || pushedIn {
|
||||
created, linked, err := Reconcile(w.knoxDB)
|
||||
if err != nil {
|
||||
log.Printf("[knox] gossip reconcile: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user