Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

localstore: fix data races on subscriptions #1970

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions storage/localstore/subscription_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}:
Expand Down
5 changes: 2 additions & 3 deletions storage/localstore/subscription_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down