fix(node): let a node take back a client orphaned before the upgrade

The migration backfills sync_orphaned_by = 0 for every client a node
merge had already soft-orphaned, and the gate refused a detached record
unless its mark named the reporting node. A client inside its orphan
grace window at upgrade time was therefore refused when its node
reported it again, and ReapSyncOrphans then deleted it on the master
while the node kept serving it.

A mark that names no node predates the column and may be taken back by
any node, as before.
This commit is contained in:
MHSanaei
2026-11-01 13:13:10 +01:00
parent 828855cdb5
commit 1d373cf67e
2 changed files with 10 additions and 4 deletions
+2 -1
View File
@@ -160,7 +160,8 @@ func loadNodeClientClaims(tx *gorm.DB, nodeID int, snap *runtime.TrafficSnapshot
case scope.elsewhere:
claims.refused[email] = "it is attached only to inbounds this node does not host"
claims.usageOnly[email] = struct{}{}
case !scope.here && (rec.SyncOrphanedAt == 0 || rec.SyncOrphanedBy != nodeID):
// A mark from before sync_orphaned_by existed names no node, so any node may take it back.
case !scope.here && (rec.SyncOrphanedAt == 0 || (rec.SyncOrphanedBy != 0 && rec.SyncOrphanedBy != nodeID)):
claims.refused[email] = "it is detached from every inbound on the master"
case subID != rec.SubID && subID != "" && subIDTaken(email, subID):
claims.storedSubID[email] = rec.SubID