mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-28 14:47:16 +00:00
Fixup for a possible deadlock if db.env.BeginTxn fails (#516)
* attempt to fix the deadlock * slightly more correct check Co-authored-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
parent
a86baf3e81
commit
95e361fa1e
@ -402,6 +402,11 @@ func (db *MdbxKV) BeginRo(ctx context.Context) (txn kv.Tx, err error) {
|
||||
if err == nil {
|
||||
db.wg.Add(1)
|
||||
}
|
||||
if txn == nil {
|
||||
// on error, or if there is whatever reason that we don't return a tx,
|
||||
// we need to free up the limiter slot, otherwise it could lead to deadlocks
|
||||
<-db.roTxsLimiter
|
||||
}
|
||||
}()
|
||||
|
||||
tx, err := db.env.BeginTxn(nil, mdbx.Readonly)
|
||||
|
Loading…
Reference in New Issue
Block a user