From e1215d5da8f6f0e9f2fab1d65a6623b3ec624b85 Mon Sep 17 00:00:00 2001 From: Michal Niewrzal Date: Tue, 26 Sep 2023 09:41:15 +0200 Subject: [PATCH] satellite/overlay: add AOST to GetParticipatingNodes method This method is sometimes ends with transaction error. Most probably because it's trying to do full table scan on nodes table which is heavily used. Adding AOST should help with DB contention. Change-Id: Ibd4358d28dc26922b60c6b30862f20e7c0662cd1 --- satellite/overlay/config.go | 1 + satellite/overlay/service.go | 3 +-- scripts/testdata/satellite-config.yaml.lock | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/satellite/overlay/config.go b/satellite/overlay/config.go index b3931d40a..9f9d2ee94 100644 --- a/satellite/overlay/config.go +++ b/satellite/overlay/config.go @@ -29,6 +29,7 @@ type Config struct { RepairExcludedCountryCodes []string `help:"list of country codes to exclude nodes from target repair selection" default:"" testDefault:"FR,BE"` SendNodeEmails bool `help:"whether to send emails to nodes" default:"false"` MinimumNewNodeIDDifficulty int `help:"the minimum node id difficulty required for new nodes. existing nodes remain allowed" devDefault:"0" releaseDefault:"36"` + AsOfSystemTime time.Duration `help:"default AS OF SYSTEM TIME for service" default:"-10s" testDefault:"0"` } // AsOfSystemTimeConfig is a configuration struct to enable 'AS OF SYSTEM TIME' for CRDB queries. diff --git a/satellite/overlay/service.go b/satellite/overlay/service.go index d7da60932..51290117e 100644 --- a/satellite/overlay/service.go +++ b/satellite/overlay/service.go @@ -506,8 +506,7 @@ func (service *Service) GetNodes(ctx context.Context, nodeIDs storj.NodeIDList) func (service *Service) GetParticipatingNodes(ctx context.Context) (records []nodeselection.SelectedNode, err error) { defer mon.Task()(&ctx)(&err) - // TODO add as of system time. - return service.db.GetParticipatingNodes(ctx, service.config.Node.OnlineWindow, 0) + return service.db.GetParticipatingNodes(ctx, service.config.Node.OnlineWindow, service.config.AsOfSystemTime) } // UpdateReputation updates the DB columns for any of the reputation fields. diff --git a/scripts/testdata/satellite-config.yaml.lock b/scripts/testdata/satellite-config.yaml.lock index 61c2a48d8..deb55df95 100755 --- a/scripts/testdata/satellite-config.yaml.lock +++ b/scripts/testdata/satellite-config.yaml.lock @@ -802,6 +802,9 @@ identity.key-path: /root/.local/share/storj/identity/satellite/identity.key # how many concurrent orders to process at once. zero is unlimited # orders.orders-semaphore-size: 2 +# default AS OF SYSTEM TIME for service +# overlay.as-of-system-time: -10s + # the location of the maxmind database containing geoip country information # overlay.geo-ip.db: ""