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

Conversation

acud
Copy link
Member

@acud acud commented Nov 21, 2019

This PR fixes data races that were detected by the go race detector:

WARNING: DATA RACE
Write at 0x00c0082deb80 by goroutine 2475:
  runtime.slicecopy()
      /usr/local/go/src/runtime/slice.go:197 +0x0
  github.com/ethersphere/swarm/storage/localstore.(*DB).SubscribePull.func2()
      /home/growlie/go/src/github.com/ethersphere/swarm/storage/localstore/subscription_pull.go:173 +0x38b
  github.com/ethersphere/swarm/network/stream.(*Registry).serverCollectBatch()
      /home/growlie/go/src/github.com/ethersphere/swarm/network/stream/stream.go:962 +0xb22
  github.com/ethersphere/swarm/network/stream.(*Registry).serverHandleGetRange()
      /home/growlie/go/src/github.com/ethersphere/swarm/network/stream/stream.go:443 +0x682
  github.com/ethersphere/swarm/network/stream.(*Registry).HandleMsg.func1.1()
      /home/growlie/go/src/github.com/ethersphere/swarm/network/stream/stream.go:188 +0xa6b

Previous read at 0x00c0082deb80 by goroutine 2477:
  github.com/ethersphere/swarm/storage/localstore.(*DB).triggerPullSubscriptions()
      /home/growlie/go/src/github.com/ethersphere/swarm/storage/localstore/subscription_pull.go:210 +0x10d
  github.com/ethersphere/swarm/storage/localstore.(*DB).put()
      /home/growlie/go/src/github.com/ethersphere/swarm/storage/localstore/mode_put.go:150 +0x5aa
  github.com/ethersphere/swarm/storage/localstore.(*DB).Put()
      /home/growlie/go/src/github.com/ethersphere/swarm/storage/localstore/mode_put.go:41 +0x234
  github.com/ethersphere/swarm/storage.(*NetStore).Put()
      /home/growlie/go/src/github.com/ethersphere/swarm/storage/netstore.go:116 +0x479
  github.com/ethersphere/swarm/storage.(*LNetStore).Put()
      <autogenerated>:1 +0xc9
  github.com/ethersphere/swarm/storage.(*FileStore).Put()

@acud acud requested review from janos and zelig November 21, 2019 09:37
@acud acud self-assigned this Nov 21, 2019
Copy link
Member

@janos janos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding and fixing this.

@holisticode holisticode self-requested a review November 21, 2019 15:00
@acud acud added the core label Nov 21, 2019
@acud acud merged commit 47b8a33 into master Nov 21, 2019
@acud acud deleted the fix-localstore-race branch November 21, 2019 15:21
@acud acud added this to the 0.5.3 milestone Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants