mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-02 11:18:57 +08:00
fix node manager deadlock by moving audit write outside lock
This commit is contained in:
@@ -41,7 +41,6 @@ func (m *Manager) SetAuditPath(path string) {
|
||||
|
||||
func (m *Manager) Upsert(info NodeInfo) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
now := time.Now().UTC()
|
||||
old, existed := m.nodes[info.ID]
|
||||
info.LastSeenAt = now
|
||||
@@ -60,6 +59,7 @@ func (m *Manager) Upsert(info NodeInfo) {
|
||||
info.RegisteredAt = now
|
||||
}
|
||||
m.nodes[info.ID] = info
|
||||
m.mu.Unlock()
|
||||
m.appendAudit("upsert", info.ID, map[string]interface{}{"existed": existed, "endpoint": info.Endpoint, "version": info.Version})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user