Skip to content

Commit

Permalink
contention: prevent nil type assertion in event store
Browse files Browse the repository at this point in the history
This commit prevents a nil type assertion from causing the system to panic.

Fixes #88091.

Release note: None
  • Loading branch information
ericharmeling committed Sep 23, 2022
1 parent bdcab67 commit 439def3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/sql/contention/event_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,22 +276,26 @@ func (s *eventStore) ForEachEvent(
// getting the event. In this case we simply ignore it.
continue
}
if err := op(&event); err != nil {
if err := op(event); err != nil {
return err
}
}

return nil
}

func (s *eventStore) getEventByEventHash(
hash uint64,
) (_ contentionpb.ExtendedContentionEvent, ok bool) {
) (_ *contentionpb.ExtendedContentionEvent, ok bool) {
s.mu.RLock()
defer s.mu.RUnlock()

event, ok := s.mu.store.Get(hash)
return event.(contentionpb.ExtendedContentionEvent), ok
var contentionEvent contentionpb.ExtendedContentionEvent
var event interface{}
if event, ok = s.mu.store.Get(hash); ok {
if contentionEvent, ok = event.(contentionpb.ExtendedContentionEvent); ok {
return &contentionEvent, ok
}
}
return nil, ok
}

// flushAndResolve is the main method called by the resolver goroutine each
Expand Down

0 comments on commit 439def3

Please sign in to comment.