Skip to content

Commit 3c0e61c

Browse files
authored
Merge pull request #1130 from lrweck/fix/race_condition_kind_count
fix race condition
2 parents 76c172a + f3ded6f commit 3c0e61c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cluster/gossiper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func (g *Gossiper) GetActorCount() map[string]int64 {
341341
clusterKinds := g.cluster.GetClusterKinds()
342342
for _, kindName := range clusterKinds {
343343
kind := g.cluster.GetClusterKind(kindName)
344-
m[kindName] = int64(kind.count)
344+
m[kindName] = int64(kind.Count())
345345
}
346346
g.cluster.Logger().Debug("Actor Count", slog.Any("count", m))
347347

cluster/kind.go

+4
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ func (ak *ActivatedKind) Inc() {
5555
func (ak *ActivatedKind) Dec() {
5656
atomic.AddInt32(&ak.count, -1)
5757
}
58+
59+
func (ak *ActivatedKind) Count() int32 {
60+
return atomic.LoadInt32(&ak.count)
61+
}

0 commit comments

Comments
 (0)