forked from TrueCloudLab/frostfs-node
[#826] blobovniczatree: Do not create DB's on init
Blobovniczas will be created on write requests. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
ad0697adc4
commit
db49ad16cc
9 changed files with 46 additions and 18 deletions
|
@ -183,6 +183,7 @@ type subStorageCfg struct {
|
||||||
leafWidth uint64
|
leafWidth uint64
|
||||||
openedCacheSize int
|
openedCacheSize int
|
||||||
initWorkerCount int
|
initWorkerCount int
|
||||||
|
initInAdvance bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// readConfig fills applicationConfiguration with raw configuration values
|
// readConfig fills applicationConfiguration with raw configuration values
|
||||||
|
@ -302,6 +303,7 @@ func (a *applicationConfiguration) setShardStorageConfig(newConfig *shardCfg, ol
|
||||||
sCfg.leafWidth = sub.LeafWidth()
|
sCfg.leafWidth = sub.LeafWidth()
|
||||||
sCfg.openedCacheSize = sub.OpenedCacheSize()
|
sCfg.openedCacheSize = sub.OpenedCacheSize()
|
||||||
sCfg.initWorkerCount = sub.InitWorkerCount()
|
sCfg.initWorkerCount = sub.InitWorkerCount()
|
||||||
|
sCfg.initInAdvance = sub.InitInAdvance()
|
||||||
case fstree.Type:
|
case fstree.Type:
|
||||||
sub := fstreeconfig.From((*config.Config)(storagesCfg[i]))
|
sub := fstreeconfig.From((*config.Config)(storagesCfg[i]))
|
||||||
sCfg.depth = sub.Depth()
|
sCfg.depth = sub.Depth()
|
||||||
|
@ -802,6 +804,7 @@ func (c *cfg) getSubstorageOpts(shCfg shardCfg) []blobstor.SubStorage {
|
||||||
blobovniczatree.WithBlobovniczaLeafWidth(sRead.leafWidth),
|
blobovniczatree.WithBlobovniczaLeafWidth(sRead.leafWidth),
|
||||||
blobovniczatree.WithOpenedCacheSize(sRead.openedCacheSize),
|
blobovniczatree.WithOpenedCacheSize(sRead.openedCacheSize),
|
||||||
blobovniczatree.WithInitWorkerCount(sRead.initWorkerCount),
|
blobovniczatree.WithInitWorkerCount(sRead.initWorkerCount),
|
||||||
|
blobovniczatree.WithInitInAdvance(sRead.initInAdvance),
|
||||||
blobovniczatree.WithLogger(c.log),
|
blobovniczatree.WithLogger(c.log),
|
||||||
blobovniczatree.WithObjectSizeLimit(shCfg.smallSizeObjectLimit),
|
blobovniczatree.WithObjectSizeLimit(shCfg.smallSizeObjectLimit),
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,7 @@ func TestEngineSection(t *testing.T) {
|
||||||
require.EqualValues(t, 50, blz.OpenedCacheSize())
|
require.EqualValues(t, 50, blz.OpenedCacheSize())
|
||||||
require.EqualValues(t, 10, blz.LeafWidth())
|
require.EqualValues(t, 10, blz.LeafWidth())
|
||||||
require.EqualValues(t, 10, blz.InitWorkerCount())
|
require.EqualValues(t, 10, blz.InitWorkerCount())
|
||||||
|
require.EqualValues(t, true, blz.InitInAdvance())
|
||||||
|
|
||||||
require.Equal(t, "tmp/0/blob", ss[1].Path())
|
require.Equal(t, "tmp/0/blob", ss[1].Path())
|
||||||
require.EqualValues(t, 0o644, ss[1].Perm())
|
require.EqualValues(t, 0o644, ss[1].Perm())
|
||||||
|
|
|
@ -131,3 +131,13 @@ func (x *Config) InitWorkerCount() int {
|
||||||
|
|
||||||
return InitWorkerCountDefault
|
return InitWorkerCountDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InitInAdvance returns the value of "init_in_advance" config parameter.
|
||||||
|
//
|
||||||
|
// Returns False if the value is not defined or invalid.
|
||||||
|
func (x *Config) InitInAdvance() bool {
|
||||||
|
return config.BoolSafe(
|
||||||
|
(*config.Config)(x),
|
||||||
|
"init_in_advance",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -127,6 +127,7 @@ FROSTFS_STORAGE_SHARD_0_BLOBSTOR_0_WIDTH=4
|
||||||
FROSTFS_STORAGE_SHARD_0_BLOBSTOR_0_OPENED_CACHE_CAPACITY=50
|
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_LEAF_WIDTH=10
|
||||||
FROSTFS_STORAGE_SHARD_0_BLOBSTOR_0_INIT_WORKER_COUNT=10
|
FROSTFS_STORAGE_SHARD_0_BLOBSTOR_0_INIT_WORKER_COUNT=10
|
||||||
|
FROSTFS_STORAGE_SHARD_0_BLOBSTOR_0_INIT_IN_ADVANCE=TRUE
|
||||||
### FSTree config
|
### FSTree config
|
||||||
FROSTFS_STORAGE_SHARD_0_BLOBSTOR_1_TYPE=fstree
|
FROSTFS_STORAGE_SHARD_0_BLOBSTOR_1_TYPE=fstree
|
||||||
FROSTFS_STORAGE_SHARD_0_BLOBSTOR_1_PATH=tmp/0/blob
|
FROSTFS_STORAGE_SHARD_0_BLOBSTOR_1_PATH=tmp/0/blob
|
||||||
|
|
|
@ -174,7 +174,8 @@
|
||||||
"width": 4,
|
"width": 4,
|
||||||
"opened_cache_capacity": 50,
|
"opened_cache_capacity": 50,
|
||||||
"leaf_width": 10,
|
"leaf_width": 10,
|
||||||
"init_worker_count": 10
|
"init_worker_count": 10,
|
||||||
|
"init_in_advance": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "fstree",
|
"type": "fstree",
|
||||||
|
|
|
@ -186,6 +186,7 @@ storage:
|
||||||
- type: blobovnicza
|
- type: blobovnicza
|
||||||
path: tmp/0/blob/blobovnicza
|
path: tmp/0/blob/blobovnicza
|
||||||
init_worker_count: 10 #count of workers to initialize blobovniczas
|
init_worker_count: 10 #count of workers to initialize blobovniczas
|
||||||
|
init_in_advance: true
|
||||||
- type: fstree
|
- type: fstree
|
||||||
path: tmp/0/blob # blobstor path
|
path: tmp/0/blob # blobstor path
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ func (b *Blobovniczas) initializeDBs(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if b.createDBInAdvance {
|
||||||
err = b.iterateSortedLeaves(egCtx, nil, func(p string) (bool, error) {
|
err = b.iterateSortedLeaves(egCtx, nil, func(p string) (bool, error) {
|
||||||
if _, found := visited[p]; found {
|
if _, found := visited[p]; found {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@ -104,6 +105,7 @@ func (b *Blobovniczas) initializeDBs(ctx context.Context) error {
|
||||||
_ = eg.Wait()
|
_ = eg.Wait()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return eg.Wait()
|
return eg.Wait()
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ func TestIterateSortedLeavesAndDBPathsAreSame(t *testing.T) {
|
||||||
WithBlobovniczaShallowWidth(5),
|
WithBlobovniczaShallowWidth(5),
|
||||||
WithRootPath(t.TempDir()),
|
WithRootPath(t.TempDir()),
|
||||||
)
|
)
|
||||||
|
blz.createDBInAdvance = true
|
||||||
require.NoError(t, blz.Open(false))
|
require.NoError(t, blz.Open(false))
|
||||||
require.NoError(t, blz.Init())
|
require.NoError(t, blz.Init())
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
|
@ -26,6 +26,7 @@ type cfg struct {
|
||||||
waitBeforeDropDB time.Duration
|
waitBeforeDropDB time.Duration
|
||||||
blzInitWorkerCount int
|
blzInitWorkerCount int
|
||||||
blzMoveBatchSize int
|
blzMoveBatchSize int
|
||||||
|
createDBInAdvance bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Option func(*cfg)
|
type Option func(*cfg)
|
||||||
|
@ -139,3 +140,10 @@ func WithInitWorkerCount(v int) Option {
|
||||||
c.blzInitWorkerCount = v
|
c.blzInitWorkerCount = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithInitInAdvance returns an option to create blobovnicza tree DB's in advance.
|
||||||
|
func WithInitInAdvance(v bool) Option {
|
||||||
|
return func(c *cfg) {
|
||||||
|
c.createDBInAdvance = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue