mdbx: fix possible semaphore exhaustion on cancelled context (#567)

This commit is contained in:
Ryan Schneider 2022-08-03 21:43:56 -07:00 committed by GitHub
parent 1d6c297797
commit 8fbf01ca91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -419,12 +419,6 @@ func (db *MdbxKV) BeginRo(ctx context.Context) (txn kv.Tx, err error) {
return nil, semErr
}
// if context cancelled as we acquire the sempahore, it may succeed without blocking
// in this case we should return
if ctx.Err() != nil {
return nil, ctx.Err()
}
defer func() {
if err == nil {
db.wg.Add(1)