Prevent deadlock on trace GC

This commit is contained in:
arkpar 2016-07-31 12:43:16 +02:00
parent 9e5e57fdcd
commit b0b7a3aa39

View File

@ -264,10 +264,11 @@ impl<T> TraceDatabase for TraceDB<T> where T: DatabaseExtras {
// at first, let's insert new block traces
{
// note_used must be called before locking traces to avoid cache/traces deadlock on garbage collection
self.note_used(CacheID::Trace(request.block_hash.clone()));
let mut traces = self.traces.write();
// it's important to use overwrite here,
// cause this value might be queried by hash later
self.note_used(CacheID::Trace(request.block_hash.clone()));
batch.write_with_cache(DB_COL_TRACE, traces.deref_mut(), request.block_hash, request.traces, CacheUpdatePolicy::Overwrite);
}