From 237e68059d836d6abf199097997f3315722e992d Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 31 Mar 2024 17:45:26 -0700 Subject: [PATCH] shutdown follower if no clients, not only publishers to avoid overhead when a publisher repeatedly send one message and close --- weed/mq/topic/local_partition.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/weed/mq/topic/local_partition.go b/weed/mq/topic/local_partition.go index 0873d6bd7..40ab3cee6 100644 --- a/weed/mq/topic/local_partition.go +++ b/weed/mq/topic/local_partition.go @@ -190,7 +190,7 @@ func (p *LocalPartition) MaybeConnectToFollowers(initMessage *mq_pb.PublishMessa func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) { - if p.Publishers.Size() == 0 { + if p.Publishers.Size() == 0 && p.Subscribers.Size() == 0 { if p.followerStream != nil { // send close to the follower if followErr := p.followerStream.Send(&mq_pb.PublishFollowMeRequest{ @@ -205,9 +205,7 @@ func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) { p.followerStream = nil p.follower = "" } - } - if p.Publishers.Size() == 0 && p.Subscribers.Size() == 0 { p.LogBuffer.ShutdownLogBuffer() hasShutdown = true }