diff --git a/storage/localstore/subscription_pull.go b/storage/localstore/subscription_pull.go index 99b4f6e6c1..512e94b1b1 100644 --- a/storage/localstore/subscription_pull.go +++ b/storage/localstore/subscription_pull.go @@ -201,12 +201,12 @@ func (db *DB) LastPullSubscriptionBinID(bin uint8) (id uint64, err error) { // this function should be called. func (db *DB) triggerPullSubscriptions(bin uint8) { db.pullTriggersMu.RLock() + defer db.pullTriggersMu.RUnlock() + triggers, ok := db.pullTriggers[bin] - db.pullTriggersMu.RUnlock() if !ok { return } - for _, t := range triggers { select { case t <- struct{}{}: diff --git a/storage/localstore/subscription_push.go b/storage/localstore/subscription_push.go index 07821adf97..8521979f1b 100644 --- a/storage/localstore/subscription_push.go +++ b/storage/localstore/subscription_push.go @@ -150,10 +150,9 @@ func (db *DB) SubscribePush(ctx context.Context) (c <-chan chunk.Chunk, stop fun // this function should be called. func (db *DB) triggerPushSubscriptions() { db.pushTriggersMu.RLock() - triggers := db.pushTriggers - db.pushTriggersMu.RUnlock() + defer db.pushTriggersMu.RUnlock() - for _, t := range triggers { + for _, t := range db.pushTriggers { select { case t <- struct{}{}: default: