From acbf251a3cad56d40703b48b4ec3a0a75847685d Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Thu, 3 May 2018 10:03:42 +0200 Subject: [PATCH] Fix race condition in `LDBDatabase.Close()` - https://jenkins.status.im/job/status-go/job/race-check/54/consoleFull --- .../patches/geth/0026-ethdb-error-deadlock.patch | 13 ++++++++++++- .../ethereum/go-ethereum/ethdb/database.go | 5 ++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/_assets/patches/geth/0026-ethdb-error-deadlock.patch b/_assets/patches/geth/0026-ethdb-error-deadlock.patch index 002fa502a..b83006f28 100644 --- a/_assets/patches/geth/0026-ethdb-error-deadlock.patch +++ b/_assets/patches/geth/0026-ethdb-error-deadlock.patch @@ -35,9 +35,20 @@ index 001d8f0bb..4c9b1412c 100644 - go db.meter(3 * time.Second) + db.wg.Add(1) + go func() { -+ db.wg.Done() ++ defer db.wg.Done() + db.meter(3 * time.Second) + }() } // meter periodically retrieves internal leveldb counters and reports them to +@@ -345,9 +347,8 @@ func (db *LDBDatabase) meter(refresh tim + + // Sleep a bit, then repeat the stats collection + select { +- case errc := <-db.quitChan: ++ case <-db.quitChan: + // Quit requesting, stop hammering the database +- errc <- nil + return + + case <-time.After(refresh): diff --git a/vendor/github.com/ethereum/go-ethereum/ethdb/database.go b/vendor/github.com/ethereum/go-ethereum/ethdb/database.go index 4c9b1412c..44fbcd2f6 100644 --- a/vendor/github.com/ethereum/go-ethereum/ethdb/database.go +++ b/vendor/github.com/ethereum/go-ethereum/ethdb/database.go @@ -173,7 +173,7 @@ func (db *LDBDatabase) Meter(prefix string) { db.wg.Add(1) go func() { - db.wg.Done() + defer db.wg.Done() db.meter(3 * time.Second) }() } @@ -347,9 +347,8 @@ func (db *LDBDatabase) meter(refresh time.Duration) { // Sleep a bit, then repeat the stats collection select { - case errc := <-db.quitChan: + case <-db.quitChan: // Quit requesting, stop hammering the database - errc <- nil return case <-time.After(refresh):