Skip to content

Commit

Permalink
Merge pull request #5071 from multiversx/config-value-for-vm-query-delay
Browse files Browse the repository at this point in the history
extracted configuration value for vm-queries delay
  • Loading branch information
bogdan-rosianu committed Mar 14, 2023
2 parents 1e52082 + 235796b commit eddbb8b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cmd/node/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@
TrieOperationsDeadlineMilliseconds = 10000
# GetAddressesBulkMaxSize represents the maximum number of addresses to be fetched in a bulk per API request. 0 means unlimited
GetAddressesBulkMaxSize = 100
# VmQueryDelayAfterStartInSec represents the number of seconds to wait when starting node before accepting vm query requests
VmQueryDelayAfterStartInSec = 120
# EndpointsThrottlers represents a map for maximum simultaneous go routines for an endpoint
EndpointsThrottlers = [{ Endpoint = "/transaction/:hash", MaxNumGoRoutines = 10 },
{ Endpoint = "/transaction/send", MaxNumGoRoutines = 2 },
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ type WebServerAntifloodConfig struct {
SameSourceResetIntervalInSec uint32
TrieOperationsDeadlineMilliseconds uint32
GetAddressesBulkMaxSize uint32
VmQueryDelayAfterStartInSec uint32
EndpointsThrottlers []EndpointsThrottlersConfig
}

Expand Down
11 changes: 8 additions & 3 deletions node/nodeRunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ import (

const (
// TODO: remove this after better handling VM versions switching
// delayBeforeScQueriesStart represents the delay before the sc query processor should start to allow external queries
delayBeforeScQueriesStart = 2 * time.Minute
// defaultDelayBeforeScQueriesStartInSec represents the default delay before the sc query processor should start to allow external queries
defaultDelayBeforeScQueriesStartInSec = 120

maxTimeToClose = 10 * time.Second
// SoftRestartMessage is the custom message used when the node does a soft restart operation
Expand Down Expand Up @@ -516,9 +516,14 @@ func (nr *nodeRunner) executeOneComponentCreationCycle(

log.Info("application is now running")

delayInSecBeforeAllowingVmQueries := configs.GeneralConfig.WebServerAntiflood.VmQueryDelayAfterStartInSec
if delayInSecBeforeAllowingVmQueries == 0 {
log.Warn("WebServerAntiflood.VmQueryDelayAfterStartInSec value not set. will use default", "default", defaultDelayBeforeScQueriesStartInSec)
delayInSecBeforeAllowingVmQueries = defaultDelayBeforeScQueriesStartInSec
}
// TODO: remove this and treat better the VM versions switching
go func(statusHandler core.AppStatusHandler) {
time.Sleep(delayBeforeScQueriesStart)
time.Sleep(time.Duration(delayInSecBeforeAllowingVmQueries) * time.Second)
close(allowExternalVMQueriesChan)
statusHandler.SetStringValue(common.MetricAreVMQueriesReady, strconv.FormatBool(true))
}(managedStatusCoreComponents.AppStatusHandler())
Expand Down

0 comments on commit eddbb8b

Please sign in to comment.