From b0b7a3aa39b5d0d6e156895aa692f34cb98c2cef Mon Sep 17 00:00:00 2001 From: arkpar Date: Sun, 31 Jul 2016 12:43:16 +0200 Subject: [PATCH] Prevent deadlock on trace GC --- ethcore/src/trace/db.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethcore/src/trace/db.rs b/ethcore/src/trace/db.rs index 722d87273..25e900eed 100644 --- a/ethcore/src/trace/db.rs +++ b/ethcore/src/trace/db.rs @@ -264,10 +264,11 @@ impl TraceDatabase for TraceDB 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); }