Advance durable Agent session generations on restart
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user