[#1118] neofs-node: add shard_ro_error_threshold config setting

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-02-01 11:15:54 +03:00 committed by Alex Vanin
parent ed50cf6207
commit e03cb91b64
6 changed files with 13 additions and 0 deletions

View file

@ -331,6 +331,7 @@ func initLocalStorage(c *cfg) {
engineOpts := []engine.Option{
engine.WithLogger(c.log),
engine.WithShardPoolSize(engineconfig.ShardPoolSize(c.appCfg)),
engine.WithErrorThreshold(engineconfig.ShardErrorThreshold(c.appCfg)),
}
if c.metricsCollector != nil {
engineOpts = append(engineOpts, engine.WithMetrics(c.metricsCollector))

View file

@ -58,3 +58,10 @@ func ShardPoolSize(c *config.Config) uint32 {
return ShardPoolSizeDefault
}
// ShardErrorThreshold returns value of "shard_ro_error_threshold" config parameter from "storage" section.
//
// Returns 0 if the value is missing.
func ShardErrorThreshold(c *config.Config) uint32 {
return config.Uint32Safe(c.Sub(subsection), "shard_ro_error_threshold")
}

View file

@ -31,6 +31,7 @@ func TestEngineSection(t *testing.T) {
require.False(t, handlerCalled)
require.EqualValues(t, 0, engineconfig.ShardErrorThreshold(empty))
require.EqualValues(t, engineconfig.ShardPoolSizeDefault, engineconfig.ShardPoolSize(empty))
require.EqualValues(t, shard.ModeReadWrite, shardconfig.From(empty).Mode())
})
@ -40,6 +41,7 @@ func TestEngineSection(t *testing.T) {
var fileConfigTest = func(c *config.Config) {
num := 0
require.EqualValues(t, 100, engineconfig.ShardErrorThreshold(c))
require.EqualValues(t, 15, engineconfig.ShardPoolSize(c))
engineconfig.IterateShards(c, true, func(sc *shardconfig.Config) {

View file

@ -70,6 +70,7 @@ NEOFS_OBJECT_PUT_POOL_SIZE_REMOTE=100
# Storage engine section
NEOFS_STORAGE_SHARD_POOL_SIZE=15
NEOFS_STORAGE_SHARD_NUM=2
NEOFS_STORAGE_SHARD_RO_ERROR_THRESHOLD=100
## 0 shard
### Flag to refill Metabase from BlobStor
NEOFS_STORAGE_SHARD_0_RESYNC_METABASE=false

View file

@ -115,6 +115,7 @@
"storage": {
"shard_pool_size": 15,
"shard_num": 2,
"shard_ro_error_threshold": 100,
"shard": {
"0": {
"mode": "read-only",

View file

@ -99,6 +99,7 @@ storage:
# note: shard configuration can be omitted for relay node (see `node.relay`)
shard_pool_size: 15 # size of per-shard worker pools used for PUT operations
shard_num: 2 # total number of shards
shard_ro_error_threshold: 100 # amount of errors to occur before shard is made read-only (default: 0, ignore errors)
default: # section with the default shard parameters
resync_metabase: true # sync metabase with blobstor on start, expensive, leave false until complete understanding