mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-15 23:38:19 +00:00
ensure kv semaphore has at least 1 count (#641)
This commit is contained in:
parent
ef693175fe
commit
547ac03eeb
@ -281,7 +281,11 @@ func (opts MdbxOpts) Open() (kv.RwDB, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opts.roTxsLimiter == nil {
|
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{
|
db := &MdbxKV{
|
||||||
opts: opts,
|
opts: opts,
|
||||||
|
@ -69,12 +69,17 @@ func (opts remoteOpts) WithBucketsConfig(f mdbx.TableCfgFunc) remoteOpts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (opts remoteOpts) Open() (*RemoteKV, error) {
|
func (opts remoteOpts) Open() (*RemoteKV, error) {
|
||||||
|
targetSemCount := int64(runtime.GOMAXPROCS(-1)) - 1
|
||||||
|
if targetSemCount <= 1 {
|
||||||
|
targetSemCount = 2
|
||||||
|
}
|
||||||
|
|
||||||
db := &RemoteKV{
|
db := &RemoteKV{
|
||||||
opts: opts,
|
opts: opts,
|
||||||
remoteKV: opts.remoteKV,
|
remoteKV: opts.remoteKV,
|
||||||
log: log.New("remote_db", opts.DialAddress),
|
log: log.New("remote_db", opts.DialAddress),
|
||||||
buckets: kv.TableCfg{},
|
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)
|
customBuckets := opts.bucketsCfg(kv.ChaindataTablesCfg)
|
||||||
for name, cfg := range customBuckets { // copy map to avoid changing global variable
|
for name, cfg := range customBuckets { // copy map to avoid changing global variable
|
||||||
|
Loading…
Reference in New Issue
Block a user