Advance durable Agent session generations on restart

This commit is contained in:
2026-09-30 07:21:16 +08:00
parent ac0abfc734
commit 7bcde1812f
5 changed files with 66 additions and 3 deletions
+9
View File
@@ -294,6 +294,9 @@ func (r *SessionRegistry) Activate(binding *agentpb.AgentBinding, activationOper
return cloneSession(existing.session), true, nil
}
if binding.SessionGeneration == 0 {
if existing.binding.SessionGeneration == ^uint64(0) {
return nil, false, status.Error(codes.Aborted, "session generation is exhausted")
}
binding = proto.Clone(binding).(*agentpb.AgentBinding)
binding.SessionGeneration = existing.binding.SessionGeneration + 1
}
@@ -304,6 +307,12 @@ func (r *SessionRegistry) Activate(binding *agentpb.AgentBinding, activationOper
if binding.SessionGeneration == 0 {
binding = proto.Clone(binding).(*agentpb.AgentBinding)
binding.SessionGeneration = 1
if previous, ok := r.generations[binding.AgentId]; ok {
if previous == ^uint64(0) {
return nil, false, status.Error(codes.Aborted, "session generation is exhausted")
}
binding.SessionGeneration = previous + 1
}
}
if previous, ok := r.generations[binding.AgentId]; ok && binding.SessionGeneration <= previous {
return nil, false, status.Error(codes.Aborted, "persisted session generation is fenced")