fix(pier): an ended session is never written back by a request still in flight
- persisting a session's protocol state after a request now rewrites an existing record only (Redis SET XX, the memory store likewise) and closes the local copy when the record is gone - before, a request that finished after DELETE, a revoked or deleted subject event or the idle expiry put the record back, and the next request rehydrated the ended session - found by plan 19.7-05's TestFanOut (revocation and deletion cases, about one run in a hundred)
This commit is contained in:
@@ -52,6 +52,19 @@ func (m *memoryStore) Get(_ context.Context, id string) (Record, bool, error) {
|
||||
return r.rec, true, nil
|
||||
}
|
||||
|
||||
// Update rewrites an existing record; a missing or expired one stays gone.
|
||||
func (m *memoryStore) Update(_ context.Context, id string, rec Record, ttl time.Duration) (bool, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
r, ok := m.records[id]
|
||||
if !ok || !r.expires.After(m.now()) {
|
||||
delete(m.records, id)
|
||||
return false, nil
|
||||
}
|
||||
m.records[id] = memoryRecord{rec: rec, expires: m.now().Add(ttl)}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (m *memoryStore) Touch(_ context.Context, id string, ttl time.Duration) error {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user