mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 01:58:34 +08:00
fix: rockmq race condition (#40482)
fix #40481 Signed-off-by: xiaofanluan <xiaofan.luan@zilliz.com>
This commit is contained in:
parent
d6a650bd14
commit
1c9d43ee9f
@ -612,9 +612,16 @@ func (rmq *rocksmq) destroyConsumerGroupInternal(topicName, groupName string) er
|
||||
consumers := vals.([]*Consumer)
|
||||
for index, v := range consumers {
|
||||
if v.GroupName == groupName {
|
||||
// Fix data race: close the channel before modifying the slice
|
||||
close(v.MsgMutex)
|
||||
consumers = append(consumers[:index], consumers[index+1:]...)
|
||||
rmq.consumers.Store(topicName, consumers)
|
||||
|
||||
// Create a new slice to avoid data race
|
||||
newConsumers := make([]*Consumer, 0, len(consumers)-1)
|
||||
newConsumers = append(newConsumers, consumers[:index]...)
|
||||
if index < len(consumers)-1 {
|
||||
newConsumers = append(newConsumers, consumers[index+1:]...)
|
||||
}
|
||||
rmq.consumers.Store(topicName, newConsumers)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user