fix(node-sync): don't delete a node's central inbounds when its snapshot is empty

The central-inbound sweep deletes any central inbound whose tag is absent from the node's snapshot, with no guard for an empty snapshot. A node mid-restart or with a transient DB error (e.g. Postgres 57P01) can return an empty inbound list with success=true, which wiped all of that node's central inbounds and their clients (and reset traffic history on re-create) — observed on the Germany node: 0 clients but still 44 online (online survives because it comes from the snapshot's online tree, not the central inbound). Skip the sweep entirely when the snapshot reports zero inbounds; a real per-inbound deletion still sweeps via a non-empty snapshot that omits one tag.
This commit is contained in:
MHSanaei
2026-06-22 16:32:33 +02:00
parent 7458ed4064
commit e0ac65a05f
2 changed files with 46 additions and 0 deletions
+9
View File
@@ -499,6 +499,15 @@ func (s *InboundService) setRemoteTrafficLocked(nodeID int, snap *runtime.Traffi
if dirty {
continue
}
if len(snapTags) == 0 {
// A node mid-restart or with a transient DB error can return an empty
// inbound list with success=true. Treat "zero inbounds reported" as
// "nothing to say", not "delete all my inbounds" — otherwise a blip
// wipes the node's central inbounds and every client on them (and
// resets traffic history on re-create). A real per-inbound deletion
// still sweeps, because the node keeps reporting its other inbounds.
continue
}
if _, kept := snapTags[c.Tag]; kept {
continue
}