From ab18ce0f204cb1bf75dd34bd009694832cef0f11 Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Fri, 25 Apr 2025 11:33:05 +0300 Subject: [PATCH] [#1708] tree: Introduce `unsafe_sync_disabled` param to disable synchronization Close #1708. Change-Id: Id2eafe332cf495a2886c468348d1dcafddae1f2d Signed-off-by: Anton Nikiforov --- cmd/frostfs-node/config/tree/config.go | 6 ++++++ cmd/frostfs-node/tree.go | 1 + pkg/services/tree/options.go | 7 +++++++ pkg/services/tree/service.go | 4 ++++ pkg/services/tree/sync.go | 3 +++ 5 files changed, 21 insertions(+) diff --git a/cmd/frostfs-node/config/tree/config.go b/cmd/frostfs-node/config/tree/config.go index da877791e..a3c3d691b 100644 --- a/cmd/frostfs-node/config/tree/config.go +++ b/cmd/frostfs-node/config/tree/config.go @@ -87,6 +87,12 @@ func (c TreeConfig) SyncBatchSize() int { return SyncBatchSizeDefault } +// UnsafeSyncDisabled returns the value of "unsafe_sync_disabled" +// config parameter from the "tree" section. +func (c TreeConfig) UnsafeSyncDisabled() bool { + return config.BoolSafe(c.cfg, "unsafe_sync_disabled") +} + // AuthorizedKeys parses and returns an array of "authorized_keys" config // parameter from "tree" section. // diff --git a/cmd/frostfs-node/tree.go b/cmd/frostfs-node/tree.go index 62af45389..72cf57e9d 100644 --- a/cmd/frostfs-node/tree.go +++ b/cmd/frostfs-node/tree.go @@ -64,6 +64,7 @@ func initTreeService(c *cfg) { tree.WithReplicationChannelCapacity(treeConfig.ReplicationChannelCapacity()), tree.WithReplicationWorkerCount(treeConfig.ReplicationWorkerCount()), tree.WithSyncBatchSize(treeConfig.SyncBatchSize()), + tree.WithSyncDisabled(treeConfig.UnsafeSyncDisabled()), tree.WithAuthorizedKeys(treeConfig.AuthorizedKeys()), tree.WithMetrics(c.metricsCollector.TreeService()), tree.WithAPELocalOverrideStorage(c.cfgObject.cfgAccessPolicyEngine.accessPolicyEngine.LocalStorage()), diff --git a/pkg/services/tree/options.go b/pkg/services/tree/options.go index 56cbcc081..a28651452 100644 --- a/pkg/services/tree/options.go +++ b/pkg/services/tree/options.go @@ -44,6 +44,7 @@ type cfg struct { containerCacheSize int authorizedKeys atomic.Pointer[[][]byte] syncBatchSize int + syncDisabled bool localOverrideStorage policyengine.LocalOverrideStorage morphChainStorage policyengine.MorphRuleChainStorageReader @@ -122,6 +123,12 @@ func WithSyncBatchSize(n int) Option { } } +func WithSyncDisabled(d bool) Option { + return func(c *cfg) { + c.syncDisabled = d + } +} + func WithContainerCacheSize(n int) Option { return func(c *cfg) { if n > 0 { diff --git a/pkg/services/tree/service.go b/pkg/services/tree/service.go index 343a2c902..81aa98b4d 100644 --- a/pkg/services/tree/service.go +++ b/pkg/services/tree/service.go @@ -89,6 +89,10 @@ func New(opts ...Option) *Service { func (s *Service) Start(ctx context.Context) { ctx = tagging.ContextWithIOTag(ctx, qos.IOTagTreeSync.String()) go s.replicateLoop(ctx) + if s.syncDisabled { + s.initialSyncDone.Store(true) + return + } go s.syncLoop(ctx) select { diff --git a/pkg/services/tree/sync.go b/pkg/services/tree/sync.go index af355639f..1480bff92 100644 --- a/pkg/services/tree/sync.go +++ b/pkg/services/tree/sync.go @@ -419,6 +419,9 @@ func (s *Service) SynchronizeAll() error { return ErrShuttingDown default: } + if s.syncDisabled { + return nil + } select { case s.syncChan <- struct{}{}: