Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion kv/mdbx/kv_mdbx.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@ func (opts MdbxOpts) Open() (kv.RwDB, error) {
}

if opts.roTxsLimiter == nil {
opts.roTxsLimiter = semaphore.NewWeighted(int64(runtime.GOMAXPROCS(-1)) - 1) // 1 less than max to allow unlocking to happen
targetSemCount := int64(runtime.GOMAXPROCS(-1)) - 1
if targetSemCount <= 1 {
targetSemCount = 2
}
opts.roTxsLimiter = semaphore.NewWeighted(targetSemCount) // 1 less than max to allow unlocking to happen
}
db := &MdbxKV{
opts: opts,
Expand Down
7 changes: 6 additions & 1 deletion kv/remotedb/kv_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,17 @@ func (opts remoteOpts) WithBucketsConfig(f mdbx.TableCfgFunc) remoteOpts {
}

func (opts remoteOpts) Open() (*RemoteKV, error) {
targetSemCount := int64(runtime.GOMAXPROCS(-1)) - 1
if targetSemCount <= 1 {
targetSemCount = 2
}

db := &RemoteKV{
opts: opts,
remoteKV: opts.remoteKV,
log: log.New("remote_db", opts.DialAddress),
buckets: kv.TableCfg{},
roTxsLimiter: semaphore.NewWeighted(int64(runtime.GOMAXPROCS(-1)) - 1), // 1 less than max to allow unlocking
roTxsLimiter: semaphore.NewWeighted(targetSemCount), // 1 less than max to allow unlocking
}
customBuckets := opts.bucketsCfg(kv.ChaindataTablesCfg)
for name, cfg := range customBuckets { // copy map to avoid changing global variable
Expand Down