Skip to content

Commit

Permalink
Fix for API data race. (#4030)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Collison <derek@nats.io>
  • Loading branch information
derekcollison committed Apr 6, 2023
2 parents f02f379 + a60f623 commit 33451e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/events_test.go
Expand Up @@ -1515,6 +1515,7 @@ func TestAccountClaimsUpdatesWithServiceImports(t *testing.T) {
nc.Publish(claimUpdateSubj, []byte(ajwt2))
}
nc.Flush()
time.Sleep(50 * time.Millisecond)

if startSubs < s.NumSubscriptions() {
t.Fatalf("Subscriptions leaked: %d vs %d", startSubs, s.NumSubscriptions())
Expand Down
7 changes: 7 additions & 0 deletions server/jetstream_api.go
Expand Up @@ -890,10 +890,17 @@ func (s *Server) sendAPIErrResponse(ci *ClientInfo, acc *Account, subject, reply
const errRespDelay = 500 * time.Millisecond

func (s *Server) sendDelayedAPIErrResponse(ci *ClientInfo, acc *Account, subject, reply, request, response string, rg *raftGroup) {
js := s.getJetStream()
if js == nil {
return
}
var quitCh <-chan struct{}
js.mu.RLock()
if rg != nil && rg.node != nil {
quitCh = rg.node.QuitC()
}
js.mu.RUnlock()

s.startGoRoutine(func() {
defer s.grWG.Done()
select {
Expand Down

0 comments on commit 33451e5

Please sign in to comment.