Skip to content

Commit

Permalink
Merge pull request #88611 from cockroachdb/blathers/backport-release-…
Browse files Browse the repository at this point in the history
…22.1-88532

release-22.1: contention: prevent nil type assertion in event store
  • Loading branch information
ericharmeling authored Sep 23, 2022
2 parents f970524 + 439def3 commit 12f2054
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 12f2054

Please sign in to comment.