Skip to content

Commit

Permalink
Merge 035c98f into 82edf4b
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovic committed Feb 12, 2022
2 parents 82edf4b + 035c98f commit 789c869
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions server/server.go
Expand Up @@ -3245,19 +3245,19 @@ func (s *StanServer) checkClientHealth(clientID string) {
client.fhb++
// If we have reached the max number of failures
if client.fhb > s.opts.ClientHBFailCount {
s.log.Errorf("[Client:%s] Timed out on heartbeats", clientID)
// close the client (connection). This locks the
// client object internally so unlock here.
client.Unlock()
// If clustered, thread operations through Raft.
if s.isClustered {
if err := s.replicateConnClose(&pb.CloseRequest{ClientID: clientID}, false); err != nil {
s.log.Errorf("[Client:%s] Failed to replicate disconnect on heartbeat expiration: %v",
clientID, err)
s.barrier(func() {
s.log.Errorf("[Client:%s] Timed out on heartbeats", clientID)
// If clustered, thread operations through Raft.
if s.isClustered {
if err := s.replicateConnClose(&pb.CloseRequest{ClientID: clientID}, false); err != nil {
s.log.Errorf("[Client:%s] Failed to replicate disconnect on heartbeat expiration: %v",
clientID, err)
}
} else {
s.closeClient(clientID)
}
} else {
s.closeClient(clientID)
}
})
return
}
} else {
Expand Down Expand Up @@ -3298,14 +3298,16 @@ func (s *StanServer) closeClient(clientID string) error {
return ErrUnknownClient
}

// Remove all non-durable subscribers.
s.removeAllNonDurableSubscribers(client)

// Remove from our clientStore.
// Remove from our clientStore before removing subs.
// This prevent race when the same client ID is just
// reconnecting and registering a durable.
if _, err := s.clients.unregister(clientID); err != nil {
s.log.Errorf("Error unregistering client %q: %v", clientID, err)
}

// Remove all non-durable subscribers.
s.removeAllNonDurableSubscribers(client)

if s.debug {
client.RLock()
hbInbox := client.info.HbInbox
Expand Down

0 comments on commit 789c869

Please sign in to comment.