[#145] shard-gc: Delete expired objects after locks
GC deletes expired locks and objects sequentially. Expired locks and objects are now being deleted concurrently in batches. Added a config parameter that controls the number of concurrent workers and batch size. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
6c4a1699ef
commit
5059dcc19d
10 changed files with 196 additions and 32 deletions
|
@ -117,8 +117,10 @@ type shardCfg struct {
|
|||
subStorages []subStorageCfg
|
||||
|
||||
gcCfg struct {
|
||||
removerBatchSize int
|
||||
removerSleepInterval time.Duration
|
||||
removerBatchSize int
|
||||
removerSleepInterval time.Duration
|
||||
expiredCollectorBatchSize int
|
||||
expiredCollectorWorkersCount int
|
||||
}
|
||||
|
||||
writecacheCfg struct {
|
||||
|
@ -287,6 +289,8 @@ func (a *applicationConfiguration) readConfig(c *config.Config) error {
|
|||
|
||||
sh.gcCfg.removerBatchSize = gcCfg.RemoverBatchSize()
|
||||
sh.gcCfg.removerSleepInterval = gcCfg.RemoverSleepInterval()
|
||||
sh.gcCfg.expiredCollectorBatchSize = gcCfg.ExpiredCollectorBatchSize()
|
||||
sh.gcCfg.expiredCollectorWorkersCount = gcCfg.ExpiredCollectorWorkersCount()
|
||||
|
||||
a.EngineCfg.shards = append(a.EngineCfg.shards, sh)
|
||||
|
||||
|
@ -753,6 +757,8 @@ func (c *cfg) shardOpts() []shardOptsWithID {
|
|||
shard.WithWriteCacheOptions(writeCacheOpts...),
|
||||
shard.WithRemoverBatchSize(shCfg.gcCfg.removerBatchSize),
|
||||
shard.WithGCRemoverSleepInterval(shCfg.gcCfg.removerSleepInterval),
|
||||
shard.WithExpiredCollectorBatchSize(shCfg.gcCfg.expiredCollectorBatchSize),
|
||||
shard.WithExpiredCollectorWorkersCount(shCfg.gcCfg.expiredCollectorWorkersCount),
|
||||
shard.WithGCWorkerPoolInitializer(func(sz int) util.WorkerPool {
|
||||
pool, err := ants.NewPool(sz)
|
||||
fatalOnErr(err)
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
shardconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/engine/shard"
|
||||
blobovniczaconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/engine/shard/blobstor/blobovnicza"
|
||||
fstreeconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/engine/shard/blobstor/fstree"
|
||||
gcconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/engine/shard/gc"
|
||||
piloramaconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/engine/shard/pilorama"
|
||||
configtest "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/test"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||
|
@ -103,6 +104,8 @@ func TestEngineSection(t *testing.T) {
|
|||
|
||||
require.EqualValues(t, 150, gc.RemoverBatchSize())
|
||||
require.Equal(t, 2*time.Minute, gc.RemoverSleepInterval())
|
||||
require.Equal(t, 1500, gc.ExpiredCollectorBatchSize())
|
||||
require.Equal(t, 15, gc.ExpiredCollectorWorkersCount())
|
||||
|
||||
require.Equal(t, false, sc.RefillMetabase())
|
||||
require.Equal(t, mode.ReadOnly, sc.Mode())
|
||||
|
@ -149,6 +152,8 @@ func TestEngineSection(t *testing.T) {
|
|||
|
||||
require.EqualValues(t, 200, gc.RemoverBatchSize())
|
||||
require.Equal(t, 5*time.Minute, gc.RemoverSleepInterval())
|
||||
require.Equal(t, gcconfig.ExpiredCollectorBatchSizeDefault, gc.ExpiredCollectorBatchSize())
|
||||
require.Equal(t, gcconfig.ExpiredCollectorWorkersCountDefault, gc.ExpiredCollectorWorkersCount())
|
||||
|
||||
require.Equal(t, true, sc.RefillMetabase())
|
||||
require.Equal(t, mode.ReadWrite, sc.Mode())
|
||||
|
|
|
@ -16,6 +16,12 @@ const (
|
|||
|
||||
// RemoverSleepIntervalDefault is a default sleep interval of Shard GC's remover.
|
||||
RemoverSleepIntervalDefault = time.Minute
|
||||
|
||||
// ExpiredCollectorWorkersCountDefault is a default workers count of Shard GC expired object collector.
|
||||
ExpiredCollectorWorkersCountDefault = 5
|
||||
|
||||
// ExpiredCollectorBatchSizeDefault is a default batch size of Shard GC expired object collector.
|
||||
ExpiredCollectorBatchSizeDefault = 500
|
||||
)
|
||||
|
||||
// From wraps config section into Config.
|
||||
|
@ -56,3 +62,37 @@ func (x *Config) RemoverSleepInterval() time.Duration {
|
|||
|
||||
return RemoverSleepIntervalDefault
|
||||
}
|
||||
|
||||
// ExpiredCollectorWorkersCount returns the value of "expired_collector_workers_count"
|
||||
// config parameter.
|
||||
//
|
||||
// Returns ExpiredCollectorWorkersCountDefault if the value is not a positive number.
|
||||
func (x *Config) ExpiredCollectorWorkersCount() int {
|
||||
s := config.IntSafe(
|
||||
(*config.Config)(x),
|
||||
"expired_collector_workers_count",
|
||||
)
|
||||
|
||||
if s > 0 {
|
||||
return int(s)
|
||||
}
|
||||
|
||||
return ExpiredCollectorWorkersCountDefault
|
||||
}
|
||||
|
||||
// ExpiredCollectorBatchSize returns the value of "expired_collector_batch_size"
|
||||
// config parameter.
|
||||
//
|
||||
// Returns ExpiredCollectorBatchSizeDefault if the value is not a positive number.
|
||||
func (x *Config) ExpiredCollectorBatchSize() int {
|
||||
s := config.IntSafe(
|
||||
(*config.Config)(x),
|
||||
"expired_collector_batch_size",
|
||||
)
|
||||
|
||||
if s > 0 {
|
||||
return int(s)
|
||||
}
|
||||
|
||||
return ExpiredCollectorBatchSizeDefault
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue