Fix for API data race. (#4030)

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2023-04-06 10:45:29 -07:00
committed by GitHub
2 changed files with 8 additions and 0 deletions

View File

@@ -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())

View File

@@ -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 {