diff --git a/server/norace_test.go b/server/norace_test.go index 2aad8473..bcc68cd5 100644 --- a/server/norace_test.go +++ b/server/norace_test.go @@ -790,4 +790,18 @@ func TestNoRaceFetchAccountDoesNotRegisterAccountTwice(t *testing.T) { if !ok { t.Fatalf("B should be able to receive messages") } + + checkTmpAccounts := func(t *testing.T, s *Server) { + t.Helper() + empty := true + s.tmpAccounts.Range(func(_, _ interface{}) bool { + empty = false + return false + }) + if !empty { + t.Fatalf("tmpAccounts is not empty") + } + } + checkTmpAccounts(t, sa) + checkTmpAccounts(t, sb) } diff --git a/server/server.go b/server/server.go index 424fc594..27e67584 100644 --- a/server/server.go +++ b/server/server.go @@ -878,6 +878,7 @@ func (s *Server) registerAccountNoLock(acc *Account) *Account { // We are under the server lock. Lookup from map, if present // return existing account. if a, _ := s.accounts.Load(acc.Name); a != nil { + s.tmpAccounts.Delete(acc.Name) return a.(*Account) } // Finish account setup and store.