Skip to content

Commit

Permalink
Prevent frequent commits to the node DB in sentries (erigontech#2505)
Browse files Browse the repository at this point in the history
* Prevent frequent commits to the node DB in sentries

* Commit when btree goes over limit

* iterator for SeedQuery

* Fixing test

* Fix tests

Co-authored-by: Alexey Sharp <[email protected]>
  • Loading branch information
AlexeyAkhunov and Alexey Sharp authored Aug 9, 2021
1 parent 350d7fe commit 65a9a26
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 38 deletions.
9 changes: 9 additions & 0 deletions cmd/sentry/download/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/golang/protobuf/ptypes/empty"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"

//grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/holiman/uint256"
"github.com/ledgerwatch/erigon-lib/gointerfaces"
Expand Down Expand Up @@ -552,6 +553,7 @@ func Sentry(datadir string, sentryAddr string, discoveryDNS []string, cfg *p2p.C
sentryServer.discoveryDNS = discoveryDNS

<-ctx.Done()
sentryServer.Close()
return nil
}

Expand Down Expand Up @@ -946,6 +948,13 @@ func (ss *SentryServerImpl) Messages(req *proto_sentry.MessagesRequest, server p
}
}

// Close performs cleanup operations for the sentry
func (ss *SentryServerImpl) Close() {
if ss.P2pServer != nil {
ss.P2pServer.Stop()
}
}

// MessageStreams - it's safe to use this class as non-pointer
type MessageStreams struct {
mu sync.RWMutex
Expand Down
3 changes: 3 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,5 +721,8 @@ func (s *Ethereum) Stop() error {
if s.config.Miner.Enabled {
<-s.waitForMiningStop
}
for _, sentryServer := range s.sentryServers {
sentryServer.Close()
}
return nil
}
Loading

0 comments on commit 65a9a26

Please sign in to comment.