mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-02 10:17:10 +01:00
fix: only log endpoint_changed when endpoint actually changed
ProcessAssignment now compares pre/post endpoint state before logging session_invalidated with "endpoint_changed" reason. Normal session supersede (same endpoint, assignment_intent) no longer mislabeled as endpoint change. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5cdee4a011
commit
adaff8ddb3
1 file changed
+6
-4
@@ -28,10 +28,11 @@ func NewRecoveryOrchestrator() *RecoveryOrchestrator {
|
|||||||
// ProcessAssignment applies an assignment intent and logs the result.
|
// ProcessAssignment applies an assignment intent and logs the result.
|
||||||
// Detects endpoint-change invalidations automatically.
|
// Detects endpoint-change invalidations automatically.
|
||||||
func (o *RecoveryOrchestrator) ProcessAssignment(intent AssignmentIntent) AssignmentResult {
|
func (o *RecoveryOrchestrator) ProcessAssignment(intent AssignmentIntent) AssignmentResult {
|
||||||
// Snapshot pre-assignment session state for invalidation detection.
|
// Snapshot pre-assignment state for invalidation detection.
|
||||||
type preState struct {
|
type preState struct {
|
||||||
hadSession bool
|
hadSession bool
|
||||||
sessionID uint64
|
sessionID uint64
|
||||||
|
endpoint Endpoint
|
||||||
}
|
}
|
||||||
pre := map[string]preState{}
|
pre := map[string]preState{}
|
||||||
for _, ra := range intent.Replicas {
|
for _, ra := range intent.Replicas {
|
||||||
@@ -39,6 +40,7 @@ func (o *RecoveryOrchestrator) ProcessAssignment(intent AssignmentIntent) Assign
|
|||||||
pre[ra.ReplicaID] = preState{
|
pre[ra.ReplicaID] = preState{
|
||||||
hadSession: s.HasActiveSession(),
|
hadSession: s.HasActiveSession(),
|
||||||
sessionID: s.SessionID(),
|
sessionID: s.SessionID(),
|
||||||
|
endpoint: s.Endpoint(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,12 +54,12 @@ func (o *RecoveryOrchestrator) ProcessAssignment(intent AssignmentIntent) Assign
|
|||||||
o.Log.Record(id, 0, "sender_removed", "")
|
o.Log.Record(id, 0, "sender_removed", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect endpoint-change invalidations: if the session ID changed
|
// Detect endpoint-change invalidations: only log "endpoint_changed" when
|
||||||
// (old session was invalidated and possibly replaced), log the old one.
|
// the endpoint actually changed, not on normal session supersede.
|
||||||
for id, p := range pre {
|
for id, p := range pre {
|
||||||
if p.hadSession {
|
if p.hadSession {
|
||||||
s := o.Registry.Sender(id)
|
s := o.Registry.Sender(id)
|
||||||
if s != nil && s.SessionID() != p.sessionID {
|
if s != nil && s.SessionID() != p.sessionID && s.Endpoint().Changed(p.endpoint) {
|
||||||
o.Log.Record(id, p.sessionID, "session_invalidated", "endpoint_changed")
|
o.Log.Record(id, p.sessionID, "session_invalidated", "endpoint_changed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user