From 5fdec03389b47649faf52bac447a93c93cab8ba7 Mon Sep 17 00:00:00 2001 From: sergeykranga Date: Mon, 20 Mar 2023 19:17:31 +0200 Subject: [PATCH] Issue 730: inmemory deleteTopic is not thread-safe --- core/internal/storage/inmemory.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/internal/storage/inmemory.go b/core/internal/storage/inmemory.go index 5f8fcd8c..d2dfd39e 100644 --- a/core/internal/storage/inmemory.go +++ b/core/internal/storage/inmemory.go @@ -642,6 +642,7 @@ func (module *InMemoryStorage) deleteTopic(request *protocol.StorageRequest, req return } + clusterMap.consumerLock.RLock() // Work backwards - remove the topic from consumer groups first for _, consumerMap := range clusterMap.consumer { consumerMap.lock.Lock() @@ -649,6 +650,7 @@ func (module *InMemoryStorage) deleteTopic(request *protocol.StorageRequest, req delete(consumerMap.topics, request.Topic) consumerMap.lock.Unlock() } + clusterMap.consumerLock.RUnlock() // Now remove the topic from the broker list clusterMap.brokerLock.Lock()