From 4332066a5a21a59e455c8dceff2cb743fac97704 Mon Sep 17 00:00:00 2001 From: lyndon-li <98304688+Lyndon-Li@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:34:23 +0800 Subject: [PATCH] Revert "refactor(general): [0.16.0] Add allow-index-write-on-load to open options" --- internal/epoch/epoch_manager.go | 16 +++++++--------- internal/epoch/epoch_manager_test.go | 6 +++--- repo/content/committed_read_manager.go | 7 +++---- repo/content/content_manager.go | 1 - repo/open.go | 3 --- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/internal/epoch/epoch_manager.go b/internal/epoch/epoch_manager.go index 6b55f50ca02..ddd4bf8d520 100644 --- a/internal/epoch/epoch_manager.go +++ b/internal/epoch/epoch_manager.go @@ -1130,28 +1130,26 @@ func rangeCheckpointBlobPrefix(epoch1, epoch2 int) blob.ID { return blob.ID(fmt.Sprintf("%v%v_%v_", RangeCheckpointIndexBlobPrefix, epoch1, epoch2)) } -func allowWritesOnIndexLoad(fromParam bool) bool { - if fromParam { - return true - } - +func allowWritesOnIndexLoad() bool { v := strings.ToLower(os.Getenv("KOPIA_ALLOW_WRITE_ON_INDEX_LOAD")) - if v == "true" || v == "1" { + + if v == "" { + // temporary default to be changed once index cleanup is performed on maintenance return true } - return false + return v == "true" || v == "1" } // NewManager creates new epoch manager. -func NewManager(st blob.Storage, paramProvider ParametersProvider, compactor CompactionFunc, log logging.Logger, timeNow func() time.Time, optAllowWriteOnIndexLoad bool) *Manager { +func NewManager(st blob.Storage, paramProvider ParametersProvider, compactor CompactionFunc, log logging.Logger, timeNow func() time.Time) *Manager { return &Manager{ st: st, log: log, compact: compactor, timeFunc: timeNow, paramProvider: paramProvider, - allowCleanupWritesOnIndexLoad: allowWritesOnIndexLoad(optAllowWriteOnIndexLoad), + allowCleanupWritesOnIndexLoad: allowWritesOnIndexLoad(), getCompleteIndexSetTooSlow: new(int32), committedStateRefreshTooSlow: new(int32), writeIndexTooSlow: new(int32), diff --git a/internal/epoch/epoch_manager_test.go b/internal/epoch/epoch_manager_test.go index e101b9005a9..811082d9160 100644 --- a/internal/epoch/epoch_manager_test.go +++ b/internal/epoch/epoch_manager_test.go @@ -102,7 +102,7 @@ func newTestEnv(t *testing.T) *epochManagerTestEnv { EpochAdvanceOnCountThreshold: 15, EpochAdvanceOnTotalSizeBytesThreshold: 20 << 20, DeleteParallelism: 1, - }}, te.compact, testlogging.NewTestLogger(t), te.ft.NowFunc(), true) + }}, te.compact, testlogging.NewTestLogger(t), te.ft.NowFunc()) te.mgr = m te.faultyStorage = fs te.data = data @@ -121,7 +121,7 @@ func (te *epochManagerTestEnv) another() *epochManagerTestEnv { faultyStorage: te.faultyStorage, } - te2.mgr = NewManager(te2.st, te.mgr.paramProvider, te2.compact, te.mgr.log, te.mgr.timeFunc, true) + te2.mgr = NewManager(te2.st, te.mgr.paramProvider, te2.compact, te.mgr.log, te.mgr.timeFunc) return te2 } @@ -386,7 +386,7 @@ func TestIndexEpochManager_NoCompactionInReadOnly(t *testing.T) { } // Set new epoch manager to read-only to ensure we don't get stuck. - te2.mgr = NewManager(te2.st, te.mgr.paramProvider, te2.compact, te.mgr.log, te.mgr.timeFunc, true) + te2.mgr = NewManager(te2.st, te.mgr.paramProvider, te2.compact, te.mgr.log, te.mgr.timeFunc) // Use assert.Eventually here so we'll exit the test early instead of getting // stuck until the timeout. diff --git a/repo/content/committed_read_manager.go b/repo/content/committed_read_manager.go index 15e64c0529b..c45ffc9d535 100644 --- a/repo/content/committed_read_manager.go +++ b/repo/content/committed_read_manager.go @@ -443,7 +443,7 @@ func indexBlobCacheSweepSettings(caching *CachingOptions) cache.SweepSettings { } } -func (sm *SharedManager) setupCachesAndIndexManagers(ctx context.Context, caching *CachingOptions, mr *metrics.Registry, allowWriteOnIndexLoad bool) error { +func (sm *SharedManager) setupCachesAndIndexManagers(ctx context.Context, caching *CachingOptions, mr *metrics.Registry) error { dataCache, err := cache.NewContentCache(ctx, sm.st, cache.Options{ BaseCacheDirectory: caching.CacheDirectory, CacheSubDir: "contents", @@ -514,8 +514,7 @@ func (sm *SharedManager) setupCachesAndIndexManagers(ctx context.Context, cachin return errors.Wrap(sm.indexBlobManagerV1.CompactEpoch(ctx, blobIDs, outputPrefix), "CompactEpoch") }, sm.namedLogger("epoch-manager"), - sm.timeNow, - allowWriteOnIndexLoad), + sm.timeNow), sm.timeNow, sm.format, sm.namedLogger("index-blob-manager"), @@ -637,7 +636,7 @@ func NewSharedManager(ctx context.Context, st blob.Storage, prov format.Provider caching = caching.CloneOrDefault() - if err := sm.setupCachesAndIndexManagers(ctx, caching, mr, opts.AllowWriteOnIndexLoad); err != nil { + if err := sm.setupCachesAndIndexManagers(ctx, caching, mr); err != nil { return nil, errors.Wrap(err, "error setting up read manager caches") } diff --git a/repo/content/content_manager.go b/repo/content/content_manager.go index c9264f8f27f..ae8097b173f 100644 --- a/repo/content/content_manager.go +++ b/repo/content/content_manager.go @@ -951,7 +951,6 @@ type ManagerOptions struct { TimeNow func() time.Time // Time provider DisableInternalLog bool PermissiveCacheLoading bool - AllowWriteOnIndexLoad bool } // CloneOrDefault returns a clone of provided ManagerOptions or default empty struct if nil. diff --git a/repo/open.go b/repo/open.go index 2e97e6c03f7..3eef8bf92b7 100644 --- a/repo/open.go +++ b/repo/open.go @@ -76,8 +76,6 @@ type Options struct { // test-only flags TestOnlyIgnoreMissingRequiredFeatures bool // ignore missing features - - AllowWriteOnIndexLoad bool } // ErrInvalidPassword is returned when repository password is invalid. @@ -243,7 +241,6 @@ func openWithConfig(ctx context.Context, st blob.Storage, cliOpts ClientOptions, TimeNow: defaultTime(options.TimeNowFunc), DisableInternalLog: options.DisableInternalLog, PermissiveCacheLoading: cliOpts.PermissiveCacheLoading, - AllowWriteOnIndexLoad: options.AllowWriteOnIndexLoad, } mr := metrics.NewRegistry()