diff --git a/nsqd/client_v2.go b/nsqd/client_v2.go index 41002b5bd..877d6b234 100644 --- a/nsqd/client_v2.go +++ b/nsqd/client_v2.go @@ -327,8 +327,11 @@ func (c *clientV2) IsReadyForMessages() bool { } func (c *clientV2) SetReadyCount(count int64) { - atomic.StoreInt64(&c.ReadyCount, count) - c.tryUpdateReadyState() + oldCount := atomic.SwapInt64(&c.ReadyCount, count) + + if oldCount != count { + c.tryUpdateReadyState() + } } func (c *clientV2) tryUpdateReadyState() {