mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-16 15:17:14 +00:00
fix(node): fan out operations that call every node
An operation that calls every node has to finish inside the panel's 30s write timeout. Reset all traffic, UpdatePanels and bulk inbound delete walked the nodes one at a time, up to 10s per hanging node, so 15 hanging nodes out of 150 kept each request running for 2m41s while the browser had already been told it failed. All three now fan out through fanoutInboundResults, bounded by nodeFanoutConcurrency (32, the heartbeat's bound), and UpdatePanels keeps its results in request order. Bulk delete still removes the rows one at a time, since each rewrites shared routing references, and only fans out the node pushes that delInbound now hands back.
This commit is contained in:
@@ -935,12 +935,11 @@ func (s *NodeService) UpdatePanels(ids []int, dev bool) ([]NodeUpdateResult, err
|
||||
if mgr == nil {
|
||||
return nil, fmt.Errorf("runtime manager unavailable")
|
||||
}
|
||||
results := make([]NodeUpdateResult, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
results, panics := fanoutInboundResults(ids, nodeFanoutConcurrency, func(i int) NodeUpdateResult {
|
||||
id := ids[i]
|
||||
n, err := s.GetById(id)
|
||||
if err != nil || n == nil {
|
||||
results = append(results, NodeUpdateResult{Id: id, OK: false, Error: "node not found"})
|
||||
continue
|
||||
return NodeUpdateResult{Id: id, OK: false, Error: "node not found"}
|
||||
}
|
||||
res := NodeUpdateResult{Id: id, Name: n.Name}
|
||||
switch {
|
||||
@@ -963,7 +962,12 @@ func (s *NodeService) UpdatePanels(ids []int, dev bool) ([]NodeUpdateResult, err
|
||||
res.OK = true
|
||||
}
|
||||
}
|
||||
results = append(results, res)
|
||||
return res
|
||||
})
|
||||
for i, panicErr := range panics {
|
||||
if panicErr != nil {
|
||||
results[i] = NodeUpdateResult{Id: ids[i], Error: panicErr.Error()}
|
||||
}
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user