fix race condition where leveldb is closed before the iterator
should solve assertion errors like: db/version_set.cc:710: leveldb::VersionSet::~VersionSet(): Assertion `dummy_versions_.next_ == &dummy_versions_' failedmaster
parent
178aba56dd
commit
129799328d
|
@ -86,6 +86,10 @@ func (p *NodesCache) Iter() chan *element.Node {
|
|||
ro := levigo.NewReadOptions()
|
||||
ro.SetFillCache(false)
|
||||
it := p.db.NewIterator(ro)
|
||||
// we need to Close the iter before closing the
|
||||
// chan (and thus signaling that we are done)
|
||||
// to avoid race where db is closed before the iterator
|
||||
close(nodes)
|
||||
defer it.Close()
|
||||
it.SeekToFirst()
|
||||
for ; it.Valid(); it.Next() {
|
||||
|
@ -97,7 +101,6 @@ func (p *NodesCache) Iter() chan *element.Node {
|
|||
|
||||
nodes <- node
|
||||
}
|
||||
close(nodes)
|
||||
}()
|
||||
return nodes
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@ func (p *RelationsCache) Iter() chan *element.Relation {
|
|||
ro := levigo.NewReadOptions()
|
||||
ro.SetFillCache(false)
|
||||
it := p.db.NewIterator(ro)
|
||||
// we need to Close the iter before closing the
|
||||
// chan (and thus signaling that we are done)
|
||||
// to avoid race where db is closed before the iterator
|
||||
defer close(rels)
|
||||
defer it.Close()
|
||||
it.SeekToFirst()
|
||||
for ; it.Valid(); it.Next() {
|
||||
|
@ -64,7 +68,6 @@ func (p *RelationsCache) Iter() chan *element.Relation {
|
|||
|
||||
rels <- rel
|
||||
}
|
||||
close(rels)
|
||||
}()
|
||||
return rels
|
||||
}
|
||||
|
|
|
@ -72,6 +72,10 @@ func (p *WaysCache) Iter() chan *element.Way {
|
|||
ro := levigo.NewReadOptions()
|
||||
ro.SetFillCache(false)
|
||||
it := p.db.NewIterator(ro)
|
||||
// we need to Close the iter before closing the
|
||||
// chan (and thus signaling that we are done)
|
||||
// to avoid race where db is closed before the iterator
|
||||
defer close(ways)
|
||||
defer it.Close()
|
||||
it.SeekToFirst()
|
||||
for ; it.Valid(); it.Next() {
|
||||
|
@ -82,7 +86,6 @@ func (p *WaysCache) Iter() chan *element.Way {
|
|||
way.Id = idFromKeyBuf(it.Key())
|
||||
ways <- way
|
||||
}
|
||||
close(ways)
|
||||
}()
|
||||
return ways
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue