Skip to content

Commit c17500d

Browse files
authored
Merge pull request #860 from extole/delete-topic-not-thread-safe
Issue 730: inmemory deleteTopic is not thread-safe
2 parents 5205034 + 5fdec03 commit c17500d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

core/internal/storage/inmemory.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,13 +643,15 @@ func (module *InMemoryStorage) deleteTopic(request *protocol.StorageRequest, req
643643
return
644644
}
645645

646+
clusterMap.consumerLock.RLock()
646647
// Work backwards - remove the topic from consumer groups first
647648
for _, consumerMap := range clusterMap.consumer {
648649
consumerMap.lock.Lock()
649650
// No need to check for existence
650651
delete(consumerMap.topics, request.Topic)
651652
consumerMap.lock.Unlock()
652653
}
654+
clusterMap.consumerLock.RUnlock()
653655

654656
// Now remove the topic from the broker list
655657
clusterMap.brokerLock.Lock()

0 commit comments

Comments
 (0)