Skip to content

Commit

Permalink
Fix data race when updating account
Browse files Browse the repository at this point in the history
Signed-off-by: Waldemar Quevedo <wally@nats.io>
  • Loading branch information
wallyqs committed Aug 28, 2023
1 parent f1bf412 commit d06fbfa
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/server.go
Expand Up @@ -1898,11 +1898,14 @@ func (s *Server) LookupAccount(name string) (*Account, error) {
// This will fetch new claims and if found update the account with new claims.
// Lock MUST NOT be held upon entry.
func (s *Server) updateAccount(acc *Account) error {
acc.mu.RLock()
// TODO(dlc) - Make configurable
if !acc.incomplete && time.Since(acc.updated) < time.Second {
acc.mu.RUnlock()
s.Debugf("Requested account update for [%s] ignored, too soon", acc.Name)
return ErrAccountResolverUpdateTooSoon
}
acc.mu.RUnlock()
claimJWT, err := s.fetchRawAccountClaims(acc.Name)
if err != nil {
return err
Expand Down

0 comments on commit d06fbfa

Please sign in to comment.