mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-02-11 23:22:54 +00:00
core: perform synchronized persist if GC took some time
The intention here is to reduce the amount of in-flight changes and prevent OOM. It doesn't matter what we're doing, persisting or collecting garbage, what matters is that we're behind the schedule of regular persist cycle. Refs. #3783. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
1f83f472c7
commit
ba0ca6a4ab
1 changed files with 2 additions and 3 deletions
|
@ -1119,7 +1119,6 @@ func (bc *Blockchain) Run() {
|
|||
return
|
||||
case <-persistTimer.C:
|
||||
var oldPersisted uint32
|
||||
var gcDur time.Duration
|
||||
|
||||
if bc.config.Ledger.RemoveUntraceableBlocks {
|
||||
oldPersisted = atomic.LoadUint32(&bc.persistedHeight)
|
||||
|
@ -1129,10 +1128,10 @@ func (bc *Blockchain) Run() {
|
|||
bc.log.Warn("failed to persist blockchain", zap.Error(err))
|
||||
}
|
||||
if bc.config.Ledger.RemoveUntraceableBlocks {
|
||||
gcDur = bc.tryRunGC(oldPersisted)
|
||||
dur += bc.tryRunGC(oldPersisted)
|
||||
}
|
||||
nextSync = dur > persistInterval*2
|
||||
interval := persistInterval - dur - gcDur
|
||||
interval := persistInterval - dur
|
||||
interval = max(interval, time.Microsecond) // Reset doesn't work with zero or negative value.
|
||||
persistTimer.Reset(interval)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue