From 702351a5d1b422a12815cbe4598c81e0bf1b503c Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Mon, 4 Mar 2024 18:01:39 +0300 Subject: [PATCH] [#983] blobstor: Allow to specify wait before drop time Signed-off-by: Dmitrii Stepanov --- cmd/frostfs-node/config.go | 15 +++++++++------ cmd/frostfs-node/config/engine/config_test.go | 2 ++ .../shard/blobstor/blobovnicza/config.go | 19 +++++++++++++++++++ config/example/node.env | 1 + config/example/node.json | 3 ++- config/example/node.yaml | 1 + docs/storage-node-configuration.md | 19 +++++++++++-------- 7 files changed, 45 insertions(+), 15 deletions(-) diff --git a/cmd/frostfs-node/config.go b/cmd/frostfs-node/config.go index 360fdbec6..e5d3f7311 100644 --- a/cmd/frostfs-node/config.go +++ b/cmd/frostfs-node/config.go @@ -178,12 +178,13 @@ type subStorageCfg struct { noSync bool // blobovnicza-specific - size uint64 - width uint64 - leafWidth uint64 - openedCacheSize int - initWorkerCount int - initInAdvance bool + size uint64 + width uint64 + leafWidth uint64 + openedCacheSize int + initWorkerCount int + initInAdvance bool + rebuildDropTimeout time.Duration } // readConfig fills applicationConfiguration with raw configuration values @@ -303,6 +304,7 @@ func (a *applicationConfiguration) setShardStorageConfig(newConfig *shardCfg, ol sCfg.openedCacheSize = sub.OpenedCacheSize() sCfg.initWorkerCount = sub.InitWorkerCount() sCfg.initInAdvance = sub.InitInAdvance() + sCfg.rebuildDropTimeout = sub.RebuildDropTimeout() case fstree.Type: sub := fstreeconfig.From((*config.Config)(storagesCfg[i])) sCfg.depth = sub.Depth() @@ -887,6 +889,7 @@ func (c *cfg) getSubstorageOpts(shCfg shardCfg) []blobstor.SubStorage { blobovniczatree.WithOpenedCacheSize(sRead.openedCacheSize), blobovniczatree.WithInitWorkerCount(sRead.initWorkerCount), blobovniczatree.WithInitInAdvance(sRead.initInAdvance), + blobovniczatree.WithWaitBeforeDropDB(sRead.rebuildDropTimeout), blobovniczatree.WithLogger(c.log), blobovniczatree.WithObjectSizeLimit(shCfg.smallSizeObjectLimit), } diff --git a/cmd/frostfs-node/config/engine/config_test.go b/cmd/frostfs-node/config/engine/config_test.go index 6c7b23cc4..86c938309 100644 --- a/cmd/frostfs-node/config/engine/config_test.go +++ b/cmd/frostfs-node/config/engine/config_test.go @@ -101,6 +101,7 @@ func TestEngineSection(t *testing.T) { require.EqualValues(t, 10, blz.LeafWidth()) require.EqualValues(t, 10, blz.InitWorkerCount()) require.EqualValues(t, true, blz.InitInAdvance()) + require.EqualValues(t, 30*time.Second, blz.RebuildDropTimeout()) require.Equal(t, "tmp/0/blob", ss[1].Path()) require.EqualValues(t, 0o644, ss[1].Perm()) @@ -151,6 +152,7 @@ func TestEngineSection(t *testing.T) { require.EqualValues(t, 50, blz.OpenedCacheSize()) require.EqualValues(t, 10, blz.LeafWidth()) require.EqualValues(t, blobovniczaconfig.InitWorkerCountDefault, blz.InitWorkerCount()) + require.EqualValues(t, blobovniczaconfig.RebuildDropTimeoutDefault, blz.RebuildDropTimeout()) require.Equal(t, "tmp/1/blob", ss[1].Path()) require.EqualValues(t, 0o644, ss[1].Perm()) diff --git a/cmd/frostfs-node/config/engine/shard/blobstor/blobovnicza/config.go b/cmd/frostfs-node/config/engine/shard/blobstor/blobovnicza/config.go index 37191cc72..9619a1027 100644 --- a/cmd/frostfs-node/config/engine/shard/blobstor/blobovnicza/config.go +++ b/cmd/frostfs-node/config/engine/shard/blobstor/blobovnicza/config.go @@ -1,6 +1,8 @@ package blobovniczaconfig import ( + "time" + "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config" boltdbconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/engine/shard/boltdb" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/blobovniczatree" @@ -25,6 +27,9 @@ const ( // InitWorkerCountDefault is a default workers count to initialize Blobovnicza's. InitWorkerCountDefault = 5 + + // RebuildDropTimeoutDefault is a default timeout value to wait before drop single blobovnicza. + RebuildDropTimeoutDefault = 10 * time.Second ) // From wraps config section into Config. @@ -141,3 +146,17 @@ func (x *Config) InitInAdvance() bool { "init_in_advance", ) } + +// RebuildDropTimeout returns the value of "rebuild_drop_timeout" config parameter. +// +// Returns RebuildDropTimeoutDefault if the value is not defined or invalid. +func (x *Config) RebuildDropTimeout() time.Duration { + d := config.DurationSafe( + (*config.Config)(x), + "rebuild_drop_timeout", + ) + if d > 0 { + return d + } + return RebuildDropTimeoutDefault +} diff --git a/config/example/node.env b/config/example/node.env index b0364b741..810a2842b 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -129,6 +129,7 @@ FROSTFS_STORAGE_SHARD_0_BLOBSTOR_0_OPENED_CACHE_CAPACITY=50 FROSTFS_STORAGE_SHARD_0_BLOBSTOR_0_LEAF_WIDTH=10 FROSTFS_STORAGE_SHARD_0_BLOBSTOR_0_INIT_WORKER_COUNT=10 FROSTFS_STORAGE_SHARD_0_BLOBSTOR_0_INIT_IN_ADVANCE=TRUE +FROSTFS_STORAGE_SHARD_0_BLOBSTOR_0_REBUILD_DROP_TIMEOUT=30s ### FSTree config FROSTFS_STORAGE_SHARD_0_BLOBSTOR_1_TYPE=fstree FROSTFS_STORAGE_SHARD_0_BLOBSTOR_1_PATH=tmp/0/blob diff --git a/config/example/node.json b/config/example/node.json index 495fcb8ce..e24a12f5f 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -176,7 +176,8 @@ "opened_cache_capacity": 50, "leaf_width": 10, "init_worker_count": 10, - "init_in_advance": true + "init_in_advance": true, + "rebuild_drop_timeout": "30s" }, { "type": "fstree", diff --git a/config/example/node.yaml b/config/example/node.yaml index 96af3b208..c9886355f 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -190,6 +190,7 @@ storage: path: tmp/0/blob/blobovnicza init_worker_count: 10 #count of workers to initialize blobovniczas init_in_advance: true + rebuild_drop_timeout: 30s # timeout before drop single blobovnicza - type: fstree path: tmp/0/blob # blobstor path diff --git a/docs/storage-node-configuration.md b/docs/storage-node-configuration.md index 6573e3ea2..15071f23d 100644 --- a/docs/storage-node-configuration.md +++ b/docs/storage-node-configuration.md @@ -225,14 +225,17 @@ blobstor: | `depth` | `int` | `4` | File-system tree depth. | #### `blobovnicza` type options -| Parameter | Type | Default value | Description | -|-------------------------|-----------|---------------|-------------------------------------------------------| -| `path` | `string` | | Path to the root of the blobstor. | -| `perm` | file mode | `0660` | Default permission for created files and directories. | -| `size` | `size` | `1 G` | Maximum size of a single blobovnicza | -| `depth` | `int` | `2` | Blobovnicza tree depth. | -| `width` | `int` | `16` | Blobovnicza tree width. | -| `opened_cache_capacity` | `int` | `16` | Maximum number of simultaneously opened blobovniczas. | +| Parameter | Type | Default value | Description | +| ----------------------- | ---------- | ------------- | --------------------------------------------------------------------- | +| `path` | `string` | | Path to the root of the blobstor. | +| `perm` | file mode | `0660` | Default permission for created files and directories. | +| `size` | `size` | `1 G` | Maximum size of a single blobovnicza | +| `depth` | `int` | `2` | Blobovnicza tree depth. | +| `width` | `int` | `16` | Blobovnicza tree width. | +| `opened_cache_capacity` | `int` | `16` | Maximum number of simultaneously opened blobovniczas. | +| `init_worker_count` | `int` | `5` | Maximum number of concurrent initialization workers. | +| `init_in_advance` | `bool` | `false` | If `true`, than all the blobovnicza files will be created on startup. | +| `rebuild_drop_timeout` | `duration` | `10s` | Timeout before drop empty blobovnicza file during rebuild. | ### `gc` subsection -- 2.45.2