From dfe2c667e1f01621c3a612c032f2d87ee2cd0c1f Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 18 Oct 2021 19:13:56 +0300 Subject: [PATCH] core: do not hold the lock while seeking over persistent store --- pkg/core/storage/memcached_store.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/core/storage/memcached_store.go b/pkg/core/storage/memcached_store.go index 6619876be..ef1f1e583 100644 --- a/pkg/core/storage/memcached_store.go +++ b/pkg/core/storage/memcached_store.go @@ -125,6 +125,7 @@ func (s *MemCachedStore) SeekAsync(ctx context.Context, key []byte, cutPrefix bo }) } } + ps := s.ps s.mut.RUnlock() // Sort memRes items for further comparison with ps items. sort.Slice(memRes, func(i, j int) bool { @@ -152,9 +153,8 @@ func (s *MemCachedStore) SeekAsync(ctx context.Context, key []byte, cutPrefix bo // Seek over persistent store. go func() { - s.mut.RLock() var done bool - s.ps.Seek(key, func(k, v []byte) { + ps.Seek(key, func(k, v []byte) { if done { return } @@ -169,7 +169,6 @@ func (s *MemCachedStore) SeekAsync(ctx context.Context, key []byte, cutPrefix bo } } }) - s.mut.RUnlock() close(data2) }()