Merge pull request #1833 from ethcore/trace-deadlock-fix

Fixing another deadlock in trace db
This commit is contained in:
Marek Kotewicz 2016-08-04 10:36:45 +02:00 committed by GitHub
commit ab079fd7bf

View File

@ -294,10 +294,11 @@ impl<T> TraceDatabase for TraceDB<T> where T: DatabaseExtras {
.map(|p| (From::from(p.0), From::from(p.1))) .map(|p| (From::from(p.0), From::from(p.1)))
.collect::<HashMap<TraceGroupPosition, blooms::BloomGroup>>(); .collect::<HashMap<TraceGroupPosition, blooms::BloomGroup>>();
let mut blooms = self.blooms.write(); // note_used must be called before locking blooms to avoid cache/traces deadlock on garbage collection
for key in blooms_to_insert.keys() { for key in blooms_to_insert.keys() {
self.note_used(CacheID::Bloom(key.clone())); self.note_used(CacheID::Bloom(key.clone()));
} }
let mut blooms = self.blooms.write();
batch.extend_with_cache(DB_COL_TRACE, blooms.deref_mut(), blooms_to_insert, CacheUpdatePolicy::Remove); batch.extend_with_cache(DB_COL_TRACE, blooms.deref_mut(), blooms_to_insert, CacheUpdatePolicy::Remove);
} }
} }