mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
swarm/storage: investigation of dbstore.Put deadlock
This commit is contained in:
parent
82e24a488d
commit
6d7cc72c91
1 changed files with 13 additions and 11 deletions
|
|
@ -553,38 +553,39 @@ func (s *DbStore) Put(chunk *Chunk) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
ikey := getIndexKey(chunk.Key)
|
||||||
|
var index dpaDBIndex
|
||||||
|
|
||||||
|
po := s.po(chunk.Key)
|
||||||
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.db.Get is being called...", "hash", chunk.Key.Hex())
|
||||||
|
|
||||||
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.LOCK acquiring", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.LOCK acquiring", "hash", chunk.Key.Hex())
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.LOCK acquired", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.LOCK acquired", "hash", chunk.Key.Hex())
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
|
|
||||||
ikey := getIndexKey(chunk.Key)
|
|
||||||
var index dpaDBIndex
|
|
||||||
|
|
||||||
po := s.po(chunk.Key)
|
|
||||||
|
|
||||||
idata, err := s.db.Get(ikey)
|
idata, err := s.db.Get(ikey)
|
||||||
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.db.Get", "hash", chunk.Key.Hex(), "err", err)
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.db.Get done", "hash", chunk.Key.Hex(), "err", err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.doPut(chunk, ikey, &index, po)
|
s.doPut(chunk, ikey, &index, po)
|
||||||
batchC := s.batchC
|
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put PANIC", "hash", chunk.Key.Hex(), "err", err)
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put PANIC", "hash", chunk.Key.Hex(), "err", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
<-batchC
|
|
||||||
close(chunk.dbStored)
|
|
||||||
}()
|
}()
|
||||||
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put doPut", "hash", chunk.Key.Hex(), "dataIdx", s.dataIdx)
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put doPut", "hash", chunk.Key.Hex(), "dataIdx", s.dataIdx)
|
||||||
} else {
|
} else {
|
||||||
log.Trace(fmt.Sprintf("DbStore: chunk already exists, only update access"))
|
log.Trace(fmt.Sprintf("DbStore: chunk already exists, only update access"))
|
||||||
decodeIndex(idata, &index)
|
decodeIndex(idata, &index)
|
||||||
close(chunk.dbStored)
|
|
||||||
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put already found", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put already found", "hash", chunk.Key.Hex())
|
||||||
}
|
}
|
||||||
|
batchC := s.batchC
|
||||||
|
go func() {
|
||||||
|
<-batchC
|
||||||
|
close(chunk.dbStored)
|
||||||
|
}()
|
||||||
index.Access = s.accessCnt
|
index.Access = s.accessCnt
|
||||||
s.accessCnt++
|
s.accessCnt++
|
||||||
idata = encodeIndex(&index)
|
idata = encodeIndex(&index)
|
||||||
|
|
@ -593,6 +594,7 @@ func (s *DbStore) Put(chunk *Chunk) {
|
||||||
case s.batchesC <- struct{}{}:
|
case s.batchesC <- struct{}{}:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.db.Put done", "hash", chunk.Key.Hex(), "err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// force putting into db, does not check access index
|
// force putting into db, does not check access index
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue